PageSourceSearch

https://ethjs.github.io/offline/

html ethjs.github.io collected 2026-10-03 09:10:22 UTC 1,244,200 bytes, 44,800 lines download raw bytes

1<html>
2
3  <head>
4
5    <title>EthOffline</title>
6
7  </head>
8
9  <body>
10
11    <style type="text/css">
12
13    body, html {
14      font-family: Arial;
15    }
16
17    label {
18      font-size: 14px;
19      font-weight: bold;
20      text-transform: capitalize;
21    }
22
23    input, textarea, select {
24      padding: 15px;
25      font-size: 14;
26      width: 100%;
27    }
28
29    .unitValue {
30      width: 85%;
31    }
32
33    .unitSelector, .dataKindSelector {
34      width: 14%;
35      -webkit-appearance: none;
36      -moz-appearance: none;
37      appearance: none;
38    }
39
40    .scrollable {
41      overflow-y: scroll;
42      max-height: 100%;
43      height: 99%;
44    }
45
46    #result {
47      border: 1px solid #333;
48      padding: 20px;
49    }
50
51    #onlineWarning {
52      padding: 20px;
53      margin-top: 20px;
54      margin-bottom: 20px;
55      color: darkred;
56      border: 1px solid darkred;
57    }
58
59    </style>
60
61    <div style="margin: 0px auto; width: 50%; display: block;">
62
63      <h1>EthOffline | Transaction Signer</h1>
64
65      <h4>Welcome to EthOffline app, offline Ethereum transaction signing tool.</h4>
66
67      <div id="onlineWarning" style="display: none;">
68        WARNING: You are currently online and connected to the internet. This tool is meant to be used on an offline (preferably on an air-gapped computer).
69
70        <br /><br />
71
72        Do not use this tool with your actual private keys while connected to the internet.
73      </div>
74
75      <div id="privateKeyWrapper">
76
77        <br />
78
79        <label>Private Key</label> <br />
80        <input type="password" id="privatekey" placeholder="Example: 0xe230d63e82551f42a1d00ee75448e01f5370ba387998835415983144a46bd504" autofocus /> <br /> <br />
81
82        <small>
83          Please provide your Etheruem private key here, it must be hex '0x...' prefixed (this is not your Bip39 seed or passphrase).
84
85          A QR code will be prompted if you have entered a valid private key.
86
87          If your private key is valid, your private key data will be hidden to protect it from any cameras or devices.
88        </small>
89
90        <br /><br />
91
92        <small>
93
94          If you're using Ian Coleman's Bip39 Tool, open that tool offline.
95
96          Enter your seed and passphrase, scroll down and copy your Private Key on the right hand side of the page, then paste it above.
97        </small>
98
99      </div>
100
101      <div id="transactionFields" style="display: none;">
102
103        <br /><br />
104
105        <label>From Address (your account address)</label> <br />
106        <input type="text" id="from" disabled="disabled" /> <br /> <br />
107
108        <br /><br />
109
110        <label>Nonce</label> <br />
111        <input type="number" id="nonce" placeholder="Example: 1" /> <br /> <br />
112
113        <label>Gas</label> <br />
114        <input type="number" id="gas" class="unitValue" placeholder="Example: 500000 [wei]" value="500000" />
115
116        <select id="gasUnit" class="unitSelector" data-target="gas">
117          <option value="wei" selected="selected">wei</option>
118
119          <option value="gwei">Gwei</option>
120
121          <option value="ether">ether</option>
122        </select>
123
124        <br /> <br />
125
126        <label>Gas Price</label> <br />
127        <input type="number" id="gasPrice" class="unitValue" placeholder="Example: 5 [gWei]" value="5" />
128
129        <select id="gasPriceUnit" class="unitSelector" data-target="gasPrice">
130          <option value="wei">wei</option>
131
132          <option value="gwei" selected="selected">Gwei</option>
133
134          <option value="ether">ether</option>
135        </select>
136
137        <div id="transactionDataWrapper" style="display: none;">
138
139          <br /> <br />
140
141          <br /> <br />
142
143          <label>To Address</label> <br />
144          <input type="text" id="to" placeholder="Example: 0x325e4f509e582cfeD31b767bc9F992f5b86f0e67" /> <br /> <br />
145
146          <label>Value</label> <br />
147          <input type="number" id="value" class="unitValue" placeholder="Example: 45 [ether]" value="0" />
148
149          <select id="valueUnit" class="unitSelector" data-target="value">
150            <option value="wei">wei</option>
151
152            <option value="gwei">Gwei</option>
153
154            <option value="ether" selected="selected">ether</option>
155          </select>
156
157          <br /> <br />
158
159          <br /> <br />
160
161          <label>Data</label> <br />
162
163          <select id="dataKind" class="dataKindSelector" style="width: 99%;">
164            <option value="noData">No Data</option>
165            <option value="custom">Custom Data (experts only)</option>
166            <option disabled></option>
167            <option disabled>Gnosis Multi-Signature Wallet</option>
168            <option value="submitTransaction">&nbsp;&nbsp;&nbsp;&nbsp;Submit Transaction</option>
169            <option value="confirmTransaction">&nbsp;&nbsp;&nbsp;&nbsp;Confirm Transaction</option>
170            <option disabled></option>
171            <option disabled>ERC20 Ethereum Standard Token</option>
172            <option value="transfer">&nbsp;&nbsp;&nbsp;&nbsp;Transfer</option>
173            <option value="transferFrom">&nbsp;&nbsp;&nbsp;&nbsp;Transfer From</option>
174            <option value="approve">&nbsp;&nbsp;&nbsp;&nbsp;Approve</option>
175          </select> <br />
176
177          <div id="dataWrapper">
178
179
180
181          </div>
182
183          <br />
184
185          <input type="hidden" id="data" placeholder="data" value="
1850x" /> <br /> <br />
186
187        </div>
188
189        <br /><br /><br /><br />
190
191        <input type="button" id="signTransaction" value="Sign Transaction" />
192
193      </div>
194
195
196      <br /><br />
197
198      <div id="result" style="display: none;"></div>
199
200      <div>
201        <br /><br />
202
203        <h2>WARNING</h2>
204
205        <h4>Only use this Tool Offline on a safe computer. This tool is not meant to handle private keys on a computer or mobile device connected to the internet.</h4>
206
207        <h2>License</h2>
208
209        <p>Please refer to the software license for more detail.</p>
210
211        <p>The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.</p>
212
213        <h2>About</h2>
214
215        <h4>This tool is produced by the EthJS team using EthJS libraries. Please contact the ethereumjs community for more details.</h4>
216
217        <h2>Hash Verification</h2>
218
219        <h4>Please verify this tool by using a sha256sum and checking the release information at: https://github.com/ethjs/ethjs.github.io/releases.</h4>
220
221        <h2>Offline Usage</h2>
222
223        <p>You can use this tool without having to be online.</p>
224
225        <p>In your browser, select file save-as, and save this page as a file.</p>
226
227        <p>Double-click that file to open it in a browser on any offline computer.</p>
228
229        <p>Alternatively, download the file from the repository - <a href="https://github.com/ethjs/ethjs.github.io" target="_blank">https://github.com/ethjs/ethjs.github.io</a></p>
230
231        <h2>Open-Source</h2>
232
233        <p>This project is <b>100% open-source code</b></p>
234
235        <p>Get the source code from the repository - <a href="https://github.com/ethjs/ethjs.github.io" target="_blank">https://github.com/ethjs/ethjs.github.io</a></p>
236
237        <br /><br />
238      </div>
239
240    </div>
241
242    <div id="signedTransactionDataWrapper" style="position: fixed; color: #666; z-index: 5000; top: 0px; bottom: 0px; right: 0px; left: 0px; display: none; background: rgba(0,0,0,1); text-align: center; padding-top: 30px;">
243
244      <div class="scrollable">
245
246        <h3>Raw Signed Transaction Data</h3>
247
248        <textarea id="rawSignedTransactionData" style="width: 500px;"></textarea>
249
250        <br /><br />
251
252        <h3>Signed Transaction Data</h3>
253
254        <textarea id="signedTransactionData" style="width: 500px;"></textarea>
255
256        <br /><br />
257
258        <canvas id="signedTransactionDataQRCode" width="500" height="500" style="width: 500px; height: 500px; display: inline-block;"></canvas>
259
260        <br /><br />
261
262        <h3 style="z-index: 10000; font-weight: normal;">Scan this QR code with: <span style="color: #F3F3F3;">https://ethjs.github.io/scanner</span> on Android/PC/Mac</h3>
263
264        <br /><br />
265
266        <button id="closeTransactionQRCodeQR" style="padding: 20px; cursor: pointer;"><h3>Hide Signed Transaction</h3></button>
267
268        <br /><br />
269
270      </div>
271
272    </div>
273
274    <div id="addressQRWrapper" style="position: fixed; z-index: 5000; color: #666; top: 0px; bottom: 0px; right: 0px; left: 0px; display: none; background: rgba(0,0,0,1); text-align: center;">
275
276      <div class="scrollable">
277
278        <h3 style="z-index: 10000; margin-top: 100px;" id="addressValue"></h3>
279
280        <br /><br />
281
282        <canvas id="addressQR" width="500" height="500" style="width: 500px; z-index: 10000; height: 500px; display: inline-block;"></canvas>
283
284        <br /><br />
285
286        <h3 style="z-index: 10000; font-weight: normal;">Scan this QR code with: <span style="color: #F3F3F3;">https://ethjs.github.io/scanner</span> on Android/PC/Mac</h3>
287
288        <br /><br />
289
290        <button id="closeAddressQR" style="padding: 20px; cursor: pointer;"><h3>I know my <b>Nonce</b> and <b>Gas Values</b></h3></button>
291
292        <br /><br />
293
294      </div>
295
296    </div>
297
298    
vendor: 2,803 bytes, lines 298-383
298<script> /* eslint-disable */ 
299(function webpackUniversalModuleDefinition(root, factory) {
300	if(typeof exports === 'object' && typeof module === 'object')
301		module.exports = factory();
302	else if(typeof define === 'function' && define.amd)
303		define("ethAbi", [], factory);
304	else if(typeof exports === 'object')
305		exports["ethAbi"] = factory();
306	else
307		root["ethAbi"] = factory();
308})(this, function() {
309return /******/ (function(modules) { // webpackBootstrap
310/******/ 	// The module cache
311/******/ 	var installedModules = {};
312
313/******/ 	// The require function
314/******/ 	function __webpack_require__(moduleId) {
315
316/******/ 		// Check if module is in cache
317/******/ 		if(installedModules[moduleId])
318/******/ 			return installedModules[moduleId].exports;
319
320/******/ 		// Create a new module (and put it into the cache)
321/******/ 		var module = installedModules[moduleId] = {
322/******/ 			i: moduleId,
323/******/ 			l: false,
324/******/ 			exports: {}
325/******/ 		};
326
327/******/ 		// Execute the module function
328/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
329
330/******/ 		// Flag the module as loaded
331/******/ 		module.l = true;
332
333/******/ 		// Return the exports of the module
334/******/ 		return module.exports;
335/******/ 	}
336
337
338/******/ 	// expose the modules object (__webpack_modules__)
339/******/ 	__webpack_require__.m = modules;
340
341/******/ 	// expose the module cache
342/******/ 	__webpack_require__.c = installedModules;
343
344/******/ 	// identity function for calling harmory imports with the correct context
345/******/ 	__webpack_require__.i = function(value) { return value; };
346
347/******/ 	// define getter function for harmory exports
348/******/ 	__webpack_require__.d = function(exports, name, getter) {
349/******/ 		Object.defineProperty(exports, name, {
350/******/ 			configurable: false,
351/******/ 			enumerable: true,
352/******/ 			get: getter
353/******/ 		});
354/******/ 	};
355
356/******/ 	// Object.prototype.hasOwnProperty.call
357/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
358
359/******/ 	// __webpack_public_path__
360/******/ 	__webpack_require__.p = "";
361
362/******/ 	// Load entry module and return exports
363/******/ 	return __webpack_require__(__webpack_require__.s = 4);
364/******/ })
365/************************************************************************/
366/******/ ([
367/* 0 */
368/***/ function(module, exports, __webpack_require__) {
369
370"use strict";
371/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
372 * The buffer module from node.js, for the browser.
373 *
374 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
375 * @license  MIT
376 */
377/* eslint-disable no-proto */
378
379'use strict'
380
381var base64 = __webpack_require__(5)
382var ieee754 = __webpack_require__(6)
383var isArray = __webpack_require__(8
vendor: 48,349 bytes, lines 383-2161
383)
384
385exports.Buffer = Buffer
386exports.SlowBuffer = SlowBuffer
387exports.INSPECT_MAX_BYTES = 50
388
389/**
390 * If `Buffer.TYPED_ARRAY_SUPPORT`:
391 *   === true    Use Uint8Array implementation (fastest)
392 *   === false   Use Object implementation (most compatible, even IE6)
393 *
394 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
395 * Opera 11.6+, iOS 4.2+.
396 *
397 * Due to various browser bugs, sometimes the Object implementation will be used even
398 * when the browser supports typed arrays.
399 *
400 * Note:
401 *
402 *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
403 *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
404 *
405 *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
406 *
407 *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
408 *     incorrect length in some situations.
409
410 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
411 * get the Object implementation, which is slower but behaves correctly.
412 */
413Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
414  ? global.TYPED_ARRAY_SUPPORT
415  : typedArraySupport()
416
417/*
418 * Export kMaxLength after typed array support is determined.
419 */
420exports.kMaxLength = kMaxLength()
421
422function typedArraySupport () {
423  try {
424    var arr = new Uint8Array(1)
425    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
426    return arr.foo() === 42 && // typed array instances can be augmented
427        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
428        arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
429  } catch (e) {
430    return false
431  }
432}
433
434function kMaxLength () {
435  return Buffer.TYPED_ARRAY_SUPPORT
436    ? 0x7fffffff
437    : 0x3fffffff
438}
439
440function createBuffer (that, length) {
441  if (kMaxLength() < length) {
442    throw new RangeError('Invalid typed array length')
443  }
444  if (Buffer.TYPED_ARRAY_SUPPORT) {
445    // Return an augmented `Uint8Array` instance, for best performance
446    that = new Uint8Array(length)
447    that.__proto__ = Buffer.prototype
448  } else {
449    // Fallback: Return an object instance of the Buffer class
450    if (that === null) {
451      that = new Buffer(length)
452    }
453    that.length = length
454  }
455
456  return that
457}
458
459/**
460 * The Buffer constructor returns instances of `Uint8Array` that have their
461 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
462 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
463 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
464 * returns a single octet.
465 *
466 * The `Uint8Array` prototype remains unmodified.
467 */
468
469function Buffer (arg, encodingOrOffset, length) {
470  if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
471    return new Buffer(arg, encodingOrOffset, length)
472  }
473
474  // Common case.
475  if (typeof arg === 'number') {
476    if (typeof encodingOrOffset === 'string') {
477      throw new Error(
478        'If encoding is specified then the first argument must be a string'
479      )
480    }
481    return allocUnsafe(this, arg)
482  }
483  return from(this, arg, encodingOrOffset, length)
484}
485
486Buffer.poolSize = 8192 // not used by this implementation
487
488// TODO: Legacy, not needed anymore. Remove in next major version.
489Buffer._augment = function (arr) {
490  arr.__proto__ = Buffer.prototype
491  return arr
492}
493
494function from (that, value, encodingOrOffset, length) {
495  if (typeof value === 'number') {
496    throw new TypeError('"value" argument must not be a number')
497  }
498
499  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
500    return fromArrayBuffer(that, value, encodingOrOffset, length)
501  }
502
503  if (typeof value === 'string') {
504    return fromString(that, value, encodingOrOffset)
505  }
506
507  return fromObject(that, value)
508}
509
510/**
511 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
512 * if value is a number.
513 * Buffer.from(str[, encoding])
514 * Buffer.from(array)
515 * Buffer.from(buffer)
516 * Buffer.from(arrayBuffer[, byteOffset[, length]])
517 **/
518Buffer.from = function (value, encodingOrOffset, length) {
519  return from(null, value, encodingOrOffset, length)
520}
521
522if (Buffer.TYPED_ARRAY_SUPPORT) {
523  Buffer.prototype.__proto__ = Uint8Array.prototype
524  Buffer.__proto__ = Uint8Array
525  if (typeof Symbol !== 'undefined' && Symbol.species &&
526      Buffer[Symbol.species] === Buffer) {
527    // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
528    Object.defineProperty(Buffer, Symbol.species, {
529      value: null,
530      configurable: true
531    })
532  }
533}
534
535function assertSize (size) {
536  if (typeof size !== 'number') {
537    throw new TypeError('"size" argument must be a number')
538  } else if (size < 0) {
539    throw new RangeError('"size" argument must not be negative')
540  }
541}
542
543function alloc (that, size, fill, encoding) {
544  assertSize(size)
545  if (size <= 0) {
546    return createBuffer(that, size)
547  }
548  if (fill !== undefined) {
549    // Only pay attention to encoding if it's a string. This
550    // prevents accidentally sending in a number that would
551    // be interpretted as a start offset.
552    return typeof encoding === 'string'
553      ? createBuffer(that, size).fill(fill, encoding)
554      : createBuffer(that, size).fill(fill)
555  }
556  return createBuffer(that, size)
557}
558
559/**
560 * Creates a new filled Buffer instance.
561 * alloc(size[, fill[, encoding]])
562 **/
563Buffer.alloc = function (size, fill, encoding) {
564  return alloc(null, size, fill, encoding)
565}
566
567function allocUnsafe (that, size) {
568  assertSize(size)
569  that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
570  if (!Buffer.TYPED_ARRAY_SUPPORT) {
571    for (var i = 0; i < size; ++i) {
572      that[i] = 0
573    }
574  }
575  return that
576}
577
578/**
579 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
580 * */
581Buffer.allocUnsafe = function (size) {
582  return allocUnsafe(null, size)
583}
584/**
585 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
586 */
587Buffer.allocUnsafeSlow = function (size) {
588  return allocUnsafe(null, size)
589}
590
591function fromString (that, string, encoding) {
592  if (typeof encoding !== 'string' || encoding === '') {
593    encoding = 'utf8'
594  }
595
596  if (!Buffer.isEncoding(encoding)) {
597    throw new TypeError('"encoding" must be a valid string encoding')
598  }
599
600  var length = byteLength(string, encoding) | 0
601  that = createBuffer(that, length)
602
603  var actual = that.write(string, encoding)
604
605  if (actual !== length) {
606    // Writing a hex string, for example, that contains invalid characters will
607    // cause everything after the first invalid character to be ignored. (e.g.
608    // 'abxxcd' will be treated as 'ab')
609    that = that.slice(0, actual)
610  }
611
612  return that
613}
614
615function fromArrayLike (that, array) {
616  var length = array.length < 0 ? 0 : checked(array.length) | 0
617  that = createBuffer(that, length)
618  for (var i = 0; i < length; i += 1) {
619    that[i] = array[i] & 255
620  }
621  return that
622}
623
624function fromArrayBuffer (that, array, byteOffset, length) {
625  array.byteLength // this throws if `array` is not a valid ArrayBuffer
626
627  if (byteOffset < 0 || array.byteLength < byteOffset) {
628    throw new RangeError('\'offset\' is out of bounds')
629  }
630
631  if (array.byteLength < byteOffset + (length || 0)) {
632    throw new RangeError('\'length\' is out of bounds')
633  }
634
635  if (byteOffset === undefined && length === undefined) {
636    array = new Uint8Array(array)
637  } else if (length === undefined) {
638    array = new Uint8Array(array, byteOffset)
639  } else {
640    array = new Uint8Array(array, byteOffset, length)
641  }
642
643  if (Buffer.TYPED_ARRAY_SUPPORT) {
644    // Return an augmented `Uint8Array` instance, for best performance
645    that = array
646    that.__proto__ = Buffer.prototype
647  } else {
648    // Fallback: Return an object instance of the Buffer class
649    that = fromArrayLike(that, array)
650  }
651  return that
652}
653
654function fromObject (that, obj) {
655  if (Buffer.isBuffer(obj)) {
656    var len = checked(obj.length) | 0
657    that = createBuffer(that, len)
658
659    if (that.length === 0) {
660      return that
661    }
662
663    obj.copy(that, 0, 0, len)
664    return that
665  }
666
667  if (obj) {
668    if ((typeof ArrayBuffer !== 'undefined' &&
669        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
670      if (typeof obj.length !== 'number' || isnan(obj.length)) {
671        return createBuffer(that, 0)
672      }
673      return fromArrayLike(that, obj)
674    }
675
676    if (obj.type === 'Buffer' && isArray(obj.data)) {
677      return fromArrayLike(that, obj.data)
678    }
679  }
680
681  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
682}
683
684function checked (length) {
685  // Note: cannot use `length < kMaxLength()` here because that fails when
686  // length is NaN (which is otherwise coerced to zero.)
687  if (length >= kMaxLength()) {
688    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
689                         'size: 0x' + kMaxLength().toString(16) + ' bytes')
690  }
691  return length | 0
692}
693
694function SlowBuffer (length) {
695  if (+length != length) { // eslint-disable-line eqeqeq
696    length = 0
697  }
698  return Buffer.alloc(+length)
699}
700
701Buffer.isBuffer = function isBuffer (b) {
702  return !!(b != null && b._isBuffer)
703}
704
705Buffer.compare = function compare (a, b) {
706  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
707    throw new TypeError('Arguments must be Buffers')
708  }
709
710  if (a === b) return 0
711
712  var x = a.length
713  var y = b.length
714
715  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
716    if (a[i] !== b[i]) {
717      x = a[i]
718      y = b[i]
719      break
720    }
721  }
722
723  if (x < y) return -1
724  if (y < x) return 1
725  return 0
726}
727
728Buffer.isEncoding = function isEncoding (encoding) {
729  switch (String(encoding).toLowerCase()) {
730    case 'hex':
731    case 'utf8':
732    case 'utf-8':
733    case 'ascii':
734    case 'latin1':
735    case 'binary':
736    case 'base64':
737    case 'ucs2':
738    case 'ucs-2':
739    case 'utf16le':
740    case 'utf-16le':
741      return true
742    default:
743      return false
744  }
745}
746
747Buffer.concat = function concat (list, length) {
748  if (!isArray(list)) {
749    throw new TypeError('"list" argument must be an Array of Buffers')
750  }
751
752  if (list.length === 0) {
753    return Buffer.alloc(0)
754  }
755
756  var i
757  if (length === undefined) {
758    length = 0
759    for (i = 0; i < list.length; ++i) {
760      length += list[i].length
761    }
762  }
763
764  var buffer = Buffer.allocUnsafe(length)
765  var pos = 0
766  for (i = 0; i < list.length; ++i) {
767    var buf = list[i]
768    if (!Buffer.isBuffer(buf)) {
769      throw new TypeError('"list" argument must be an Array of Buffers')
770    }
771    buf.copy(buffer, pos)
772    pos += buf.length
773  }
774  return buffer
775}
776
777function byteLength (string, encoding) {
778  if (Buffer.isBuffer(string)) {
779    return string.length
780  }
781  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
782      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
783    return string.byteLength
784  }
785  if (typeof string !== 'string') {
786    string = '' + string
787  }
788
789  var len = string.length
790  if (len === 0) return 0
791
792  // Use a for loop to avoid recursion
793  var loweredCase = false
794  for (;;) {
795    switch (encoding) {
796      case 'ascii':
797      case 'latin1':
798      case 'binary':
799        return len
800      case 'utf8':
801      case 'utf-8':
802      case undefined:
803        return utf8ToBytes(string).length
804      case 'ucs2':
805      case 'ucs-2':
806      case 'utf16le':
807      case 'utf-16le':
808        return len * 2
809      case 'hex':
810        return len >>> 1
811      case 'base64':
812        return base64ToBytes(string).length
813      default:
814        if (loweredCase) return utf8ToBytes(string).length // assume utf8
815        encoding = ('' + encoding).toLowerCase()
816        loweredCase = true
817    }
818  }
819}
820Buffer.byteLength = byteLength
821
822function slowToString (encoding, start, end) {
823  var loweredCase = false
824
825  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
826  // property of a typed array.
827
828  // This behaves neither like String nor Uint8Array in that we set start/end
829  // to their upper/lower bounds if the value passed is out of range.
830  // undefined is handled specially as per ECMA-262 6th Edition,
831  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
832  if (start === undefined || start < 0) {
833    start = 0
834  }
835  // Return early if start > this.length. Done here to prevent potential uint32
836  // coercion fail below.
837  if (start > this.length) {
838    return ''
839  }
840
841  if (end === undefined || end > this.length) {
842    end = this.length
843  }
844
845  if (end <= 0) {
846    return ''
847  }
848
849  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
850  end >>>= 0
851  start >>>= 0
852
853  if (end <= start) {
854    return ''
855  }
856
857  if (!encoding) encoding = 'utf8'
858
859  while (true) {
860    switch (encoding) {
861      case 'hex':
862        return hexSlice(this, start, end)
863
864      case 'utf8':
865      case 'utf-8':
866        return utf8Slice(this, start, end)
867
868      case 'ascii':
869        return asciiSlice(this, start, end)
870
871      case 'latin1':
872      case 'binary':
873        return latin1Slice(this, start, end)
874
875      case 'base64':
876        return base64Slice(this, start, end)
877
878      case 'ucs2':
879      case 'ucs-2':
880      case 'utf16le':
881      case 'utf-16le':
882        return utf16leSlice(this, start, end)
883
884      default:
885        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
886        encoding = (encoding + '').toLowerCase()
887        loweredCase = true
888    }
889  }
890}
891
892// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
893// Buffer instances.
894Buffer.prototype._isBuffer = true
895
896function swap (b, n, m) {
897  var i = b[n]
898  b[n] = b[m]
899  b[m] = i
900}
901
902Buffer.prototype.swap16 = function swap16 () {
903  var len = this.length
904  if (len % 2 !== 0) {
905    throw new RangeError('Buffer size must be a multiple of 16-bits')
906  }
907  for (var i = 0; i < len; i += 2) {
908    swap(this, i, i + 1)
909  }
910  return this
911}
912
913Buffer.prototype.swap32 = function swap32 () {
914  var len = this.length
915  if (len % 4 !== 0) {
916    throw new RangeError('Buffer size must be a multiple of 32-bits')
917  }
918  for (var i = 0; i < len; i += 4) {
919    swap(this, i, i + 3)
920    swap(this, i + 1, i + 2)
921  }
922  return this
923}
924
925Buffer.prototype.swap64 = function swap64 () {
926  var len = this.length
927  if (len % 8 !== 0) {
928    throw new RangeError('Buffer size must be a multiple of 64-bits')
929  }
930  for (var i = 0; i < len; i += 8) {
931    swap(this, i, i + 7)
932    swap(this, i + 1, i + 6)
933    swap(this, i + 2, i + 5)
934    swap(this, i + 3, i + 4)
935  }
936  return this
937}
938
939Buffer.prototype.toString = function toString () {
940  var length = this.length | 0
941  if (length === 0) return ''
942  if (arguments.length === 0) return utf8Slice(this, 0, length)
943  return slowToString.apply(this, arguments)
944}
945
946Buffer.prototype.equals = function equals (b) {
947  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
948  if (this === b) return true
949  return Buffer.compare(this, b) === 0
950}
951
952Buffer.prototype.inspect = function inspect () {
953  var str = ''
954  var max = exports.INSPECT_MAX_BYTES
955  if (this.length > 0) {
956    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
957    if (this.length > max) str += ' ... '
958  }
959  return '<Buffer ' + str + '>'
960}
961
962Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
963  if (!Buffer.isBuffer(target)) {
964    throw new TypeError('Argument must be a Buffer')
965  }
966
967  if (start === undefined) {
968    start = 0
969  }
970  if (end === undefined) {
971    end = target ? target.length : 0
972  }
973  if (thisStart === undefined) {
974    thisStart = 0
975  }
976  if (thisEnd === undefined) {
977    thisEnd = this.length
978  }
979
980  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
981    throw new RangeError('out of range index')
982  }
983
984  if (thisStart >= thisEnd && start >= end) {
985    return 0
986  }
987  if (thisStart >= thisEnd) {
988    return -1
989  }
990  if (start >= end) {
991    return 1
992  }
993
994  start >>>= 0
995  end >>>= 0
996  thisStart >>>= 0
997  thisEnd >>>= 0
998
999  if (this === target) return 0
1000
1001  var x = thisEnd - thisStart
1002  var y = end - start
1003  var len = Math.min(x, y)
1004
1005  var thisCopy = this.slice(thisStart, thisEnd)
1006  var targetCopy = target.slice(start, end)
1007
1008  for (var i = 0; i < len; ++i) {
1009    if (thisCopy[i] !== targetCopy[i]) {
1010      x = thisCopy[i]
1011      y = targetCopy[i]
1012      break
1013    }
1014  }
1015
1016  if (x < y) return -1
1017  if (y < x) return 1
1018  return 0
1019}
1020
1021// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1022// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1023//
1024// Arguments:
1025// - buffer - a Buffer to search
1026// - val - a string, Buffer, or number
1027// - byteOffset - an index into `buffer`; will be clamped to an int32
1028// - encoding - an optional encoding, relevant is val is a string
1029// - dir - true for indexOf, false for lastIndexOf
1030function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1031  // Empty buffer means no match
1032  if (buffer.length === 0) return -1
1033
1034  // Normalize byteOffset
1035  if (typeof byteOffset === 'string') {
1036    encoding = byteOffset
1037    byteOffset = 0
1038  } else if (byteOffset > 0x7fffffff) {
1039    byteOffset = 0x7fffffff
1040  } else if (byteOffset < -0x80000000) {
1041    byteOffset = -0x80000000
1042  }
1043  byteOffset = +byteOffset  // Coerce to Number.
1044  if (isNaN(byteOffset)) {
1045    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1046    byteOffset = dir ? 0 : (buffer.length - 1)
1047  }
1048
1049  // Normalize byteOffset: negative offsets start from the end of the buffer
1050  if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1051  if (byteOffset >= buffer.length) {
1052    if (dir) return -1
1053    else byteOffset = buffer.length - 1
1054  } else if (byteOffset < 0) {
1055    if (dir) byteOffset = 0
1056    else return -1
1057  }
1058
1059  // Normalize val
1060  if (typeof val === 'string') {
1061    val = Buffer.from(val, encoding)
1062  }
1063
1064  // Finally, search either indexOf (if dir is true) or lastIndexOf
1065  if (Buffer.isBuffer(val)) {
1066    // Special case: looking for empty string/buffer always fails
1067    if (val.length === 0) {
1068      return -1
1069    }
1070    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1071  } else if (typeof val === 'number') {
1072    val = val & 0xFF // Search for a byte value [0-255]
1073    if (Buffer.TYPED_ARRAY_SUPPORT &&
1074        typeof Uint8Array.prototype.indexOf === 'function') {
1075      if (dir) {
1076        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1077      } else {
1078        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1079      }
1080    }
1081    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1082  }
1083
1084  throw new TypeError('val must be string, number or Buffer')
1085}
1086
1087function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1088  var indexSize = 1
1089  var arrLength = arr.length
1090  var valLength = val.length
1091
1092  if (encoding !== undefined) {
1093    encoding = String(encoding).toLowerCase()
1094    if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1095        encoding === 'utf16le' || encoding === 'utf-16le') {
1096      if (arr.length < 2 || val.length < 2) {
1097        return -1
1098      }
1099      indexSize = 2
1100      arrLength /= 2
1101      valLength /= 2
1102      byteOffset /= 2
1103    }
1104  }
1105
1106  function read (buf, i) {
1107    if (indexSize === 1) {
1108      return buf[i]
1109    } else {
1110      return buf.readUInt16BE(i * indexSize)
1111    }
1112  }
1113
1114  var i
1115  if (dir) {
1116    var foundIndex = -1
1117    for (i = byteOffset; i < arrLength; i++) {
1118      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1119        if (foundIndex === -1) foundIndex = i
1120        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1121      } else {
1122        if (foundIndex !== -1) i -= i - foundIndex
1123        foundIndex = -1
1124      }
1125    }
1126  } else {
1127    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1128    for (i = byteOffset; i >= 0; i--) {
1129      var found = true
1130      for (var j = 0; j < valLength; j++) {
1131        if (read(arr, i + j) !== read(val, j)) {
1132          found = false
1133          break
1134        }
1135      }
1136      if (found) return i
1137    }
1138  }
1139
1140  return -1
1141}
1142
1143Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1144  return this.indexOf(val, byteOffset, encoding) !== -1
1145}
1146
1147Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1148  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1149}
1150
1151Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1152  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1153}
1154
1155function hexWrite (buf, string, offset, length) {
1156  offset = Number(offset) || 0
1157  var remaining = buf.length - offset
1158  if (!length) {
1159    length = remaining
1160  } else {
1161    length = Number(length)
1162    if (length > remaining) {
1163      length = remaining
1164    }
1165  }
1166
1167  // must be an even number of digits
1168  var strLen = string.length
1169  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1170
1171  if (length > strLen / 2) {
1172    length = strLen / 2
1173  }
1174  for (var i = 0; i < length; ++i) {
1175    var parsed = parseInt(string.substr(i * 2, 2), 16)
1176    if (isNaN(parsed)) return i
1177    buf[offset + i] = parsed
1178  }
1179  return i
1180}
1181
1182function utf8Write (buf, string, offset, length) {
1183  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1184}
1185
1186function asciiWrite (buf, string, offset, length) {
1187  return blitBuffer(asciiToBytes(string), buf, offset, length)
1188}
1189
1190function latin1Write (buf, string, offset, length) {
1191  return asciiWrite(buf, string, offset, length)
1192}
1193
1194function base64Write (buf, string, offset, length) {
1195  return blitBuffer(base64ToBytes(string), buf, offset, length)
1196}
1197
1198function ucs2Write (buf, string, offset, length) {
1199  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1200}
1201
1202Buffer.prototype.write = function write (string, offset, length, encoding) {
1203  // Buffer#write(string)
1204  if (offset === undefined) {
1205    encoding = 'utf8'
1206    length = this.length
1207    offset = 0
1208  // Buffer#write(string, encoding)
1209  } else if (length === undefined && typeof offset === 'string') {
1210    encoding = offset
1211    length = this.length
1212    offset = 0
1213  // Buffer#write(string, offset[, length][, encoding])
1214  } else if (isFinite(offset)) {
1215    offset = offset | 0
1216    if (isFinite(length)) {
1217      length = length | 0
1218      if (encoding === undefined) encoding = 'utf8'
1219    } else {
1220      encoding = length
1221      length = undefined
1222    }
1223  // legacy write(string, encoding, offset, length) - remove in v0.13
1224  } else {
1225    throw new Error(
1226      'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1227    )
1228  }
1229
1230  var remaining = this.length - offset
1231  if (length === undefined || length > remaining) length = remaining
1232
1233  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1234    throw new RangeError('Attempt to write outside buffer bounds')
1235  }
1236
1237  if (!encoding) encoding = 'utf8'
1238
1239  var loweredCase = false
1240  for (;;) {
1241    switch (encoding) {
1242      case 'hex':
1243        return hexWrite(this, string, offset, length)
1244
1245      case 'utf8':
1246      case 'utf-8':
1247        return utf8Write(this, string, offset, length)
1248
1249      case 'ascii':
1250        return asciiWrite(this, string, offset, length)
1251
1252      case 'latin1':
1253      case 'binary':
1254        return latin1Write(this, string, offset, length)
1255
1256      case 'base64':
1257        // Warning: maxLength not taken into account in base64Write
1258        return base64Write(this, string, offset, length)
1259
1260      case 'ucs2':
1261      case 'ucs-2':
1262      case 'utf16le':
1263      case 'utf-16le':
1264        return ucs2Write(this, string, offset, length)
1265
1266      default:
1267        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1268        encoding = ('' + encoding).toLowerCase()
1269        loweredCase = true
1270    }
1271  }
1272}
1273
1274Buffer.prototype.toJSON = function toJSON () {
1275  return {
1276    type: 'Buffer',
1277    data: Array.prototype.slice.call(this._arr || this, 0)
1278  }
1279}
1280
1281function base64Slice (buf, start, end) {
1282  if (start === 0 && end === buf.length) {
1283    return base64.fromByteArray(buf)
1284  } else {
1285    return base64.fromByteArray(buf.slice(start, end))
1286  }
1287}
1288
1289function utf8Slice (buf, start, end) {
1290  end = Math.min(buf.length, end)
1291  var res = []
1292
1293  var i = start
1294  while (i < end) {
1295    var firstByte = buf[i]
1296    var codePoint = null
1297    var bytesPerSequence = (firstByte > 0xEF) ? 4
1298      : (firstByte > 0xDF) ? 3
1299      : (firstByte > 0xBF) ? 2
1300      : 1
1301
1302    if (i + bytesPerSequence <= end) {
1303      var secondByte, thirdByte, fourthByte, tempCodePoint
1304
1305      switch (bytesPerSequence) {
1306        case 1:
1307          if (firstByte < 0x80) {
1308            codePoint = firstByte
1309          }
1310          break
1311        case 2:
1312          secondByte = buf[i + 1]
1313          if ((secondByte & 0xC0) === 0x80) {
1314            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1315            if (tempCodePoint > 0x7F) {
1316              codePoint = tempCodePoint
1317            }
1318          }
1319          break
1320        case 3:
1321          secondByte = buf[i + 1]
1322          thirdByte = buf[i + 2]
1323          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1324            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1325            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1326              codePoint = tempCodePoint
1327            }
1328          }
1329          break
1330        case 4:
1331          secondByte = buf[i + 1]
1332          thirdByte = buf[i + 2]
1333          fourthByte = buf[i + 3]
1334          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1335            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1336            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1337              codePoint = tempCodePoint
1338            }
1339          }
1340      }
1341    }
1342
1343    if (codePoint === null) {
1344      // we did not generate a valid codePoint so insert a
1345      // replacement char (U+FFFD) and advance only 1 byte
1346      codePoint = 0xFFFD
1347      bytesPerSequence = 1
1348    } else if (codePoint > 0xFFFF) {
1349      // encode to utf16 (surrogate pair dance)
1350      codePoint -= 0x10000
1351      res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1352      codePoint = 0xDC00 | codePoint & 0x3FF
1353    }
1354
1355    res.push(codePoint)
1356    i += bytesPerSequence
1357  }
1358
1359  return decodeCodePointsArray(res)
1360}
1361
1362// Based on http://stackoverflow.com/a/22747272/680742, the browser with
1363// the lowest limit is Chrome, with 0x10000 args.
1364// We go 1 magnitude less, for safety
1365var MAX_ARGUMENTS_LENGTH = 0x1000
1366
1367function decodeCodePointsArray (codePoints) {
1368  var len = codePoints.length
1369  if (len <= MAX_ARGUMENTS_LENGTH) {
1370    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1371  }
1372
1373  // Decode in chunks to avoid "call stack size exceeded".
1374  var res = ''
1375  var i = 0
1376  while (i < len) {
1377    res += String.fromCharCode.apply(
1378      String,
1379      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1380    )
1381  }
1382  return res
1383}
1384
1385function asciiSlice (buf, start, end) {
1386  var ret = ''
1387  end = Math.min(buf.length, end)
1388
1389  for (var i = start; i < end; ++i) {
1390    ret += String.fromCharCode(buf[i] & 0x7F)
1391  }
1392  return ret
1393}
1394
1395function latin1Slice (buf, start, end) {
1396  var ret = ''
1397  end = Math.min(buf.length, end)
1398
1399  for (var i = start; i < end; ++i) {
1400    ret += String.fromCharCode(buf[i])
1401  }
1402  return ret
1403}
1404
1405function hexSlice (buf, start, end) {
1406  var len = buf.length
1407
1408  if (!start || start < 0) start = 0
1409  if (!end || end < 0 || end > len) end = len
1410
1411  var out = ''
1412  for (var i = start; i < end; ++i) {
1413    out += toHex(buf[i])
1414  }
1415  return out
1416}
1417
1418function utf16leSlice (buf, start, end) {
1419  var bytes = buf.slice(start, end)
1420  var res = ''
1421  for (var i = 0; i < bytes.length; i += 2) {
1422    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1423  }
1424  return res
1425}
1426
1427Buffer.prototype.slice = function slice (start, end) {
1428  var len = this.length
1429  start = ~~start
1430  end = end === undefined ? len : ~~end
1431
1432  if (start < 0) {
1433    start += len
1434    if (start < 0) start = 0
1435  } else if (start > len) {
1436    start = len
1437  }
1438
1439  if (end < 0) {
1440    end += len
1441    if (end < 0) end = 0
1442  } else if (end > len) {
1443    end = len
1444  }
1445
1446  if (end < start) end = start
1447
1448  var newBuf
1449  if (Buffer.TYPED_ARRAY_SUPPORT) {
1450    newBuf = this.subarray(start, end)
1451    newBuf.__proto__ = Buffer.prototype
1452  } else {
1453    var sliceLen = end - start
1454    newBuf = new Buffer(sliceLen, undefined)
1455    for (var i = 0; i < sliceLen; ++i) {
1456      newBuf[i] = this[i + start]
1457    }
1458  }
1459
1460  return newBuf
1461}
1462
1463/*
1464 * Need to make sure that buffer isn't trying to write out of bounds.
1465 */
1466function checkOffset (offset, ext, length) {
1467  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1468  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1469}
1470
1471Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1472  offset = offset | 0
1473  byteLength = byteLength | 0
1474  if (!noAssert) checkOffset(offset, byteLength, this.length)
1475
1476  var val = this[offset]
1477  var mul = 1
1478  var i = 0
1479  while (++i < byteLength && (mul *= 0x100)) {
1480    val += this[offset + i] * mul
1481  }
1482
1483  return val
1484}
1485
1486Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1487  offset = offset | 0
1488  byteLength = byteLength | 0
1489  if (!noAssert) {
1490    checkOffset(offset, byteLength, this.length)
1491  }
1492
1493  var val = this[offset + --byteLength]
1494  var mul = 1
1495  while (byteLength > 0 && (mul *= 0x100)) {
1496    val += this[offset + --byteLength] * mul
1497  }
1498
1499  return val
1500}
1501
1502Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1503  if (!noAssert) checkOffset(offset, 1, this.length)
1504  return this[offset]
1505}
1506
1507Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1508  if (!noAssert) checkOffset(offset, 2, this.length)
1509  return this[offset] | (this[offset + 1] << 8)
1510}
1511
1512Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1513  if (!noAssert) checkOffset(offset, 2, this.length)
1514  return (this[offset] << 8) | this[offset + 1]
1515}
1516
1517Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1518  if (!noAssert) checkOffset(offset, 4, this.length)
1519
1520  return ((this[offset]) |
1521      (this[offset + 1] << 8) |
1522      (this[offset + 2] << 16)) +
1523      (this[offset + 3] * 0x1000000)
1524}
1525
1526Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1527  if (!noAssert) checkOffset(offset, 4, this.length)
1528
1529  return (this[offset] * 0x1000000) +
1530    ((this[offset + 1] << 16) |
1531    (this[offset + 2] << 8) |
1532    this[offset + 3])
1533}
1534
1535Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1536  offset = offset | 0
1537  byteLength = byteLength | 0
1538  if (!noAssert) checkOffset(offset, byteLength, this.length)
1539
1540  var val = this[offset]
1541  var mul = 1
1542  var i = 0
1543  while (++i < byteLength && (mul *= 0x100)) {
1544    val += this[offset + i] * mul
1545  }
1546  mul *= 0x80
1547
1548  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1549
1550  return val
1551}
1552
1553Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1554  offset = offset | 0
1555  byteLength = byteLength | 0
1556  if (!noAssert) checkOffset(offset, byteLength, this.length)
1557
1558  var i = byteLength
1559  var mul = 1
1560  var val = this[offset + --i]
1561  while (i > 0 && (mul *= 0x100)) {
1562    val += this[offset + --i] * mul
1563  }
1564  mul *= 0x80
1565
1566  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1567
1568  return val
1569}
1570
1571Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1572  if (!noAssert) checkOffset(offset, 1, this.length)
1573  if (!(this[offset] & 0x80)) return (this[offset])
1574  return ((0xff - this[offset] + 1) * -1)
1575}
1576
1577Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1578  if (!noAssert) checkOffset(offset, 2, this.length)
1579  var val = this[offset] | (this[offset + 1] << 8)
1580  return (val & 0x8000) ? val | 0xFFFF0000 : val
1581}
1582
1583Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1584  if (!noAssert) checkOffset(offset, 2, this.length)
1585  var val = this[offset + 1] | (this[offset] << 8)
1586  return (val & 0x8000) ? val | 0xFFFF0000 : val
1587}
1588
1589Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1590  if (!noAssert) checkOffset(offset, 4, this.length)
1591
1592  return (this[offset]) |
1593    (this[offset + 1] << 8) |
1594    (this[offset + 2] << 16) |
1595    (this[offset + 3] << 24)
1596}
1597
1598Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1599  if (!noAssert) checkOffset(offset, 4, this.length)
1600
1601  return (this[offset] << 24) |
1602    (this[offset + 1] << 16) |
1603    (this[offset + 2] << 8) |
1604    (this[offset + 3])
1605}
1606
1607Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1608  if (!noAssert) checkOffset(offset, 4, this.length)
1609  return ieee754.read(this, offset, true, 23, 4)
1610}
1611
1612Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1613  if (!noAssert) checkOffset(offset, 4, this.length)
1614  return ieee754.read(this, offset, false, 23, 4)
1615}
1616
1617Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1618  if (!noAssert) checkOffset(offset, 8, this.length)
1619  return ieee754.read(this, offset, true, 52, 8)
1620}
1621
1622Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1623  if (!noAssert) checkOffset(offset, 8, this.length)
1624  return ieee754.read(this, offset, false, 52, 8)
1625}
1626
1627function checkInt (buf, value, offset, ext, max, min) {
1628  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1629  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1630  if (offset + ext > buf.length) throw new RangeError('Index out of range')
1631}
1632
1633Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1634  value = +value
1635  offset = offset | 0
1636  byteLength = byteLength | 0
1637  if (!noAssert) {
1638    var maxBytes = Math.pow(2, 8 * byteLength) - 1
1639    checkInt(this, value, offset, byteLength, maxBytes, 0)
1640  }
1641
1642  var mul = 1
1643  var i = 0
1644  this[offset] = value & 0xFF
1645  while (++i < byteLength && (mul *= 0x100)) {
1646    this[offset + i] = (value / mul) & 0xFF
1647  }
1648
1649  return offset + byteLength
1650}
1651
1652Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1653  value = +value
1654  offset = offset | 0
1655  byteLength = byteLength | 0
1656  if (!noAssert) {
1657    var maxBytes = Math.pow(2, 8 * byteLength) - 1
1658    checkInt(this, value, offset, byteLength, maxBytes, 0)
1659  }
1660
1661  var i = byteLength - 1
1662  var mul = 1
1663  this[offset + i] = value & 0xFF
1664  while (--i >= 0 && (mul *= 0x100)) {
1665    this[offset + i] = (value / mul) & 0xFF
1666  }
1667
1668  return offset + byteLength
1669}
1670
1671Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1672  value = +value
1673  offset = offset | 0
1674  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1675  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1676  this[offset] = (value & 0xff)
1677  return offset + 1
1678}
1679
1680function objectWriteUInt16 (buf, value, offset, littleEndian) {
1681  if (value < 0) value = 0xffff + value + 1
1682  for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1683    buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1684      (littleEndian ? i : 1 - i) * 8
1685  }
1686}
1687
1688Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1689  value = +value
1690  offset = offset | 0
1691  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1692  if (Buffer.TYPED_ARRAY_SUPPORT) {
1693    this[offset] = (value & 0xff)
1694    this[offset + 1] = (value >>> 8)
1695  } else {
1696    objectWriteUInt16(this, value, offset, true)
1697  }
1698  return offset + 2
1699}
1700
1701Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1702  value = +value
1703  offset = offset | 0
1704  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1705  if (Buffer.TYPED_ARRAY_SUPPORT) {
1706    this[offset] = (value >>> 8)
1707    this[offset + 1] = (value & 0xff)
1708  } else {
1709    objectWriteUInt16(this, value, offset, false)
1710  }
1711  return offset + 2
1712}
1713
1714function objectWriteUInt32 (buf, value, offset, littleEndian) {
1715  if (value < 0) value = 0xffffffff + value + 1
1716  for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1717    buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1718  }
1719}
1720
1721Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1722  value = +value
1723  offset = offset | 0
1724  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1725  if (Buffer.TYPED_ARRAY_SUPPORT) {
1726    this[offset + 3] = (value >>> 24)
1727    this[offset + 2] = (value >>> 16)
1728    this[offset + 1] = (value >>> 8)
1729    this[offset] = (value & 0xff)
1730  } else {
1731    objectWriteUInt32(this, value, offset, true)
1732  }
1733  return offset + 4
1734}
1735
1736Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1737  value = +value
1738  offset = offset | 0
1739  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1740  if (Buffer.TYPED_ARRAY_SUPPORT) {
1741    this[offset] = (value >>> 24)
1742    this[offset + 1] = (value >>> 16)
1743    this[offset + 2] = (value >>> 8)
1744    this[offset + 3] = (value & 0xff)
1745  } else {
1746    objectWriteUInt32(this, value, offset, false)
1747  }
1748  return offset + 4
1749}
1750
1751Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1752  value = +value
1753  offset = offset | 0
1754  if (!noAssert) {
1755    var limit = Math.pow(2, 8 * byteLength - 1)
1756
1757    checkInt(this, value, offset, byteLength, limit - 1, -limit)
1758  }
1759
1760  var i = 0
1761  var mul = 1
1762  var sub = 0
1763  this[offset] = value & 0xFF
1764  while (++i < byteLength && (mul *= 0x100)) {
1765    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1766      sub = 1
1767    }
1768    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1769  }
1770
1771  return offset + byteLength
1772}
1773
1774Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1775  value = +value
1776  offset = offset | 0
1777  if (!noAssert) {
1778    var limit = Math.pow(2, 8 * byteLength - 1)
1779
1780    checkInt(this, value, offset, byteLength, limit - 1, -limit)
1781  }
1782
1783  var i = byteLength - 1
1784  var mul = 1
1785  var sub = 0
1786  this[offset + i] = value & 0xFF
1787  while (--i >= 0 && (mul *= 0x100)) {
1788    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1789      sub = 1
1790    }
1791    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1792  }
1793
1794  return offset + byteLength
1795}
1796
1797Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1798  value = +value
1799  offset = offset | 0
1800  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1801  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1802  if (value < 0) value = 0xff + value + 1
1803  this[offset] = (value & 0xff)
1804  return offset + 1
1805}
1806
1807Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1808  value = +value
1809  offset = offset | 0
1810  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1811  if (Buffer.TYPED_ARRAY_SUPPORT) {
1812    this[offset] = (value & 0xff)
1813    this[offset + 1] = (value >>> 8)
1814  } else {
1815    objectWriteUInt16(this, value, offset, true)
1816  }
1817  return offset + 2
1818}
1819
1820Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1821  value = +value
1822  offset = offset | 0
1823  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1824  if (Buffer.TYPED_ARRAY_SUPPORT) {
1825    this[offset] = (value >>> 8)
1826    this[offset + 1] = (value & 0xff)
1827  } else {
1828    objectWriteUInt16(this, value, offset, false)
1829  }
1830  return offset + 2
1831}
1832
1833Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1834  value = +value
1835  offset = offset | 0
1836  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1837  if (Buffer.TYPED_ARRAY_SUPPORT) {
1838    this[offset] = (value & 0xff)
1839    this[offset + 1] = (value >>> 8)
1840    this[offset + 2] = (value >>> 16)
1841    this[offset + 3] = (value >>> 24)
1842  } else {
1843    objectWriteUInt32(this, value, offset, true)
1844  }
1845  return offset + 4
1846}
1847
1848Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1849  value = +value
1850  offset = offset | 0
1851  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1852  if (value < 0) value = 0xffffffff + value + 1
1853  if (Buffer.TYPED_ARRAY_SUPPORT) {
1854    this[offset] = (value >>> 24)
1855    this[offset + 1] = (value >>> 16)
1856    this[offset + 2] = (value >>> 8)
1857    this[offset + 3] = (value & 0xff)
1858  } else {
1859    objectWriteUInt32(this, value, offset, false)
1860  }
1861  return offset + 4
1862}
1863
1864function checkIEEE754 (buf, value, offset, ext, max, min) {
1865  if (offset + ext > buf.length) throw new RangeError('Index out of range')
1866  if (offset < 0) throw new RangeError('Index out of range')
1867}
1868
1869function writeFloat (buf, value, offset, littleEndian, noAssert) {
1870  if (!noAssert) {
1871    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1872  }
1873  ieee754.write(buf, value, offset, littleEndian, 23, 4)
1874  return offset + 4
1875}
1876
1877Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1878  return writeFloat(this, value, offset, true, noAssert)
1879}
1880
1881Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1882  return writeFloat(this, value, offset, false, noAssert)
1883}
1884
1885function writeDouble (buf, value, offset, littleEndian, noAssert) {
1886  if (!noAssert) {
1887    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1888  }
1889  ieee754.write(buf, value, offset, littleEndian, 52, 8)
1890  return offset + 8
1891}
1892
1893Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1894  return writeDouble(this, value, offset, true, noAssert)
1895}
1896
1897Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1898  return writeDouble(this, value, offset, false, noAssert)
1899}
1900
1901// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1902Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1903  if (!start) start = 0
1904  if (!end && end !== 0) end = this.length
1905  if (targetStart >= target.length) targetStart = target.length
1906  if (!targetStart) targetStart = 0
1907  if (end > 0 && end < start) end = start
1908
1909  // Copy 0 bytes; we're done
1910  if (end === start) return 0
1911  if (target.length === 0 || this.length === 0) return 0
1912
1913  // Fatal error conditions
1914  if (targetStart < 0) {
1915    throw new RangeError('targetStart out of bounds')
1916  }
1917  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1918  if (end < 0) throw new RangeError('sourceEnd out of bounds')
1919
1920  // Are we oob?
1921  if (end > this.length) end = this.length
1922  if (target.length - targetStart < end - start) {
1923    end = target.length - targetStart + start
1924  }
1925
1926  var len = end - start
1927  var i
1928
1929  if (this === target && start < targetStart && targetStart < end) {
1930    // descending copy from end
1931    for (i = len - 1; i >= 0; --i) {
1932      target[i + targetStart] = this[i + start]
1933    }
1934  } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1935    // ascending copy from start
1936    for (i = 0; i < len; ++i) {
1937      target[i + targetStart] = this[i + start]
1938    }
1939  } else {
1940    Uint8Array.prototype.set.call(
1941      target,
1942      this.subarray(start, start + len),
1943      targetStart
1944    )
1945  }
1946
1947  return len
1948}
1949
1950// Usage:
1951//    buffer.fill(number[, offset[, end]])
1952//    buffer.fill(buffer[, offset[, end]])
1953//    buffer.fill(string[, offset[, end]][, encoding])
1954Buffer.prototype.fill = function fill (val, start, end, encoding) {
1955  // Handle string cases:
1956  if (typeof val === 'string') {
1957    if (typeof start === 'string') {
1958      encoding = start
1959      start = 0
1960      end = this.length
1961    } else if (typeof end === 'string') {
1962      encoding = end
1963      end = this.length
1964    }
1965    if (val.length === 1) {
1966      var code = val.charCodeAt(0)
1967      if (code < 256) {
1968        val = code
1969      }
1970    }
1971    if (encoding !== undefined && typeof encoding !== 'string') {
1972      throw new TypeError('encoding must be a string')
1973    }
1974    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1975      throw new TypeError('Unknown encoding: ' + encoding)
1976    }
1977  } else if (typeof val === 'number') {
1978    val = val & 255
1979  }
1980
1981  // Invalid ranges are not set to a default, so can range check early.
1982  if (start < 0 || this.length < start || this.length < end) {
1983    throw new RangeError('Out of range index')
1984  }
1985
1986  if (end <= start) {
1987    return this
1988  }
1989
1990  start = start >>> 0
1991  end = end === undefined ? this.length : end >>> 0
1992
1993  if (!val) val = 0
1994
1995  var i
1996  if (typeof val === 'number') {
1997    for (i = start; i < end; ++i) {
1998      this[i] = val
1999    }
2000  } else {
2001    var bytes = Buffer.isBuffer(val)
2002      ? val
2003      : utf8ToBytes(new Buffer(val, encoding).toString())
2004    var len = bytes.length
2005    for (i = 0; i < end - start; ++i) {
2006      this[i + start] = bytes[i % len]
2007    }
2008  }
2009
2010  return this
2011}
2012
2013// HELPER FUNCTIONS
2014// ================
2015
2016var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
2017
2018function base64clean (str) {
2019  // Node strips out invalid characters like \n and \t from the string, base64-js does not
2020  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
2021  // Node converts strings with length < 2 to ''
2022  if (str.length < 2) return ''
2023  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2024  while (str.length % 4 !== 0) {
2025    str = str + '='
2026  }
2027  return str
2028}
2029
2030function stringtrim (str) {
2031  if (str.trim) return str.trim()
2032  return str.replace(/^\s+|\s+$/g, '')
2033}
2034
2035function toHex (n) {
2036  if (n < 16) return '0' + n.toString(16)
2037  return n.toString(16)
2038}
2039
2040function utf8ToBytes (string, units) {
2041  units = units || Infinity
2042  var codePoint
2043  var length = string.length
2044  var leadSurrogate = null
2045  var bytes = []
2046
2047  for (var i = 0; i < length; ++i) {
2048    codePoint = string.charCodeAt(i)
2049
2050    // is surrogate component
2051    if (codePoint > 0xD7FF && codePoint < 0xE000) {
2052      // last char was a lead
2053      if (!leadSurrogate) {
2054        // no lead yet
2055        if (codePoint > 0xDBFF) {
2056          // unexpected trail
2057          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2058          continue
2059        } else if (i + 1 === length) {
2060          // unpaired lead
2061          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2062          continue
2063        }
2064
2065        // valid lead
2066        leadSurrogate = codePoint
2067
2068        continue
2069      }
2070
2071      // 2 leads in a row
2072      if (codePoint < 0xDC00) {
2073        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2074        leadSurrogate = codePoint
2075        continue
2076      }
2077
2078      // valid surrogate pair
2079      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2080    } else if (leadSurrogate) {
2081      // valid bmp char, but last char was a lead
2082      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2083    }
2084
2085    leadSurrogate = null
2086
2087    // encode utf8
2088    if (codePoint < 0x80) {
2089      if ((units -= 1) < 0) break
2090      bytes.push(codePoint)
2091    } else if (codePoint < 0x800) {
2092      if ((units -= 2) < 0) break
2093      bytes.push(
2094        codePoint >> 0x6 | 0xC0,
2095        codePoint & 0x3F | 0x80
2096      )
2097    } else if (codePoint < 0x10000) {
2098      if ((units -= 3) < 0) break
2099      bytes.push(
2100        codePoint >> 0xC | 0xE0,
2101        codePoint >> 0x6 & 0x3F | 0x80,
2102        codePoint & 0x3F | 0x80
2103      )
2104    } else if (codePoint < 0x110000) {
2105      if ((units -= 4) < 0) break
2106      bytes.push(
2107        codePoint >> 0x12 | 0xF0,
2108        codePoint >> 0xC & 0x3F | 0x80,
2109        codePoint >> 0x6 & 0x3F | 0x80,
2110        codePoint & 0x3F | 0x80
2111      )
2112    } else {
2113      throw new Error('Invalid code point')
2114    }
2115  }
2116
2117  return bytes
2118}
2119
2120function asciiToBytes (str) {
2121  var byteArray = []
2122  for (var i = 0; i < str.length; ++i) {
2123    // Node's code seems to be doing this and not & 0x7F..
2124    byteArray.push(str.charCodeAt(i) & 0xFF)
2125  }
2126  return byteArray
2127}
2128
2129function utf16leToBytes (str, units) {
2130  var c, hi, lo
2131  var byteArray = []
2132  for (var i = 0; i < str.length; ++i) {
2133    if ((units -= 2) < 0) break
2134
2135    c = str.charCodeAt(i)
2136    hi = c >> 8
2137    lo = c % 256
2138    byteArray.push(lo)
2139    byteArray.push(hi)
2140  }
2141
2142  return byteArray
2143}
2144
2145function base64ToBytes (str) {
2146  return base64.toByteArray(base64clean(str))
2147}
2148
2149function blitBuffer (src, dst, offset, length) {
2150  for (var i = 0; i < length; ++i) {
2151    if ((i + offset >= dst.length) || (i >= src.length)) break
2152    dst[i + offset] = src[i]
2153  }
2154  return i
2155}
2156
2157function isnan (val) {
2158  return val !== val // eslint-disable-line no-self-compare
2159}
2160
2161/* WEBPACK VAR INJECTION */}.call(
vendor: 7,349 bytes, lines 2161-2472
2161exports, __webpack_require__(0).Buffer, __webpack_require__(2)))
2162
2163/***/ },
2164/* 1 */
2165/***/ function(module, exports, __webpack_require__) {
2166
2167/* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
2168  'use strict';
2169
2170  // Utils
2171  function assert (val, msg) {
2172    if (!val) throw new Error(msg || 'Assertion failed');
2173  }
2174
2175  // Could use `inherits` module, but don't want to move from single file
2176  // architecture yet.
2177  function inherits (ctor, superCtor) {
2178    ctor.super_ = superCtor;
2179    var TempCtor = function () {};
2180    TempCtor.prototype = superCtor.prototype;
2181    ctor.prototype = new TempCtor();
2182    ctor.prototype.constructor = ctor;
2183  }
2184
2185  // BN
2186
2187  function BN (number, base, endian) {
2188    if (BN.isBN(number)) {
2189      return number;
2190    }
2191
2192    this.negative = 0;
2193    this.words = null;
2194    this.length = 0;
2195
2196    // Reduction context
2197    this.red = null;
2198
2199    if (number !== null) {
2200      if (base === 'le' || base === 'be') {
2201        endian = base;
2202        base = 10;
2203      }
2204
2205      this._init(number || 0, base || 10, endian || 'be');
2206    }
2207  }
2208  if (typeof module === 'object') {
2209    module.exports = BN;
2210  } else {
2211    exports.BN = BN;
2212  }
2213
2214  BN.BN = BN;
2215  BN.wordSize = 26;
2216
2217  var Buffer;
2218  try {
2219    Buffer = __webpack_require__(0).Buffer;
2220  } catch (e) {
2221  }
2222
2223  BN.isBN = function isBN (num) {
2224    if (num instanceof BN) {
2225      return true;
2226    }
2227
2228    return num !== null && typeof num === 'object' &&
2229      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
2230  };
2231
2232  BN.max = function max (left, right) {
2233    if (left.cmp(right) > 0) return left;
2234    return right;
2235  };
2236
2237  BN.min = function min (left, right) {
2238    if (left.cmp(right) < 0) return left;
2239    return right;
2240  };
2241
2242  BN.prototype._init = function init (number, base, endian) {
2243    if (typeof number === 'number') {
2244      return this._initNumber(number, base, endian);
2245    }
2246
2247    if (typeof number === 'object') {
2248      return this._initArray(number, base, endian);
2249    }
2250
2251    if (base === 'hex') {
2252      base = 16;
2253    }
2254    assert(base === (base | 0) && base >= 2 && base <= 36);
2255
2256    number = number.toString().replace(/\s+/g, '');
2257    var start = 0;
2258    if (number[0] === '-') {
2259      start++;
2260    }
2261
2262    if (base === 16) {
2263      this._parseHex(number, start);
2264    } else {
2265      this._parseBase(number, base, start);
2266    }
2267
2268    if (number[0] === '-') {
2269      this.negative = 1;
2270    }
2271
2272    this.strip();
2273
2274    if (endian !== 'le') return;
2275
2276    this._initArray(this.toArray(), base, endian);
2277  };
2278
2279  BN.prototype._initNumber = function _initNumber (number, base, endian) {
2280    if (number < 0) {
2281      this.negative = 1;
2282      number = -number;
2283    }
2284    if (number < 0x4000000) {
2285      this.words = [ number & 0x3ffffff ];
2286      this.length = 1;
2287    } else if (number < 0x10000000000000) {
2288      this.words = [
2289        number & 0x3ffffff,
2290        (number / 0x4000000) & 0x3ffffff
2291      ];
2292      this.length = 2;
2293    } else {
2294      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
2295      this.words = [
2296        number & 0x3ffffff,
2297        (number / 0x4000000) & 0x3ffffff,
2298        1
2299      ];
2300      this.length = 3;
2301    }
2302
2303    if (endian !== 'le') return;
2304
2305    // Reverse the bytes
2306    this._initArray(this.toArray(), base, endian);
2307  };
2308
2309  BN.prototype._initArray = function _initArray (number, base, endian) {
2310    // Perhaps a Uint8Array
2311    assert(typeof number.length === 'number');
2312    if (number.length <= 0) {
2313      this.words = [ 0 ];
2314      this.length = 1;
2315      return this;
2316    }
2317
2318    this.length = Math.ceil(number.length / 3);
2319    this.words = new Array(this.length);
2320    for (var i = 0; i < this.length; i++) {
2321      this.words[i] = 0;
2322    }
2323
2324    var j, w;
2325    var off = 0;
2326    if (endian === 'be') {
2327      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
2328        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
2329        this.words[j] |= (w << off) & 0x3ffffff;
2330        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
2331        off += 24;
2332        if (off >= 26) {
2333          off -= 26;
2334          j++;
2335        }
2336      }
2337    } else if (endian === 'le') {
2338      for (i = 0, j = 0; i < number.length; i += 3) {
2339        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
2340        this.words[j] |= (w << off) & 0x3ffffff;
2341        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
2342        off += 24;
2343        if (off >= 26) {
2344          off -= 26;
2345          j++;
2346        }
2347      }
2348    }
2349    return this.strip();
2350  };
2351
2352  function parseHex (str, start, end) {
2353    var r = 0;
2354    var len = Math.min(str.length, end);
2355    for (var i = start; i < len; i++) {
2356      var c = str.charCodeAt(i) - 48;
2357
2358      r <<= 4;
2359
2360      // 'a' - 'f'
2361      if (c >= 49 && c <= 54) {
2362        r |= c - 49 + 0xa;
2363
2364      // 'A' - 'F'
2365      } else if (c >= 17 && c <= 22) {
2366        r |= c - 17 + 0xa;
2367
2368      // '0' - '9'
2369      } else {
2370        r |= c & 0xf;
2371      }
2372    }
2373    return r;
2374  }
2375
2376  BN.prototype._parseHex = function _parseHex (number, start) {
2377    // Create possibly bigger array to ensure that it fits the number
2378    this.length = Math.ceil((number.length - start) / 6);
2379    this.words = new Array(this.length);
2380    for (var i = 0; i < this.length; i++) {
2381      this.words[i] = 0;
2382    }
2383
2384    var j, w;
2385    // Scan 24-bit chunks and add them to the number
2386    var off = 0;
2387    for (i = number.length - 6, j = 0; i >= start; i -= 6) {
2388      w = parseHex(number, i, i + 6);
2389      this.words[j] |= (w << off) & 0x3ffffff;
2390      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
2391      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
2392      off += 24;
2393      if (off >= 26) {
2394        off -= 26;
2395        j++;
2396      }
2397    }
2398    if (i + 6 !== start) {
2399      w = parseHex(number, start, i + 6);
2400      this.words[j] |= (w << off) & 0x3ffffff;
2401      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
2402    }
2403    this.strip();
2404  };
2405
2406  function parseBase (str, start, end, mul) {
2407    var r = 0;
2408    var len = Math.min(str.length, end);
2409    for (var i = start; i < len; i++) {
2410      var c = str.charCodeAt(i) - 48;
2411
2412      r *= mul;
2413
2414      // 'a'
2415      if (c >= 49) {
2416        r += c - 49 + 0xa;
2417
2418      // 'A'
2419      } else if (c >= 17) {
2420        r += c - 17 + 0xa;
2421
2422      // '0' - '9'
2423      } else {
2424        r += c;
2425      }
2426    }
2427    return r;
2428  }
2429
2430  BN.prototype._parseBase = function _parseBase (number, base, start) {
2431    // Initialize as zero
2432    this.words = [ 0 ];
2433    this.length = 1;
2434
2435    // Find length of limb in base
2436    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
2437      limbLen++;
2438    }
2439    limbLen--;
2440    limbPow = (limbPow / base) | 0;
2441
2442    var total = number.length - start;
2443    var mod = total % limbLen;
2444    var end = Math.min(total, total - mod) + start;
2445
2446    var word = 0;
2447    for (var i = start; i < end; i += limbLen) {
2448      word = parseBase(number, i, i + limbLen, base);
2449
2450      this.imuln(limbPow);
2451      if (this.words[0] + word < 0x4000000) {
2452        this.words[0] += word;
2453      } else {
2454        this._iaddn(word);
2455      }
2456    }
2457
2458    if (mod !== 0) {
2459      var pow = 1;
2460      word = parseBase(number, i, number.length, base);
2461
2462      for (i = 0; i < mod; i++) {
2463        pow *= base;
2464      }
2465
2466      this.imuln(pow);
2467      if (this.words[0] + word < 0x4000000) {
2468        this.words[0] += word;
2469      } else {
2470        this._iaddn(word);
2471      }
2472    }
vendor: 68,018 bytes, lines 2472-5076
2472
2473  };
2474
2475  BN.prototype.copy = function copy (dest) {
2476    dest.words = new Array(this.length);
2477    for (var i = 0; i < this.length; i++) {
2478      dest.words[i] = this.words[i];
2479    }
2480    dest.length = this.length;
2481    dest.negative = this.negative;
2482    dest.red = this.red;
2483  };
2484
2485  BN.prototype.clone = function clone () {
2486    var r = new BN(null);
2487    this.copy(r);
2488    return r;
2489  };
2490
2491  BN.prototype._expand = function _expand (size) {
2492    while (this.length < size) {
2493      this.words[this.length++] = 0;
2494    }
2495    return this;
2496  };
2497
2498  // Remove leading `0` from `this`
2499  BN.prototype.strip = function strip () {
2500    while (this.length > 1 && this.words[this.length - 1] === 0) {
2501      this.length--;
2502    }
2503    return this._normSign();
2504  };
2505
2506  BN.prototype._normSign = function _normSign () {
2507    // -0 = 0
2508    if (this.length === 1 && this.words[0] === 0) {
2509      this.negative = 0;
2510    }
2511    return this;
2512  };
2513
2514  BN.prototype.inspect = function inspect () {
2515    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
2516  };
2517
2518  /*
2519
2520  var zeros = [];
2521  var groupSizes = [];
2522  var groupBases = [];
2523
2524  var s = '';
2525  var i = -1;
2526  while (++i < BN.wordSize) {
2527    zeros[i] = s;
2528    s += '0';
2529  }
2530  groupSizes[0] = 0;
2531  groupSizes[1] = 0;
2532  groupBases[0] = 0;
2533  groupBases[1] = 0;
2534  var base = 2 - 1;
2535  while (++base < 36 + 1) {
2536    var groupSize = 0;
2537    var groupBase = 1;
2538    while (groupBase < (1 << BN.wordSize) / base) {
2539      groupBase *= base;
2540      groupSize += 1;
2541    }
2542    groupSizes[base] = groupSize;
2543    groupBases[base] = groupBase;
2544  }
2545
2546  */
2547
2548  var zeros = [
2549    '',
2550    '0',
2551    '00',
2552    '000',
2553    '0000',
2554    '00000',
2555    '000000',
2556    '0000000',
2557    '00000000',
2558    '000000000',
2559    '0000000000',
2560    '00000000000',
2561    '000000000000',
2562    '0000000000000',
2563    '00000000000000',
2564    '000000000000000',
2565    '0000000000000000',
2566    '00000000000000000',
2567    '000000000000000000',
2568    '0000000000000000000',
2569    '00000000000000000000',
2570    '000000000000000000000',
2571    '0000000000000000000000',
2572    '00000000000000000000000',
2573    '000000000000000000000000',
2574    '0000000000000000000000000'
2575  ];
2576
2577  var groupSizes = [
2578    0, 0,
2579    25, 16, 12, 11, 10, 9, 8,
2580    8, 7, 7, 7, 7, 6, 6,
2581    6, 6, 6, 6, 6, 5, 5,
2582    5, 5, 5, 5, 5, 5, 5,
2583    5, 5, 5, 5, 5, 5, 5
2584  ];
2585
2586  var groupBases = [
2587    0, 0,
2588    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
2589    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
2590    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
2591    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
2592    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
2593  ];
2594
2595  BN.prototype.toString = function toString (base, padding) {
2596    base = base || 10;
2597    padding = padding | 0 || 1;
2598
2599    var out;
2600    if (base === 16 || base === 'hex') {
2601      out = '';
2602      var off = 0;
2603      var carry = 0;
2604      for (var i = 0; i < this.length; i++) {
2605        var w = this.words[i];
2606        var word = (((w << off) | carry) & 0xffffff).toString(16);
2607        carry = (w >>> (24 - off)) & 0xffffff;
2608        if (carry !== 0 || i !== this.length - 1) {
2609          out = zeros[6 - word.length] + word + out;
2610        } else {
2611          out = word + out;
2612        }
2613        off += 2;
2614        if (off >= 26) {
2615          off -= 26;
2616          i--;
2617        }
2618      }
2619      if (carry !== 0) {
2620        out = carry.toString(16) + out;
2621      }
2622      while (out.length % padding !== 0) {
2623        out = '0' + out;
2624      }
2625      if (this.negative !== 0) {
2626        out = '-' + out;
2627      }
2628      return out;
2629    }
2630
2631    if (base === (base | 0) && base >= 2 && base <= 36) {
2632      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
2633      var groupSize = groupSizes[base];
2634      // var groupBase = Math.pow(base, groupSize);
2635      var groupBase = groupBases[base];
2636      out = '';
2637      var c = this.clone();
2638      c.negative = 0;
2639      while (!c.isZero()) {
2640        var r = c.modn(groupBase).toString(base);
2641        c = c.idivn(groupBase);
2642
2643        if (!c.isZero()) {
2644          out = zeros[groupSize - r.length] + r + out;
2645        } else {
2646          out = r + out;
2647        }
2648      }
2649      if (this.isZero()) {
2650        out = '0' + out;
2651      }
2652      while (out.length % padding !== 0) {
2653        out = '0' + out;
2654      }
2655      if (this.negative !== 0) {
2656        out = '-' + out;
2657      }
2658      return out;
2659    }
2660
2661    assert(false, 'Base should be between 2 and 36');
2662  };
2663
2664  BN.prototype.toNumber = function toNumber () {
2665    var ret = this.words[0];
2666    if (this.length === 2) {
2667      ret += this.words[1] * 0x4000000;
2668    } else if (this.length === 3 && this.words[2] === 0x01) {
2669      // NOTE: at this stage it is known that the top bit is set
2670      ret += 0x10000000000000 + (this.words[1] * 0x4000000);
2671    } else if (this.length > 2) {
2672      assert(false, 'Number can only safely store up to 53 bits');
2673    }
2674    return (this.negative !== 0) ? -ret : ret;
2675  };
2676
2677  BN.prototype.toJSON = function toJSON () {
2678    return this.toString(16);
2679  };
2680
2681  BN.prototype.toBuffer = function toBuffer (endian, length) {
2682    assert(typeof Buffer !== 'undefined');
2683    return this.toArrayLike(Buffer, endian, length);
2684  };
2685
2686  BN.prototype.toArray = function toArray (endian, length) {
2687    return this.toArrayLike(Array, endian, length);
2688  };
2689
2690  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
2691    var byteLength = this.byteLength();
2692    var reqLength = length || Math.max(1, byteLength);
2693    assert(byteLength <= reqLength, 'byte array longer than desired length');
2694    assert(reqLength > 0, 'Requested array length <= 0');
2695
2696    this.strip();
2697    var littleEndian = endian === 'le';
2698    var res = new ArrayType(reqLength);
2699
2700    var b, i;
2701    var q = this.clone();
2702    if (!littleEndian) {
2703      // Assume big-endian
2704      for (i = 0; i < reqLength - byteLength; i++) {
2705        res[i] = 0;
2706      }
2707
2708      for (i = 0; !q.isZero(); i++) {
2709        b = q.andln(0xff);
2710        q.iushrn(8);
2711
2712        res[reqLength - i - 1] = b;
2713      }
2714    } else {
2715      for (i = 0; !q.isZero(); i++) {
2716        b = q.andln(0xff);
2717        q.iushrn(8);
2718
2719        res[i] = b;
2720      }
2721
2722      for (; i < reqLength; i++) {
2723        res[i] = 0;
2724      }
2725    }
2726
2727    return res;
2728  };
2729
2730  if (Math.clz32) {
2731    BN.prototype._countBits = function _countBits (w) {
2732      return 32 - Math.clz32(w);
2733    };
2734  } else {
2735    BN.prototype._countBits = function _countBits (w) {
2736      var t = w;
2737      var r = 0;
2738      if (t >= 0x1000) {
2739        r += 13;
2740        t >>>= 13;
2741      }
2742      if (t >= 0x40) {
2743        r += 7;
2744        t >>>= 7;
2745      }
2746      if (t >= 0x8) {
2747        r += 4;
2748        t >>>= 4;
2749      }
2750      if (t >= 0x02) {
2751        r += 2;
2752        t >>>= 2;
2753      }
2754      return r + t;
2755    };
2756  }
2757
2758  BN.prototype._zeroBits = function _zeroBits (w) {
2759    // Short-cut
2760    if (w === 0) return 26;
2761
2762    var t = w;
2763    var r = 0;
2764    if ((t & 0x1fff) === 0) {
2765      r += 13;
2766      t >>>= 13;
2767    }
2768    if ((t & 0x7f) === 0) {
2769      r += 7;
2770      t >>>= 7;
2771    }
2772    if ((t & 0xf) === 0) {
2773      r += 4;
2774      t >>>= 4;
2775    }
2776    if ((t & 0x3) === 0) {
2777      r += 2;
2778      t >>>= 2;
2779    }
2780    if ((t & 0x1) === 0) {
2781      r++;
2782    }
2783    return r;
2784  };
2785
2786  // Return number of used bits in a BN
2787  BN.prototype.bitLength = function bitLength () {
2788    var w = this.words[this.length - 1];
2789    var hi = this._countBits(w);
2790    return (this.length - 1) * 26 + hi;
2791  };
2792
2793  function toBitArray (num) {
2794    var w = new Array(num.bitLength());
2795
2796    for (var bit = 0; bit < w.length; bit++) {
2797      var off = (bit / 26) | 0;
2798      var wbit = bit % 26;
2799
2800      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
2801    }
2802
2803    return w;
2804  }
2805
2806  // Number of trailing zero bits
2807  BN.prototype.zeroBits = function zeroBits () {
2808    if (this.isZero()) return 0;
2809
2810    var r = 0;
2811    for (var i = 0; i < this.length; i++) {
2812      var b = this._zeroBits(this.words[i]);
2813      r += b;
2814      if (b !== 26) break;
2815    }
2816    return r;
2817  };
2818
2819  BN.prototype.byteLength = function byteLength () {
2820    return Math.ceil(this.bitLength() / 8);
2821  };
2822
2823  BN.prototype.toTwos = function toTwos (width) {
2824    if (this.negative !== 0) {
2825      return this.abs().inotn(width).iaddn(1);
2826    }
2827    return this.clone();
2828  };
2829
2830  BN.prototype.fromTwos = function fromTwos (width) {
2831    if (this.testn(width - 1)) {
2832      return this.notn(width).iaddn(1).ineg();
2833    }
2834    return this.clone();
2835  };
2836
2837  BN.prototype.isNeg = function isNeg () {
2838    return this.negative !== 0;
2839  };
2840
2841  // Return negative clone of `this`
2842  BN.prototype.neg = function neg () {
2843    return this.clone().ineg();
2844  };
2845
2846  BN.prototype.ineg = function ineg () {
2847    if (!this.isZero()) {
2848      this.negative ^= 1;
2849    }
2850
2851    return this;
2852  };
2853
2854  // Or `num` with `this` in-place
2855  BN.prototype.iuor = function iuor (num) {
2856    while (this.length < num.length) {
2857      this.words[this.length++] = 0;
2858    }
2859
2860    for (var i = 0; i < num.length; i++) {
2861      this.words[i] = this.words[i] | num.words[i];
2862    }
2863
2864    return this.strip();
2865  };
2866
2867  BN.prototype.ior = function ior (num) {
2868    assert((this.negative | num.negative) === 0);
2869    return this.iuor(num);
2870  };
2871
2872  // Or `num` with `this`
2873  BN.prototype.or = function or (num) {
2874    if (this.length > num.length) return this.clone().ior(num);
2875    return num.clone().ior(this);
2876  };
2877
2878  BN.prototype.uor = function uor (num) {
2879    if (this.length > num.length) return this.clone().iuor(num);
2880    return num.clone().iuor(this);
2881  };
2882
2883  // And `num` with `this` in-place
2884  BN.prototype.iuand = function iuand (num) {
2885    // b = min-length(num, this)
2886    var b;
2887    if (this.length > num.length) {
2888      b = num;
2889    } else {
2890      b = this;
2891    }
2892
2893    for (var i = 0; i < b.length; i++) {
2894      this.words[i] = this.words[i] & num.words[i];
2895    }
2896
2897    this.length = b.length;
2898
2899    return this.strip();
2900  };
2901
2902  BN.prototype.iand = function iand (num) {
2903    assert((this.negative | num.negative) === 0);
2904    return this.iuand(num);
2905  };
2906
2907  // And `num` with `this`
2908  BN.prototype.and = function and (num) {
2909    if (this.length > num.length) return this.clone().iand(num);
2910    return num.clone().iand(this);
2911  };
2912
2913  BN.prototype.uand = function uand (num) {
2914    if (this.length > num.length) return this.clone().iuand(num);
2915    return num.clone().iuand(this);
2916  };
2917
2918  // Xor `num` with `this` in-place
2919  BN.prototype.iuxor = function iuxor (num) {
2920    // a.length > b.length
2921    var a;
2922    var b;
2923    if (this.length > num.length) {
2924      a = this;
2925      b = num;
2926    } else {
2927      a = num;
2928      b = this;
2929    }
2930
2931    for (var i = 0; i < b.length; i++) {
2932      this.words[i] = a.words[i] ^ b.words[i];
2933    }
2934
2935    if (this !== a) {
2936      for (; i < a.length; i++) {
2937        this.words[i] = a.words[i];
2938      }
2939    }
2940
2941    this.length = a.length;
2942
2943    return this.strip();
2944  };
2945
2946  BN.prototype.ixor = function ixor (num) {
2947    assert((this.negative | num.negative) === 0);
2948    return this.iuxor(num);
2949  };
2950
2951  // Xor `num` with `this`
2952  BN.prototype.xor = function xor (num) {
2953    if (this.length > num.length) return this.clone().ixor(num);
2954    return num.clone().ixor(this);
2955  };
2956
2957  BN.prototype.uxor = function uxor (num) {
2958    if (this.length > num.length) return this.clone().iuxor(num);
2959    return num.clone().iuxor(this);
2960  };
2961
2962  // Not ``this`` with ``width`` bitwidth
2963  BN.prototype.inotn = function inotn (width) {
2964    assert(typeof width === 'number' && width >= 0);
2965
2966    var bytesNeeded = Math.ceil(width / 26) | 0;
2967    var bitsLeft = width % 26;
2968
2969    // Extend the buffer with leading zeroes
2970    this._expand(bytesNeeded);
2971
2972    if (bitsLeft > 0) {
2973      bytesNeeded--;
2974    }
2975
2976    // Handle complete words
2977    for (var i = 0; i < bytesNeeded; i++) {
2978      this.words[i] = ~this.words[i] & 0x3ffffff;
2979    }
2980
2981    // Handle the residue
2982    if (bitsLeft > 0) {
2983      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
2984    }
2985
2986    // And remove leading zeroes
2987    return this.strip();
2988  };
2989
2990  BN.prototype.notn = function notn (width) {
2991    return this.clone().inotn(width);
2992  };
2993
2994  // Set `bit` of `this`
2995  BN.prototype.setn = function setn (bit, val) {
2996    assert(typeof bit === 'number' && bit >= 0);
2997
2998    var off = (bit / 26) | 0;
2999    var wbit = bit % 26;
3000
3001    this._expand(off + 1);
3002
3003    if (val) {
3004      this.words[off] = this.words[off] | (1 << wbit);
3005    } else {
3006      this.words[off] = this.words[off] & ~(1 << wbit);
3007    }
3008
3009    return this.strip();
3010  };
3011
3012  // Add `num` to `this` in-place
3013  BN.prototype.iadd = function iadd (num) {
3014    var r;
3015
3016    // negative + positive
3017    if (this.negative !== 0 && num.negative === 0) {
3018      this.negative = 0;
3019      r = this.isub(num);
3020      this.negative ^= 1;
3021      return this._normSign();
3022
3023    // positive + negative
3024    } else if (this.negative === 0 && num.negative !== 0) {
3025      num.negative = 0;
3026      r = this.isub(num);
3027      num.negative = 1;
3028      return r._normSign();
3029    }
3030
3031    // a.length > b.length
3032    var a, b;
3033    if (this.length > num.length) {
3034      a = this;
3035      b = num;
3036    } else {
3037      a = num;
3038      b = this;
3039    }
3040
3041    var carry = 0;
3042    for (var i = 0; i < b.length; i++) {
3043      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
3044      this.words[i] = r & 0x3ffffff;
3045      carry = r >>> 26;
3046    }
3047    for (; carry !== 0 && i < a.length; i++) {
3048      r = (a.words[i] | 0) + carry;
3049      this.words[i] = r & 0x3ffffff;
3050      carry = r >>> 26;
3051    }
3052
3053    this.length = a.length;
3054    if (carry !== 0) {
3055      this.words[this.length] = carry;
3056      this.length++;
3057    // Copy the rest of the words
3058    } else if (a !== this) {
3059      for (; i < a.length; i++) {
3060        this.words[i] = a.words[i];
3061      }
3062    }
3063
3064    return this;
3065  };
3066
3067  // Add `num` to `this`
3068  BN.prototype.add = function add (num) {
3069    var res;
3070    if (num.negative !== 0 && this.negative === 0) {
3071      num.negative = 0;
3072      res = this.sub(num);
3073      num.negative ^= 1;
3074      return res;
3075    } else if (num.negative === 0 && this.negative !== 0) {
3076      this.negative = 0;
3077      res = num.sub(this);
3078      this.negative = 1;
3079      return res;
3080    }
3081
3082    if (this.length > num.length) return this.clone().iadd(num);
3083
3084    return num.clone().iadd(this);
3085  };
3086
3087  // Subtract `num` from `this` in-place
3088  BN.prototype.isub = function isub (num) {
3089    // this - (-num) = this + num
3090    if (num.negative !== 0) {
3091      num.negative = 0;
3092      var r = this.iadd(num);
3093      num.negative = 1;
3094      return r._normSign();
3095
3096    // -this - num = -(this + num)
3097    } else if (this.negative !== 0) {
3098      this.negative = 0;
3099      this.iadd(num);
3100      this.negative = 1;
3101      return this._normSign();
3102    }
3103
3104    // At this point both numbers are positive
3105    var cmp = this.cmp(num);
3106
3107    // Optimization - zeroify
3108    if (cmp === 0) {
3109      this.negative = 0;
3110      this.length = 1;
3111      this.words[0] = 0;
3112      return this;
3113    }
3114
3115    // a > b
3116    var a, b;
3117    if (cmp > 0) {
3118      a = this;
3119      b = num;
3120    } else {
3121      a = num;
3122      b = this;
3123    }
3124
3125    var carry = 0;
3126    for (var i = 0; i < b.length; i++) {
3127      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
3128      carry = r >> 26;
3129      this.words[i] = r & 0x3ffffff;
3130    }
3131    for (; carry !== 0 && i < a.length; i++) {
3132      r = (a.words[i] | 0) + carry;
3133      carry = r >> 26;
3134      this.words[i] = r & 0x3ffffff;
3135    }
3136
3137    // Copy rest of the words
3138    if (carry === 0 && i < a.length && a !== this) {
3139      for (; i < a.length; i++) {
3140        this.words[i] = a.words[i];
3141      }
3142    }
3143
3144    this.length = Math.max(this.length, i);
3145
3146    if (a !== this) {
3147      this.negative = 1;
3148    }
3149
3150    return this.strip();
3151  };
3152
3153  // Subtract `num` from `this`
3154  BN.prototype.sub = function sub (num) {
3155    return this.clone().isub(num);
3156  };
3157
3158  function smallMulTo (self, num, out) {
3159    out.negative = num.negative ^ self.negative;
3160    var len = (self.length + num.length) | 0;
3161    out.length = len;
3162    len = (len - 1) | 0;
3163
3164    // Peel one iteration (compiler can't do it, because of code complexity)
3165    var a = self.words[0] | 0;
3166    var b = num.words[0] | 0;
3167    var r = a * b;
3168
3169    var lo = r & 0x3ffffff;
3170    var carry = (r / 0x4000000) | 0;
3171    out.words[0] = lo;
3172
3173    for (var k = 1; k < len; k++) {
3174      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
3175      // note that ncarry could be >= 0x3ffffff
3176      var ncarry = carry >>> 26;
3177      var rword = carry & 0x3ffffff;
3178      var maxJ = Math.min(k, num.length - 1);
3179      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
3180        var i = (k - j) | 0;
3181        a = self.words[i] | 0;
3182        b = num.words[j] | 0;
3183        r = a * b + rword;
3184        ncarry += (r / 0x4000000) | 0;
3185        rword = r & 0x3ffffff;
3186      }
3187      out.words[k] = rword | 0;
3188      carry = ncarry | 0;
3189    }
3190    if (carry !== 0) {
3191      out.words[k] = carry | 0;
3192    } else {
3193      out.length--;
3194    }
3195
3196    return out.strip();
3197  }
3198
3199  // TODO(indutny): it may be reasonable to omit it for users who don't need
3200  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
3201  // multiplication (like elliptic secp256k1).
3202  var comb10MulTo = function comb10MulTo (self, num, out) {
3203    var a = self.words;
3204    var b = num.words;
3205    var o = out.words;
3206    var c = 0;
3207    var lo;
3208    var mid;
3209    var hi;
3210    var a0 = a[0] | 0;
3211    var al0 = a0 & 0x1fff;
3212    var ah0 = a0 >>> 13;
3213    var a1 = a[1] | 0;
3214    var al1 = a1 & 0x1fff;
3215    var ah1 = a1 >>> 13;
3216    var a2 = a[2] | 0;
3217    var al2 = a2 & 0x1fff;
3218    var ah2 = a2 >>> 13;
3219    var a3 = a[3] | 0;
3220    var al3 = a3 & 0x1fff;
3221    var ah3 = a3 >>> 13;
3222    var a4 = a[4] | 0;
3223    var al4 = a4 & 0x1fff;
3224    var ah4 = a4 >>> 13;
3225    var a5 = a[5] | 0;
3226    var al5 = a5 & 0x1fff;
3227    var ah5 = a5 >>> 13;
3228    var a6 = a[6] | 0;
3229    var al6 = a6 & 0x1fff;
3230    var ah6 = a6 >>> 13;
3231    var a7 = a[7] | 0;
3232    var al7 = a7 & 0x1fff;
3233    var ah7 = a7 >>> 13;
3234    var a8 = a[8] | 0;
3235    var al8 = a8 & 0x1fff;
3236    var ah8 = a8 >>> 13;
3237    var a9 = a[9] | 0;
3238    var al9 = a9 & 0x1fff;
3239    var ah9 = a9 >>> 13;
3240    var b0 = b[0] | 0;
3241    var bl0 = b0 & 0x1fff;
3242    var bh0 = b0 >>> 13;
3243    var b1 = b[1] | 0;
3244    var bl1 = b1 & 0x1fff;
3245    var bh1 = b1 >>> 13;
3246    var b2 = b[2] | 0;
3247    var bl2 = b2 & 0x1fff;
3248    var bh2 = b2 >>> 13;
3249    var b3 = b[3] | 0;
3250    var bl3 = b3 & 0x1fff;
3251    var bh3 = b3 >>> 13;
3252    var b4 = b[4] | 0;
3253    var bl4 = b4 & 0x1fff;
3254    var bh4 = b4 >>> 13;
3255    var b5 = b[5] | 0;
3256    var bl5 = b5 & 0x1fff;
3257    var bh5 = b5 >>> 13;
3258    var b6 = b[6] | 0;
3259    var bl6 = b6 & 0x1fff;
3260    var bh6 = b6 >>> 13;
3261    var b7 = b[7] | 0;
3262    var bl7 = b7 & 0x1fff;
3263    var bh7 = b7 >>> 13;
3264    var b8 = b[8] | 0;
3265    var bl8 = b8 & 0x1fff;
3266    var bh8 = b8 >>> 13;
3267    var b9 = b[9] | 0;
3268    var bl9 = b9 & 0x1fff;
3269    var bh9 = b9 >>> 13;
3270
3271    out.negative = self.negative ^ num.negative;
3272    out.length = 19;
3273    /* k = 0 */
3274    lo = Math.imul(al0, bl0);
3275    mid = Math.imul(al0, bh0);
3276    mid = (mid + Math.imul(ah0, bl0)) | 0;
3277    hi = Math.imul(ah0, bh0);
3278    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3279    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
3280    w0 &= 0x3ffffff;
3281    /* k = 1 */
3282    lo = Math.imul(al1, bl0);
3283    mid = Math.imul(al1, bh0);
3284    mid = (mid + Math.imul(ah1, bl0)) | 0;
3285    hi = Math.imul(ah1, bh0);
3286    lo = (lo + Math.imul(al0, bl1)) | 0;
3287    mid = (mid + Math.imul(al0, bh1)) | 0;
3288    mid = (mid + Math.imul(ah0, bl1)) | 0;
3289    hi = (hi + Math.imul(ah0, bh1)) | 0;
3290    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3291    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
3292    w1 &= 0x3ffffff;
3293    /* k = 2 */
3294    lo = Math.imul(al2, bl0);
3295    mid = Math.imul(al2, bh0);
3296    mid = (mid + Math.imul(ah2, bl0)) | 0;
3297    hi = Math.imul(ah2, bh0);
3298    lo = (lo + Math.imul(al1, bl1)) | 0;
3299    mid = (mid + Math.imul(al1, bh1)) | 0;
3300    mid = (mid + Math.imul(ah1, bl1)) | 0;
3301    hi = (hi + Math.imul(ah1, bh1)) | 0;
3302    lo = (lo + Math.imul(al0, bl2)) | 0;
3303    mid = (mid + Math.imul(al0, bh2)) | 0;
3304    mid = (mid + Math.imul(ah0, bl2)) | 0;
3305    hi = (hi + Math.imul(ah0, bh2)) | 0;
3306    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3307    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
3308    w2 &= 0x3ffffff;
3309    /* k = 3 */
3310    lo = Math.imul(al3, bl0);
3311    mid = Math.imul(al3, bh0);
3312    mid = (mid + Math.imul(ah3, bl0)) | 0;
3313    hi = Math.imul(ah3, bh0);
3314    lo = (lo + Math.imul(al2, bl1)) | 0;
3315    mid = (mid + Math.imul(al2, bh1)) | 0;
3316    mid = (mid + Math.imul(ah2, bl1)) | 0;
3317    hi = (hi + Math.imul(ah2, bh1)) | 0;
3318    lo = (lo + Math.imul(al1, bl2)) | 0;
3319    mid = (mid + Math.imul(al1, bh2)) | 0;
3320    mid = (mid + Math.imul(ah1, bl2)) | 0;
3321    hi = (hi + Math.imul(ah1, bh2)) | 0;
3322    lo = (lo + Math.imul(al0, bl3)) | 0;
3323    mid = (mid + Math.imul(al0, bh3)) | 0;
3324    mid = (mid + Math.imul(ah0, bl3)) | 0;
3325    hi = (hi + Math.imul(ah0, bh3)) | 0;
3326    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3327    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
3328    w3 &= 0x3ffffff;
3329    /* k = 4 */
3330    lo = Math.imul(al4, bl0);
3331    mid = Math.imul(al4, bh0);
3332    mid = (mid + Math.imul(ah4, bl0)) | 0;
3333    hi = Math.imul(ah4, bh0);
3334    lo = (lo + Math.imul(al3, bl1)) | 0;
3335    mid = (mid + Math.imul(al3, bh1)) | 0;
3336    mid = (mid + Math.imul(ah3, bl1)) | 0;
3337    hi = (hi + Math.imul(ah3, bh1)) | 0;
3338    lo = (lo + Math.imul(al2, bl2)) | 0;
3339    mid = (mid + Math.imul(al2, bh2)) | 0;
3340    mid = (mid + Math.imul(ah2, bl2)) | 0;
3341    hi = (hi + Math.imul(ah2, bh2)) | 0;
3342    lo = (lo + Math.imul(al1, bl3)) | 0;
3343    mid = (mid + Math.imul(al1, bh3)) | 0;
3344    mid = (mid + Math.imul(ah1, bl3)) | 0;
3345    hi = (hi + Math.imul(ah1, bh3)) | 0;
3346    lo = (lo + Math.imul(al0, bl4)) | 0;
3347    mid = (mid + Math.imul(al0, bh4)) | 0;
3348    mid = (mid + Math.imul(ah0, bl4)) | 0;
3349    hi = (hi + Math.imul(ah0, bh4)) | 0;
3350    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3351    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
3352    w4 &= 0x3ffffff;
3353    /* k = 5 */
3354    lo = Math.imul(al5, bl0);
3355    mid = Math.imul(al5, bh0);
3356    mid = (mid + Math.imul(ah5, bl0)) | 0;
3357    hi = Math.imul(ah5, bh0);
3358    lo = (lo + Math.imul(al4, bl1)) | 0;
3359    mid = (mid + Math.imul(al4, bh1)) | 0;
3360    mid = (mid + Math.imul(ah4, bl1)) | 0;
3361    hi = (hi + Math.imul(ah4, bh1)) | 0;
3362    lo = (lo + Math.imul(al3, bl2)) | 0;
3363    mid = (mid + Math.imul(al3, bh2)) | 0;
3364    mid = (mid + Math.imul(ah3, bl2)) | 0;
3365    hi = (hi + Math.imul(ah3, bh2)) | 0;
3366    lo = (lo + Math.imul(al2, bl3)) | 0;
3367    mid = (mid + Math.imul(al2, bh3)) | 0;
3368    mid = (mid + Math.imul(ah2, bl3)) | 0;
3369    hi = (hi + Math.imul(ah2, bh3)) | 0;
3370    lo = (lo + Math.imul(al1, bl4)) | 0;
3371    mid = (mid + Math.imul(al1, bh4)) | 0;
3372    mid = (mid + Math.imul(ah1, bl4)) | 0;
3373    hi = (hi + Math.imul(ah1, bh4)) | 0;
3374    lo = (lo + Math.imul(al0, bl5)) | 0;
3375    mid = (mid + Math.imul(al0, bh5)) | 0;
3376    mid = (mid + Math.imul(ah0, bl5)) | 0;
3377    hi = (hi + Math.imul(ah0, bh5)) | 0;
3378    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3379    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
3380    w5 &= 0x3ffffff;
3381    /* k = 6 */
3382    lo = Math.imul(al6, bl0);
3383    mid = Math.imul(al6, bh0);
3384    mid = (mid + Math.imul(ah6, bl0)) | 0;
3385    hi = Math.imul(ah6, bh0);
3386    lo = (lo + Math.imul(al5, bl1)) | 0;
3387    mid = (mid + Math.imul(al5, bh1)) | 0;
3388    mid = (mid + Math.imul(ah5, bl1)) | 0;
3389    hi = (hi + Math.imul(ah5, bh1)) | 0;
3390    lo = (lo + Math.imul(al4, bl2)) | 0;
3391    mid = (mid + Math.imul(al4, bh2)) | 0;
3392    mid = (mid + Math.imul(ah4, bl2)) | 0;
3393    hi = (hi + Math.imul(ah4, bh2)) | 0;
3394    lo = (lo + Math.imul(al3, bl3)) | 0;
3395    mid = (mid + Math.imul(al3, bh3)) | 0;
3396    mid = (mid + Math.imul(ah3, bl3)) | 0;
3397    hi = (hi + Math.imul(ah3, bh3)) | 0;
3398    lo = (lo + Math.imul(al2, bl4)) | 0;
3399    mid = (mid + Math.imul(al2, bh4)) | 0;
3400    mid = (mid + Math.imul(ah2, bl4)) | 0;
3401    hi = (hi + Math.imul(ah2, bh4)) | 0;
3402    lo = (lo + Math.imul(al1, bl5)) | 0;
3403    mid = (mid + Math.imul(al1, bh5)) | 0;
3404    mid = (mid + Math.imul(ah1, bl5)) | 0;
3405    hi = (hi + Math.imul(ah1, bh5)) | 0;
3406    lo = (lo + Math.imul(al0, bl6)) | 0;
3407    mid = (mid + Math.imul(al0, bh6)) | 0;
3408    mid = (mid + Math.imul(ah0, bl6)) | 0;
3409    hi = (hi + Math.imul(ah0, bh6)) | 0;
3410    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3411    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
3412    w6 &= 0x3ffffff;
3413    /* k = 7 */
3414    lo = Math.imul(al7, bl0);
3415    mid = Math.imul(al7, bh0);
3416    mid = (mid + Math.imul(ah7, bl0)) | 0;
3417    hi = Math.imul(ah7, bh0);
3418    lo = (lo + Math.imul(al6, bl1)) | 0;
3419    mid = (mid + Math.imul(al6, bh1)) | 0;
3420    mid = (mid + Math.imul(ah6, bl1)) | 0;
3421    hi = (hi + Math.imul(ah6, bh1)) | 0;
3422    lo = (lo + Math.imul(al5, bl2)) | 0;
3423    mid = (mid + Math.imul(al5, bh2)) | 0;
3424    mid = (mid + Math.imul(ah5, bl2)) | 0;
3425    hi = (hi + Math.imul(ah5, bh2)) | 0;
3426    lo = (lo + Math.imul(al4, bl3)) | 0;
3427    mid = (mid + Math.imul(al4, bh3)) | 0;
3428    mid = (mid + Math.imul(ah4, bl3)) | 0;
3429    hi = (hi + Math.imul(ah4, bh3)) | 0;
3430    lo = (lo + Math.imul(al3, bl4)) | 0;
3431    mid = (mid + Math.imul(al3, bh4)) | 0;
3432    mid = (mid + Math.imul(ah3, bl4)) | 0;
3433    hi = (hi + Math.imul(ah3, bh4)) | 0;
3434    lo = (lo + Math.imul(al2, bl5)) | 0;
3435    mid = (mid + Math.imul(al2, bh5)) | 0;
3436    mid = (mid + Math.imul(ah2, bl5)) | 0;
3437    hi = (hi + Math.imul(ah2, bh5)) | 0;
3438    lo = (lo + Math.imul(al1, bl6)) | 0;
3439    mid = (mid + Math.imul(al1, bh6)) | 0;
3440    mid = (mid + Math.imul(ah1, bl6)) | 0;
3441    hi = (hi + Math.imul(ah1, bh6)) | 0;
3442    lo = (lo + Math.imul(al0, bl7)) | 0;
3443    mid = (mid + Math.imul(al0, bh7)) | 0;
3444    mid = (mid + Math.imul(ah0, bl7)) | 0;
3445    hi = (hi + Math.imul(ah0, bh7)) | 0;
3446    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3447    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
3448    w7 &= 0x3ffffff;
3449    /* k = 8 */
3450    lo = Math.imul(al8, bl0);
3451    mid = Math.imul(al8, bh0);
3452    mid = (mid + Math.imul(ah8, bl0)) | 0;
3453    hi = Math.imul(ah8, bh0);
3454    lo = (lo + Math.imul(al7, bl1)) | 0;
3455    mid = (mid + Math.imul(al7, bh1)) | 0;
3456    mid = (mid + Math.imul(ah7, bl1)) | 0;
3457    hi = (hi + Math.imul(ah7, bh1)) | 0;
3458    lo = (lo + Math.imul(al6, bl2)) | 0;
3459    mid = (mid + Math.imul(al6, bh2)) | 0;
3460    mid = (mid + Math.imul(ah6, bl2)) | 0;
3461    hi = (hi + Math.imul(ah6, bh2)) | 0;
3462    lo = (lo + Math.imul(al5, bl3)) | 0;
3463    mid = (mid + Math.imul(al5, bh3)) | 0;
3464    mid = (mid + Math.imul(ah5, bl3)) | 0;
3465    hi = (hi + Math.imul(ah5, bh3)) | 0;
3466    lo = (lo + Math.imul(al4, bl4)) | 0;
3467    mid = (mid + Math.imul(al4, bh4)) | 0;
3468    mid = (mid + Math.imul(ah4, bl4)) | 0;
3469    hi = (hi + Math.imul(ah4, bh4)) | 0;
3470    lo = (lo + Math.imul(al3, bl5)) | 0;
3471    mid = (mid + Math.imul(al3, bh5)) | 0;
3472    mid = (mid + Math.imul(ah3, bl5)) | 0;
3473    hi = (hi + Math.imul(ah3, bh5)) | 0;
3474    lo = (lo + Math.imul(al2, bl6)) | 0;
3475    mid = (mid + Math.imul(al2, bh6)) | 0;
3476    mid = (mid + Math.imul(ah2, bl6)) | 0;
3477    hi = (hi + Math.imul(ah2, bh6)) | 0;
3478    lo = (lo + Math.imul(al1, bl7)) | 0;
3479    mid = (mid + Math.imul(al1, bh7)) | 0;
3480    mid = (mid + Math.imul(ah1, bl7)) | 0;
3481    hi = (hi + Math.imul(ah1, bh7)) | 0;
3482    lo = (lo + Math.imul(al0, bl8)) | 0;
3483    mid = (mid + Math.imul(al0, bh8)) | 0;
3484    mid = (mid + Math.imul(ah0, bl8)) | 0;
3485    hi = (hi + Math.imul(ah0, bh8)) | 0;
3486    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3487    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
3488    w8 &= 0x3ffffff;
3489    /* k = 9 */
3490    lo = Math.imul(al9, bl0);
3491    mid = Math.imul(al9, bh0);
3492    mid = (mid + Math.imul(ah9, bl0)) | 0;
3493    hi = Math.imul(ah9, bh0);
3494    lo = (lo + Math.imul(al8, bl1)) | 0;
3495    mid = (mid + Math.imul(al8, bh1)) | 0;
3496    mid = (mid + Math.imul(ah8, bl1)) | 0;
3497    hi = (hi + Math.imul(ah8, bh1)) | 0;
3498    lo = (lo + Math.imul(al7, bl2)) | 0;
3499    mid = (mid + Math.imul(al7, bh2)) | 0;
3500    mid = (mid + Math.imul(ah7, bl2)) | 0;
3501    hi = (hi + Math.imul(ah7, bh2)) | 0;
3502    lo = (lo + Math.imul(al6, bl3)) | 0;
3503    mid = (mid + Math.imul(al6, bh3)) | 0;
3504    mid = (mid + Math.imul(ah6, bl3)) | 0;
3505    hi = (hi + Math.imul(ah6, bh3)) | 0;
3506    lo = (lo + Math.imul(al5, bl4)) | 0;
3507    mid = (mid + Math.imul(al5, bh4)) | 0;
3508    mid = (mid + Math.imul(ah5, bl4)) | 0;
3509    hi = (hi + Math.imul(ah5, bh4)) | 0;
3510    lo = (lo + Math.imul(al4, bl5)) | 0;
3511    mid = (mid + Math.imul(al4, bh5)) | 0;
3512    mid = (mid + Math.imul(ah4, bl5)) | 0;
3513    hi = (hi + Math.imul(ah4, bh5)) | 0;
3514    lo = (lo + Math.imul(al3, bl6)) | 0;
3515    mid = (mid + Math.imul(al3, bh6)) | 0;
3516    mid = (mid + Math.imul(ah3, bl6)) | 0;
3517    hi = (hi + Math.imul(ah3, bh6)) | 0;
3518    lo = (lo + Math.imul(al2, bl7)) | 0;
3519    mid = (mid + Math.imul(al2, bh7)) | 0;
3520    mid = (mid + Math.imul(ah2, bl7)) | 0;
3521    hi = (hi + Math.imul(ah2, bh7)) | 0;
3522    lo = (lo + Math.imul(al1, bl8)) | 0;
3523    mid = (mid + Math.imul(al1, bh8)) | 0;
3524    mid = (mid + Math.imul(ah1, bl8)) | 0;
3525    hi = (hi + Math.imul(ah1, bh8)) | 0;
3526    lo = (lo + Math.imul(al0, bl9)) | 0;
3527    mid = (mid + Math.imul(al0, bh9)) | 0;
3528    mid = (mid + Math.imul(ah0, bl9)) | 0;
3529    hi = (hi + Math.imul(ah0, bh9)) | 0;
3530    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3531    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
3532    w9 &= 0x3ffffff;
3533    /* k = 10 */
3534    lo = Math.imul(al9, bl1);
3535    mid = Math.imul(al9, bh1);
3536    mid = (mid + Math.imul(ah9, bl1)) | 0;
3537    hi = Math.imul(ah9, bh1);
3538    lo = (lo + Math.imul(al8, bl2)) | 0;
3539    mid = (mid + Math.imul(al8, bh2)) | 0;
3540    mid = (mid + Math.imul(ah8, bl2)) | 0;
3541    hi = (hi + Math.imul(ah8, bh2)) | 0;
3542    lo = (lo + Math.imul(al7, bl3)) | 0;
3543    mid = (mid + Math.imul(al7, bh3)) | 0;
3544    mid = (mid + Math.imul(ah7, bl3)) | 0;
3545    hi = (hi + Math.imul(ah7, bh3)) | 0;
3546    lo = (lo + Math.imul(al6, bl4)) | 0;
3547    mid = (mid + Math.imul(al6, bh4)) | 0;
3548    mid = (mid + Math.imul(ah6, bl4)) | 0;
3549    hi = (hi + Math.imul(ah6, bh4)) | 0;
3550    lo = (lo + Math.imul(al5, bl5)) | 0;
3551    mid = (mid + Math.imul(al5, bh5)) | 0;
3552    mid = (mid + Math.imul(ah5, bl5)) | 0;
3553    hi = (hi + Math.imul(ah5, bh5)) | 0;
3554    lo = (lo + Math.imul(al4, bl6)) | 0;
3555    mid = (mid + Math.imul(al4, bh6)) | 0;
3556    mid = (mid + Math.imul(ah4, bl6)) | 0;
3557    hi = (hi + Math.imul(ah4, bh6)) | 0;
3558    lo = (lo + Math.imul(al3, bl7)) | 0;
3559    mid = (mid + Math.imul(al3, bh7)) | 0;
3560    mid = (mid + Math.imul(ah3, bl7)) | 0;
3561    hi = (hi + Math.imul(ah3, bh7)) | 0;
3562    lo = (lo + Math.imul(al2, bl8)) | 0;
3563    mid = (mid + Math.imul(al2, bh8)) | 0;
3564    mid = (mid + Math.imul(ah2, bl8)) | 0;
3565    hi = (hi + Math.imul(ah2, bh8)) | 0;
3566    lo = (lo + Math.imul(al1, bl9)) | 0;
3567    mid = (mid + Math.imul(al1, bh9)) | 0;
3568    mid = (mid + Math.imul(ah1, bl9)) | 0;
3569    hi = (hi + Math.imul(ah1, bh9)) | 0;
3570    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3571    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
3572    w10 &= 0x3ffffff;
3573    /* k = 11 */
3574    lo = Math.imul(al9, bl2);
3575    mid = Math.imul(al9, bh2);
3576    mid = (mid + Math.imul(ah9, bl2)) | 0;
3577    hi = Math.imul(ah9, bh2);
3578    lo = (lo + Math.imul(al8, bl3)) | 0;
3579    mid = (mid + Math.imul(al8, bh3)) | 0;
3580    mid = (mid + Math.imul(ah8, bl3)) | 0;
3581    hi = (hi + Math.imul(ah8, bh3)) | 0;
3582    lo = (lo + Math.imul(al7, bl4)) | 0;
3583    mid = (mid + Math.imul(al7, bh4)) | 0;
3584    mid = (mid + Math.imul(ah7, bl4)) | 0;
3585    hi = (hi + Math.imul(ah7, bh4)) | 0;
3586    lo = (lo + Math.imul(al6, bl5)) | 0;
3587    mid = (mid + Math.imul(al6, bh5)) | 0;
3588    mid = (mid + Math.imul(ah6, bl5)) | 0;
3589    hi = (hi + Math.imul(ah6, bh5)) | 0;
3590    lo = (lo + Math.imul(al5, bl6)) | 0;
3591    mid = (mid + Math.imul(al5, bh6)) | 0;
3592    mid = (mid + Math.imul(ah5, bl6)) | 0;
3593    hi = (hi + Math.imul(ah5, bh6)) | 0;
3594    lo = (lo + Math.imul(al4, bl7)) | 0;
3595    mid = (mid + Math.imul(al4, bh7)) | 0;
3596    mid = (mid + Math.imul(ah4, bl7)) | 0;
3597    hi = (hi + Math.imul(ah4, bh7)) | 0;
3598    lo = (lo + Math.imul(al3, bl8)) | 0;
3599    mid = (mid + Math.imul(al3, bh8)) | 0;
3600    mid = (mid + Math.imul(ah3, bl8)) | 0;
3601    hi = (hi + Math.imul(ah3, bh8)) | 0;
3602    lo = (lo + Math.imul(al2, bl9)) | 0;
3603    mid = (mid + Math.imul(al2, bh9)) | 0;
3604    mid = (mid + Math.imul(ah2, bl9)) | 0;
3605    hi = (hi + Math.imul(ah2, bh9)) | 0;
3606    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3607    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
3608    w11 &= 0x3ffffff;
3609    /* k = 12 */
3610    lo = Math.imul(al9, bl3);
3611    mid = Math.imul(al9, bh3);
3612    mid = (mid + Math.imul(ah9, bl3)) | 0;
3613    hi = Math.imul(ah9, bh3);
3614    lo = (lo + Math.imul(al8, bl4)) | 0;
3615    mid = (mid + Math.imul(al8, bh4)) | 0;
3616    mid = (mid + Math.imul(ah8, bl4)) | 0;
3617    hi = (hi + Math.imul(ah8, bh4)) | 0;
3618    lo = (lo + Math.imul(al7, bl5)) | 0;
3619    mid = (mid + Math.imul(al7, bh5)) | 0;
3620    mid = (mid + Math.imul(ah7, bl5)) | 0;
3621    hi = (hi + Math.imul(ah7, bh5)) | 0;
3622    lo = (lo + Math.imul(al6, bl6)) | 0;
3623    mid = (mid + Math.imul(al6, bh6)) | 0;
3624    mid = (mid + Math.imul(ah6, bl6)) | 0;
3625    hi = (hi + Math.imul(ah6, bh6)) | 0;
3626    lo = (lo + Math.imul(al5, bl7)) | 0;
3627    mid = (mid + Math.imul(al5, bh7)) | 0;
3628    mid = (mid + Math.imul(ah5, bl7)) | 0;
3629    hi = (hi + Math.imul(ah5, bh7)) | 0;
3630    lo = (lo + Math.imul(al4, bl8)) | 0;
3631    mid = (mid + Math.imul(al4, bh8)) | 0;
3632    mid = (mid + Math.imul(ah4, bl8)) | 0;
3633    hi = (hi + Math.imul(ah4, bh8)) | 0;
3634    lo = (lo + Math.imul(al3, bl9)) | 0;
3635    mid = (mid + Math.imul(al3, bh9)) | 0;
3636    mid = (mid + Math.imul(ah3, bl9)) | 0;
3637    hi = (hi + Math.imul(ah3, bh9)) | 0;
3638    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3639    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
3640    w12 &= 0x3ffffff;
3641    /* k = 13 */
3642    lo = Math.imul(al9, bl4);
3643    mid = Math.imul(al9, bh4);
3644    mid = (mid + Math.imul(ah9, bl4)) | 0;
3645    hi = Math.imul(ah9, bh4);
3646    lo = (lo + Math.imul(al8, bl5)) | 0;
3647    mid = (mid + Math.imul(al8, bh5)) | 0;
3648    mid = (mid + Math.imul(ah8, bl5)) | 0;
3649    hi = (hi + Math.imul(ah8, bh5)) | 0;
3650    lo = (lo + Math.imul(al7, bl6)) | 0;
3651    mid = (mid + Math.imul(al7, bh6)) | 0;
3652    mid = (mid + Math.imul(ah7, bl6)) | 0;
3653    hi = (hi + Math.imul(ah7, bh6)) | 0;
3654    lo = (lo + Math.imul(al6, bl7)) | 0;
3655    mid = (mid + Math.imul(al6, bh7)) | 0;
3656    mid = (mid + Math.imul(ah6, bl7)) | 0;
3657    hi = (hi + Math.imul(ah6, bh7)) | 0;
3658    lo = (lo + Math.imul(al5, bl8)) | 0;
3659    mid = (mid + Math.imul(al5, bh8)) | 0;
3660    mid = (mid + Math.imul(ah5, bl8)) | 0;
3661    hi = (hi + Math.imul(ah5, bh8)) | 0;
3662    lo = (lo + Math.imul(al4, bl9)) | 0;
3663    mid = (mid + Math.imul(al4, bh9)) | 0;
3664    mid = (mid + Math.imul(ah4, bl9)) | 0;
3665    hi = (hi + Math.imul(ah4, bh9)) | 0;
3666    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3667    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
3668    w13 &= 0x3ffffff;
3669    /* k = 14 */
3670    lo = Math.imul(al9, bl5);
3671    mid = Math.imul(al9, bh5);
3672    mid = (mid + Math.imul(ah9, bl5)) | 0;
3673    hi = Math.imul(ah9, bh5);
3674    lo = (lo + Math.imul(al8, bl6)) | 0;
3675    mid = (mid + Math.imul(al8, bh6)) | 0;
3676    mid = (mid + Math.imul(ah8, bl6)) | 0;
3677    hi = (hi + Math.imul(ah8, bh6)) | 0;
3678    lo = (lo + Math.imul(al7, bl7)) | 0;
3679    mid = (mid + Math.imul(al7, bh7)) | 0;
3680    mid = (mid + Math.imul(ah7, bl7)) | 0;
3681    hi = (hi + Math.imul(ah7, bh7)) | 0;
3682    lo = (lo + Math.imul(al6, bl8)) | 0;
3683    mid = (mid + Math.imul(al6, bh8)) | 0;
3684    mid = (mid + Math.imul(ah6, bl8)) | 0;
3685    hi = (hi + Math.imul(ah6, bh8)) | 0;
3686    lo = (lo + Math.imul(al5, bl9)) | 0;
3687    mid = (mid + Math.imul(al5, bh9)) | 0;
3688    mid = (mid + Math.imul(ah5, bl9)) | 0;
3689    hi = (hi + Math.imul(ah5, bh9)) | 0;
3690    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3691    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
3692    w14 &= 0x3ffffff;
3693    /* k = 15 */
3694    lo = Math.imul(al9, bl6);
3695    mid = Math.imul(al9, bh6);
3696    mid = (mid + Math.imul(ah9, bl6)) | 0;
3697    hi = Math.imul(ah9, bh6);
3698    lo = (lo + Math.imul(al8, bl7)) | 0;
3699    mid = (mid + Math.imul(al8, bh7)) | 0;
3700    mid = (mid + Math.imul(ah8, bl7)) | 0;
3701    hi = (hi + Math.imul(ah8, bh7)) | 0;
3702    lo = (lo + Math.imul(al7, bl8)) | 0;
3703    mid = (mid + Math.imul(al7, bh8)) | 0;
3704    mid = (mid + Math.imul(ah7, bl8)) | 0;
3705    hi = (hi + Math.imul(ah7, bh8)) | 0;
3706    lo = (lo + Math.imul(al6, bl9)) | 0;
3707    mid = (mid + Math.imul(al6, bh9)) | 0;
3708    mid = (mid + Math.imul(ah6, bl9)) | 0;
3709    hi = (hi + Math.imul(ah6, bh9)) | 0;
3710    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3711    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
3712    w15 &= 0x3ffffff;
3713    /* k = 16 */
3714    lo = Math.imul(al9, bl7);
3715    mid = Math.imul(al9, bh7);
3716    mid = (mid + Math.imul(ah9, bl7)) | 0;
3717    hi = Math.imul(ah9, bh7);
3718    lo = (lo + Math.imul(al8, bl8)) | 0;
3719    mid = (mid + Math.imul(al8, bh8)) | 0;
3720    mid = (mid + Math.imul(ah8, bl8)) | 0;
3721    hi = (hi + Math.imul(ah8, bh8)) | 0;
3722    lo = (lo + Math.imul(al7, bl9)) | 0;
3723    mid = (mid + Math.imul(al7, bh9)) | 0;
3724    mid = (mid + Math.imul(ah7, bl9)) | 0;
3725    hi = (hi + Math.imul(ah7, bh9)) | 0;
3726    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3727    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
3728    w16 &= 0x3ffffff;
3729    /* k = 17 */
3730    lo = Math.imul(al9, bl8);
3731    mid = Math.imul(al9, bh8);
3732    mid = (mid + Math.imul(ah9, bl8)) | 0;
3733    hi = Math.imul(ah9, bh8);
3734    lo = (lo + Math.imul(al8, bl9)) | 0;
3735    mid = (mid + Math.imul(al8, bh9)) | 0;
3736    mid = (mid + Math.imul(ah8, bl9)) | 0;
3737    hi = (hi + Math.imul(ah8, bh9)) | 0;
3738    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3739    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
3740    w17 &= 0x3ffffff;
3741    /* k = 18 */
3742    lo = Math.imul(al9, bl9);
3743    mid = Math.imul(al9, bh9);
3744    mid = (mid + Math.imul(ah9, bl9)) | 0;
3745    hi = Math.imul(ah9, bh9);
3746    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3747    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
3748    w18 &= 0x3ffffff;
3749    o[0] = w0;
3750    o[1] = w1;
3751    o[2] = w2;
3752    o[3] = w3;
3753    o[4] = w4;
3754    o[5] = w5;
3755    o[6] = w6;
3756    o[7] = w7;
3757    o[8] = w8;
3758    o[9] = w9;
3759    o[10] = w10;
3760    o[11] = w11;
3761    o[12] = w12;
3762    o[13] = w13;
3763    o[14] = w14;
3764    o[15] = w15;
3765    o[16] = w16;
3766    o[17] = w17;
3767    o[18] = w18;
3768    if (c !== 0) {
3769      o[19] = c;
3770      out.length++;
3771    }
3772    return out;
3773  };
3774
3775  // Polyfill comb
3776  if (!Math.imul) {
3777    comb10MulTo = smallMulTo;
3778  }
3779
3780  function bigMulTo (self, num, out) {
3781    out.negative = num.negative ^ self.negative;
3782    out.length = self.length + num.length;
3783
3784    var carry = 0;
3785    var hncarry = 0;
3786    for (var k = 0; k < out.length - 1; k++) {
3787      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
3788      // note that ncarry could be >= 0x3ffffff
3789      var ncarry = hncarry;
3790      hncarry = 0;
3791      var rword = carry & 0x3ffffff;
3792      var maxJ = Math.min(k, num.length - 1);
3793      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
3794        var i = k - j;
3795        var a = self.words[i] | 0;
3796        var b = num.words[j] | 0;
3797        var r = a * b;
3798
3799        var lo = r & 0x3ffffff;
3800        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
3801        lo = (lo + rword) | 0;
3802        rword = lo & 0x3ffffff;
3803        ncarry = (ncarry + (lo >>> 26)) | 0;
3804
3805        hncarry += ncarry >>> 26;
3806        ncarry &= 0x3ffffff;
3807      }
3808      out.words[k] = rword;
3809      carry = ncarry;
3810      ncarry = hncarry;
3811    }
3812    if (carry !== 0) {
3813      out.words[k] = carry;
3814    } else {
3815      out.length--;
3816    }
3817
3818    return out.strip();
3819  }
3820
3821  function jumboMulTo (self, num, out) {
3822    var fftm = new FFTM();
3823    return fftm.mulp(self, num, out);
3824  }
3825
3826  BN.prototype.mulTo = function mulTo (num, out) {
3827    var res;
3828    var len = this.length + num.length;
3829    if (this.length === 10 && num.length === 10) {
3830      res = comb10MulTo(this, num, out);
3831    } else if (len < 63) {
3832      res = smallMulTo(this, num, out);
3833    } else if (len < 1024) {
3834      res = bigMulTo(this, num, out);
3835    } else {
3836      res = jumboMulTo(this, num, out);
3837    }
3838
3839    return res;
3840  };
3841
3842  // Cooley-Tukey algorithm for FFT
3843  // slightly revisited to rely on looping instead of recursion
3844
3845  function FFTM (x, y) {
3846    this.x = x;
3847    this.y = y;
3848  }
3849
3850  FFTM.prototype.makeRBT = function makeRBT (N) {
3851    var t = new Array(N);
3852    var l = BN.prototype._countBits(N) - 1;
3853    for (var i = 0; i < N; i++) {
3854      t[i] = this.revBin(i, l, N);
3855    }
3856
3857    return t;
3858  };
3859
3860  // Returns binary-reversed representation of `x`
3861  FFTM.prototype.revBin = function revBin (x, l, N) {
3862    if (x === 0 || x === N - 1) return x;
3863
3864    var rb = 0;
3865    for (var i = 0; i < l; i++) {
3866      rb |= (x & 1) << (l - i - 1);
3867      x >>= 1;
3868    }
3869
3870    return rb;
3871  };
3872
3873  // Performs "tweedling" phase, therefore 'emulating'
3874  // behaviour of the recursive algorithm
3875  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
3876    for (var i = 0; i < N; i++) {
3877      rtws[i] = rws[rbt[i]];
3878      itws[i] = iws[rbt[i]];
3879    }
3880  };
3881
3882  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
3883    this.permute(rbt, rws, iws, rtws, itws, N);
3884
3885    for (var s = 1; s < N; s <<= 1) {
3886      var l = s << 1;
3887
3888      var rtwdf = Math.cos(2 * Math.PI / l);
3889      var itwdf = Math.sin(2 * Math.PI / l);
3890
3891      for (var p = 0; p < N; p += l) {
3892        var rtwdf_ = rtwdf;
3893        var itwdf_ = itwdf;
3894
3895        for (var j = 0; j < s; j++) {
3896          var re = rtws[p + j];
3897          var ie = itws[p + j];
3898
3899          var ro = rtws[p + j + s];
3900          var io = itws[p + j + s];
3901
3902          var rx = rtwdf_ * ro - itwdf_ * io;
3903
3904          io = rtwdf_ * io + itwdf_ * ro;
3905          ro = rx;
3906
3907          rtws[p + j] = re + ro;
3908          itws[p + j] = ie + io;
3909
3910          rtws[p + j + s] = re - ro;
3911          itws[p + j + s] = ie - io;
3912
3913          /* jshint maxdepth : false */
3914          if (j !== l) {
3915            rx = rtwdf * rtwdf_ - itwdf * itwdf_;
3916
3917            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
3918            rtwdf_ = rx;
3919          }
3920        }
3921      }
3922    }
3923  };
3924
3925  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
3926    var N = Math.max(m, n) | 1;
3927    var odd = N & 1;
3928    var i = 0;
3929    for (N = N / 2 | 0; N; N = N >>> 1) {
3930      i++;
3931    }
3932
3933    return 1 << i + 1 + odd;
3934  };
3935
3936  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
3937    if (N <= 1) return;
3938
3939    for (var i = 0; i < N / 2; i++) {
3940      var t = rws[i];
3941
3942      rws[i] = rws[N - i - 1];
3943      rws[N - i - 1] = t;
3944
3945      t = iws[i];
3946
3947      iws[i] = -iws[N - i - 1];
3948      iws[N - i - 1] = -t;
3949    }
3950  };
3951
3952  FFTM.prototype.normalize13b = function normalize13b (ws, N) {
3953    var carry = 0;
3954    for (var i = 0; i < N / 2; i++) {
3955      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
3956        Math.round(ws[2 * i] / N) +
3957        carry;
3958
3959      ws[i] = w & 0x3ffffff;
3960
3961      if (w < 0x4000000) {
3962        carry = 0;
3963      } else {
3964        carry = w / 0x4000000 | 0;
3965      }
3966    }
3967
3968    return ws;
3969  };
3970
3971  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
3972    var carry = 0;
3973    for (var i = 0; i < len; i++) {
3974      carry = carry + (ws[i] | 0);
3975
3976      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
3977      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
3978    }
3979
3980    // Pad with zeroes
3981    for (i = 2 * len; i < N; ++i) {
3982      rws[i] = 0;
3983    }
3984
3985    assert(carry === 0);
3986    assert((carry & ~0x1fff) === 0);
3987  };
3988
3989  FFTM.prototype.stub = function stub (N) {
3990    var ph = new Array(N);
3991    for (var i = 0; i < N; i++) {
3992      ph[i] = 0;
3993    }
3994
3995    return ph;
3996  };
3997
3998  FFTM.prototype.mulp = function mulp (x, y, out) {
3999    var N = 2 * this.guessLen13b(x.length, y.length);
4000
4001    var rbt = this.makeRBT(N);
4002
4003    var _ = this.stub(N);
4004
4005    var rws = new Array(N);
4006    var rwst = new Array(N);
4007    var iwst = new Array(N);
4008
4009    var nrws = new Array(N);
4010    var nrwst = new Array(N);
4011    var niwst = new Array(N);
4012
4013    var rmws = out.words;
4014    rmws.length = N;
4015
4016    this.convert13b(x.words, x.length, rws, N);
4017    this.convert13b(y.words, y.length, nrws, N);
4018
4019    this.transform(rws, _, rwst, iwst, N, rbt);
4020    this.transform(nrws, _, nrwst, niwst, N, rbt);
4021
4022    for (var i = 0; i < N; i++) {
4023      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
4024      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
4025      rwst[i] = rx;
4026    }
4027
4028    this.conjugate(rwst, iwst, N);
4029    this.transform(rwst, iwst, rmws, _, N, rbt);
4030    this.conjugate(rmws, _, N);
4031    this.normalize13b(rmws, N);
4032
4033    out.negative = x.negative ^ y.negative;
4034    out.length = x.length + y.length;
4035    return out.strip();
4036  };
4037
4038  // Multiply `this` by `num`
4039  BN.prototype.mul = function mul (num) {
4040    var out = new BN(null);
4041    out.words = new Array(this.length + num.length);
4042    return this.mulTo(num, out);
4043  };
4044
4045  // Multiply employing FFT
4046  BN.prototype.mulf = function mulf (num) {
4047    var out = new BN(null);
4048    out.words = new Array(this.length + num.length);
4049    return jumboMulTo(this, num, out);
4050  };
4051
4052  // In-place Multiplication
4053  BN.prototype.imul = function imul (num) {
4054    return this.clone().mulTo(num, this);
4055  };
4056
4057  BN.prototype.imuln = function imuln (num) {
4058    assert(typeof num === 'number');
4059    assert(num < 0x4000000);
4060
4061    // Carry
4062    var carry = 0;
4063    for (var i = 0; i < this.length; i++) {
4064      var w = (this.words[i] | 0) * num;
4065      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
4066      carry >>= 26;
4067      carry += (w / 0x4000000) | 0;
4068      // NOTE: lo is 27bit maximum
4069      carry += lo >>> 26;
4070      this.words[i] = lo & 0x3ffffff;
4071    }
4072
4073    if (carry !== 0) {
4074      this.words[i] = carry;
4075      this.length++;
4076    }
4077
4078    return this;
4079  };
4080
4081  BN.prototype.muln = function muln (num) {
4082    return this.clone().imuln(num);
4083  };
4084
4085  // `this` * `this`
4086  BN.prototype.sqr = function sqr () {
4087    return this.mul(this);
4088  };
4089
4090  // `this` * `this` in-place
4091  BN.prototype.isqr = function isqr () {
4092    return this.imul(this.clone());
4093  };
4094
4095  // Math.pow(`this`, `num`)
4096  BN.prototype.pow = function pow (num) {
4097    var w = toBitArray(num);
4098    if (w.length === 0) return new BN(1);
4099
4100    // Skip leading zeroes
4101    var res = this;
4102    for (var i = 0; i < w.length; i++, res = res.sqr()) {
4103      if (w[i] !== 0) break;
4104    }
4105
4106    if (++i < w.length) {
4107      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
4108        if (w[i] === 0) continue;
4109
4110        res = res.mul(q);
4111      }
4112    }
4113
4114    return res;
4115  };
4116
4117  // Shift-left in-place
4118  BN.prototype.iushln = function iushln (bits) {
4119    assert(typeof bits === 'number' && bits >= 0);
4120    var r = bits % 26;
4121    var s = (bits - r) / 26;
4122    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
4123    var i;
4124
4125    if (r !== 0) {
4126      var carry = 0;
4127
4128      for (i = 0; i < this.length; i++) {
4129        var newCarry = this.words[i] & carryMask;
4130        var c = ((this.words[i] | 0) - newCarry) << r;
4131        this.words[i] = c | carry;
4132        carry = newCarry >>> (26 - r);
4133      }
4134
4135      if (carry) {
4136        this.words[i] = carry;
4137        this.length++;
4138      }
4139    }
4140
4141    if (s !== 0) {
4142      for (i = this.length - 1; i >= 0; i--) {
4143        this.words[i + s] = this.words[i];
4144      }
4145
4146      for (i = 0; i < s; i++) {
4147        this.words[i] = 0;
4148      }
4149
4150      this.length += s;
4151    }
4152
4153    return this.strip();
4154  };
4155
4156  BN.prototype.ishln = function ishln (bits) {
4157    // TODO(indutny): implement me
4158    assert(this.negative === 0);
4159    return this.iushln(bits);
4160  };
4161
4162  // Shift-right in-place
4163  // NOTE: `hint` is a lowest bit before trailing zeroes
4164  // NOTE: if `extended` is present - it will be filled with destroyed bits
4165  BN.prototype.iushrn = function iushrn (bits, hint, extended) {
4166    assert(typeof bits === 'number' && bits >= 0);
4167    var h;
4168    if (hint) {
4169      h = (hint - (hint % 26)) / 26;
4170    } else {
4171      h = 0;
4172    }
4173
4174    var r = bits % 26;
4175    var s = Math.min((bits - r) / 26, this.length);
4176    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
4177    var maskedWords = extended;
4178
4179    h -= s;
4180    h = Math.max(0, h);
4181
4182    // Extended mode, copy masked part
4183    if (maskedWords) {
4184      for (var i = 0; i < s; i++) {
4185        maskedWords.words[i] = this.words[i];
4186      }
4187      maskedWords.length = s;
4188    }
4189
4190    if (s === 0) {
4191      // No-op, we should not move anything at all
4192    } else if (this.length > s) {
4193      this.length -= s;
4194      for (i = 0; i < this.length; i++) {
4195        this.words[i] = this.words[i + s];
4196      }
4197    } else {
4198      this.words[0] = 0;
4199      this.length = 1;
4200    }
4201
4202    var carry = 0;
4203    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
4204      var word = this.words[i] | 0;
4205      this.words[i] = (carry << (26 - r)) | (word >>> r);
4206      carry = word & mask;
4207    }
4208
4209    // Push carried bits as a mask
4210    if (maskedWords && carry !== 0) {
4211      maskedWords.words[maskedWords.length++] = carry;
4212    }
4213
4214    if (this.length === 0) {
4215      this.words[0] = 0;
4216      this.length = 1;
4217    }
4218
4219    return this.strip();
4220  };
4221
4222  BN.prototype.ishrn = function ishrn (bits, hint, extended) {
4223    // TODO(indutny): implement me
4224    assert(this.negative === 0);
4225    return this.iushrn(bits, hint, extended);
4226  };
4227
4228  // Shift-left
4229  BN.prototype.shln = function shln (bits) {
4230    return this.clone().ishln(bits);
4231  };
4232
4233  BN.prototype.ushln = function ushln (bits) {
4234    return this.clone().iushln(bits);
4235  };
4236
4237  // Shift-right
4238  BN.prototype.shrn = function shrn (bits) {
4239    return this.clone().ishrn(bits);
4240  };
4241
4242  BN.prototype.ushrn = function ushrn (bits) {
4243    return this.clone().iushrn(bits);
4244  };
4245
4246  // Test if n bit is set
4247  BN.prototype.testn = function testn (bit) {
4248    assert(typeof bit === 'number' && bit >= 0);
4249    var r = bit % 26;
4250    var s = (bit - r) / 26;
4251    var q = 1 << r;
4252
4253    // Fast case: bit is much higher than all existing words
4254    if (this.length <= s) return false;
4255
4256    // Check bit and return
4257    var w = this.words[s];
4258
4259    return !!(w & q);
4260  };
4261
4262  // Return only lowers bits of number (in-place)
4263  BN.prototype.imaskn = function imaskn (bits) {
4264    assert(typeof bits === 'number' && bits >= 0);
4265    var r = bits % 26;
4266    var s = (bits - r) / 26;
4267
4268    assert(this.negative === 0, 'imaskn works only with positive numbers');
4269
4270    if (this.length <= s) {
4271      return this;
4272    }
4273
4274    if (r !== 0) {
4275      s++;
4276    }
4277    this.length = Math.min(s, this.length);
4278
4279    if (r !== 0) {
4280      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
4281      this.words[this.length - 1] &= mask;
4282    }
4283
4284    return this.strip();
4285  };
4286
4287  // Return only lowers bits of number
4288  BN.prototype.maskn = function maskn (bits) {
4289    return this.clone().imaskn(bits);
4290  };
4291
4292  // Add plain number `num` to `this`
4293  BN.prototype.iaddn = function iaddn (num) {
4294    assert(typeof num === 'number');
4295    assert(num < 0x4000000);
4296    if (num < 0) return this.isubn(-num);
4297
4298    // Possible sign change
4299    if (this.negative !== 0) {
4300      if (this.length === 1 && (this.words[0] | 0) < num) {
4301        this.words[0] = num - (this.words[0] | 0);
4302        this.negative = 0;
4303        return this;
4304      }
4305
4306      this.negative = 0;
4307      this.isubn(num);
4308      this.negative = 1;
4309      return this;
4310    }
4311
4312    // Add without checks
4313    return this._iaddn(num);
4314  };
4315
4316  BN.prototype._iaddn = function _iaddn (num) {
4317    this.words[0] += num;
4318
4319    // Carry
4320    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
4321      this.words[i] -= 0x4000000;
4322      if (i === this.length - 1) {
4323        this.words[i + 1] = 1;
4324      } else {
4325        this.words[i + 1]++;
4326      }
4327    }
4328    this.length = Math.max(this.length, i + 1);
4329
4330    return this;
4331  };
4332
4333  // Subtract plain number `num` from `this`
4334  BN.prototype.isubn = function isubn (num) {
4335    assert(typeof num === 'number');
4336    assert(num < 0x4000000);
4337    if (num < 0) return this.iaddn(-num);
4338
4339    if (this.negative !== 0) {
4340      this.negative = 0;
4341      this.iaddn(num);
4342      this.negative = 1;
4343      return this;
4344    }
4345
4346    this.words[0] -= num;
4347
4348    if (this.length === 1 && this.words[0] < 0) {
4349      this.words[0] = -this.words[0];
4350      this.negative = 1;
4351    } else {
4352      // Carry
4353      for (var i = 0; i < this.length && this.words[i] < 0; i++) {
4354        this.words[i] += 0x4000000;
4355        this.words[i + 1] -= 1;
4356      }
4357    }
4358
4359    return this.strip();
4360  };
4361
4362  BN.prototype.addn = function addn (num) {
4363    return this.clone().iaddn(num);
4364  };
4365
4366  BN.prototype.subn = function subn (num) {
4367    return this.clone().isubn(num);
4368  };
4369
4370  BN.prototype.iabs = function iabs () {
4371    this.negative = 0;
4372
4373    return this;
4374  };
4375
4376  BN.prototype.abs = function abs () {
4377    return this.clone().iabs();
4378  };
4379
4380  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
4381    var len = num.length + shift;
4382    var i;
4383
4384    this._expand(len);
4385
4386    var w;
4387    var carry = 0;
4388    for (i = 0; i < num.length; i++) {
4389      w = (this.words[i + shift] | 0) + carry;
4390      var right = (num.words[i] | 0) * mul;
4391      w -= right & 0x3ffffff;
4392      carry = (w >> 26) - ((right / 0x4000000) | 0);
4393      this.words[i + shift] = w & 0x3ffffff;
4394    }
4395    for (; i < this.length - shift; i++) {
4396      w = (this.words[i + shift] | 0) + carry;
4397      carry = w >> 26;
4398      this.words[i + shift] = w & 0x3ffffff;
4399    }
4400
4401    if (carry === 0) return this.strip();
4402
4403    // Subtraction overflow
4404    assert(carry === -1);
4405    carry = 0;
4406    for (i = 0; i < this.length; i++) {
4407      w = -(this.words[i] | 0) + carry;
4408      carry = w >> 26;
4409      this.words[i] = w & 0x3ffffff;
4410    }
4411    this.negative = 1;
4412
4413    return this.strip();
4414  };
4415
4416  BN.prototype._wordDiv = function _wordDiv (num, mode) {
4417    var shift = this.length - num.length;
4418
4419    var a = this.clone();
4420    var b = num;
4421
4422    // Normalize
4423    var bhi = b.words[b.length - 1] | 0;
4424    var bhiBits = this._countBits(bhi);
4425    shift = 26 - bhiBits;
4426    if (shift !== 0) {
4427      b = b.ushln(shift);
4428      a.iushln(shift);
4429      bhi = b.words[b.length - 1] | 0;
4430    }
4431
4432    // Initialize quotient
4433    var m = a.length - b.length;
4434    var q;
4435
4436    if (mode !== 'mod') {
4437      q = new BN(null);
4438      q.length = m + 1;
4439      q.words = new Array(q.length);
4440      for (var i = 0; i < q.length; i++) {
4441        q.words[i] = 0;
4442      }
4443    }
4444
4445    var diff = a.clone()._ishlnsubmul(b, 1, m);
4446    if (diff.negative === 0) {
4447      a = diff;
4448      if (q) {
4449        q.words[m] = 1;
4450      }
4451    }
4452
4453    for (var j = m - 1; j >= 0; j--) {
4454      var qj = (a.words[b.length + j] | 0) * 0x4000000 +
4455        (a.words[b.length + j - 1] | 0);
4456
4457      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
4458      // (0x7ffffff)
4459      qj = Math.min((qj / bhi) | 0, 0x3ffffff);
4460
4461      a._ishlnsubmul(b, qj, j);
4462      while (a.negative !== 0) {
4463        qj--;
4464        a.negative = 0;
4465        a._ishlnsubmul(b, 1, j);
4466        if (!a.isZero()) {
4467          a.negative ^= 1;
4468        }
4469      }
4470      if (q) {
4471        q.words[j] = qj;
4472      }
4473    }
4474    if (q) {
4475      q.strip();
4476    }
4477    a.strip();
4478
4479    // Denormalize
4480    if (mode !== 'div' && shift !== 0) {
4481      a.iushrn(shift);
4482    }
4483
4484    return {
4485      div: q || null,
4486      mod: a
4487    };
4488  };
4489
4490  // NOTE: 1) `mode` can be set to `mod` to request mod only,
4491  //       to `div` to request div only, or be absent to
4492  //       request both div & mod
4493  //       2) `positive` is true if unsigned mod is requested
4494  BN.prototype.divmod = function divmod (num, mode, positive) {
4495    assert(!num.isZero());
4496
4497    if (this.isZero()) {
4498      return {
4499        div: new BN(0),
4500        mod: new BN(0)
4501      };
4502    }
4503
4504    var div, mod, res;
4505    if (this.negative !== 0 && num.negative === 0) {
4506      res = this.neg().divmod(num, mode);
4507
4508      if (mode !== 'mod') {
4509        div = res.div.neg();
4510      }
4511
4512      if (mode !== 'div') {
4513        mod = res.mod.neg();
4514        if (positive && mod.negative !== 0) {
4515          mod.iadd(num);
4516        }
4517      }
4518
4519      return {
4520        div: div,
4521        mod: mod
4522      };
4523    }
4524
4525    if (this.negative === 0 && num.negative !== 0) {
4526      res = this.divmod(num.neg(), mode);
4527
4528      if (mode !== 'mod') {
4529        div = res.div.neg();
4530      }
4531
4532      return {
4533        div: div,
4534        mod: res.mod
4535      };
4536    }
4537
4538    if ((this.negative & num.negative) !== 0) {
4539      res = this.neg().divmod(num.neg(), mode);
4540
4541      if (mode !== 'div') {
4542        mod = res.mod.neg();
4543        if (positive && mod.negative !== 0) {
4544          mod.isub(num);
4545        }
4546      }
4547
4548      return {
4549        div: res.div,
4550        mod: mod
4551      };
4552    }
4553
4554    // Both numbers are positive at this point
4555
4556    // Strip both numbers to approximate shift value
4557    if (num.length > this.length || this.cmp(num) < 0) {
4558      return {
4559        div: new BN(0),
4560        mod: this
4561      };
4562    }
4563
4564    // Very short reduction
4565    if (num.length === 1) {
4566      if (mode === 'div') {
4567        return {
4568          div: this.divn(num.words[0]),
4569          mod: null
4570        };
4571      }
4572
4573      if (mode === 'mod') {
4574        return {
4575          div: null,
4576          mod: new BN(this.modn(num.words[0]))
4577        };
4578      }
4579
4580      return {
4581        div: this.divn(num.words[0]),
4582        mod: new BN(this.modn(num.words[0]))
4583      };
4584    }
4585
4586    return this._wordDiv(num, mode);
4587  };
4588
4589  // Find `this` / `num`
4590  BN.prototype.div = function div (num) {
4591    return this.divmod(num, 'div', false).div;
4592  };
4593
4594  // Find `this` % `num`
4595  BN.prototype.mod = function mod (num) {
4596    return this.divmod(num, 'mod', false).mod;
4597  };
4598
4599  BN.prototype.umod = function umod (num) {
4600    return this.divmod(num, 'mod', true).mod;
4601  };
4602
4603  // Find Round(`this` / `num`)
4604  BN.prototype.divRound = function divRound (num) {
4605    var dm = this.divmod(num);
4606
4607    // Fast case - exact division
4608    if (dm.mod.isZero()) return dm.div;
4609
4610    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
4611
4612    var half = num.ushrn(1);
4613    var r2 = num.andln(1);
4614    var cmp = mod.cmp(half);
4615
4616    // Round down
4617    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
4618
4619    // Round up
4620    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
4621  };
4622
4623  BN.prototype.modn = function modn (num) {
4624    assert(num <= 0x3ffffff);
4625    var p = (1 << 26) % num;
4626
4627    var acc = 0;
4628    for (var i = this.length - 1; i >= 0; i--) {
4629      acc = (p * acc + (this.words[i] | 0)) % num;
4630    }
4631
4632    return acc;
4633  };
4634
4635  // In-place division by number
4636  BN.prototype.idivn = function idivn (num) {
4637    assert(num <= 0x3ffffff);
4638
4639    var carry = 0;
4640    for (var i = this.length - 1; i >= 0; i--) {
4641      var w = (this.words[i] | 0) + carry * 0x4000000;
4642      this.words[i] = (w / num) | 0;
4643      carry = w % num;
4644    }
4645
4646    return this.strip();
4647  };
4648
4649  BN.prototype.divn = function divn (num) {
4650    return this.clone().idivn(num);
4651  };
4652
4653  BN.prototype.egcd = function egcd (p) {
4654    assert(p.negative === 0);
4655    assert(!p.isZero());
4656
4657    var x = this;
4658    var y = p.clone();
4659
4660    if (x.negative !== 0) {
4661      x = x.umod(p);
4662    } else {
4663      x = x.clone();
4664    }
4665
4666    // A * x + B * y = x
4667    var A = new BN(1);
4668    var B = new BN(0);
4669
4670    // C * x + D * y = y
4671    var C = new BN(0);
4672    var D = new BN(1);
4673
4674    var g = 0;
4675
4676    while (x.isEven() && y.isEven()) {
4677      x.iushrn(1);
4678      y.iushrn(1);
4679      ++g;
4680    }
4681
4682    var yp = y.clone();
4683    var xp = x.clone();
4684
4685    while (!x.isZero()) {
4686      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
4687      if (i > 0) {
4688        x.iushrn(i);
4689        while (i-- > 0) {
4690          if (A.isOdd() || B.isOdd()) {
4691            A.iadd(yp);
4692            B.isub(xp);
4693          }
4694
4695          A.iushrn(1);
4696          B.iushrn(1);
4697        }
4698      }
4699
4700      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
4701      if (j > 0) {
4702        y.iushrn(j);
4703        while (j-- > 0) {
4704          if (C.isOdd() || D.isOdd()) {
4705            C.iadd(yp);
4706            D.isub(xp);
4707          }
4708
4709          C.iushrn(1);
4710          D.iushrn(1);
4711        }
4712      }
4713
4714      if (x.cmp(y) >= 0) {
4715        x.isub(y);
4716        A.isub(C);
4717        B.isub(D);
4718      } else {
4719        y.isub(x);
4720        C.isub(A);
4721        D.isub(B);
4722      }
4723    }
4724
4725    return {
4726      a: C,
4727      b: D,
4728      gcd: y.iushln(g)
4729    };
4730  };
4731
4732  // This is reduced incarnation of the binary EEA
4733  // above, designated to invert members of the
4734  // _prime_ fields F(p) at a maximal speed
4735  BN.prototype._invmp = function _invmp (p) {
4736    assert(p.negative === 0);
4737    assert(!p.isZero());
4738
4739    var a = this;
4740    var b = p.clone();
4741
4742    if (a.negative !== 0) {
4743      a = a.umod(p);
4744    } else {
4745      a = a.clone();
4746    }
4747
4748    var x1 = new BN(1);
4749    var x2 = new BN(0);
4750
4751    var delta = b.clone();
4752
4753    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
4754      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
4755      if (i > 0) {
4756        a.iushrn(i);
4757        while (i-- > 0) {
4758          if (x1.isOdd()) {
4759            x1.iadd(delta);
4760          }
4761
4762          x1.iushrn(1);
4763        }
4764      }
4765
4766      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
4767      if (j > 0) {
4768        b.iushrn(j);
4769        while (j-- > 0) {
4770          if (x2.isOdd()) {
4771            x2.iadd(delta);
4772          }
4773
4774          x2.iushrn(1);
4775        }
4776      }
4777
4778      if (a.cmp(b) >= 0) {
4779        a.isub(b);
4780        x1.isub(x2);
4781      } else {
4782        b.isub(a);
4783        x2.isub(x1);
4784      }
4785    }
4786
4787    var res;
4788    if (a.cmpn(1) === 0) {
4789      res = x1;
4790    } else {
4791      res = x2;
4792    }
4793
4794    if (res.cmpn(0) < 0) {
4795      res.iadd(p);
4796    }
4797
4798    return res;
4799  };
4800
4801  BN.prototype.gcd = function gcd (num) {
4802    if (this.isZero()) return num.abs();
4803    if (num.isZero()) return this.abs();
4804
4805    var a = this.clone();
4806    var b = num.clone();
4807    a.negative = 0;
4808    b.negative = 0;
4809
4810    // Remove common factor of two
4811    for (var shift = 0; a.isEven() && b.isEven(); shift++) {
4812      a.iushrn(1);
4813      b.iushrn(1);
4814    }
4815
4816    do {
4817      while (a.isEven()) {
4818        a.iushrn(1);
4819      }
4820      while (b.isEven()) {
4821        b.iushrn(1);
4822      }
4823
4824      var r = a.cmp(b);
4825      if (r < 0) {
4826        // Swap `a` and `b` to make `a` always bigger than `b`
4827        var t = a;
4828        a = b;
4829        b = t;
4830      } else if (r === 0 || b.cmpn(1) === 0) {
4831        break;
4832      }
4833
4834      a.isub(b);
4835    } while (true);
4836
4837    return b.iushln(shift);
4838  };
4839
4840  // Invert number in the field F(num)
4841  BN.prototype.invm = function invm (num) {
4842    return this.egcd(num).a.umod(num);
4843  };
4844
4845  BN.prototype.isEven = function isEven () {
4846    return (this.words[0] & 1) === 0;
4847  };
4848
4849  BN.prototype.isOdd = function isOdd () {
4850    return (this.words[0] & 1) === 1;
4851  };
4852
4853  // And first word and num
4854  BN.prototype.andln = function andln (num) {
4855    return this.words[0] & num;
4856  };
4857
4858  // Increment at the bit position in-line
4859  BN.prototype.bincn = function bincn (bit) {
4860    assert(typeof bit === 'number');
4861    var r = bit % 26;
4862    var s = (bit - r) / 26;
4863    var q = 1 << r;
4864
4865    // Fast case: bit is much higher than all existing words
4866    if (this.length <= s) {
4867      this._expand(s + 1);
4868      this.words[s] |= q;
4869      return this;
4870    }
4871
4872    // Add bit and propagate, if needed
4873    var carry = q;
4874    for (var i = s; carry !== 0 && i < this.length; i++) {
4875      var w = this.words[i] | 0;
4876      w += carry;
4877      carry = w >>> 26;
4878      w &= 0x3ffffff;
4879      this.words[i] = w;
4880    }
4881    if (carry !== 0) {
4882      this.words[i] = carry;
4883      this.length++;
4884    }
4885    return this;
4886  };
4887
4888  BN.prototype.isZero = function isZero () {
4889    return this.length === 1 && this.words[0] === 0;
4890  };
4891
4892  BN.prototype.cmpn = function cmpn (num) {
4893    var negative = num < 0;
4894
4895    if (this.negative !== 0 && !negative) return -1;
4896    if (this.negative === 0 && negative) return 1;
4897
4898    this.strip();
4899
4900    var res;
4901    if (this.length > 1) {
4902      res = 1;
4903    } else {
4904      if (negative) {
4905        num = -num;
4906      }
4907
4908      assert(num <= 0x3ffffff, 'Number is too big');
4909
4910      var w = this.words[0] | 0;
4911      res = w === num ? 0 : w < num ? -1 : 1;
4912    }
4913    if (this.negative !== 0) return -res | 0;
4914    return res;
4915  };
4916
4917  // Compare two numbers and return:
4918  // 1 - if `this` > `num`
4919  // 0 - if `this` == `num`
4920  // -1 - if `this` < `num`
4921  BN.prototype.cmp = function cmp (num) {
4922    if (this.negative !== 0 && num.negative === 0) return -1;
4923    if (this.negative === 0 && num.negative !== 0) return 1;
4924
4925    var res = this.ucmp(num);
4926    if (this.negative !== 0) return -res | 0;
4927    return res;
4928  };
4929
4930  // Unsigned comparison
4931  BN.prototype.ucmp = function ucmp (num) {
4932    // At this point both numbers have the same sign
4933    if (this.length > num.length) return 1;
4934    if (this.length < num.length) return -1;
4935
4936    var res = 0;
4937    for (var i = this.length - 1; i >= 0; i--) {
4938      var a = this.words[i] | 0;
4939      var b = num.words[i] | 0;
4940
4941      if (a === b) continue;
4942      if (a < b) {
4943        res = -1;
4944      } else if (a > b) {
4945        res = 1;
4946      }
4947      break;
4948    }
4949    return res;
4950  };
4951
4952  BN.prototype.gtn = function gtn (num) {
4953    return this.cmpn(num) === 1;
4954  };
4955
4956  BN.prototype.gt = function gt (num) {
4957    return this.cmp(num) === 1;
4958  };
4959
4960  BN.prototype.gten = function gten (num) {
4961    return this.cmpn(num) >= 0;
4962  };
4963
4964  BN.prototype.gte = function gte (num) {
4965    return this.cmp(num) >= 0;
4966  };
4967
4968  BN.prototype.ltn = function ltn (num) {
4969    return this.cmpn(num) === -1;
4970  };
4971
4972  BN.prototype.lt = function lt (num) {
4973    return this.cmp(num) === -1;
4974  };
4975
4976  BN.prototype.lten = function lten (num) {
4977    return this.cmpn(num) <= 0;
4978  };
4979
4980  BN.prototype.lte = function lte (num) {
4981    return this.cmp(num) <= 0;
4982  };
4983
4984  BN.prototype.eqn = function eqn (num) {
4985    return this.cmpn(num) === 0;
4986  };
4987
4988  BN.prototype.eq = function eq (num) {
4989    return this.cmp(num) === 0;
4990  };
4991
4992  //
4993  // A reduce context, could be using montgomery or something better, depending
4994  // on the `m` itself.
4995  //
4996  BN.red = function red (num) {
4997    return new Red(num);
4998  };
4999
5000  BN.prototype.toRed = function toRed (ctx) {
5001    assert(!this.red, 'Already a number in reduction context');
5002    assert(this.negative === 0, 'red works only with positives');
5003    return ctx.convertTo(this)._forceRed(ctx);
5004  };
5005
5006  BN.prototype.fromRed = function fromRed () {
5007    assert(this.red, 'fromRed works only with numbers in reduction context');
5008    return this.red.convertFrom(this);
5009  };
5010
5011  BN.prototype._forceRed = function _forceRed (ctx) {
5012    this.red = ctx;
5013    return this;
5014  };
5015
5016  BN.prototype.forceRed = function forceRed (ctx) {
5017    assert(!this.red, 'Already a number in reduction context');
5018    return this._forceRed(ctx);
5019  };
5020
5021  BN.prototype.redAdd = function redAdd (num) {
5022    assert(this.red, 'redAdd works only with red numbers');
5023    return this.red.add(this, num);
5024  };
5025
5026  BN.prototype.redIAdd = function redIAdd (num) {
5027    assert(this.red, 'redIAdd works only with red numbers');
5028    return this.red.iadd(this, num);
5029  };
5030
5031  BN.prototype.redSub = function redSub (num) {
5032    assert(this.red, 'redSub works only with red numbers');
5033    return this.red.sub(this, num);
5034  };
5035
5036  BN.prototype.redISub = function redISub (num) {
5037    assert(this.red, 'redISub works only with red numbers');
5038    return this.red.isub(this, num);
5039  };
5040
5041  BN.prototype.redShl = function redShl (num) {
5042    assert(this.red, 'redShl works only with red numbers');
5043    return this.red.shl(this, num);
5044  };
5045
5046  BN.prototype.redMul = function redMul (num) {
5047    assert(this.red, 'redMul works only with red numbers');
5048    this.red._verify2(this, num);
5049    return this.red.mul(this, num);
5050  };
5051
5052  BN.prototype.redIMul = function redIMul (num) {
5053    assert(this.red, 'redMul works only with red numbers');
5054    this.red._verify2(this, num);
5055    return this.red.imul(this, num);
5056  };
5057
5058  BN.prototype.redSqr = function redSqr () {
5059    assert(this.red, 'redSqr works only with red numbers');
5060    this.red._verify1(this);
5061    return this.red.sqr(this);
5062  };
5063
5064  BN.prototype.redISqr = function redISqr () {
5065    assert(this.red, 'redISqr works only with red numbers');
5066    this.red._verify1(this);
5067    return this.red.isqr(this);
5068  };
5069
5070  // Square root over p
5071  BN.prototype.redSqrt = function redSqrt () {
5072    assert(this.red, 'redSqrt works only with red numbers');
5073    this.red._verify1(this);
5074    return this.red.sqrt(this);
5075  };
5076
vendor: 8,763 bytes, lines 5077-5456
5077  BN.prototype.redInvm = function redInvm () {
5078    assert(this.red, 'redInvm works only with red numbers');
5079    this.red._verify1(this);
5080    return this.red.invm(this);
5081  };
5082
5083  // Return negative clone of `this` % `red modulo`
5084  BN.prototype.redNeg = function redNeg () {
5085    assert(this.red, 'redNeg works only with red numbers');
5086    this.red._verify1(this);
5087    return this.red.neg(this);
5088  };
5089
5090  BN.prototype.redPow = function redPow (num) {
5091    assert(this.red && !num.red, 'redPow(normalNum)');
5092    this.red._verify1(this);
5093    return this.red.pow(this, num);
5094  };
5095
5096  // Prime numbers with efficient reduction
5097  var primes = {
5098    k256: null,
5099    p224: null,
5100    p192: null,
5101    p25519: null
5102  };
5103
5104  // Pseudo-Mersenne prime
5105  function MPrime (name, p) {
5106    // P = 2 ^ N - K
5107    this.name = name;
5108    this.p = new BN(p, 16);
5109    this.n = this.p.bitLength();
5110    this.k = new BN(1).iushln(this.n).isub(this.p);
5111
5112    this.tmp = this._tmp();
5113  }
5114
5115  MPrime.prototype._tmp = function _tmp () {
5116    var tmp = new BN(null);
5117    tmp.words = new Array(Math.ceil(this.n / 13));
5118    return tmp;
5119  };
5120
5121  MPrime.prototype.ireduce = function ireduce (num) {
5122    // Assumes that `num` is less than `P^2`
5123    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
5124    var r = num;
5125    var rlen;
5126
5127    do {
5128      this.split(r, this.tmp);
5129      r = this.imulK(r);
5130      r = r.iadd(this.tmp);
5131      rlen = r.bitLength();
5132    } while (rlen > this.n);
5133
5134    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
5135    if (cmp === 0) {
5136      r.words[0] = 0;
5137      r.length = 1;
5138    } else if (cmp > 0) {
5139      r.isub(this.p);
5140    } else {
5141      r.strip();
5142    }
5143
5144    return r;
5145  };
5146
5147  MPrime.prototype.split = function split (input, out) {
5148    input.iushrn(this.n, 0, out);
5149  };
5150
5151  MPrime.prototype.imulK = function imulK (num) {
5152    return num.imul(this.k);
5153  };
5154
5155  function K256 () {
5156    MPrime.call(
5157      this,
5158      'k256',
5159      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
5160  }
5161  inherits(K256, MPrime);
5162
5163  K256.prototype.split = function split (input, output) {
5164    // 256 = 9 * 26 + 22
5165    var mask = 0x3fffff;
5166
5167    var outLen = Math.min(input.length, 9);
5168    for (var i = 0; i < outLen; i++) {
5169      output.words[i] = input.words[i];
5170    }
5171    output.length = outLen;
5172
5173    if (input.length <= 9) {
5174      input.words[0] = 0;
5175      input.length = 1;
5176      return;
5177    }
5178
5179    // Shift by 9 limbs
5180    var prev = input.words[9];
5181    output.words[output.length++] = prev & mask;
5182
5183    for (i = 10; i < input.length; i++) {
5184      var next = input.words[i] | 0;
5185      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
5186      prev = next;
5187    }
5188    prev >>>= 22;
5189    input.words[i - 10] = prev;
5190    if (prev === 0 && input.length > 10) {
5191      input.length -= 10;
5192    } else {
5193      input.length -= 9;
5194    }
5195  };
5196
5197  K256.prototype.imulK = function imulK (num) {
5198    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
5199    num.words[num.length] = 0;
5200    num.words[num.length + 1] = 0;
5201    num.length += 2;
5202
5203    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
5204    var lo = 0;
5205    for (var i = 0; i < num.length; i++) {
5206      var w = num.words[i] | 0;
5207      lo += w * 0x3d1;
5208      num.words[i] = lo & 0x3ffffff;
5209      lo = w * 0x40 + ((lo / 0x4000000) | 0);
5210    }
5211
5212    // Fast length reduction
5213    if (num.words[num.length - 1] === 0) {
5214      num.length--;
5215      if (num.words[num.length - 1] === 0) {
5216        num.length--;
5217      }
5218    }
5219    return num;
5220  };
5221
5222  function P224 () {
5223    MPrime.call(
5224      this,
5225      'p224',
5226      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
5227  }
5228  inherits(P224, MPrime);
5229
5230  function P192 () {
5231    MPrime.call(
5232      this,
5233      'p192',
5234      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
5235  }
5236  inherits(P192, MPrime);
5237
5238  function P25519 () {
5239    // 2 ^ 255 - 19
5240    MPrime.call(
5241      this,
5242      '25519',
5243      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
5244  }
5245  inherits(P25519, MPrime);
5246
5247  P25519.prototype.imulK = function imulK (num) {
5248    // K = 0x13
5249    var carry = 0;
5250    for (var i = 0; i < num.length; i++) {
5251      var hi = (num.words[i] | 0) * 0x13 + carry;
5252      var lo = hi & 0x3ffffff;
5253      hi >>>= 26;
5254
5255      num.words[i] = lo;
5256      carry = hi;
5257    }
5258    if (carry !== 0) {
5259      num.words[num.length++] = carry;
5260    }
5261    return num;
5262  };
5263
5264  // Exported mostly for testing purposes, use plain name instead
5265  BN._prime = function prime (name) {
5266    // Cached version of prime
5267    if (primes[name]) return primes[name];
5268
5269    var prime;
5270    if (name === 'k256') {
5271      prime = new K256();
5272    } else if (name === 'p224') {
5273      prime = new P224();
5274    } else if (name === 'p192') {
5275      prime = new P192();
5276    } else if (name === 'p25519') {
5277      prime = new P25519();
5278    } else {
5279      throw new Error('Unknown prime ' + name);
5280    }
5281    primes[name] = prime;
5282
5283    return prime;
5284  };
5285
5286  //
5287  // Base reduction engine
5288  //
5289  function Red (m) {
5290    if (typeof m === 'string') {
5291      var prime = BN._prime(m);
5292      this.m = prime.p;
5293      this.prime = prime;
5294    } else {
5295      assert(m.gtn(1), 'modulus must be greater than 1');
5296      this.m = m;
5297      this.prime = null;
5298    }
5299  }
5300
5301  Red.prototype._verify1 = function _verify1 (a) {
5302    assert(a.negative === 0, 'red works only with positives');
5303    assert(a.red, 'red works only with red numbers');
5304  };
5305
5306  Red.prototype._verify2 = function _verify2 (a, b) {
5307    assert((a.negative | b.negative) === 0, 'red works only with positives');
5308    assert(a.red && a.red === b.red,
5309      'red works only with red numbers');
5310  };
5311
5312  Red.prototype.imod = function imod (a) {
5313    if (this.prime) return this.prime.ireduce(a)._forceRed(this);
5314    return a.umod(this.m)._forceRed(this);
5315  };
5316
5317  Red.prototype.neg = function neg (a) {
5318    if (a.isZero()) {
5319      return a.clone();
5320    }
5321
5322    return this.m.sub(a)._forceRed(this);
5323  };
5324
5325  Red.prototype.add = function add (a, b) {
5326    this._verify2(a, b);
5327
5328    var res = a.add(b);
5329    if (res.cmp(this.m) >= 0) {
5330      res.isub(this.m);
5331    }
5332    return res._forceRed(this);
5333  };
5334
5335  Red.prototype.iadd = function iadd (a, b) {
5336    this._verify2(a, b);
5337
5338    var res = a.iadd(b);
5339    if (res.cmp(this.m) >= 0) {
5340      res.isub(this.m);
5341    }
5342    return res;
5343  };
5344
5345  Red.prototype.sub = function sub (a, b) {
5346    this._verify2(a, b);
5347
5348    var res = a.sub(b);
5349    if (res.cmpn(0) < 0) {
5350      res.iadd(this.m);
5351    }
5352    return res._forceRed(this);
5353  };
5354
5355  Red.prototype.isub = function isub (a, b) {
5356    this._verify2(a, b);
5357
5358    var res = a.isub(b);
5359    if (res.cmpn(0) < 0) {
5360      res.iadd(this.m);
5361    }
5362    return res;
5363  };
5364
5365  Red.prototype.shl = function shl (a, num) {
5366    this._verify1(a);
5367    return this.imod(a.ushln(num));
5368  };
5369
5370  Red.prototype.imul = function imul (a, b) {
5371    this._verify2(a, b);
5372    return this.imod(a.imul(b));
5373  };
5374
5375  Red.prototype.mul = function mul (a, b) {
5376    this._verify2(a, b);
5377    return this.imod(a.mul(b));
5378  };
5379
5380  Red.prototype.isqr = function isqr (a) {
5381    return this.imul(a, a.clone());
5382  };
5383
5384  Red.prototype.sqr = function sqr (a) {
5385    return this.mul(a, a);
5386  };
5387
5388  Red.prototype.sqrt = function sqrt (a) {
5389    if (a.isZero()) return a.clone();
5390
5391    var mod3 = this.m.andln(3);
5392    assert(mod3 % 2 === 1);
5393
5394    // Fast case
5395    if (mod3 === 3) {
5396      var pow = this.m.add(new BN(1)).iushrn(2);
5397      return this.pow(a, pow);
5398    }
5399
5400    // Tonelli-Shanks algorithm (Totally unoptimized and slow)
5401    //
5402    // Find Q and S, that Q * 2 ^ S = (P - 1)
5403    var q = this.m.subn(1);
5404    var s = 0;
5405    while (!q.isZero() && q.andln(1) === 0) {
5406      s++;
5407      q.iushrn(1);
5408    }
5409    assert(!q.isZero());
5410
5411    var one = new BN(1).toRed(this);
5412    var nOne = one.redNeg();
5413
5414    // Find quadratic non-residue
5415    // NOTE: Max is such because of generalized Riemann hypothesis.
5416    var lpow = this.m.subn(1).iushrn(1);
5417    var z = this.m.bitLength();
5418    z = new BN(2 * z * z).toRed(this);
5419
5420    while (this.pow(z, lpow).cmp(nOne) !== 0) {
5421      z.redIAdd(nOne);
5422    }
5423
5424    var c = this.pow(z, q);
5425    var r = this.pow(a, q.addn(1).iushrn(1));
5426    var t = this.pow(a, q);
5427    var m = s;
5428    while (t.cmp(one) !== 0) {
5429      var tmp = t;
5430      for (var i = 0; tmp.cmp(one) !== 0; i++) {
5431        tmp = tmp.redSqr();
5432      }
5433      assert(i < m);
5434      var b = this.pow(c, new BN(1).iushln(m - i - 1));
5435
5436      r = r.redMul(b);
5437      c = b.redSqr();
5438      t = t.redMul(c);
5439      m = i;
5440    }
5441
5442    return r;
5443  };
5444
5445  Red.prototype.invm = function invm (a) {
5446    var inv = a._invmp(this.m);
5447    if (inv.negative !== 0) {
5448      inv.negative = 0;
5449      return this.imod(inv).redNeg();
5450    } else {
5451      return this.imod(inv);
5452    }
5453  };
5454
5455  Red.prototype.pow = function pow (a, num) {
5456    if (num.isZero()) return new BN(1)
vendor: 3,338 bytes, lines 5456-5598
5456;
5457    if (num.cmpn(1) === 0) return a.clone();
5458
5459    var windowSize = 4;
5460    var wnd = new Array(1 << windowSize);
5461    wnd[0] = new BN(1).toRed(this);
5462    wnd[1] = a;
5463    for (var i = 2; i < wnd.length; i++) {
5464      wnd[i] = this.mul(wnd[i - 1], a);
5465    }
5466
5467    var res = wnd[0];
5468    var current = 0;
5469    var currentLen = 0;
5470    var start = num.bitLength() % 26;
5471    if (start === 0) {
5472      start = 26;
5473    }
5474
5475    for (i = num.length - 1; i >= 0; i--) {
5476      var word = num.words[i];
5477      for (var j = start - 1; j >= 0; j--) {
5478        var bit = (word >> j) & 1;
5479        if (res !== wnd[0]) {
5480          res = this.sqr(res);
5481        }
5482
5483        if (bit === 0 && current === 0) {
5484          currentLen = 0;
5485          continue;
5486        }
5487
5488        current <<= 1;
5489        current |= bit;
5490        currentLen++;
5491        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
5492
5493        res = this.mul(res, wnd[current]);
5494        currentLen = 0;
5495        current = 0;
5496      }
5497      start = 26;
5498    }
5499
5500    return res;
5501  };
5502
5503  Red.prototype.convertTo = function convertTo (num) {
5504    var r = num.umod(this.m);
5505
5506    return r === num ? r.clone() : r;
5507  };
5508
5509  Red.prototype.convertFrom = function convertFrom (num) {
5510    var res = num.clone();
5511    res.red = null;
5512    return res;
5513  };
5514
5515  //
5516  // Montgomery method engine
5517  //
5518
5519  BN.mont = function mont (num) {
5520    return new Mont(num);
5521  };
5522
5523  function Mont (m) {
5524    Red.call(this, m);
5525
5526    this.shift = this.m.bitLength();
5527    if (this.shift % 26 !== 0) {
5528      this.shift += 26 - (this.shift % 26);
5529    }
5530
5531    this.r = new BN(1).iushln(this.shift);
5532    this.r2 = this.imod(this.r.sqr());
5533    this.rinv = this.r._invmp(this.m);
5534
5535    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
5536    this.minv = this.minv.umod(this.r);
5537    this.minv = this.r.sub(this.minv);
5538  }
5539  inherits(Mont, Red);
5540
5541  Mont.prototype.convertTo = function convertTo (num) {
5542    return this.imod(num.ushln(this.shift));
5543  };
5544
5545  Mont.prototype.convertFrom = function convertFrom (num) {
5546    var r = this.imod(num.mul(this.rinv));
5547    r.red = null;
5548    return r;
5549  };
5550
5551  Mont.prototype.imul = function imul (a, b) {
5552    if (a.isZero() || b.isZero()) {
5553      a.words[0] = 0;
5554      a.length = 1;
5555      return a;
5556    }
5557
5558    var t = a.imul(b);
5559    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
5560    var u = t.isub(c).iushrn(this.shift);
5561    var res = u;
5562
5563    if (u.cmp(this.m) >= 0) {
5564      res = u.isub(this.m);
5565    } else if (u.cmpn(0) < 0) {
5566      res = u.iadd(this.m);
5567    }
5568
5569    return res._forceRed(this);
5570  };
5571
5572  Mont.prototype.mul = function mul (a, b) {
5573    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
5574
5575    var t = a.mul(b);
5576    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
5577    var u = t.isub(c).iushrn(this.shift);
5578    var res = u;
5579    if (u.cmp(this.m) >= 0) {
5580      res = u.isub(this.m);
5581    } else if (u.cmpn(0) < 0) {
5582      res = u.iadd(this.m);
5583    }
5584
5585    return res._forceRed(this);
5586  };
5587
5588  Mont.prototype.invm = function invm (a) {
5589    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
5590    var res = this.imod(a._invmp(this.m).mul(this.r2));
5591    return res._forceRed(this);
5592  };
5593})(typeof module === 'undefined' || module, this);
5594
5595/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)(module)))
5596
5597/***/ },
5598/* 2 */
5599/***/ function(module, exports) {
5600
5601var g;
5602
5603// This works in non-strict mode
5604g = (function() { return this; })();
5605
5606try {
5607	// This works if eval is allowed (see CSP)
5608	g = g || Function("return this")() || (1,eval)("this");
5609} catch(e) {
5610	// This works if the window reference is available
5611	if(typeof window === "object")
5612		g = window;
5613}
5614
5615// g can still be undefined, but nothing to do about it...
5616// We return undefined, instead of nothing here, so it's
5617// easier to handle this case. if(!global) { ...}
5618
5619module.exports = g;
5620
5621
5622/***/ },
5623/* 3 */
5624/***/ function(module, exports, __webpack_require__) {
5625
5626"use strict";
5627/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
5628
5629var BN = __webpack_require__(1);
5630var numberToBN = __webpack_require__(10);
5631var keccak256 = __webpack_require__(9).keccak_256;
5632
5633// from ethereumjs-util
5634function stripZeros(aInput) {
5635  var a = aInput; // eslint-disable-line
5636  var first = a[0]; // eslint-disable-line
5637  while (a.length > 0 && first.toString() === '0') {
5638    a = a.slice(1);
5639    first = a[0];
5640  }
5641  return a;
5642}
5643
5644function bnToBuffer(bnInput) {
5645  var bn = bnInput; // eslint-disable-line
5646  var hex = bn.toString(16); // eslint-disable-line
5647  if (hex.length % 2) {
5648    hex = '0' + hex;
5649  }
5650  return stripZeros(new Buffer(hex, 'hex'));
5651}
5652
5653function isHexString(value, length) {
5654  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
5655    return false;
5656  }
5657  if (length && value.length !== 2 + 2 * length) {
5658    return false;
5659  }
5660  return true;
5661}
5662
5663function hexOrBuffer(valueInput, name) {
5664  var value = valueInput; // eslint-disable-line
5665  if (!Buffer.isBuffer(value)) {
5666    if (!isHexString(value)) {
5667      var error = new Error(name ? '[ethjs-abi] invalid ' + name : '[ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string');
5668      error.reason = '[ethjs-abi] invalid hex string, hex must be prefixed and alphanumeric (e.g. 0x023..)';
5669      error.value = value;
5670      throw error;
5671    }
5672
5673    value = value.substring(2);
5674    if (value.length % 2) {
5675      value = '0' + value;
5676    }
5677    value = new Buffer(value, 'hex');
5678  }
5679
5680  return value;
5681}
5682
5683function hexlify(value) {
5684  if (typeof value === 'number') {
5685    return '0x' + bnToBuffer(new BN(value)).toString('hex');
5686  } else if (value.mod || value.modulo) {
5687    return '0x' + bnToBuffer(value).toString('hex');
5688  } else {
5689    // eslint-disable-line
5690    return '0x' + hexOrBuffer(value).toString('hex');
5691  }
5692}
5693
5694// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
5695function getKeys(params, key, allowEmpty) {
5696  var result = []; // eslint-disable-line
5697
5698  if (!Array.isArray(params)) {
5699    throw new Error('[ethjs-abi] while getting keys, invalid params value ' + JSON.stringify(params));
5700  }
5701
5702  for (var i = 0; i < params.length; i++) {
5703    // eslint-disable-line
5704    var value = params[i][key]; // eslint-disable-line
5705    if (allowEmpty && !value) {
5706      value = '';
5707    } else if (typeof value !== 'string') {
5708      throw new Error('[ethjs-abi] while getKeys found invalid ABI data structure, type value not string');
5709    }
5710    result.push(value);
5711  }
5712
5713  return result;
5714}
5715
5716function coderNumber(size, signed) {
5717  return {
5718    encode: function encodeNumber(valueInput) {
5719      var value = valueInput; // eslint-disable-line
5720
5721      if (typeof value === 'object' && value.toString && (value.toTwos || value.dividedToIntegerBy)) {
5722        value = value.toString(10).split('.')[0];
5723      }
5724
5725      if (typeof value === 'string' || typeof value === 'number') {
5726        value = String(value).split('.')[0];
5727      }
5728
5729      value = numberToBN(value);
5730      value = value.toTwos(size * 8).maskn(size * 8);
5731      if (signed) {
5732        value = value.fromTwos(size * 8).toTwos(256);
5733      }
5734      return value.toArrayLike(Buffer, 'be', 32);
5735    },
5736    decode: function decodeNumber(data, offset) {
5737      var junkLength = 32 - size; // eslint-disable-line
5738      var value = new BN(data.slice(offset + junkLength, offset + 32)); // eslint-disable-line
5739      if (signed) {
5740        value = value.fromTwos(size * 8);
5741      } else {
5742        value = value.maskn(size * 8);
5743      }
5744      return {
5745        consumed: 32,
5746        value: new BN(value.toString(10))
5747      };
5748    }
5749  };
5750}
5751var uint256Coder = coderNumber(32, false);
5752
5753var coderBoolean = {
5754  encode: function encodeBoolean(value) {
5755    return uint256Coder.encode(value ? 1 : 0);
5756  },
5757  decode: function decodeBoolean(data, offset) {
5758    var result = uint256Coder.decode(data, offset); // eslint-disable-line
5759    return {
5760      consumed: result.consumed,
5761      value: !result.value.isZero()
5762    };
5763  }
5764};
5765
5766function coderFixedBytes(length) {
5767  return {
5768    encode: function encodeFixedBytes(valueInput) {
5769      var value = valueInput; // eslint-disable-line
5770      value = hexOrBuffer(value);
5771
5772      if (value.length === 32) {
5773        return value;
5774      }
5775
5776      var result = new Buffer(32); // eslint-disable-line
5777      result.fill(0);
5778      value.copy(result);
5779      return result;
5780    },
5781    decode: function decodeFixedBytes(data, offset) {
5782      if (data.length < offset + 32) {
5783        throw new Error('[ethjs-abi] while decoding fixed bytes, invalid bytes data length: ' + length);
5784      }
5785
5786      return {
5787        consumed: 32,
5788        value: '0x' + data.slice(offset, offset + length).toString('hex')
5789      };
5790    }
5791  };
5792}
5793
5794var coderAddress = {
5795  encode: function encodeAddress(valueInput) {
5796    var value = valueInput; // eslint-disable-line
5797    var result = new Buffer(32); // eslint-disable-line
5798    if (!isHexString(value, 20)) {
5799      throw new Error('[ethjs-abi] while encoding address, invalid address value, not alphanumeric 20 byte hex string');
5800    }
5801    value = hexOrBuffer(value);
5802    result.fill(0);
5803    value.copy(result, 12);
5804    return result;
5805  },
5806  decode: function decodeAddress(data, offset) {
5807    if (data.length === 0) {
5808      return {
5809        consumed: 32,
5810        value: '0x'
5811      };
5812    }
5813    if (data.length < offset + 32) {
5814      throw new Error('[ethjs-abi] while decoding address data, invalid address data, invalid byte length ' + data.length);
5815    }
5816    return {
5817      consumed: 32,
5818      value: '0x' + data.slice(offset + 12, offset + 32).toString('hex')
5819    };
5820  }
5821};
5822
5823function encodeDynamicBytesHelper(value) {
5824  var dataLength = parseInt(32 * Math.ceil(value.length / 32)); // eslint-disable-line
5825  var padding = new Buffer(dataLength - value.length); // eslint-disable-line
5826  padding.fill(0);
5827
5828  return Buffer.concat([uint256Coder.encode(value.length), value, padding]);
5829}
5830
5831function decodeDynamicBytesHelper(data, offset) {
5832  if (data.length < offset + 32) {
5833    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32));
5834  }
5835
5836  var length = uint256Coder.decode(data, offset).value; // eslint-disable-line
5837  length = length.toNumber();
5838  if (data.length < offset + 32 + length) {
5839    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32 + length));
5840  }
5841
5842  return {
5843    consumed: parseInt(32 + 32 * Math.ceil(length / 32), 10),
5844    value: data.slice(offset + 32, offset + 32 + length)
5845  };
5846}
5847
5848var coderDynamicBytes = {
5849  encode: function encodeDynamicBytes(value) {
5850    return encodeDynamicBytesHelper(hexOrBuffer(value));
5851  },
5852  decode: function decodeDynamicBytes(data, offset) {
5853    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line
5854    result.value = '0x' + result.value.toString('hex');
5855    return result;
5856  },
5857  dynamic: true
5858};
5859
5860var coderString = {
5861  encode: function encodeString(value) {
5862    return encodeDynamicBytesHelper(new Buffer(value, 'utf8'));
5863  },
5864  decode: function decodeString(data, offset) {
5865    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line
5866    result.value = result.value.toString('utf8');
5867    return result;
5868  },
5869  dynamic: true
5870};
5871
5872function coderArray(coder, lengthInput) {
5873  return {
5874    encode: function encodeArray(value) {
5875      var result = new Buffer(0); // eslint-disable-line
5876      var length = lengthInput; // eslint-disable-line
5877
5878      if (!Array.isArray(value)) {
5879        throw new Error('[ethjs-abi] while encoding array, invalid array data, not type Object (Array)');
5880      }
5881
5882      if (length === -1) {
5883        length = value.length;
5884        result = uint256Coder.encode(length);
5885      }
5886
5887      if (length !== value.length) {
5888        throw new Error('[ethjs-abi] while encoding array, size mismatch array length ' + length + ' does not equal ' + value.length);
5889      }
5890
5891      value.forEach(function (resultValue) {
5892        result = Buffer.concat([result, coder.encode(resultValue)]);
5893      });
5894
5895      return result;
5896    },
5897    decode: function decodeArray(data, offsetInput) {
5898      var length = lengthInput; // eslint-disable-line
5899      var offset = offsetInput; // eslint-disable-line
5900      // @TODO:
5901      // if (data.length < offset + length * 32) { throw new Error('invalid array'); }
5902
5903      var consumed = 0; // eslint-disable-line
5904      var decodeResult; // eslint-disable-line
5905
5906      if (length === -1) {
5907        decodeResult = uint256Coder.decode(data, offset);
5908        length = decodeResult.value.toNumber();
5909        consumed += decodeResult.consumed;
5910        offset += decodeResult.consumed;
5911      }
5912
5913      var value = []; // eslint-disable-line
5914
5915      for (var i = 0; i < length; i++) {
5916        // eslint-disable-line
5917        var loopResult = coder.decode(data, offset);
5918        consumed += loopResult.consumed;
5919        offset += loopResult.consumed;
5920        value.push(loopResult.value);
5921      }
5922
5923      return {
5924        consumed: consumed,
5925        value: value
5926      };
5927    },
5928    dynamic: lengthInput === -1
5929  };
5930}
5931
5932// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and
5933// build the coder up from its parts
5934var paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\[([0-9]*)\]))/);
5935
5936function getParamCoder(typeInput) {
5937  var type = typeInput; // eslint-disable-line
5938  var coder = null; // eslint-disable-line
5939  var invalidTypeErrorMessage = '[ethjs-abi] while getting param coder (getParamCoder) type value ' + JSON.stringify(type) + ' is either invalid or unsupported by ethjs-abi.';
5940
5941  while (type) {
5942    var part = type.match(paramTypePart); // eslint-disable-line
5943    if (!part) {
5944      throw new Error(invalidTypeErrorMessage);
5945    }
5946    type = type.substring(part[0].length);
5947
5948    var prefix = part[2] || part[4] || part[5]; // eslint-disable-line
5949    switch (prefix) {
5950      case 'int':case 'uint':
5951        if (coder) {
5952          throw new Error(invalidTypeErrorMessage);
5953        }
5954        var intSize = parseInt(part[3] || 256); // eslint-disable-line
5955        if (intSize === 0 || intSize > 256 || intSize % 8 !== 0) {
5956          throw new Error('[ethjs-abi] while getting param coder for type ' + type + ', invalid ' + prefix + '<N> width: ' + type);
5957        }
5958
5959        coder = coderNumber(intSize / 8, prefix === 'int');
5960        break;
5961
5962      case 'bool':
5963        if (coder) {
5964          throw new Error(invalidTypeErrorMessage);
5965        }
5966        coder = coderBoolean;
5967        break;
5968
5969      case 'string':
5970        if (coder) {
5971          throw new Error(invalidTypeErrorMessage);
5972        }
5973        coder = coderString;
5974        break;
5975
5976      case 'bytes':
5977        if (coder) {
5978          throw new Error(invalidTypeErrorMessage);
5979        }
5980        if (part[3]) {
5981          var size = parseInt(part[3]); // eslint-disable-line
5982          if (size === 0 || size > 32) {
5983            throw new Error('[ethjs-abi] while getting param coder for prefix bytes, invalid type ' + type + ', size ' + size + ' should be 0 or greater than 32');
5984          }
5985          coder = coderFixedBytes(size);
5986        } else {
5987          coder = coderDynamicBytes;
5988        }
5989        break;
5990
5991      case 'address':
5992        if (coder) {
5993          throw new Error(invalidTypeErrorMessage);
5994        }
5995        coder = coderAddress;
5996        break;
5997
5998      case '[]':
5999        if (!coder || coder.dynamic) {
6000          throw new Error(invalidTypeErrorMessage);
6001        }
6002        coder = coderArray(coder, -1);
6003        break;
6004
6005      // "[0-9+]"
6006      default:
6007        if (!coder || coder.dynamic) {
6008          throw new Error(invalidTypeErrorMessage);
6009        }
6010        var defaultSize = parseInt(part[6]); // eslint-disable-line
6011        coder = coderArray(coder, defaultSize);
6012    }
6013  }
6014
6015  if (!coder) {
6016    throw new Error(invalidTypeErrorMessage);
6017  }
6018  return coder;
6019}
6020
6021module.exports = {
6022  BN: BN,
6023  bnToBuffer: bnToBuffer,
6024  isHexString: isHexString,
6025  hexOrBuffer: hexOrBuffer,
6026  hexlify: hexlify,
6027  stripZeros: stripZeros,
6028
6029  keccak256: keccak256,
6030
6031  getKeys: getKeys,
6032  numberToBN: numberToBN,
6033  coderNumber: coderNumber,
6034  uint256Coder: uint256Coder,
6035  coderBoolean: coderBoolean,
6036  coderFixedBytes: coderFixedBytes,
6037  coderAddress: coderAddress,
6038  coderDynamicBytes: coderDynamicBytes,
6039  coderString: coderString,
6040  coderArray: coderArray,
6041  paramTypePart: paramTypePart,
6042  getParamCoder: getParamCoder
6043};
6044/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
6045
6046/***/ },
6047/* 4 */
6048/***/ function(module, exports, __webpack_require__) {
6049
6050"use strict";
6051/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
6052
6053/* eslint-disable */
6054
6055var utils = __webpack_require__(3);
6056var uint256Coder = utils.uint256Coder;
6057var coderBoolean = utils.coderBoolean;
6058var coderFixedBytes = utils.coderFixedBytes;
6059var coderAddress = utils.coderAddress;
6060var coderDynamicBytes = utils.coderDynamicBytes;
6061var coderString = utils.coderString;
6062var coderArray = utils.coderArray;
6063var paramTypePart = utils.paramTypePart;
6064var getParamCoder = utils.getParamCoder;
6065
6066function Result() {}
6067
6068function encodeParams(types, values) {
6069  if (types.length !== values.length) {
6070    throw new Error('[ethjs-abi] while encoding params, types/values mismatch, Your contract requires ' + types.length + ' types (arguments), and you passed in ' + values.length);
6071  }
6072
6073  var parts = [];
6074
6075  types.forEach(function (type, index) {
6076    var coder = getParamCoder(type);
6077    parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });
6078  });
6079
6080  function alignSize(size) {
6081    return parseInt(32 * Math.ceil(size / 32));
6082  }
6083
6084  var staticSize = 0,
6085      dynamicSize = 0;
6086  parts.forEach(function (part) {
6087    if (part.dynamic) {
6088      staticSize += 32;
6089      dynamicSize += alignSize(part.value.length);
6090    } else {
6091      staticSize += alignSize(part.value.length);
6092    }
6093  });
6094
6095  var offset = 0,
6096      dynamicOffset = staticSize;
6097  var data = new Buffer(staticSize + dynamicSize);
6098
6099  parts.forEach(function (part, index) {
6100    if (part.dynamic) {
6101      uint256Coder.encode(dynamicOffset).copy(data, offset);
6102      offset += 32;
6103
6104      part.value.copy(data, dynamicOffset);
6105      dynamicOffset += alignSize(part.value.length);
6106    } else {
6107      part.value.copy(data, offset);
6108      offset += alignSize(part.value.length);
6109    }
6110  });
6111
6112  return '0x' + data.toString('hex');
6113}
6114
6115// decode bytecode data from output names and types
6116function decodeParams(names, types, data) {
6117  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
6118
6119  // Names is optional, so shift over all the parameters if not provided
6120  if (arguments.length < 3) {
6121    data = types;
6122    types = names;
6123    names = [];
6124  }
6125
6126  data = utils.hexOrBuffer(data);
6127  var values = new Result();
6128
6129  var offset = 0;
6130  types.forEach(function (type, index) {
6131    var coder = getParamCoder(type);
6132    if (coder.dynamic) {
6133      var dynamicOffset = uint256Coder.decode(data, offset);
6134      var result = coder.decode(data, dynamicOffset.value.toNumber());
6135      offset += dynamicOffset.consumed;
6136    } else {
6137      var result = coder.decode(data, offset);
6138      offset += result.consumed;
6139    }
6140    if (useNumberedParams) values[index] = result.value;
6141    if (names[index]) {
6142      values[names[index]] = result.value;
6143    }
6144  });
6145  return values;
6146}
6147
6148// encode method ABI object with values in an array, output bytecode
6149function encodeMethod(method, values) {
6150  var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';
6151  var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');
6152  var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);
6153
6154  return '' + signatureEncoded + paramsEncoded;
6155}
6156
6157// decode method data bytecode, from method ABI object
6158function decodeMethod(method, data) {
6159  var outputNames = utils.getKeys(method.outputs, 'name', true);
6160  var outputTypes = utils.getKeys(method.outputs, 'type');
6161
6162  return decodeParams(outputNames, outputTypes, utils.hexOrBuffer(data));
6163}
6164
6165// decode method data bytecode, from method ABI object
6166function encodeEvent(eventObject, values) {
6167  return encodeMethod(eventObject, values);
6168}
6169
6170function eventSignature(eventObject) {
6171  var signature = eventObject.name + '(' + utils.getKeys(eventObject.inputs, 'type').join(',') + ')';
6172  return '0x' + utils.keccak256(signature);
6173}
6174
6175// decode method data bytecode, from method ABI object
6176function decodeEvent(eventObject, data, topics) {
6177  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
6178
6179  var nonIndexed = eventObject.inputs.filter(function (input) {
6180    return !input.indexed;
6181  });
6182  var nonIndexedNames = utils.getKeys(nonIndexed, 'name', true);
6183  var nonIndexedTypes = utils.getKeys(nonIndexed, 'type');
6184  var event = decodeParams(nonIndexedNames, nonIndexedTypes, utils.hexOrBuffer(data), useNumberedParams);
6185  var topicOffset = eventObject.anonymous ? 0 : 1;
6186  eventObject.inputs.filter(function (input) {
6187    return input.indexed;
6188  }).map(function (input, i) {
6189    var topic = new Buffer(topics[i + topicOffset].slice(2), 'hex');
6190    var coder = getParamCoder(input.type);
6191    event[input.name] = coder.decode(topic, 0).value;
6192  });
6193  event._eventName = eventObject.name;
6194  return event;
6195}
6196
6197// Decode a specific log item with a specific event abi
6198function decodeLogItem(eventObject, log) {
6199  var useNumberedParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
6200
vendor: 4,804 bytes, lines 6201-6362
6201  if (eventObject && log.topics[0] === eventSignature(eventObject)) {
6202    return decodeEvent(eventObject, log.data, log.topics, useNumberedParams);
6203  }
6204}
6205
6206// Create a decoder for all events defined in an abi. It returns a function which is called
6207// on an array of log entries such as received from getLogs or getTransactionReceipt and parses
6208// any matching log entries
6209function logDecoder(abi) {
6210  var useNumberedParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
6211
6212  var eventMap = {};
6213  abi.filter(function (item) {
6214    return item.type === 'event';
6215  }).map(function (item) {
6216    eventMap[eventSignature(item)] = item;
6217  });
6218  return function (logItems) {
6219    return logItems.map(function (log) {
6220      return decodeLogItem(eventMap[log.topics[0]], log, useNumberedParams);
6221    }).filter(function (i) {
6222      return i;
6223    });
6224  };
6225}
6226
6227module.exports = {
6228  encodeParams: encodeParams,
6229  decodeParams: decodeParams,
6230  encodeMethod: encodeMethod,
6231  decodeMethod: decodeMethod,
6232  encodeEvent: encodeEvent,
6233  decodeEvent: decodeEvent,
6234  decodeLogItem: decodeLogItem,
6235  logDecoder: logDecoder,
6236  eventSignature: eventSignature
6237};
6238/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
6239
6240/***/ },
6241/* 5 */
6242/***/ function(module, exports) {
6243
6244"use strict";
6245'use strict'
6246
6247exports.byteLength = byteLength
6248exports.toByteArray = toByteArray
6249exports.fromByteArray = fromByteArray
6250
6251var lookup = []
6252var revLookup = []
6253var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
6254
6255var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
6256for (var i = 0, len = code.length; i < len; ++i) {
6257  lookup[i] = code[i]
6258  revLookup[code.charCodeAt(i)] = i
6259}
6260
6261revLookup['-'.charCodeAt(0)] = 62
6262revLookup['_'.charCodeAt(0)] = 63
6263
6264function placeHoldersCount (b64) {
6265  var len = b64.length
6266  if (len % 4 > 0) {
6267    throw new Error('Invalid string. Length must be a multiple of 4')
6268  }
6269
6270  // the number of equal signs (place holders)
6271  // if there are two placeholders, than the two characters before it
6272  // represent one byte
6273  // if there is only one, then the three characters before it represent 2 bytes
6274  // this is just a cheap hack to not do indexOf twice
6275  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
6276}
6277
6278function byteLength (b64) {
6279  // base64 is 4/3 + up to two characters of the original data
6280  return b64.length * 3 / 4 - placeHoldersCount(b64)
6281}
6282
6283function toByteArray (b64) {
6284  var i, j, l, tmp, placeHolders, arr
6285  var len = b64.length
6286  placeHolders = placeHoldersCount(b64)
6287
6288  arr = new Arr(len * 3 / 4 - placeHolders)
6289
6290  // if there are placeholders, only get up to the last complete 4 chars
6291  l = placeHolders > 0 ? len - 4 : len
6292
6293  var L = 0
6294
6295  for (i = 0, j = 0; i < l; i += 4, j += 3) {
6296    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
6297    arr[L++] = (tmp >> 16) & 0xFF
6298    arr[L++] = (tmp >> 8) & 0xFF
6299    arr[L++] = tmp & 0xFF
6300  }
6301
6302  if (placeHolders === 2) {
6303    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
6304    arr[L++] = tmp & 0xFF
6305  } else if (placeHolders === 1) {
6306    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
6307    arr[L++] = (tmp >> 8) & 0xFF
6308    arr[L++] = tmp & 0xFF
6309  }
6310
6311  return arr
6312}
6313
6314function tripletToBase64 (num) {
6315  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
6316}
6317
6318function encodeChunk (uint8, start, end) {
6319  var tmp
6320  var output = []
6321  for (var i = start; i < end; i += 3) {
6322    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
6323    output.push(tripletToBase64(tmp))
6324  }
6325  return output.join('')
6326}
6327
6328function fromByteArray (uint8) {
6329  var tmp
6330  var len = uint8.length
6331  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
6332  var output = ''
6333  var parts = []
6334  var maxChunkLength = 16383 // must be multiple of 3
6335
6336  // go through the array every three bytes, we'll deal with trailing stuff later
6337  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
6338    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
6339  }
6340
6341  // pad the end with zeros, but make sure to not forget the extra bytes
6342  if (extraBytes === 1) {
6343    tmp = uint8[len - 1]
6344    output += lookup[tmp >> 2]
6345    output += lookup[(tmp << 4) & 0x3F]
6346    output += '=='
6347  } else if (extraBytes === 2) {
6348    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
6349    output += lookup[tmp >> 10]
6350    output += lookup[(tmp >> 4) & 0x3F]
6351    output += lookup[(tmp << 2) & 0x3F]
6352    output += '='
6353  }
6354
6355  parts.push(output)
6356
6357  return parts.join('')
6358}
6359
6360
6361/***/ },
6362/* 6 */
6363/***/ function(module, exports) {
6364
6365exports.read = function (buffer, offset, isLE, mLen, nBytes) {
6366  var e, m
6367  var eLen = nBytes * 8 - mLen - 1
6368  var eMax = (1 << eLen) - 1
6369  var eBias = eMax >> 1
6370  var nBits = -7
6371  var i = isLE ? (nBytes - 1) : 0
6372  var d = isLE ? -1 : 1
6373  var s = buffer[offset + i]
6374
6375  i += d
6376
6377  e = s & ((1 << (-nBits)) - 1)
6378  s >>= (-nBits)
6379  nBits += eLen
6380  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
6381
6382  m = e & ((1 << (-nBits)) - 1)
6383  e >>= (-nBits)
6384  nBits += mLen
6385  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
6386
6387  if (e === 0) {
6388    e = 1 - eBias
6389  } else if (e === eMax) {
6390    return m ? NaN : ((s ? -1 : 1) * Infinity)
6391  } else {
6392    m = m + Math.pow(2, mLen)
6393    e = e - eBias
6394  }
6395  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
6396}
6397
6398exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
6399  var e, m, c
6400  var eLen = nBytes * 8 - mLen - 1
6401  var eMax = (1 << eLen) - 1
6402  var eBias = eMax >> 1
6403  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
6404  var i = isLE ? 0 : (nBytes - 1)
6405  var d = isLE ? 1 : -1
6406  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
6407
6408  value = Math.abs(value)
6409
6410  if (isNaN(value) || value === Infinity) {
6411    m = isNaN(value) ? 1 : 0
6412    e = eMax
6413  } else {
6414    e = Math.floor(Math.log(value) / Math.LN2)
6415    if (value * (c = Math.pow(2, -e)) < 1) {
6416      e--
6417      c *= 2
6418    }
6419    if (e + eBias >= 1) {
6420      value += rt / c
6421    } else {
6422      value += rt * Math.pow(2, 1 - eBias)
6423    }
6424    if (value * c >= 2) {
6425      e++
6426      c /= 2
6427    }
6428
6429    if (e + eBias >= eMax) {
6430      m = 0
6431      e = eMax
6432    } else if (e + eBias >= 1) {
6433      m = (value * c - 1) * Math.pow(2, mLen)
6434      e = e + eBias
6435    } else {
6436      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
6437      e = 0
6438    }
6439  }
6440
6441  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
6442
6443  e = (e << mLen) | m
6444  eLen += mLen
6445  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
6446
6447  buffer[offset + i - d] |= s * 128
6448}
6449
6450
6451/***/ },
6452/* 7 */
6453/***/ function(module, exports) {
6454
6455/**
6456 * Returns a `Boolean` on whether or not the a `String` starts with '0x'
6457 * @param {String} str the string input value
6458 * @return {Boolean} a boolean if it is or is not hex prefixed
6459 * @throws if the str input is not a string
6460 */
6461module.exports = function isHexPrefixed(str) {
6462  if (typeof str !== 'string') {
6463    throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed.");
6464  }
6465
6466  return str.slice(0, 2) === '0x';
6467}
6468
6469
6470/***/ },
6471/* 8 */
6472/***/ function(module, exports) {
6473
6474var toString = {}.toString;
6475
6476module.exports = Array.isArray || function (arr) {
6477  return toString.call(arr) == '[object Array]';
6478};
6479
6480
6481/***/ },
6482/* 9 */
6483/***/ function(module, exports, __webpack_require__) {
6484
6485/* WEBPACK VAR INJECTION */(function(process, global) {/**
6486 * [js-sha3]{@link https://github.com/emn178/js-sha3}
6487 *
6488 * @version 0.5.5
6489 * @author Chen, Yi-Cyuan [[email protected]]
6490 * @copyright Chen, Yi-Cyuan 2015-2016
6491 * @license MIT
6492 */
6493(function (root) {
6494  'use strict';
6495
6496  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
6497  if (NODE_JS) {
6498    root = global;
6499  }
6500  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;
6501  var HEX_CHARS = '0123456789abcdef'.split('');
6502  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
6503  var KECCAK_PADDING = [1, 256, 65536, 16777216];
6504  var PADDING = [6, 1536, 393216, 100663296];
6505  var SHIFT = [0, 8, 16, 24];
6506  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
6507            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 
6508            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 
6509            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
6510            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
6511  var BITS = [224, 256, 384, 512];
6512  var SHAKE_BITS = [128, 256];
6513  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];
6514
6515  var createOutputMethod = function (bits, padding, outputType) {
6516    return function (message) {
6517      return new Keccak(bits, padding, bits).update(message)[outputType]();
6518    }
6519  };
6520
6521  var createShakeOutputMethod = function (bits, padding, outputType) {
6522    return function (message, outputBits) {
6523      return new Keccak(bits, padding, outputBits).update(message)[outputType]();
6524    }
6525  };
6526
6527  var createMethod = function (bits, padding) {
6528    var method = createOutputMethod(bits, padding, 'hex');
6529    method.create = function () {
6530      return new Keccak(bits, padding, bits);
6531    };
6532    method.update = function (message) {
6533      return method.create().update(message);
6534    };
6535    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
6536      var type = OUTPUT_TYPES[i];
6537      method[type] = createOutputMethod(bits, padding, type);
6538    }
6539    return method;
6540  };
6541
6542  var createShakeMethod = function (bits, padding) {
6543    var method = createShakeOutputMethod(bits, padding, 'hex');
6544    method.create = function (outputBits) {
6545      return new Keccak(bits, padding, outputBits);
6546    };
6547    method.update = function (message, outputBits) {
6548      return method.create(outputBits).update(message);
6549    };
6550    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
6551      var type = OUTPUT_TYPES[i];
6552      method[type] = createShakeOutputMethod(bits, padding, type);
6553    }
6554    return method;
6555  };
6556
6557  var algorithms = [
6558    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},
6559    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},
vendor: 11,326 bytes, lines 6560-6908
6560    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}
6561  ];
6562
6563  var methods = {};
6564
6565  for (var i = 0;i < algorithms.length;++i) {
6566    var algorithm = algorithms[i];
6567    var bits  = algorithm.bits;
6568    for (var j = 0;j < bits.length;++j) {
6569      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);
6570    }
6571  }
6572
6573  function Keccak(bits, padding, outputBits) {
6574    this.blocks = [];
6575    this.s = [];
6576    this.padding = padding;
6577    this.outputBits = outputBits;
6578    this.reset = true;
6579    this.block = 0;
6580    this.start = 0;
6581    this.blockCount = (1600 - (bits << 1)) >> 5;
6582    this.byteCount = this.blockCount << 2;
6583    this.outputBlocks = outputBits >> 5;
6584    this.extraBytes = (outputBits & 31) >> 3;
6585
6586    for (var i = 0;i < 50;++i) {
6587      this.s[i] = 0;
6588    }
6589  };
6590
6591  Keccak.prototype.update = function (message) {
6592    var notString = typeof message != 'string';
6593    if (notString && message.constructor == root.ArrayBuffer) {
6594      message = new Uint8Array(message);
6595    }
6596    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, 
6597        blockCount = this.blockCount, index = 0, s = this.s, i, code;
6598    
6599    while (index < length) {
6600      if (this.reset) {
6601        this.reset = false;
6602        blocks[0] = this.block;
6603        for (i = 1;i < blockCount + 1;++i) {
6604          blocks[i] = 0;
6605        }
6606      }
6607      if (notString) {
6608        for (i = this.start;index < length && i < byteCount;++index) {
6609          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
6610        }
6611      } else {
6612        for (i = this.start;index < length && i < byteCount;++index) {
6613          code = message.charCodeAt(index);
6614          if (code < 0x80) {
6615            blocks[i >> 2] |= code << SHIFT[i++ & 3];
6616          } else if (code < 0x800) {
6617            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
6618            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
6619          } else if (code < 0xd800 || code >= 0xe000) {
6620            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
6621            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
6622            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
6623          } else {
6624            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
6625            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
6626            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
6627            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
6628            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
6629          }
6630        }
6631      }
6632      this.lastByteIndex = i;
6633      if (i >= byteCount) {
6634        this.start = i - byteCount;
6635        this.block = blocks[blockCount];
6636        for (i = 0;i < blockCount;++i) {
6637          s[i] ^= blocks[i];
6638        }
6639        f(s);
6640        this.reset = true;
6641      } else {
6642        this.start = i;
6643      }
6644    }
6645    return this;
6646  };
6647
6648  Keccak.prototype.finalize = function () {
6649    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
6650    blocks[i >> 2] |= this.padding[i & 3];
6651    if (this.lastByteIndex == this.byteCount) {
6652      blocks[0] = blocks[blockCount];
6653      for (i = 1;i < blockCount + 1;++i) {
6654        blocks[i] = 0;
6655      }
6656    }
6657    blocks[blockCount - 1] |= 0x80000000;
6658    for (i = 0;i < blockCount;++i) {
6659      s[i] ^= blocks[i];
6660    }
6661    f(s);
6662  };
6663
6664  Keccak.prototype.toString = Keccak.prototype.hex = function () {
6665    this.finalize();
6666
6667    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
6668        extraBytes = this.extraBytes, i = 0, j = 0;
6669    var hex = '', block;
6670    while (j < outputBlocks) {
6671      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
6672        block = s[i];
6673        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
6674               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
6675               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
6676               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
6677      }
6678      if (j % blockCount == 0) {
6679        f(s);
6680        i = 0;
6681      }
6682    }
6683    if (extraBytes) {
6684      block = s[i];
6685      if (extraBytes > 0) {
6686        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
6687      }
6688      if (extraBytes > 1) {
6689        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
6690      }
6691      if (extraBytes > 2) {
6692        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
6693      }
6694    }
6695    return hex;
6696  };
6697
6698  Keccak.prototype.arrayBuffer = function () {
6699    this.finalize();
6700
6701    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
6702        extraBytes = this.extraBytes, i = 0, j = 0;
6703    var bytes = this.outputBits >> 3;
6704    var buffer;
6705    if (extraBytes) {
6706      buffer = new ArrayBuffer((outputBlocks + 1) << 2);
6707    } else {
6708      buffer = new ArrayBuffer(bytes);
6709    }
6710    var array = new Uint32Array(buffer);
6711    while (j < outputBlocks) {
6712      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
6713        array[j] = s[i];
6714      }
6715      if (j % blockCount == 0) {
6716        f(s);
6717      }
6718    }
6719    if (extraBytes) {
6720      array[i] = s[i];
6721      buffer = buffer.slice(0, bytes);
6722    }
6723    return buffer;
6724  };
6725
6726  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
6727
6728  Keccak.prototype.digest = Keccak.prototype.array = function () {
6729    this.finalize();
6730
6731    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
6732        extraBytes = this.extraBytes, i = 0, j = 0;
6733    var array = [], offset, block;
6734    while (j < outputBlocks) {
6735      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
6736        offset = j << 2;
6737        block = s[i];
6738        array[offset] = block & 0xFF;
6739        array[offset + 1] = (block >> 8) & 0xFF;
6740        array[offset + 2] = (block >> 16) & 0xFF;
6741        array[offset + 3] = (block >> 24) & 0xFF;
6742      }
6743      if (j % blockCount == 0) {
6744        f(s);
6745      }
6746    }
6747    if (extraBytes) {
6748      offset = j << 2;
6749      block = s[i];
6750      if (extraBytes > 0) {
6751        array[offset] = block & 0xFF;
6752      }
6753      if (extraBytes > 1) {
6754        array[offset + 1] = (block >> 8) & 0xFF;
6755      }
6756      if (extraBytes > 2) {
6757        array[offset + 2] = (block >> 16) & 0xFF;
6758      }
6759    }
6760    return array;
6761  };
6762
6763  var f = function (s) {
6764    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, 
6765        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, 
6766        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, 
6767        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
6768    for (n = 0;n < 48;n += 2) {
6769      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
6770      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
6771      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
6772      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
6773      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
6774      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
6775      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
6776      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
6777      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
6778      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
6779
6780      h = c8 ^ ((c2 << 1) | (c3 >>> 31));
6781      l = c9 ^ ((c3 << 1) | (c2 >>> 31));
6782      s[0] ^= h;
6783      s[1] ^= l;
6784      s[10] ^= h;
6785      s[11] ^= l;
6786      s[20] ^= h;
6787      s[21] ^= l;
6788      s[30] ^= h;
6789      s[31] ^= l;
6790      s[40] ^= h;
6791      s[41] ^= l;
6792      h = c0 ^ ((c4 << 1) | (c5 >>> 31));
6793      l = c1 ^ ((c5 << 1) | (c4 >>> 31));
6794      s[2] ^= h;
6795      s[3] ^= l;
6796      s[12] ^= h;
6797      s[13] ^= l;
6798      s[22] ^= h;
6799      s[23] ^= l;
6800      s[32] ^= h;
6801      s[33] ^= l;
6802      s[42] ^= h;
6803      s[43] ^= l;
6804      h = c2 ^ ((c6 << 1) | (c7 >>> 31));
6805      l = c3 ^ ((c7 << 1) | (c6 >>> 31));
6806      s[4] ^= h;
6807      s[5] ^= l;
6808      s[14] ^= h;
6809      s[15] ^= l;
6810      s[24] ^= h;
6811      s[25] ^= l;
6812      s[34] ^= h;
6813      s[35] ^= l;
6814      s[44] ^= h;
6815      s[45] ^= l;
6816      h = c4 ^ ((c8 << 1) | (c9 >>> 31));
6817      l = c5 ^ ((c9 << 1) | (c8 >>> 31));
6818      s[6] ^= h;
6819      s[7] ^= l;
6820      s[16] ^= h;
6821      s[17] ^= l;
6822      s[26] ^= h;
6823      s[27] ^= l;
6824      s[36] ^= h;
6825      s[37] ^= l;
6826      s[46] ^= h;
6827      s[47] ^= l;
6828      h = c6 ^ ((c0 << 1) | (c1 >>> 31));
6829      l = c7 ^ ((c1 << 1) | (c0 >>> 31));
6830      s[8] ^= h;
6831      s[9] ^= l;
6832      s[18] ^= h;
6833      s[19] ^= l;
6834      s[28] ^= h;
6835      s[29] ^= l;
6836      s[38] ^= h;
6837      s[39] ^= l;
6838      s[48] ^= h;
6839      s[49] ^= l;
6840
6841      b0 = s[0];
6842      b1 = s[1];
6843      b32 = (s[11] << 4) | (s[10] >>> 28);
6844      b33 = (s[10] << 4) | (s[11] >>> 28);
6845      b14 = (s[20] << 3) | (s[21] >>> 29);
6846      b15 = (s[21] << 3) | (s[20] >>> 29);
6847      b46 = (s[31] << 9) | (s[30] >>> 23);
6848      b47 = (s[30] << 9) | (s[31] >>> 23);
6849      b28 = (s[40] << 18) | (s[41] >>> 14);
6850      b29 = (s[41] << 18) | (s[40] >>> 14);
6851      b20 = (s[2] << 1) | (s[3] >>> 31);
6852      b21 = (s[3] << 1) | (s[2] >>> 31);
6853      b2 = (s[13] << 12) | (s[12] >>> 20);
6854      b3 = (s[12] << 12) | (s[13] >>> 20);
6855      b34 = (s[22] << 10) | (s[23] >>> 22);
6856      b35 = (s[23] << 10) | (s[22] >>> 22);
6857      b16 = (s[33] << 13) | (s[32] >>> 19);
6858      b17 = (s[32] << 13) | (s[33] >>> 19);
6859      b48 = (s[42] << 2) | (s[43] >>> 30);
6860      b49 = (s[43] << 2) | (s[42] >>> 30);
6861      b40 = (s[5] << 30) | (s[4] >>> 2);
6862      b41 = (s[4] << 30) | (s[5] >>> 2);
6863      b22 = (s[14] << 6) | (s[15] >>> 26);
6864      b23 = (s[15] << 6) | (s[14] >>> 26);
6865      b4 = (s[25] << 11) | (s[24] >>> 21);
6866      b5 = (s[24] << 11) | (s[25] >>> 21);
6867      b36 = (s[34] << 15) | (s[35] >>> 17);
6868      b37 = (s[35] << 15) | (s[34] >>> 17);
6869      b18 = (s[45] << 29) | (s[44] >>> 3);
6870      b19 = (s[44] << 29) | (s[45] >>> 3);
6871      b10 = (s[6] << 28) | (s[7] >>> 4);
6872      b11 = (s[7] << 28) | (s[6] >>> 4);
6873      b42 = (s[17] << 23) | (s[16] >>> 9);
6874      b43 = (s[16] << 23) | (s[17] >>> 9);
6875      b24 = (s[26] << 25) | (s[27] >>> 7);
6876      b25 = (s[27] << 25) | (s[26] >>> 7);
6877      b6 = (s[36] << 21) | (s[37] >>> 11);
6878      b7 = (s[37] << 21) | (s[36] >>> 11);
6879      b38 = (s[47] << 24) | (s[46] >>> 8);
6880      b39 = (s[46] << 24) | (s[47] >>> 8);
6881      b30 = (s[8] << 27) | (s[9] >>> 5);
6882      b31 = (s[9] << 27) | (s[8] >>> 5);
6883      b12 = (s[18] << 20) | (s[19] >>> 12);
6884      b13 = (s[19] << 20) | (s[18] >>> 12);
6885      b44 = (s[29] << 7) | (s[28] >>> 25);
6886      b45 = (s[28] << 7) | (s[29] >>> 25);
6887      b26 = (s[38] << 8) | (s[39] >>> 24);
6888      b27 = (s[39] << 8) | (s[38] >>> 24);
6889      b8 = (s[48] << 14) | (s[49] >>> 18);
6890      b9 = (s[49] << 14) | (s[48] >>> 18);
6891
6892      s[0] = b0 ^ (~b2 & b4);
6893      s[1] = b1 ^ (~b3 & b5);
6894      s[10] = b10 ^ (~b12 & b14);
6895      s[11] = b11 ^ (~b13 & b15);
6896      s[20] = b20 ^ (~b22 & b24);
6897      s[21] = b21 ^ (~b23 & b25);
6898      s[30] = b30 ^ (~b32 & b34);
6899      s[31] = b31 ^ (~b33 & b35);
6900      s[40] = b40 ^ (~b42 & b44);
6901      s[41] = b41 ^ (~b43 & b45);
6902      s[2] = b2 ^ (~b4 & b6);
6903      s[3] = b3 ^ (~b5 & b7);
6904      s[12] = b12 ^ (~b14 & b16);
6905      s[13] = b13 ^ (~b15 & b17);
6906      s[22] = b22 ^ (~b24 & b26);
6907      s[23] = b23 ^ (~b25 & b27);
6908      s[32] = b32 ^ (~b34 & b36);
6909      s[33] = b33 ^ (~b35 & b37);
6910      s[42] = b42 ^ (~b44 & b46);
6911      s[43] = b43 ^ (~b45 & b47);
6912      s[4] = b4 ^ (~b6 & b8);
6913      s[5] = b5 ^ (~b7 & b9);
6914      s[14] = b14 ^ (~b16 & b18);
6915      s[15] = b15 ^ (~b17 & b19);
6916      s[24] = b24 ^ (~b26 & b28);
6917      s[25] = b25 ^ (~b27 & b29);
6918      s[34] = b34 ^ (~b36 & b38);
6919      s[35] = b35 ^ (~b37 & b39);
6920      s[44] = b44 ^ (~b46 & b48);
6921      s[45] = b45 ^ (~b47 & b49);
6922      s[6] = b6 ^ (~b8 & b0);
6923      s[7] = b7 ^ (~b9 & b1);
6924      s[16] = b16 ^ (~b18 & b10);
6925      s[17] = b17 ^ (~b19 & b11);
6926      s[26] = b26 ^ (~b28 & b20);
6927      s[27] = b27 ^ (~b29 & b21);
6928      s[36] = b36 ^ (~b38 & b30);
6929      s[37] = b37 ^ (~b39 & b31);
6930      s[46] = b46 ^ (~b48 & b40);
6931      s[47] = b47 ^ (~b49 & b41);
6932      s[8] = b8 ^ (~b0 & b2);
6933      s[9] = b9 ^ (~b1 & b3);
6934      s[18] = b18 ^ (~b10 & b12);
6935      s[19] = b19 ^ (~b11 & b13);
6936      s[28] = b28 ^ (~b20 & b22);
6937      s[29] = b29 ^ (~b21 & b23);
6938      s[38] = b38 ^ (~b30 & b32);
6939      s[39] = b39 ^ (~b31 & b33);
6940      s[48] = b48 ^ (~b40 & b42);
6941      s[49] = b49 ^ (~b41 & b43);
6942
6943      s[0] ^= RC[n];
6944      s[1] ^= RC[n + 1];
6945    }
6946  }
6947
6948  if (COMMON_JS) {
6949    module.exports = methods;
6950  } else if (root) {
6951    for (var key in methods) {
6952      root[key] = methods[key];
6953    }
6954  }
6955}(this));
6956
6957/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11), __webpack_require__(2)))
6958
6959/***/ },
6960/* 10 */
6961/***/ function(module, exports, __webpack_require__) {
6962
6963var BN = __webpack_require__(1);
6964var stripHexPrefix = __webpack_require__(12);
6965
6966/**
6967 * Returns a BN object, converts a number value to a BN
6968 * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object
6969 * @return {Object} `output` BN object of the number
6970 * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number
6971 */
6972module.exports = function numberToBN(arg) {
6973  if (typeof arg === 'string' || typeof arg === 'number') {
6974    var multiplier = new BN(1); // eslint-disable-line
6975    var formattedString = String(arg).toLowerCase().trim();
6976    var isHexPrefixed = formattedString.substr(0, 2) === '0x' || formattedString.substr(0, 3) === '-0x';
6977    var stringArg = stripHexPrefix(formattedString); // eslint-disable-line
6978    if (stringArg.substr(0, 1) === '-') {
6979      stringArg = stripHexPrefix(stringArg.slice(1));
6980      multiplier = new BN(-1, 10);
6981    }
6982    stringArg = stringArg === '' ? '0' : stringArg;
6983
6984    if ((!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/))
6985      || stringArg.match(/^[a-fA-F]+$/)
6986      || (isHexPrefixed === true && stringArg.match(/^[0-9A-Fa-f]+$/))) {
6987      return new BN(stringArg, 16).mul(multiplier);
6988    }
6989
6990    if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) {
6991      return new BN(stringArg, 10).mul(multiplier);
6992    }
6993  } else if (typeof arg === 'object' && arg.toString && (!arg.pop && !arg.push)) {
6994    if (arg.toString(10).match(/^-?[0-9]+$/) && (arg.mul || arg.dividedToIntegerBy)) {
6995      return new BN(arg.toString(10), 10);
6996    }
6997  }
6998
6999  throw new Error('[number-to-bn] while converting number ' + JSON.stringify(arg) + ' to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.');
7000}
7001
7002
7003/***/ },
7004/* 11 */
7005/***/ function(module, exports) {
7006
7007// shim for using process in browser
7008var process = module.exports = {};
7009
7010// cached from whatever global is present so that test runners that stub it
7011// don't break things.  But we need to wrap it in a try catch in case it is
7012// wrapped in strict mode code which doesn't define any globals.  It's inside a
7013// function because try/catches deoptimize in certain engines.
7014
7015var cachedSetTimeout;
7016var cachedClearTimeout;
7017
7018function defaultSetTimout() {
7019    throw new Error('setTimeout has not been defined');
7020}
7021function defaultClearTimeout () {
7022    throw new Error('clearTimeout has not been defined');
7023}
7024(function () {
7025    try {
7026        if (typeof setTimeout === 'function') {
7027            cachedSetTimeout = setTimeout;
7028        } else {
7029            cachedSetTimeout = defaultSetTimout;
7030        }
7031    } catch (e) {
7032        cachedSetTimeout = defaultSetTimout;
7033    }
7034    try {
7035        if (typeof clearTimeout === 'function') {
7036            cachedClearTimeout = clearTimeout;
7037        } else {
7038            cachedClearTimeout = defaultClearTimeout;
7039        }
7040    } catch (e) {
7041        cachedClearTimeout = defaultClearTimeout;
7042    }
7043} ())
7044function runTimeout(fun) {
7045    if (cachedSetTimeout === setTimeout) {
7046        //normal enviroments in sane situations
7047        return setTimeout(fun, 0);
7048    }
7049    // if setTimeout wasn't available but was latter defined
7050    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
7051        cachedSetTimeout = setTimeout;
7052        return setTimeout(fun, 0);
7053    }
7054    try {
7055        // when when somebody has screwed with setTimeout but no I.E. maddness
7056        return cachedSetTimeout(fun, 0);
7057    } catch(e){
7058        try {
7059            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
7060            return cachedSetTimeout.call(null, fun, 0);
7061        } catch(e){
7062            // 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
7063            return cachedSetTimeout.call(this, fun, 0);
7064        }
7065    }
7066
7067
7068}
7069function runClearTimeout(marker) {
7070    if (cachedClearTimeout === clearTimeout) {
7071        //normal enviroments in sane situations
7072        return clearTimeout(marker);
7073    }
7074    // if clearTimeout wasn't available but was latter defined
7075    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
7076        cachedClearTimeout = clearTimeout;
7077        return clearTimeout(marker);
7078    }
7079    try {
7080        // when when somebody has screwed with setTimeout but no I.E. maddness
7081        return cachedClearTimeout(marker);
7082    } catch (e){
7083        try {
7084            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
7085            return cachedClearTimeout.call(null, marker);
7086        } catch (e){
7087            // 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.
7088            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
7089            return cachedClearTimeout.call(this, marker);
7090        }
7091    }
7092
7093
7094
7095}
7096var queue = [];
7097var draining = false;
vendor: 3,093 bytes, lines 7098-7239
7098var currentQueue;
7099var queueIndex = -1;
7100
7101function cleanUpNextTick() {
7102    if (!draining || !currentQueue) {
7103        return;
7104    }
7105    draining = false;
7106    if (currentQueue.length) {
7107        queue = currentQueue.concat(queue);
7108    } else {
7109        queueIndex = -1;
7110    }
7111    if (queue.length) {
7112        drainQueue();
7113    }
7114}
7115
7116function drainQueue() {
7117    if (draining) {
7118        return;
7119    }
7120    var timeout = runTimeout(cleanUpNextTick);
7121    draining = true;
7122
7123    var len = queue.length;
7124    while(len) {
7125        currentQueue = queue;
7126        queue = [];
7127        while (++queueIndex < len) {
7128            if (currentQueue) {
7129                currentQueue[queueIndex].run();
7130            }
7131        }
7132        queueIndex = -1;
7133        len = queue.length;
7134    }
7135    currentQueue = null;
7136    draining = false;
7137    runClearTimeout(timeout);
7138}
7139
7140process.nextTick = function (fun) {
7141    var args = new Array(arguments.length - 1);
7142    if (arguments.length > 1) {
7143        for (var i = 1; i < arguments.length; i++) {
7144            args[i - 1] = arguments[i];
7145        }
7146    }
7147    queue.push(new Item(fun, args));
7148    if (queue.length === 1 && !draining) {
7149        runTimeout(drainQueue);
7150    }
7151};
7152
7153// v8 likes predictible objects
7154function Item(fun, array) {
7155    this.fun = fun;
7156    this.array = array;
7157}
7158Item.prototype.run = function () {
7159    this.fun.apply(null, this.array);
7160};
7161process.title = 'browser';
7162process.browser = true;
7163process.env = {};
7164process.argv = [];
7165process.version = ''; // empty string to avoid regexp issues
7166process.versions = {};
7167
7168function noop() {}
7169
7170process.on = noop;
7171process.addListener = noop;
7172process.once = noop;
7173process.off = noop;
7174process.removeListener = noop;
7175process.removeAllListeners = noop;
7176process.emit = noop;
7177
7178process.binding = function (name) {
7179    throw new Error('process.binding is not supported');
7180};
7181
7182process.cwd = function () { return '/' };
7183process.chdir = function (dir) {
7184    throw new Error('process.chdir is not supported');
7185};
7186process.umask = function() { return 0; };
7187
7188
7189/***/ },
7190/* 12 */
7191/***/ function(module, exports, __webpack_require__) {
7192
7193var isHexPrefixed = __webpack_require__(7);
7194
7195/**
7196 * Removes '0x' from a given `String` is present
7197 * @param {String} str the string value
7198 * @return {String|Optional} a string by pass if necessary
7199 */
7200module.exports = function stripHexPrefix(str) {
7201  if (typeof str !== 'string') {
7202    return str;
7203  }
7204
7205  return isHexPrefixed(str) ? str.slice(2) : str;
7206}
7207
7208
7209/***/ },
7210/* 13 */
7211/***/ function(module, exports) {
7212
7213module.exports = function(module) {
7214	if(!module.webpackPolyfill) {
7215		module.deprecate = function() {};
7216		module.paths = [];
7217		// module.parent = undefined by default
7218		if(!module.children) module.children = [];
7219		Object.defineProperty(module, "loaded", {
7220			enumerable: true,
7221			configurable: false,
7222			get: function() { return module.l; }
7223		});
7224		Object.defineProperty(module, "id", {
7225			enumerable: true,
7226			configurable: false,
7227			get: function() { return module.i; }
7228		});
7229		module.webpackPolyfill = 1;
7230	}
7231	return module;
7232}
7233
7234
7235/***/ }
7236/******/ ])
7237});
7238;
7239//# sourceMappingURL=ethjs-abi.js.map</script>
7239
7240
7241    
7241<script>var abiJSONData = window.abiJSONData = {
7242  "multiSigDailyLimit": {
7243    "abi": [{"inputs": [{"type": "uint256", "name": ""}], "constant": true, "name": "owners", "payable": false, "outputs": [{"type": "address", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "owner"}], "constant": false, "name": "removeOwner", "payable": false, "outputs": [], "type": "function"}, {"inputs": [{"type": "uint256", "name": "transactionId"}], "constant": false, "name": "revokeConfirmation", "payable": false, "outputs": [], "type": "function"}, {"inputs": [{"type": "address", "name": ""}], "constant": true, "name": "isOwner", "payable": false, "outputs": [{"type": "bool", "name": ""}], "type": "function"}, {"inputs": [{"type": "uint256", "name": ""}, {"type": "address", "name": ""}], "constant": true, "name": "confirmations", "payable": false, "outputs": [{"type": "bool", "name": ""}], "type": "function"}, {"inputs": [], "constant": true, "name": "calcMaxWithdraw", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}
7243, {"inputs": [{"type": "bool", "name": "pending"}, {"type": "bool", "name": "executed"}], "constant": true, "name": "getTransactionCount", "payable": false, "outputs": [{"type": "uint256", "name": "count"}], "type": "function"}, {"inputs": [], "constant": true, "name": "dailyLimit", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [], "constant": true, "name": "lastDay", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "owner"}], "constant": false, "name": "addOwner", "payable": false, "outputs": [], "type": "function"}, {"inputs": [{"type": "uint256", "name": "transactionId"}], "constant": true, "name": "isConfirmed", "payable": false, "outputs": [{"type": "bool", "name": ""}], "type": "function"}, {"inputs": [{"type": "uint256", "name": "transactionId"}], "constant": true, "name": "getConfirmationCount", "payable": false, "outputs": [{"type": "uint256", "name": "count"}], "type": "function"}
7243, {"inputs": [{"type": "uint256", "name": ""}], "constant": true, "name": "transactions", "payable": false, "outputs": [{"type": "address", "name": "destination"}, {"type": "uint256", "name": "value"}, {"type": "bytes", "name": "data"}, {"type": "bool", "name": "executed"}], "type": "function"}, {"inputs": [], "constant": true, "name": "getOwners", "payable": false, "outputs": [{"type": "address[]", "name": ""}], "type": "function"}, {"inputs": [{"type": "uint256", "name": "from"}, {"type": "uint256", "name": "to"}, {"type": "bool", "name": "pending"}, {"type": "bool", "name": "executed"}], "constant": true, "name": "getTransactionIds", "payable": false, "outputs": [{"type": "uint256[]", "name": "_transactionIds"}], "type": "function"}, {"inputs": [{"type": "uint256", "name": "transactionId"}], "constant": true, "name": "getConfirmations", "payable": false, "outputs": [{"type": "address[]", "name": "_confirmations"}], "type": "function"}, {"inputs": [], "constant": true, "name": "transactionCount", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}
7243, {"inputs": [{"type": "uint256", "name": "_required"}], "constant": false, "name": "changeRequirement", "payable": false, "outputs": [], "type": "function"}, {"inputs": [{"type": "uint256", "name": "transactionId"}], "constant": false, "name": "confirmTransaction", "payable": false, "outputs": [], "type": "function"}, {"inputs": [{"type": "address", "name": "destination"}, {"type": "uint256", "name": "value"}, {"type": "bytes", "name": "data"}], "constant": false, "name": "submitTransaction", "payable": false, "outputs": [{"type": "uint256", "name": "transactionId"}], "type": "function"}, {"inputs": [{"type": "uint256", "name": "_dailyLimit"}], "constant": false, "name": "changeDailyLimit", "payable": false, "outputs": [], "type": "function"}, {"inputs": [], "constant": true, "name": "MAX_OWNER_COUNT", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [], "constant": true, "name": "required", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}
7243, {"inputs": [{"type": "address", "name": "owner"}, {"type": "address", "name": "newOwner"}], "constant": false, "name": "replaceOwner", "payable": false, "outputs": [], "type": "function"}, {"inputs": [{"type": "uint256", "name": "transactionId"}], "constant": false, "name": "executeTransaction", "payable": false, "outputs": [], "type": "function"}, {"inputs": [], "constant": true, "name": "spentToday", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [{"type": "address[]", "name": "_owners"}, {"type": "uint256", "name": "_required"}, {"type": "uint256", "name": "_dailyLimit"}], "type": "constructor"}, {"payable": true, "type": "fallback"}, {"inputs": [{"indexed": false, "type": "uint256", "name": "dailyLimit"}], "type": "event", "name": "DailyLimitChange", "anonymous": false}, {"inputs": [{"indexed": true, "type": "address", "name": "sender"}, {"indexed": true, "type": "uint256", "name": "transactionId"}], "type": "event", "name": "Confirmation", "anonymous": false}, {"inputs": [{"indexed": true, "type": "address", "name": "sender"}, {"indexed": true, "type": "uint256", "name": "transactionId"}], "type": "event", "name": "Revocation", "anonymous": false}, {"inputs": [{"indexed": true, "type": "uint256", "name": "transactionId"}], "type": "event", "name": "Submission", "anonymous": false}, {"inputs": [{"indexed": true, "type": "uint256", "name": "transactionId"}], "type": "event", "name": "Execution", "anonymous": false}, {"inputs": [{"indexed": true, "type": "uint256", "name": "transactionId"}], "type": "event", "name": "ExecutionFailure", "anonymous": false}, {"inputs": [{"indexed": true, "type": "address", "name": "sender"}, {"indexed": false, "type": "uint256", "name": "value"}], "type": "event", "name": "Deposit", "anonymous": false}, {"inputs": [{"indexed": true, "type": "address", "name": "owner"}], "type": "event", "name": "OwnerAddition", "anonymous": false}, {"inputs": [{"indexed": true, "type": "address", "name": "owner"}], "type": "event", "name": "OwnerRemoval", "anonymous": false}, {"inputs": [{"indexed": false, "type": "uint256", "name": "required"}], "type": "event", "name": "RequirementChange", "anonymous": false}],
7244    "binHex": "0x606060405260405161164438038061164483398101604052805160805160a05191909201919082826000825182603282118061003a57508181115b80610043575080155b8061004c575081155b1561005657610002565b600092505b84518310156100ce576002600050600086858151811015610002576020908102909101810151600160a060020a031682528101919091526040016000205460ff16806100c45750848381518110156100025790602001906020020151600160a060020a03166000145b1561015357610002565b845160038054828255600082905290917fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b918201916020890182156101cd579160200282015b828111156101cd5782518254600160a060020a0319166c0100000000000000000000000091820291909104178255602090920191600190910190610114565b600160026000506000878681518110156100025790602001906020020151600160a060020a0316815260200190815260200160002060006101000a81548160ff02191690837f010000000000000000000000000000000000000000000000000000000000000090810204021790555060019092019161005b565b506101f39291505b80821115610213578054600160a060020a03191681556001016101d5565b5050506004929092555050506006555061142d9050806102176000396000f35b509056606060405236156101325760e060020a6000350463025e7c278114610180578063173825d9146101b257806320ea8d86146101df5780632f54bf6e146102135780633411c81c146102335780634bc9fdc214610260578063547415251461028357806367eeba0c146102f75780636b0c932d146103055780637065cb4814610313578063784547a71461033e5780638b51d13f1461034e5780639ace38c2146103c2578063a0e67e2b146103fd578063a8abe69a1461046e578063b5dc40c31461054d578063b77bf60014610659578063ba51a6df14610667578063c01a8c8414610693578063c6427474146106a3578063cea0862114610714578063d74f8edd1461073f578063dc8452cd1461074c578063e20056e61461075a578063ee22610b1461078a578063f059cf2b1461079a575b6107a8600034111561017e57604080513481529051600160a060020a033316917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b565b34610002576107aa60043560038054829081101561000257600091825260209091200154600160a060020a0316905081565b34610002576107a8600435600030600160a060020a031633600160a060020a0316141515610a1a57610002565b34610002576107a8600435600160a060020a033390811660009081526002602052
7244604090205460ff161515610c5f57610002565b34610002576107c660043560026020526000908152604090205460ff1681565b34610002576001602090815260043560009081526040808220909252602435815220546107c69060ff1681565b34610002576107da6007546000906201518001421115610d1b5750600654610d18565b34610002576107da6004356024356000805b600554811015610d2f578380156102be575060008181526020819052604090206003015460ff16155b806102e257508280156102e2575060008181526020819052604090206003015460ff165b156102ef57600191909101905b600101610295565b34610002576107da60065481565b34610002576107da60075481565b34610002576107a860043530600160a060020a031633600160a060020a0316141515610d3657610002565b34610002576107c6600435610801565b34610002576107da6004356000805b600354811015610e66576000838152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff16156103ba57600191909101905b60010161035d565b34610002576000602081905260043581526040902080546001820154600383015461087993600160a060020a03909316926002019060ff1684565b346100025760408051602080820183526000825260038054845181840281018401909552808552610923949283018282801561046257602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610444575b50505050509050610d18565b34610002576109236004356024356044356064356040805160208181018352600080835283519182018452808252600554935192939192909182918059106104b35750595b9080825280602002602001820160405280156104ca575b509250600091508190505b600554811015610e6c578580156104fe575060008181526020819052604090206003015460ff16155b806105225750848015610522575060008181526020819052604090206003015460ff165b156105455780838381518110156100025760209081029091010152600191909101905b6001016104d5565b34610002576109236004356040805160208181018352600080835283519182018452808252600354935192939192909182918059106105895750595b9080825280602002602001820160405280156105a0575b509250600091508190505b600354811015610ee1576000858152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff161561065157600380548290811015610002576000918252602090912001548351600160a060020a03909116908490849081101561000257600160a060020a03909216602092830290910190910152600191909101905b6001016105ab565b34610002576107da60055481565b34610002576107a86004355b30600160a060020a031633600160a060020a0316141515610f5d57610002565b34610002576107a8600435610974565b3461000257604080516020600460443581810135601f81018490048402850184019095528484526107da948235946024803595606494929391909201918190840183828082843750949650505050505050600061096d848484600083600160a060020a0381161515610b6157610002565b34610002576107a860043530600160a060020a031633600160a060020a031614151561102857610002565b34610002576107da603281565b34610002576107da60045481565b34610002576107a8600435602435600030600160a060020a031633600160a060020a031614151561106357610002565b34610002576107a86004356109f7565b34610002576107da60085481565b005b60408051600160a060020a039092168252519081900360200190f35b604080519115158252519081900360200190f35b60408051918252519081900360200190f35b600084815260208190526040902092506111d6845b600080805b600354811015610872576000848152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff161561086357600191909101905b600454821415610e5e57600192505b5050919050565b60408051600160a060020a03861681526020810185905282151560608201526080918101828152845460026000196101006001841615020190911604928201839052909160a0830190859080156109115780601f106108e657610100808354040283529160200191610911565b820191906000526020600020905b8154815290600101906020018083116108f457829003601f168201915b50509550505050505060405180910390f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b9050611021815b33600160a060020a03811660009081526002602052604090205460ff161515610fc857610002565b6000858152600160208181526040808420600160a060020a0333168086529252808420805460ff1916909317909255905187927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a3610ce6855b6000818152602081905260408120600301548190839060ff16156107ec57610002565b600160a060020a03821660009081526002602052
72446040902054829060ff161515610a4357610002565b600160a060020a0383166000908152600260205260408120805460ff1916905591505b60035460001901821015610b085782600160a060020a0316600360005083815481101561000257600091825260209091200154600160a060020a03161415610b3857600380546000198101908110156100025760009182526020909120015460038054600160a060020a039092169184908110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b600380546000198101808355919082908015829011610b4357600083815260209020610b43918101908301610c0e565b600190910190610a66565b505060035460045411159150610c26905057600354610c2690610673565b60055460408051608081018252878152602080820188815282840188815260006060850181905286815280845294852084518154606060020a91820291909104600160a060020a031990911617815591516001808401919091559051805160028085018054818a5298879020999b5096989497601f9481161561010002600019011604830185900484019490939291019083901061139257805160ff19168380011785555b506113c29291505b80821115610c225760008155600101610c0e565b5090565b604051600160a060020a038416907f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9090600090a2505050565b600082815260016020908152604080832033600160a060020a038116855292529091205483919060ff161515610cee57610002565b6000858152600160209081526040808320600160a060020a0333168085529252808320805460ff191690555187927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35b505b50505050565b600084815260208190526040902060030154849060ff1615610c9457610002565b50600854600654035b90565b6008546006541015610d0f57506000610d18565b5092915050565b600160a060020a038116600090815260026020526040902054819060ff1615610d5e57610002565b81600160a060020a0381161515610d7457610002565b6003546004546001909101906032821180610d8e57508181115b80610d97575080155b80610da0575081155b15610daa57610002565b600160a060020a0385166000908152600260205260409020805460ff19166001908117909155600380549182018082559091908281838015829011610e0057600083815260209020610e00918101908301610c0e565b50505060009283525060208220018054600160a060020a031916606060020a88810204179055604051600160a060020a038716917ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d91a25050505050565b600101610806565b50919050565b878703604051805910610e7c5750595b908082528060200260200182016040528015610e93575b5093508790505b86811015610ed6578281815181101561000257906020019060200201518489830381518110156100025760209081029091010152600101610e9a565b505050949350505050565b81604051805910610eef5750595b908082528060200260200182016040528015610f06575b509350600090505b81811015610f55578281815181101561000257906020019060200201518482815181101561000257600160a060020a03909216602092830290910190910152600101610f0e565b505050919050565b600354816032821180610f6f57508181115b80610f78575080155b80610f81575081155b15610f8b57610002565b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a1505050565b6000828152602081905260409020548290600160a060020a03161515610fed57610002565b600083815260016020908152604080832033600160a060020a038116855292529091205484919060ff161561099c57610002565b9392505050565b60068190556040805182815290517fc71bdc6afaf9b1aa90a7078191d4fc1adf3bf680fca3183697df6b0dc226bca29181900360200190a150565b600160a060020a038316600090815260026020526040902054839060ff16151561108c57610002565b600160a060020a038316600090815260026020526040902054839060ff16156110b457610002565b600092505b6003548310156111315784600160a060020a0316600360005084815481101561000257600091825260209091200154600160a060020a031614156111cb578360036000508481548110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b600160a060020a03808616600081815260026020526040808220805460ff1990811690915593881682528082208054909416600117909355915190917f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9091a2604051600160a060020a038516907ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d90600090a25050505050565b6001909201916110b9565b91508180611245575060028084015460001961010060018316150201160415801561124557506001830154611245906007546000906201518001421115611221574260075560006008555b600654600854830111806112385750600854828101105b1561142457506000611428565b15610ce85760038301805460ff1916600117905581151561126f5760018301546008805490910190555b825460018085015460405160028088018054600160a060020a039096169593949093839285926000199083161561010002019091160480156112f25780601f106112c7576101008083540402835291602001916112f2565b820191906000526020600020905b8154815290600101906020018083116112d557829003601f168201915b505091505060006040518083038185876185025a03f192505050156113415760405184907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2610ce8565b60405184907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a260038301805460ff19169055811515610ce8575050600101546008805491909103905550565b82800160010185558215610c06579182015b82811115610c065782518260005055916020019190600101906113a4565b5050606091909101516003909101805460ff191660f860020
7244a9283029290920491909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a2509392505050565b5060015b91905056"
7245  },
7246  "token": {
7247    "abi": [{"inputs": [], "constant": true, "name": "name", "payable": false, "outputs": [{"type": "string", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "spender"}, {"type": "uint256", "name": "value"}], "constant": false, "name": "approve", "payable": false, "outputs": [{"type": "bool", "name": "success"}], "type": "function"}, {"inputs": [], "constant": true, "name": "totalSupply", "payable": false, "outputs": [{"type": "uint256", "name": "supply"}], "type": "function"}, {"inputs": [{"type": "address", "name": "from"}, {"type": "address", "name": "to"}, {"type": "uint256", "name": "value"}], "constant": false, "name": "transferFrom", "payable": false, "outputs": [{"type": "bool", "name": "success"}], "type": "function"}, {"inputs": [], "constant": true, "name": "decimals", "payable": false, "outputs": [{"type": "uint8", "name": ""}], "type": "function"}
7247, {"inputs": [{"type": "address", "name": "owner"}], "constant": true, "name": "balanceOf", "payable": false, "outputs": [{"type": "uint256", "name": "balance"}], "type": "function"}, {"inputs": [], "constant": true, "name": "symbol", "payable": false, "outputs": [{"type": "string", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "to"}, {"type": "uint256", "name": "value"}], "constant": false, "name": "transfer", "payable": false, "outputs": [{"type": "bool", "name": "success"}], "type": "function"}, {"inputs": [{"type": "address", "name": "owner"}, {"type": "address", "name": "spender"}], "constant": true, "name": "allowance", "payable": false, "outputs": [{"type": "uint256", "name": "remaining"}], "type": "function"}, {"inputs": [{"indexed": true, "type": "address", "name": "from"}, {"indexed": true, "type": "address", "name": "to"}, {"indexed": false, "type": "uint256", "name": "value"}], "type": "event", "name": "Transfer", "anonymous": false}, {"inputs": [{"indexed": true, "type": "address", "name": "owner"}, {"indexed": true, "type": "address", "name": "spender"}, {"indexed": false, "type": "uint256", "name": "value"}], "type": "event", "name": "Approval", "anonymous": false}]
7248  },
7249  "multiSigDailyLimitFactory" : {
7250    "abi": [{"inputs": [{"type": "address", "name": ""}], "constant": true, "name": "isInstantiation", "payable": false, "outputs": [{"type": "bool", "name": ""}], "type": "function"}
7250, {"inputs": [{"type": "address[]", "name": "_owners"}, {"type": "uint256", "name": "_required"}, {"type": "uint256", "name": "_dailyLimit"}], "constant": false, "name": "create", "payable": false, "outputs": [{"type": "address", "name": "wallet"}], "type": "function"}, {"inputs": [{"type": "address", "name": ""}, {"type": "uint256", "name": ""}], "constant": true, "name": "instantiations", "payable": false, "outputs": [{"type": "address", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "creator"}], "constant": true, "name": "getInstantiationCount", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [{"indexed": false, "type": "address", "name": "sender"}, {"indexed": false, "type": "address", "name": "instantiation"}], "type": "event", "name": "ContractInstantiation", "anonymous": false}]
7251  }
7252};
7253</script>
7253
7254
7255    
7255<script>
vendor: 12,660 bytes, lines 7255-7598
7255/*
7256 * QRious v4.0.2
7257 * Copyright (C) 2017 Alasdair Mercer
7258 * Copyright (C) 2010 Tom Zerucha
7259 *
7260 * This program is free software: you can redistribute it and/or modify
7261 * it under the terms of the GNU General Public License as published by
7262 * the Free Software Foundation, either version 3 of the License, or
7263 * (at your option) any later version.
7264 *
7265 * This program is distributed in the hope that it will be useful,
7266 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7267 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7268 * GNU General Public License for more details.
7269 *
7270 * You should have received a copy of the GNU General Public License
7271 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
7272 */
7273(function (global, factory) {
7274  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7275  typeof define === 'function' && define.amd ? define(factory) :
7276  (global.QRious = factory());
7277}(this, (function () { 'use strict';
7278
7279  /*
7280   * Copyright (C) 2017 Alasdair Mercer, !ninja
7281   *
7282   * Permission is hereby granted, free of charge, to any person obtaining a copy
7283   * of this software and associated documentation files (the "Software"), to deal
7284   * in the Software without restriction, including without limitation the rights
7285   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7286   * copies of the Software, and to permit persons to whom the Software is
7287   * furnished to do so, subject to the following conditions:
7288   *
7289   * The above copyright notice and this permission notice shall be included in all
7290   * copies or substantial portions of the Software.
7291   *
7292   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7293   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7294   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7295   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7296   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7297   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7298   * SOFTWARE.
7299   */
7300
7301  /**
7302   * A bare-bones constructor for surrogate prototype swapping.
7303   *
7304   * @private
7305   * @constructor
7306   */
7307  var Constructor = /* istanbul ignore next */ function() {};
7308  /**
7309   * A reference to <code>Object.prototype.hasOwnProperty</code>.
7310   *
7311   * @private
7312   * @type {Function}
7313   */
7314  var hasOwnProperty = Object.prototype.hasOwnProperty;
7315  /**
7316   * A reference to <code>Array.prototype.slice</code>.
7317   *
7318   * @private
7319   * @type {Function}
7320   */
7321  var slice = Array.prototype.slice;
7322
7323  /**
7324   * Creates an object which inherits the given <code>prototype</code>.
7325   *
7326   * Optionally, the created object can be extended further with the specified <code>properties</code>.
7327   *
7328   * @param {Object} prototype - the prototype to be inherited by the created object
7329   * @param {Object} [properties] - the optional properties to be extended by the created object
7330   * @return {Object} The newly created object.
7331   * @private
7332   */
7333  function createObject(prototype, properties) {
7334    var result;
7335    /* istanbul ignore next */
7336    if (typeof Object.create === 'function') {
7337      result = Object.create(prototype);
7338    } else {
7339      Constructor.prototype = prototype;
7340      result = new Constructor();
7341      Constructor.prototype = null;
7342    }
7343
7344    if (properties) {
7345      extendObject(true, result, properties);
7346    }
7347
7348    return result;
7349  }
7350
7351  /**
7352   * Extends the constructor to which this method is associated with the <code>prototype</code> and/or
7353   * <code>statics</code> provided.
7354   *
7355   * If <code>name</code> is provided, it will be used as the class name and can be accessed via a special
7356   * <code>class_</code> property on the child constructor, otherwise the class name of the super constructor will be used
7357   * instead. The class name may also be used string representation for instances of the child constructor (via
7358   * <code>toString</code>), but this is not applicable to the <i>lite</i> version of Nevis.
7359   *
7360   * If <code>constructor</code> is provided, it will be used as the constructor for the child, otherwise a simple
7361   * constructor which only calls the super constructor will be used instead.
7362   *
7363   * The super constructor can be accessed via a special <code>super_</code> property on the child constructor.
7364   *
7365   * @param {string} [name=this.class_] - the class name to be used for the child constructor
7366   * @param {Function} [constructor] - the constructor for the child
7367   * @param {Object} [prototype] - the prototype properties to be defined for the child
7368   * @param {Object} [statics] - the static properties to be defined for the child
7369   * @return {Function} The child <code>constructor</code> provided or the one created if none was given.
7370   * @public
7371   */
7372  function extend(name, constructor, prototype, statics) {
7373    var superConstructor = this;
7374
7375    if (typeof name !== 'string') {
7376      statics = prototype;
7377      prototype = constructor;
7378      constructor = name;
7379      name = null;
7380    }
7381
7382    if (typeof constructor !== 'function') {
7383      statics = prototype;
7384      prototype = constructor;
7385      constructor = function() {
7386        return superConstructor.apply(this, arguments);
7387      };
7388    }
7389
7390    extendObject(false, constructor, superConstructor, statics);
7391
7392    constructor.prototype = createObject(superConstructor.prototype, prototype);
7393    constructor.prototype.constructor = constructor;
7394
7395    constructor.class_ = name || superConstructor.class_;
7396    constructor.super_ = superConstructor;
7397
7398    return constructor;
7399  }
7400
7401  /**
7402   * Extends the specified <code>target</code> object with the properties in each of the <code>sources</code> provided.
7403   *
7404   * if any source is <code>null</code> it will be ignored.
7405   *
7406   * @param {boolean} own - <code>true</code> to only copy <b>own</b> properties from <code>sources</code> onto
7407   * <code>target</code>; otherwise <code>false</code>
7408   * @param {Object} target - the target object which should be extended
7409   * @param {...Object} [sources] - the source objects whose properties are to be copied onto <code>target</code>
7410   * @return {void}
7411   * @private
7412   */
7413  function extendObject(own, target, sources) {
7414    sources = slice.call(arguments, 2);
7415
7416    var property;
7417    var source;
7418
7419    for (var i = 0, length = sources.length; i < length; i++) {
7420      source = sources[i];
7421
7422      for (property in source) {
7423        if (!own || hasOwnProperty.call(source, property)) {
7424          target[property] = source[property];
7425        }
7426      }
7427    }
7428  }
7429
7430  var extend_1 = extend;
7431
7432  /**
7433   * The base class from which all others should extend.
7434   *
7435   * @public
7436   * @constructor
7437   */
7438  function Nevis() {}
7439  Nevis.class_ = 'Nevis';
7440  Nevis.super_ = Object;
7441
7442  /**
7443   * Extends the constructor to which this method is associated with the <code>prototype</code> and/or
7444   * <code>statics</code> provided.
7445   *
7446   * If <code>name</code> is provided, it will be used as the class name and can be accessed via a special
7447   * <code>class_</code> property on the child constructor, otherwise the class name of the super constructor will be used
7448   * instead. The class name may also be used string representation for instances of the child constructor (via
7449   * <code>toString</code>), but this is not applicable to the <i>lite</i> version of Nevis.
7450   *
7451   * If <code>constructor</code> is provided, it will be used as the constructor for the child, otherwise a simple
7452   * constructor which only calls the super constructor will be used instead.
7453   *
7454   * The super constructor can be accessed via a special <code>super_</code> property on the child constructor.
7455   *
7456   * @param {string} [name=this.class_] - the class name to be used for the child constructor
7457   * @param {Function} [constructor] - the constructor for the child
7458   * @param {Object} [prototype] - the prototype properties to be defined for the child
7459   * @param {Object} [statics] - the static properties to be defined for the child
7460   * @return {Function} The child <code>constructor</code> provided or the one created if none was given.
7461   * @public
7462   * @static
7463   * @memberof Nevis
7464   */
7465  Nevis.extend = extend_1;
7466
7467  var nevis = Nevis;
7468
7469  var lite = nevis;
7470
7471  /**
7472   * Responsible for rendering a QR code {@link Frame} on a specific type of element.
7473   *
7474   * A renderer may be dependant on the rendering of another element, so the ordering of their execution is important.
7475   *
7476   * The rendering of a element can be deferred by disabling the renderer initially, however, any attempt get the element
7477   * from the renderer will result in it being immediately enabled and the element being rendered.
7478   *
7479   * @param {QRious} qrious - the {@link QRious} instance to be used
7480   * @param {*} element - the element onto which the QR code is to be rendered
7481   * @param {boolean} [enabled] - <code>true</code> this {@link Renderer} is enabled; otherwise <code>false</code>.
7482   * @public
7483   * @class
7484   * @extends Nevis
7485   */
7486  var Renderer = lite.extend(function(qrious, element, enabled) {
7487    /**
7488     * The {@link QRious} instance.
7489     *
7490     * @protected
7491     * @type {QRious}
7492     * @memberof Renderer#
7493     */
7494    this.qrious = qrious;
7495
7496    /**
7497     * The element onto which this {@link Renderer} is rendering the QR code.
7498     *
7499     * @protected
7500     * @type {*}
7501     * @memberof Renderer#
7502     */
7503    this.element = element;
7504    this.element.qrious = qrious;
7505
7506    /**
7507     * Whether this {@link Renderer} is enabled.
7508     *
7509     * @protected
7510     * @type {boolean}
7511     * @memberof Renderer#
7512     */
7513    this.enabled = Boolean(enabled);
7514  }, {
7515
7516    /**
7517     * Draws the specified QR code <code>frame</code> on the underlying element.
7518     *
7519     * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
7520     *
7521     * @param {Frame} frame - the {@link Frame} to be drawn
7522     * @return {void}
7523     * @protected
7524     * @abstract
7525     * @memberof Renderer#
7526     */
7527    draw: function(frame) {},
7528
7529    /**
7530     * Returns the element onto which this {@link Renderer} is rendering the QR code.
7531     *
7532     * If this method is called while this {@link Renderer} is disabled, it will be immediately enabled and rendered
7533     * before the element is returned.
7534     *
7535     * @return {*} The element.
7536     * @public
7537     * @memberof Renderer#
7538     */
7539    getElement: function() {
7540      if (!this.enabled) {
7541        this.enabled = true;
7542        this.render();
7543      }
7544
7545      return this.element;
7546    },
7547
7548    /**
7549     * Calculates the size (in pixel units) to represent an individual module within the QR code based on the
7550     * <code>frame</code> provided.
7551     *
7552     * Any configured padding will be excluded from the returned size.
7553     *
7554     * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents.
7555     * This is done so that the inevitable clipping is handled more gracefully since this way at least something is
7556     * displayed instead of just a blank space filled by the background color.
7557     *
7558     * @param {Frame} frame - the {@link Frame} from which the module size is to be derived
7559     * @return {number} The pixel size for each module in the QR code which will be no less than one.
7560     * @protected
7561     * @memberof Renderer#
7562     */
7563    getModuleSize: function(frame) {
7564      var qrious = this.qrious;
7565      var padding = qrious.padding || 0;
7566      var pixels = Math.floor((qrious.size - (padding * 2)) / frame.width);
7567
7568      return Math.max(1, pixels);
7569    },
7570
7571    /**
7572     * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the <code>frame</code>
7573     * provided.
7574     *
7575     * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its
7576     * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally
7577     * and it is not clipped from all directions.
7578     *
7579     * @param {Frame} frame - the {@link Frame} from which the offset is to be derived
7580     * @return {number} The pixel offset for the QR code which will be no less than zero.
7581     * @protected
7582     * @memberof Renderer#
7583     */
7584    getOffset: function(frame) {
7585      var qrious = this.qrious;
7586      var padding = qrious.padding;
7587
7588      if (padding != null) {
7589        return padding;
7590      }
7591
7592      var moduleSize = this.getModuleSize(frame);
7593      var offset = Math.floor((qrious.size - (moduleSize * frame.width)) / 2);
7594
7595      return Math.max(0, offset);
7596    },
7597
7598    /**
vendor: 59,196 bytes, lines 7599-9617
7599     * Renders a QR code on the underlying element based on the <code>frame</code> provided.
7600     *
7601     * @param {Frame} frame - the {@link Frame} to be rendered
7602     * @return {void}
7603     * @public
7604     * @memberof Renderer#
7605     */
7606    render: function(frame) {
7607      if (this.enabled) {
7608        this.resize();
7609        this.reset();
7610        this.draw(frame);
7611      }
7612    },
7613
7614    /**
7615     * Resets the underlying element, effectively clearing any previously rendered QR code.
7616     *
7617     * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
7618     *
7619     * @return {void}
7620     * @protected
7621     * @abstract
7622     * @memberof Renderer#
7623     */
7624    reset: function() {},
7625
7626    /**
7627     * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance.
7628     *
7629     * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
7630     *
7631     * @return {void}
7632     * @protected
7633     * @abstract
7634     * @memberof Renderer#
7635     */
7636    resize: function() {}
7637
7638  });
7639
7640  var Renderer_1 = Renderer;
7641
7642  /**
7643   * An implementation of {@link Renderer} for working with <code>canvas</code> elements.
7644   *
7645   * @public
7646   * @class
7647   * @extends Renderer
7648   */
7649  var CanvasRenderer = Renderer_1.extend({
7650
7651    /**
7652     * @override
7653     */
7654    draw: function(frame) {
7655      var i, j;
7656      var qrious = this.qrious;
7657      var moduleSize = this.getModuleSize(frame);
7658      var offset = this.getOffset(frame);
7659      var context = this.element.getContext('2d');
7660
7661      context.fillStyle = qrious.foreground;
7662      context.globalAlpha = qrious.foregroundAlpha;
7663
7664      for (i = 0; i < frame.width; i++) {
7665        for (j = 0; j < frame.width; j++) {
7666          if (frame.buffer[(j * frame.width) + i]) {
7667            context.fillRect((moduleSize * i) + offset, (moduleSize * j) + offset, moduleSize, moduleSize);
7668          }
7669        }
7670      }
7671    },
7672
7673    /**
7674     * @override
7675     */
7676    reset: function() {
7677      var qrious = this.qrious;
7678      var context = this.element.getContext('2d');
7679      var size = qrious.size;
7680
7681      context.lineWidth = 1;
7682      context.clearRect(0, 0, size, size);
7683      context.fillStyle = qrious.background;
7684      context.globalAlpha = qrious.backgroundAlpha;
7685      context.fillRect(0, 0, size, size);
7686    },
7687
7688    /**
7689     * @override
7690     */
7691    resize: function() {
7692      var element = this.element;
7693
7694      element.width = element.height = this.qrious.size;
7695    }
7696
7697  });
7698
7699  var CanvasRenderer_1 = CanvasRenderer;
7700
7701  /* eslint no-multi-spaces: "off" */
7702
7703
7704
7705  /**
7706   * Contains alignment pattern information.
7707   *
7708   * @public
7709   * @class
7710   * @extends Nevis
7711   */
7712  var Alignment = lite.extend(null, {
7713
7714    /**
7715     * The alignment pattern block.
7716     *
7717     * @public
7718     * @static
7719     * @type {number[]}
7720     * @memberof Alignment
7721     */
7722    BLOCK: [
7723      0,  11, 15, 19, 23, 27, 31,
7724      16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,
7725      26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28
7726    ]
7727
7728  });
7729
7730  var Alignment_1 = Alignment;
7731
7732  /* eslint no-multi-spaces: "off" */
7733
7734
7735
7736  /**
7737   * Contains error correction information.
7738   *
7739   * @public
7740   * @class
7741   * @extends Nevis
7742   */
7743  var ErrorCorrection = lite.extend(null, {
7744
7745    /**
7746     * The error correction blocks.
7747     *
7748     * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally
7749     * the ECC width.
7750     *
7751     * @public
7752     * @static
7753     * @type {number[]}
7754     * @memberof ErrorCorrection
7755     */
7756    BLOCKS: [
7757      1,  0,  19,  7,     1,  0,  16,  10,    1,  0,  13,  13,    1,  0,  9,   17,
7758      1,  0,  34,  10,    1,  0,  28,  16,    1,  0,  22,  22,    1,  0,  16,  28,
7759      1,  0,  55,  15,    1,  0,  44,  26,    2,  0,  17,  18,    2,  0,  13,  22,
7760      1,  0,  80,  20,    2,  0,  32,  18,    2,  0,  24,  26,    4,  0,  9,   16,
7761      1,  0,  108, 26,    2,  0,  43,  24,    2,  2,  15,  18,    2,  2,  11,  22,
7762      2,  0,  68,  18,    4,  0,  27,  16,    4,  0,  19,  24,    4,  0,  15,  28,
7763      2,  0,  78,  20,    4,  0,  31,  18,    2,  4,  14,  18,    4,  1,  13,  26,
7764      2,  0,  97,  24,    2,  2,  38,  22,    4,  2,  18,  22,    4,  2,  14,  26,
7765      2,  0,  116, 30,    3,  2,  36,  22,    4,  4,  16,  20,    4,  4,  12,  24,
7766      2,  2,  68,  18,    4,  1,  43,  26,    6,  2,  19,  24,    6,  2,  15,  28,
7767      4,  0,  81,  20,    1,  4,  50,  30,    4,  4,  22,  28,    3,  8,  12,  24,
7768      2,  2,  92,  24,    6,  2,  36,  22,    4,  6,  20,  26,    7,  4,  14,  28,
7769      4,  0,  107, 26,    8,  1,  37,  22,    8,  4,  20,  24,    12, 4,  11,  22,
7770      3,  1,  115, 30,    4,  5,  40,  24,    11, 5,  16,  20,    11, 5,  12,  24,
7771      5,  1,  87,  22,    5,  5,  41,  24,    5,  7,  24,  30,    11, 7,  12,  24,
7772      5,  1,  98,  24,    7,  3,  45,  28,    15, 2,  19,  24,    3,  13, 15,  30,
7773      1,  5,  107, 28,    10, 1,  46,  28,    1,  15, 22,  28,    2,  17, 14,  28,
7774      5,  1,  120, 30,    9,  4,  43,  26,    17, 1,  22,  28,    2,  19, 14,  28,
7775      3,  4,  113, 28,    3,  11, 44,  26,    17, 4,  21,  26,    9,  16, 13,  26,
7776      3,  5,  107, 28,    3,  13, 41,  26,    15, 5,  24,  30,    15, 10, 15,  28,
7777      4,  4,  116, 28,    17, 0,  42,  26,    17, 6,  22,  28,    19, 6,  16,  30,
7778      2,  7,  111, 28,    17, 0,  46,  28,    7,  16, 24,  30,    34, 0,  13,  24,
7779      4,  5,  121, 30,    4,  14, 47,  28,    11, 14, 24,  30,    16, 14, 15,  30,
7780      6,  4,  117, 30,    6,  14, 45,  28,    11, 16, 24,  30,    30, 2,  16,  30,
7781      8,  4,  106, 26,    8,  13, 47,  28,    7,  22, 24,  30,    22, 13, 15,  30,
7782      10, 2,  114, 28,    19, 4,  46,  28,    28, 6,  22,  28,    33, 4,  16,  30,
7783      8,  4,  122, 30,    22, 3,  45,  28,    8,  26, 23,  30,    12, 28, 15,  30,
7784      3,  10, 117, 30,    3,  23, 45,  28,    4,  31, 24,  30,    11, 31, 15,  30,
7785      7,  7,  116, 30,    21, 7,  45,  28,    1,  37, 23,  30,    19, 26, 15,  30,
7786      5,  10, 115, 30,    19, 10, 47,  28,    15, 25, 24,  30,    23, 25, 15,  30,
7787      13, 3,  115, 30,    2,  29, 46,  28,    42, 1,  24,  30,    23, 28, 15,  30,
7788      17, 0,  115, 30,    10, 23, 46,  28,    10, 35, 24,  30,    19, 35, 15,  30,
7789      17, 1,  115, 30,    14, 21, 46,  28,    29, 19, 24,  30,    11, 46, 15,  30,
7790      13, 6,  115, 30,    14, 23, 46,  28,    44, 7,  24,  30,    59, 1,  16,  30,
7791      12, 7,  121, 30,    12, 26, 47,  28,    39, 14, 24,  30,    22, 41, 15,  30,
7792      6,  14, 121, 30,    6,  34, 47,  28,    46, 10, 24,  30,    2,  64, 15,  30,
7793      17, 4,  122, 30,    29, 14, 46,  28,    49, 10, 24,  30,    24, 46, 15,  30,
7794      4,  18, 122, 30,    13, 32, 46,  28,    48, 14, 24,  30,    42, 32, 15,  30,
7795      20, 4,  117, 30,    40, 7,  47,  28,    43, 22, 24,  30,    10, 67, 15,  30,
7796      19, 6,  118, 30,    18, 31, 47,  28,    34, 34, 24,  30,    20, 61, 15,  30
7797    ],
7798
7799    /**
7800     * The final format bits with mask (level << 3 | mask).
7801     *
7802     * @public
7803     * @static
7804     * @type {number[]}
7805     * @memberof ErrorCorrection
7806     */
7807    FINAL_FORMAT: [
7808      // L
7809      0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976,
7810      // M
7811      0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0,
7812      // Q
7813      0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed,
7814      // H
7815      0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b
7816    ],
7817
7818    /**
7819     * A map of human-readable ECC levels.
7820     *
7821     * @public
7822     * @static
7823     * @type {Object.<string, number>}
7824     * @memberof ErrorCorrection
7825     */
7826    LEVELS: {
7827      L: 1,
7828      M: 2,
7829      Q: 3,
7830      H: 4
7831    }
7832
7833  });
7834
7835  var ErrorCorrection_1 = ErrorCorrection;
7836
7837  /**
7838   * Contains Galois field information.
7839   *
7840   * @public
7841   * @class
7842   * @extends Nevis
7843   */
7844  var Galois = lite.extend(null, {
7845
7846    /**
7847     * The Galois field exponent table.
7848     *
7849     * @public
7850     * @static
7851     * @type {number[]}
7852     * @memberof Galois
7853     */
7854    EXPONENT: [
7855      0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
7856      0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,
7857      0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,
7858      0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1,
7859      0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0,
7860      0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2,
7861      0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce,
7862      0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc,
7863      0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54,
7864      0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73,
7865      0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff,
7866      0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41,
7867      0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6,
7868      0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09,
7869      0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,
7870      0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00
7871    ],
7872
7873    /**
7874     * The Galois field log table.
7875     *
7876     * @public
7877     * @static
7878     * @type {number[]}
7879     * @memberof Galois
7880     */
7881    LOG: [
7882      0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,
7883      0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,
7884      0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,
7885      0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,
7886      0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,
7887      0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,
7888      0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,
7889      0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,
7890      0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,
7891      0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,
7892      0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,
7893      0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,
7894      0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,
7895      0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,
7896      0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,
7897      0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf
7898    ]
7899
7900  });
7901
7902  var Galois_1 = Galois;
7903
7904  /**
7905   * Contains version pattern information.
7906   *
7907   * @public
7908   * @class
7909   * @extends Nevis
7910   */
7911  var Version = lite.extend(null, {
7912
7913    /**
7914     * The version pattern block.
7915     *
7916     * @public
7917     * @static
7918     * @type {number[]}
7919     * @memberof Version
7920     */
7921    BLOCK: [
7922      0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532,
7923      0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5,
7924      0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69
7925    ]
7926
7927  });
7928
7929  var Version_1 = Version;
7930
7931  /**
7932   * Generates information for a QR code frame based on a specific value to be encoded.
7933   *
7934   * @param {Frame~Options} options - the options to be used
7935   * @public
7936   * @class
7937   * @extends Nevis
7938   */
7939  var Frame = lite.extend(function(options) {
7940    var dataBlock, eccBlock, index, neccBlock1, neccBlock2;
7941    var valueLength = options.value.length;
7942
7943    this._badness = [];
7944    this._level = ErrorCorrection_1.LEVELS[options.level];
7945    this._polynomial = [];
7946    this._value = options.value;
7947    this._version = 0;
7948    this._stringBuffer = [];
7949
7950    while (this._version < 40) {
7951      this._version++;
7952
7953      index = ((this._level - 1) * 4) + ((this._version - 1) * 16);
7954
7955      neccBlock1 = ErrorCorrection_1.BLOCKS[index++];
7956      neccBlock2 = ErrorCorrection_1.BLOCKS[index++];
7957      dataBlock = ErrorCorrection_1.BLOCKS[index++];
7958      eccBlock = ErrorCorrection_1.BLOCKS[index];
7959
7960      index = (dataBlock * (neccBlock1 + neccBlock2)) + neccBlock2 - 3 + (this._version <= 9);
7961
7962      if (valueLength <= index) {
7963        break;
7964      }
7965    }
7966
7967    this._dataBlock = dataBlock;
7968    this._eccBlock = eccBlock;
7969    this._neccBlock1 = neccBlock1;
7970    this._neccBlock2 = neccBlock2;
7971
7972    /**
7973     * The data width is based on version.
7974     *
7975     * @public
7976     * @type {number}
7977     * @memberof Frame#
7978     */
7979    // FIXME: Ensure that it fits instead of being truncated.
7980    var width = this.width = 17 + (4 * this._version);
7981
7982    /**
7983     * The image buffer.
7984     *
7985     * @public
7986     * @type {number[]}
7987     * @memberof Frame#
7988     */
7989    this.buffer = Frame._createArray(width * width);
7990
7991    this._ecc = Frame._createArray(dataBlock + ((dataBlock + eccBlock) * (neccBlock1 + neccBlock2)) + neccBlock2);
7992    this._mask = Frame._createArray(((width * (width + 1)) + 1) / 2);
7993
7994    this._insertFinders();
7995    this._insertAlignments();
7996
7997    // Insert single foreground cell.
7998    this.buffer[8 + (width * (width - 8))] = 1;
7999
8000    this._insertTimingGap();
8001    this._reverseMask();
8002    this._insertTimingRowAndColumn();
8003    this._insertVersion();
8004    this._syncMask();
8005    this._convertBitStream(valueLength);
8006    this._calculatePolynomial();
8007    this._appendEccToData();
8008    this._interleaveBlocks();
8009    this._pack();
8010    this._finish();
8011  }, {
8012
8013    _addAlignment: function(x, y) {
8014      var i;
8015      var buffer = this.buffer;
8016      var width = this.width;
8017
8018      buffer[x + (width * y)] = 1;
8019
8020      for (i = -2; i < 2; i++) {
8021        buffer[x + i + (width * (y - 2))] = 1;
8022        buffer[x - 2 + (width * (y + i + 1))] = 1;
8023        buffer[x + 2 + (width * (y + i))] = 1;
8024        buffer[x + i + 1 + (width * (y + 2))] = 1;
8025      }
8026
8027      for (i = 0; i < 2; i++) {
8028        this._setMask(x - 1, y + i);
8029        this._setMask(x + 1, y - i);
8030        this._setMask(x - i, y - 1);
8031        this._setMask(x + i, y + 1);
8032      }
8033    },
8034
8035    _appendData: function(data, dataLength, ecc, eccLength) {
8036      var bit, i, j;
8037      var polynomial = this._polynomial;
8038      var stringBuffer = this._stringBuffer;
8039
8040      for (i = 0; i < eccLength; i++) {
8041        stringBuffer[ecc + i] = 0;
8042      }
8043
8044      for (i = 0; i < dataLength; i++) {
8045        bit = Galois_1.LOG[stringBuffer[data + i] ^ stringBuffer[ecc]];
8046
8047        if (bit !== 255) {
8048          for (j = 1; j < eccLength; j++) {
8049            stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^
8050              Galois_1.EXPONENT[Frame._modN(bit + polynomial[eccLength - j])];
8051          }
8052        } else {
8053          for (j = ecc; j < ecc + eccLength; j++) {
8054            stringBuffer[j] = stringBuffer[j + 1];
8055          }
8056        }
8057
8058        stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois_1.EXPONENT[Frame._modN(bit + polynomial[0])];
8059      }
8060    },
8061
8062    _appendEccToData: function() {
8063      var i;
8064      var data = 0;
8065      var dataBlock = this._dataBlock;
8066      var ecc = this._calculateMaxLength();
8067      var eccBlock = this._eccBlock;
8068
8069      for (i = 0; i < this._neccBlock1; i++) {
8070        this._appendData(data, dataBlock, ecc, eccBlock);
8071
8072        data += dataBlock;
8073        ecc += eccBlock;
8074      }
8075
8076      for (i = 0; i < this._neccBlock2; i++) {
8077        this._appendData(data, dataBlock + 1, ecc, eccBlock);
8078
8079        data += dataBlock + 1;
8080        ecc += eccBlock;
8081      }
8082    },
8083
8084    _applyMask: function(mask) {
8085      var r3x, r3y, x, y;
8086      var buffer = this.buffer;
8087      var width = this.width;
8088
8089      switch (mask) {
8090      case 0:
8091        for (y = 0; y < width; y++) {
8092          for (x = 0; x < width; x++) {
8093            if (!((x + y) & 1) && !this._isMasked(x, y)) {
8094              buffer[x + (y * width)] ^= 1;
8095            }
8096          }
8097        }
8098
8099        break;
8100      case 1:
8101        for (y = 0; y < width; y++) {
8102          for (x = 0; x < width; x++) {
8103            if (!(y & 1) && !this._isMasked(x, y)) {
8104              buffer[x + (y * width)] ^= 1;
8105            }
8106          }
8107        }
8108
8109        break;
8110      case 2:
8111        for (y = 0; y < width; y++) {
8112          for (r3x = 0, x = 0; x < width; x++, r3x++) {
8113            if (r3x === 3) {
8114              r3x = 0;
8115            }
8116
8117            if (!r3x && !this._isMasked(x, y)) {
8118              buffer[x + (y * width)] ^= 1;
8119            }
8120          }
8121        }
8122
8123        break;
8124      case 3:
8125        for (r3y = 0, y = 0; y < width; y++, r3y++) {
8126          if (r3y === 3) {
8127            r3y = 0;
8128          }
8129
8130          for (r3x = r3y, x = 0; x < width; x++, r3x++) {
8131            if (r3x === 3) {
8132              r3x = 0;
8133            }
8134
8135            if (!r3x && !this._isMasked(x, y)) {
8136              buffer[x + (y * width)] ^= 1;
8137            }
8138          }
8139        }
8140
8141        break;
8142      case 4:
8143        for (y = 0; y < width; y++) {
8144          for (r3x = 0, r3y = (y >> 1) & 1, x = 0; x < width; x++, r3x++) {
8145            if (r3x === 3) {
8146              r3x = 0;
8147              r3y = !r3y;
8148            }
8149
8150            if (!r3y && !this._isMasked(x, y)) {
8151              buffer[x + (y * width)] ^= 1;
8152            }
8153          }
8154        }
8155
8156        break;
8157      case 5:
8158        for (r3y = 0, y = 0; y < width; y++, r3y++) {
8159          if (r3y === 3) {
8160            r3y = 0;
8161          }
8162
8163          for (r3x = 0, x = 0; x < width; x++, r3x++) {
8164            if (r3x === 3) {
8165              r3x = 0;
8166            }
8167
8168            if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) {
8169              buffer[x + (y * width)] ^= 1;
8170            }
8171          }
8172        }
8173
8174        break;
8175      case 6:
8176        for (r3y = 0, y = 0; y < width; y++, r3y++) {
8177          if (r3y === 3) {
8178            r3y = 0;
8179          }
8180
8181          for (r3x = 0, x = 0; x < width; x++, r3x++) {
8182            if (r3x === 3) {
8183              r3x = 0;
8184            }
8185
8186            if (!((x & y & 1) + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) {
8187              buffer[x + (y * width)] ^= 1;
8188            }
8189          }
8190        }
8191
8192        break;
8193      case 7:
8194        for (r3y = 0, y = 0; y < width; y++, r3y++) {
8195          if (r3y === 3) {
8196            r3y = 0;
8197          }
8198
8199          for (r3x = 0, x = 0; x < width; x++, r3x++) {
8200            if (r3x === 3) {
8201              r3x = 0;
8202            }
8203
8204            if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) {
8205              buffer[x + (y * width)] ^= 1;
8206            }
8207          }
8208        }
8209
8210        break;
8211      }
8212    },
8213
8214    _calculateMaxLength: function() {
8215      return (this._dataBlock * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2;
8216    },
8217
8218    _calculatePolynomial: function() {
8219      var i, j;
8220      var eccBlock = this._eccBlock;
8221      var polynomial = this._polynomial;
8222
8223      polynomial[0] = 1;
8224
8225      for (i = 0; i < eccBlock; i++) {
8226        polynomial[i + 1] = 1;
8227
8228        for (j = i; j > 0; j--) {
8229          polynomial[j] = polynomial[j] ? polynomial[j - 1] ^
8230            Galois_1.EXPONENT[Frame._modN(Galois_1.LOG[polynomial[j]] + i)] : polynomial[j - 1];
8231        }
8232
8233        polynomial[0] = Galois_1.EXPONENT[Frame._modN(Galois_1.LOG[polynomial[0]] + i)];
8234      }
8235
8236      // Use logs for generator polynomial to save calculation step.
8237      for (i = 0; i <= eccBlock; i++) {
8238        polynomial[i] = Galois_1.LOG[polynomial[i]];
8239      }
8240    },
8241
8242    _checkBadness: function() {
8243      var b, b1, h, x, y;
8244      var bad = 0;
8245      var badness = this._badness;
8246      var buffer = this.buffer;
8247      var width = this.width;
8248
8249      // Blocks of same colour.
8250      for (y = 0; y < width - 1; y++) {
8251        for (x = 0; x < width - 1; x++) {
8252          // All foreground colour.
8253          if ((buffer[x + (width * y)] &&
8254            buffer[x + 1 + (width * y)] &&
8255            buffer[x + (width * (y + 1))] &&
8256            buffer[x + 1 + (width * (y + 1))]) ||
8257            // All background colour.
8258            !(buffer[x + (width * y)] ||
8259            buffer[x + 1 + (width * y)] ||
8260            buffer[x + (width * (y + 1))] ||
8261            buffer[x + 1 + (width * (y + 1))])) {
8262            bad += Frame.N2;
8263          }
8264        }
8265      }
8266
8267      var bw = 0;
8268
8269      // X runs.
8270      for (y = 0; y < width; y++) {
8271        h = 0;
8272
8273        badness[0] = 0;
8274
8275        for (b = 0, x = 0; x < width; x++) {
8276          b1 = buffer[x + (width * y)];
8277
8278          if (b === b1) {
8279            badness[h]++;
8280          } else {
8281            badness[++h] = 1;
8282          }
8283
8284          b = b1;
8285          bw += b ? 1 : -1;
8286        }
8287
8288        bad += this._getBadness(h);
8289      }
8290
8291      if (bw < 0) {
8292        bw = -bw;
8293      }
8294
8295      var count = 0;
8296      var big = bw;
8297      big += big << 2;
8298      big <<= 1;
8299
8300      while (big > width * width) {
8301        big -= width * width;
8302        count++;
8303      }
8304
8305      bad += count * Frame.N4;
8306
8307      // Y runs.
8308      for (x = 0; x < width; x++) {
8309        h = 0;
8310
8311        badness[0] = 0;
8312
8313        for (b = 0, y = 0; y < width; y++) {
8314          b1 = buffer[x + (width * y)];
8315
8316          if (b === b1) {
8317            badness[h]++;
8318          } else {
8319            badness[++h] = 1;
8320          }
8321
8322          b = b1;
8323        }
8324
8325        bad += this._getBadness(h);
8326      }
8327
8328      return bad;
8329    },
8330
8331    _convertBitStream: function(length) {
8332      var bit, i;
8333      var ecc = this._ecc;
8334      var version = this._version;
8335
8336      // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanumeric, or kanji not supported).
8337      for (i = 0; i < length; i++) {
8338        ecc[i] = this._value.charCodeAt(i);
8339      }
8340
8341      var stringBuffer = this._stringBuffer = ecc.slice();
8342      var maxLength = this._calculateMaxLength();
8343
8344      if (length >= maxLength - 2) {
8345        length = maxLength - 2;
8346
8347        if (version > 9) {
8348          length--;
8349        }
8350      }
8351
8352      // Shift and re-pack to insert length prefix.
8353      var index = length;
8354
8355      if (version > 9) {
8356        stringBuffer[index + 2] = 0;
8357        stringBuffer[index + 3] = 0;
8358
8359        while (index--) {
8360          bit = stringBuffer[index];
8361
8362          stringBuffer[index + 3] |= 255 & (bit << 4);
8363          stringBuffer[index + 2] = bit >> 4;
8364        }
8365
8366        stringBuffer[2] |= 255 & (length << 4);
8367        stringBuffer[1] = length >> 4;
8368        stringBuffer[0] = 0x40 | (length >> 12);
8369      } else {
8370        stringBuffer[index + 1] = 0;
8371        stringBuffer[index + 2] = 0;
8372
8373        while (index--) {
8374          bit = stringBuffer[index];
8375
8376          stringBuffer[index + 2] |= 255 & (bit << 4);
8377          stringBuffer[index + 1] = bit >> 4;
8378        }
8379
8380        stringBuffer[1] |= 255 & (length << 4);
8381        stringBuffer[0] = 0x40 | (length >> 4);
8382      }
8383
8384      // Fill to end with pad pattern.
8385      index = length + 3 - (version < 10);
8386
8387      while (index < maxLength) {
8388        stringBuffer[index++] = 0xec;
8389        stringBuffer[index++] = 0x11;
8390      }
8391    },
8392
8393    _getBadness: function(length) {
8394      var i;
8395      var badRuns = 0;
8396      var badness = this._badness;
8397
8398      for (i = 0; i <= length; i++) {
8399        if (badness[i] >= 5) {
8400          badRuns += Frame.N1 + badness[i] - 5;
8401        }
8402      }
8403
8404      // FBFFFBF as in finder.
8405      for (i = 3; i < length - 1; i += 2) {
8406        if (badness[i - 2] === badness[i + 2] &&
8407          badness[i + 2] === badness[i - 1] &&
8408          badness[i - 1] === badness[i + 1] &&
8409          badness[i - 1] * 3 === badness[i] &&
8410          // Background around the foreground pattern? Not part of the specs.
8411          (badness[i - 3] === 0 || i + 3 > length ||
8412          badness[i - 3] * 3 >= badness[i] * 4 ||
8413          badness[i + 3] * 3 >= badness[i] * 4)) {
8414          badRuns += Frame.N3;
8415        }
8416      }
8417
8418      return badRuns;
8419    },
8420
8421    _finish: function() {
8422      // Save pre-mask copy of frame.
8423      this._stringBuffer = this.buffer.slice();
8424
8425      var currentMask, i;
8426      var bit = 0;
8427      var mask = 30000;
8428
8429      /*
8430       * Using for instead of while since in original Arduino code if an early mask was "good enough" it wouldn't try for
8431       * a better one since they get more complex and take longer.
8432       */
8433      for (i = 0; i < 8; i++) {
8434        // Returns foreground-background imbalance.
8435        this._applyMask(i);
8436
8437        currentMask = this._checkBadness();
8438
8439        // Is current mask better than previous best?
8440        if (currentMask < mask) {
8441          mask = currentMask;
8442          bit = i;
8443        }
8444
8445        // Don't increment "i" to a void redoing mask.
8446        if (bit === 7) {
8447          break;
8448        }
8449
8450        // Reset for next pass.
8451        this.buffer = this._stringBuffer.slice();
8452      }
8453
8454      // Redo best mask as none were "good enough" (i.e. last wasn't bit).
8455      if (bit !== i) {
8456        this._applyMask(bit);
8457      }
8458
8459      // Add in final mask/ECC level bytes.
8460      mask = ErrorCorrection_1.FINAL_FORMAT[bit + (this._level - 1 << 3)];
8461
8462      var buffer = this.buffer;
8463      var width = this.width;
8464
8465      // Low byte.
8466      for (i = 0; i < 8; i++, mask >>= 1) {
8467        if (mask & 1) {
8468          buffer[width - 1 - i + (width * 8)] = 1;
8469
8470          if (i < 6) {
8471            buffer[8 + (width * i)] = 1;
8472          } else {
8473            buffer[8 + (width * (i + 1))] = 1;
8474          }
8475        }
8476      }
8477
8478      // High byte.
8479      for (i = 0; i < 7; i++, mask >>= 1) {
8480        if (mask & 1) {
8481          buffer[8 + (width * (width - 7 + i))] = 1;
8482
8483          if (i) {
8484            buffer[6 - i + (width * 8)] = 1;
8485          } else {
8486            buffer[7 + (width * 8)] = 1;
8487          }
8488        }
8489      }
8490    },
8491
8492    _interleaveBlocks: function() {
8493      var i, j;
8494      var dataBlock = this._dataBlock;
8495      var ecc = this._ecc;
8496      var eccBlock = this._eccBlock;
8497      var k = 0;
8498      var maxLength = this._calculateMaxLength();
8499      var neccBlock1 = this._neccBlock1;
8500      var neccBlock2 = this._neccBlock2;
8501      var stringBuffer = this._stringBuffer;
8502
8503      for (i = 0; i < dataBlock; i++) {
8504        for (j = 0; j < neccBlock1; j++) {
8505          ecc[k++] = stringBuffer[i + (j * dataBlock)];
8506        }
8507
8508        for (j = 0; j < neccBlock2; j++) {
8509          ecc[k++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
8510        }
8511      }
8512
8513      for (j = 0; j < neccBlock2; j++) {
8514        ecc[k++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
8515      }
8516
8517      for (i = 0; i < eccBlock; i++) {
8518        for (j = 0; j < neccBlock1 + neccBlock2; j++) {
8519          ecc[k++] = stringBuffer[maxLength + i + (j * eccBlock)];
8520        }
8521      }
8522
8523      this._stringBuffer = ecc;
8524    },
8525
8526    _insertAlignments: function() {
8527      var i, x, y;
8528      var version = this._version;
8529      var width = this.width;
8530
8531      if (version > 1) {
8532        i = Alignment_1.BLOCK[version];
8533        y = width - 7;
8534
8535        for (;;) {
8536          x = width - 7;
8537
8538          while (x > i - 3) {
8539            this._addAlignment(x, y);
8540
8541            if (x < i) {
8542              break;
8543            }
8544
8545            x -= i;
8546          }
8547
8548          if (y <= i + 9) {
8549            break;
8550          }
8551
8552          y -= i;
8553
8554          this._addAlignment(6, y);
8555          this._addAlignment(y, 6);
8556        }
8557      }
8558    },
8559
8560    _insertFinders: function() {
8561      var i, j, x, y;
8562      var buffer = this.buffer;
8563      var width = this.width;
8564
8565      for (i = 0; i < 3; i++) {
8566        j = 0;
8567        y = 0;
8568
8569        if (i === 1) {
8570          j = width - 7;
8571        }
8572        if (i === 2) {
8573          y = width - 7;
8574        }
8575
8576        buffer[y + 3 + (width * (j + 3))] = 1;
8577
8578        for (x = 0; x < 6; x++) {
8579          buffer[y + x + (width * j)] = 1;
8580          buffer[y + (width * (j + x + 1))] = 1;
8581          buffer[y + 6 + (width * (j + x))] = 1;
8582          buffer[y + x + 1 + (width * (j + 6))] = 1;
8583        }
8584
8585        for (x = 1; x < 5; x++) {
8586          this._setMask(y + x, j + 1);
8587          this._setMask(y + 1, j + x + 1);
8588          this._setMask(y + 5, j + x);
8589          this._setMask(y + x + 1, j + 5);
8590        }
8591
8592        for (x = 2; x < 4; x++) {
8593          buffer[y + x + (width * (j + 2))] = 1;
8594          buffer[y + 2 + (width * (j + x + 1))] = 1;
8595          buffer[y + 4 + (width * (j + x))] = 1;
8596          buffer[y + x + 1 + (width * (j + 4))] = 1;
8597        }
8598      }
8599    },
8600
8601    _insertTimingGap: function() {
8602      var x, y;
8603      var width = this.width;
8604
8605      for (y = 0; y < 7; y++) {
8606        this._setMask(7, y);
8607        this._setMask(width - 8, y);
8608        this._setMask(7, y + width - 7);
8609      }
8610
8611      for (x = 0; x < 8; x++) {
8612        this._setMask(x, 7);
8613        this._setMask(x + width - 8, 7);
8614        this._setMask(x, width - 8);
8615      }
8616    },
8617
8618    _insertTimingRowAndColumn: function() {
8619      var x;
8620      var buffer = this.buffer;
8621      var width = this.width;
8622
8623      for (x = 0; x < width - 14; x++) {
8624        if (x & 1) {
8625          this._setMask(8 + x, 6);
8626          this._setMask(6, 8 + x);
8627        } else {
8628          buffer[8 + x + (width * 6)] = 1;
8629          buffer[6 + (width * (8 + x))] = 1;
8630        }
8631      }
8632    },
8633
8634    _insertVersion: function() {
8635      var i, j, x, y;
8636      var buffer = this.buffer;
8637      var version = this._version;
8638      var width = this.width;
8639
8640      if (version > 6) {
8641        i = Version_1.BLOCK[version - 7];
8642        j = 17;
8643
8644        for (x = 0; x < 6; x++) {
8645          for (y = 0; y < 3; y++, j--) {
8646            if (1 & (j > 11 ? version >> j - 12 : i >> j)) {
8647              buffer[5 - x + (width * (2 - y + width - 11))] = 1;
8648              buffer[2 - y + width - 11 + (width * (5 - x))] = 1;
8649            } else {
8650              this._setMask(5 - x, 2 - y + width - 11);
8651              this._setMask(2 - y + width - 11, 5 - x);
8652            }
8653          }
8654        }
8655      }
8656    },
8657
8658    _isMasked: function(x, y) {
8659      var bit = Frame._getMaskBit(x, y);
8660
8661      return this._mask[bit] === 1;
8662    },
8663
8664    _pack: function() {
8665      var bit, i, j;
8666      var k = 1;
8667      var v = 1;
8668      var width = this.width;
8669      var x = width - 1;
8670      var y = width - 1;
8671
8672      // Interleaved data and ECC codes.
8673      var length = ((this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2;
8674
8675      for (i = 0; i < length; i++) {
8676        bit = this._stringBuffer[i];
8677
8678        for (j = 0; j < 8; j++, bit <<= 1) {
8679          if (0x80 & bit) {
8680            this.buffer[x + (width * y)] = 1;
8681          }
8682
8683          // Find next fill position.
8684          do {
8685            if (v) {
8686              x--;
8687            } else {
8688              x++;
8689
8690              if (k) {
8691                if (y !== 0) {
8692                  y--;
8693                } else {
8694                  x -= 2;
8695                  k = !k;
8696
8697                  if (x === 6) {
8698                    x--;
8699                    y = 9;
8700                  }
8701                }
8702              } else if (y !== width - 1) {
8703                y++;
8704              } else {
8705                x -= 2;
8706                k = !k;
8707
8708                if (x === 6) {
8709                  x--;
8710                  y -= 8;
8711                }
8712              }
8713            }
8714
8715            v = !v;
8716          } while (this._isMasked(x, y));
8717        }
8718      }
8719    },
8720
8721    _reverseMask: function() {
8722      var x, y;
8723      var width = this.width;
8724
8725      for (x = 0; x < 9; x++) {
8726        this._setMask(x, 8);
8727      }
8728
8729      for (x = 0; x < 8; x++) {
8730        this._setMask(x + width - 8, 8);
8731        this._setMask(8, x);
8732      }
8733
8734      for (y = 0; y < 7; y++) {
8735        this._setMask(8, y + width - 7);
8736      }
8737    },
8738
8739    _setMask: function(x, y) {
8740      var bit = Frame._getMaskBit(x, y);
8741
8742      this._mask[bit] = 1;
8743    },
8744
8745    _syncMask: function() {
8746      var x, y;
8747      var width = this.width;
8748
8749      for (y = 0; y < width; y++) {
8750        for (x = 0; x <= y; x++) {
8751          if (this.buffer[x + (width * y)]) {
8752            this._setMask(x, y);
8753          }
8754        }
8755      }
8756    }
8757
8758  }, {
8759
8760    _createArray: function(length) {
8761      var i;
8762      var array = [];
8763
8764      for (i = 0; i < length; i++) {
8765        array[i] = 0;
8766      }
8767
8768      return array;
8769    },
8770
8771    _getMaskBit: function(x, y) {
8772      var bit;
8773
8774      if (x > y) {
8775        bit = x;
8776        x = y;
8777        y = bit;
8778      }
8779
8780      bit = y;
8781      bit += y * y;
8782      bit >>= 1;
8783      bit += x;
8784
8785      return bit;
8786    },
8787
8788    _modN: function(x) {
8789      while (x >= 255) {
8790        x -= 255;
8791        x = (x >> 8) + (x & 255);
8792      }
8793
8794      return x;
8795    },
8796
8797    // *Badness* coefficients.
8798    N1: 3,
8799    N2: 3,
8800    N3: 40,
8801    N4: 10
8802
8803  });
8804
8805  var Frame_1 = Frame;
8806
8807  /**
8808   * The options used by {@link Frame}.
8809   *
8810   * @typedef {Object} Frame~Options
8811   * @property {string} level - The ECC level to be used.
8812   * @property {string} value - The value to be encoded.
8813   */
8814
8815  /**
8816   * An implementation of {@link Renderer} for working with <code>img</code> elements.
8817   *
8818   * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from
8819   * the rendered <code>canvas</code> element as the <code>src</code> for the <code>img</code> element being rendered.
8820   *
8821   * @public
8822   * @class
8823   * @extends Renderer
8824   */
8825  var ImageRenderer = Renderer_1.extend({
8826
8827    /**
8828     * @override
8829     */
8830    draw: function() {
8831      this.element.src = this.qrious.toDataURL();
8832    },
8833
8834    /**
8835     * @override
8836     */
8837    reset: function() {
8838      this.element.src = '';
8839    },
8840
8841    /**
8842     * @override
8843     */
8844    resize: function() {
8845      var element = this.element;
8846
8847      element.width = element.height = this.qrious.size;
8848    }
8849
8850  });
8851
8852  var ImageRenderer_1 = ImageRenderer;
8853
8854  /**
8855   * Defines an available option while also configuring how values are applied to the target object.
8856   *
8857   * Optionally, a default value can be specified as well a value transformer for greater control over how the option
8858   * value is applied.
8859   *
8860   * If no value transformer is specified, then any specified option will be applied directly. All values are maintained
8861   * on the target object itself as a field using the option name prefixed with a single underscore.
8862   *
8863   * When an option is specified as modifiable, the {@link OptionManager} will be required to include a setter for the
8864   * property that is defined on the target object that uses the option name.
8865   *
8866   * @param {string} name - the name to be used
8867   * @param {boolean} [modifiable] - <code>true</code> if the property defined on target objects should include a setter;
8868   * otherwise <code>false</code>
8869   * @param {*} [defaultValue] - the default value to be used
8870   * @param {Option~ValueTransformer} [valueTransformer] - the value transformer to be used
8871   * @public
8872   * @class
8873   * @extends Nevis
8874   */
8875  var Option = lite.extend(function(name, modifiable, defaultValue, valueTransformer) {
8876    /**
8877     * The name for this {@link Option}.
8878     *
8879     * @public
8880     * @type {string}
8881     * @memberof Option#
8882     */
8883    this.name = name;
8884
8885    /**
8886     * Whether a setter should be included on the property defined on target objects for this {@link Option}.
8887     *
8888     * @public
8889     * @type {boolean}
8890     * @memberof Option#
8891     */
8892    this.modifiable = Boolean(modifiable);
8893
8894    /**
8895     * The default value for this {@link Option}.
8896     *
8897     * @public
8898     * @type {*}
8899     * @memberof Option#
8900     */
8901    this.defaultValue = defaultValue;
8902
8903    this._valueTransformer = valueTransformer;
8904  }, {
8905
8906    /**
8907     * Transforms the specified <code>value</code> so that it can be applied for this {@link Option}.
8908     *
8909     * If a value transformer has been specified for this {@link Option}, it will be called upon to transform
8910     * <code>value</code>. Otherwise, <code>value</code> will be returned directly.
8911     *
8912     * @param {*} value - the value to be transformed
8913     * @return {*} The transformed value or <code>value</code> if no value transformer is specified.
8914     * @public
8915     * @memberof Option#
8916     */
8917    transform: function(value) {
8918      var transformer = this._valueTransformer;
8919      if (typeof transformer === 'function') {
8920        return transformer(value, this);
8921      }
8922
8923      return value;
8924    }
8925
8926  });
8927
8928  var Option_1 = Option;
8929
8930  /**
8931   * Returns a transformed value for the specified <code>value</code> to be applied for the <code>option</code> provided.
8932   *
8933   * @callback Option~ValueTransformer
8934   * @param {*} value - the value to be transformed
8935   * @param {Option} option - the {@link Option} for which <code>value</code> is being transformed
8936   * @return {*} The transform value.
8937   */
8938
8939  /**
8940   * Contains utility methods that are useful throughout the library.
8941   *
8942   * @public
8943   * @class
8944   * @extends Nevis
8945   */
8946  var Utilities = lite.extend(null, {
8947
8948    /**
8949     * Returns the absolute value of a given number.
8950     *
8951     * This method is simply a convenient shorthand for <code>Math.abs</code> while ensuring that nulls are returned as
8952     * <code>null</code> instead of zero.
8953     *
8954     * @param {number} value - the number whose absolute value is to be returned
8955     * @return {number} The absolute value of <code>value</code> or <code>null</code> if <code>value</code> is
8956     * <code>null</code>.
8957     * @public
8958     * @static
8959     * @memberof Utilities
8960     */
8961    abs: function(value) {
8962      return value != null ? Math.abs(value) : null;
8963    },
8964
8965    /**
8966     * Returns whether the specified <code>object</code> has a property with the specified <code>name</code> as an own
8967     * (not inherited) property.
8968     *
8969     * @param {Object} object - the object on which the property is to be checked
8970     * @param {string} name - the name of the property to be checked
8971     * @return {boolean} <code>true</code> if <code>object</code> has an own property with <code>name</code>.
8972     * @public
8973     * @static
8974     * @memberof Utilities
8975     */
8976    hasOwn: function(object, name) {
8977      return Object.prototype.hasOwnProperty.call(object, name);
8978    },
8979
8980    /**
8981     * A non-operation method that does absolutely nothing.
8982     *
8983     * @return {void}
8984     * @public
8985     * @static
8986     * @memberof Utilities
8987     */
8988    noop: function() {},
8989
8990    /**
8991     * Transforms the specified <code>string</code> to upper case while remaining null-safe.
8992     *
8993     * @param {string} string - the string to be transformed to upper case
8994     * @return {string} <code>string</code> transformed to upper case if <code>string</code> is not <code>null</code>.
8995     * @public
8996     * @static
8997     * @memberof Utilities
8998     */
8999    toUpperCase: function(string) {
9000      return string != null ? string.toUpperCase() : null;
9001    }
9002
9003  });
9004
9005  var Utilities_1 = Utilities;
9006
9007  /**
9008   * Manages multiple {@link Option} instances that are intended to be used by multiple implementations.
9009   *
9010   * Although the option definitions are shared between targets, the values are maintained on the targets themselves.
9011   *
9012   * @param {Option[]} options - the options to be used
9013   * @public
9014   * @class
9015   * @extends Nevis
9016   */
9017  var OptionManager = lite.extend(function(options) {
9018    /**
9019     * The available options for this {@link OptionManager}.
9020     *
9021     * @public
9022     * @type {Object.<string, Option>}
9023     * @memberof OptionManager#
9024     */
9025    this.options = {};
9026
9027    options.forEach(function(option) {
9028      this.options[option.name] = option;
9029    }, this);
9030  }, {
9031
9032    /**
9033     * Returns whether an option with the specified <code>name</code> is available.
9034     *
9035     * @param {string} name - the name of the {@link Option} whose existence is to be checked
9036     * @return {boolean} <code>true</code> if an {@link Option} exists with <code>name</code>; otherwise
9037     * <code>false</code>.
9038     * @public
9039     * @memberof OptionManager#
9040     */
9041    exists: function(name) {
9042      return this.options[name] != null;
9043    },
9044
9045    /**
9046     * Returns the value of the option with the specified <code>name</code> on the <code>target</code> object provided.
9047     *
9048     * @param {string} name - the name of the {@link Option} whose value on <code>target</code> is to be returned
9049     * @param {Object} target - the object from which the value of the named {@link Option} is to be returned
9050     * @return {*} The value of the {@link Option} with <code>name</code> on <code>target</code>.
9051     * @public
9052     * @memberof OptionManager#
9053     */
9054    get: function(name, target) {
9055      return OptionManager._get(this.options[name], target);
9056    },
9057
9058    /**
9059     * Returns a copy of all of the available options on the <code>target</code> object provided.
9060     *
9061     * @param {Object} target - the object from which the option name/value pairs are to be returned
9062     * @return {Object.<string, *>} A hash containing the name/value pairs of all options on <code>target</code>.
9063     * @public
9064     * @memberof OptionManager#
9065     */
9066    getAll: function(target) {
9067      var name;
9068      var options = this.options;
9069      var result = {};
9070
9071      for (name in options) {
9072        if (Utilities_1.hasOwn(options, name)) {
9073          result[name] = OptionManager._get(options[name], target);
9074        }
9075      }
9076
9077      return result;
9078    },
9079
9080    /**
9081     * Initializes the available options for the <code>target</code> object provided and then applies the initial values
9082     * within the speciifed <code>options</code>.
9083     *
9084     * This method will throw an error if any of the names within <code>options</code> does not match an available option.
9085     *
9086     * This involves setting the default values and defining properties for all of the available options on
9087     * <code>target</code> before finally calling {@link OptionMananger#setAll} with <code>options</code> and
9088     * <code>target</code>. Any options that are configured to be modifiable will have a setter included in their defined
9089     * property that will allow its corresponding value to be modified.
9090     *
9091     * If a change handler is specified, it will be called whenever the value changes on <code>target</code> for a
9092     * modifiable option, but only when done so via the defined property's setter.
9093     *
9094     * @param {Object.<string, *>} options - the name/value pairs of the initial options to be set
9095     * @param {Object} target - the object on which the options are to be initialized
9096     * @param {Function} [changeHandler] - the function to be called whenever the value of an modifiable option changes on
9097     * <code>target</code>
9098     * @return {void}
9099     * @throws {Error} If <code>options</code> contains an invalid option name.
9100     * @public
9101     * @memberof OptionManager#
9102     */
9103    init: function(options, target, changeHandler) {
9104      if (typeof changeHandler !== 'function') {
9105        changeHandler = Utilities_1.noop;
9106      }
9107
9108      var name, option;
9109
9110      for (name in this.options) {
9111        if (Utilities_1.hasOwn(this.options, name)) {
9112          option = this.options[name];
9113
9114          OptionManager._set(option, option.defaultValue, target);
9115          OptionManager._createAccessor(option, target, changeHandler);
9116        }
9117      }
9118
9119      this._setAll(options, target, true);
9120    },
9121
9122    /**
9123     * Sets the value of the option with the specified <code>name</code> on the <code>target</code> object provided to
9124     * <code>value</code>.
9125     *
9126     * This method will throw an error if <code>name</code> does not match an available option or matches an option that
9127     * cannot be modified.
9128     *
9129     * If <code>value</code> is <code>null</code> and the {@link Option} has a default value configured, then that default
9130     * value will be used instead. If the {@link Option} also has a value transformer configured, it will be used to
9131     * transform whichever value was determined to be used.
9132     *
9133     * This method returns whether the value of the underlying field on <code>target</code> was changed as a result.
9134     *
9135     * @param {string} name - the name of the {@link Option} whose value is to be set
9136     * @param {*} value - the value to be set for the named {@link Option} on <code>target</code>
9137     * @param {Object} target - the object on which <code>value</code> is to be set for the named {@link Option}
9138     * @return {boolean} <code>true</code> if the underlying field on <code>target</code> was changed; otherwise
9139     * <code>false</code>.
9140     * @throws {Error} If <code>name</code> is invalid or is for an option that cannot be modified.
9141     * @public
9142     * @memberof OptionManager#
9143     */
9144    set: function(name, value, target) {
9145      return this._set(name, value, target);
9146    },
9147
9148    /**
9149     * Sets all of the specified <code>options</code> on the <code>target</code> object provided to their corresponding
9150     * values.
9151     *
9152     * This method will throw an error if any of the names within <code>options</code> does not match an available option
9153     * or matches an option that cannot be modified.
9154     *
9155     * If any value within <code>options</code> is <code>null</code> and the corresponding {@link Option} has a default
9156     * value configured, then that default value will be used instead. If an {@link Option} also has a value transformer
9157     * configured, it will be used to transform whichever value was determined to be used.
9158     *
9159     * This method returns whether the value for any of the underlying fields on <code>target</code> were changed as a
9160     * result.
9161     *
9162     * @param {Object.<string, *>} options - the name/value pairs of options to be set
9163     * @param {Object} target - the object on which the options are to be set
9164     * @return {boolean} <code>true</code> if any of the underlying fields on <code>target</code> were changed; otherwise
9165     * <code>false</code>.
9166     * @throws {Error} If <code>options</code> contains an invalid option name or an option that cannot be modiifed.
9167     * @public
9168     * @memberof OptionManager#
9169     */
9170    setAll: function(options, target) {
9171      return this._setAll(options, target);
9172    },
9173
9174    _set: function(name, value, target, allowUnmodifiable) {
9175      var option = this.options[name];
9176      if (!option) {
9177        throw new Error('Invalid option: ' + name);
9178      }
9179      if (!option.modifiable && !allowUnmodifiable) {
9180        throw new Error('Option cannot be modified: ' + name);
9181      }
9182
9183      return OptionManager._set(option, value, target);
9184    },
9185
9186    _setAll: function(options, target, allowUnmodifiable) {
9187      if (!options) {
9188        return false;
9189      }
9190
9191      var name;
9192      var changed = false;
9193
9194      for (name in options) {
9195        if (Utilities_1.hasOwn(options, name) && this._set(name, options[name], target, allowUnmodifiable)) {
9196          changed = true;
9197        }
9198      }
9199
9200      return changed;
9201    }
9202
9203  }, {
9204
9205    _createAccessor: function(option, target, changeHandler) {
9206      var descriptor = {
9207        get: function() {
9208          return OptionManager._get(option, target);
9209        }
9210      };
9211
9212      if (option.modifiable) {
9213        descriptor.set = function(value) {
9214          if (OptionManager._set(option, value, target)) {
9215            changeHandler(value, option);
9216          }
9217        };
9218      }
9219
9220      Object.defineProperty(target, option.name, descriptor);
9221    },
9222
9223    _get: function(option, target) {
9224      return target['_' + option.name];
9225    },
9226
9227    _set: function(option, value, target) {
9228      var fieldName = '_' + option.name;
9229      var oldValue = target[fieldName];
9230      var newValue = option.transform(value != null ? value : option.defaultValue);
9231
9232      target[fieldName] = newValue;
9233
9234      return newValue !== oldValue;
9235    }
9236
9237  });
9238
9239  var OptionManager_1 = OptionManager;
9240
9241  /**
9242   * Called whenever the value of a modifiable {@link Option} is changed on a target object via the defined property's
9243   * setter.
9244   *
9245   * @callback OptionManager~ChangeHandler
9246   * @param {*} value - the new value for <code>option</code> on the target object
9247   * @param {Option} option - the modifable {@link Option} whose value has changed on the target object.
9248   * @return {void}
9249   */
9250
9251  /**
9252   * A basic manager for {@link Service} implementations that are mapped to simple names.
9253   *
9254   * @public
9255   * @class
9256   * @extends Nevis
9257   */
9258  var ServiceManager = lite.extend(function() {
9259    this._services = {};
9260  }, {
9261
9262    /**
9263     * Returns the {@link Service} being managed with the specified <code>name</code>.
9264     *
9265     * @param {string} name - the name of the {@link Service} to be returned
9266     * @return {Service} The {@link Service} is being managed with <code>name</code>.
9267     * @throws {Error} If no {@link Service} is being managed with <code>name</code>.
9268     * @public
9269     * @memberof ServiceManager#
9270     */
9271    getService: function(name) {
9272      var service = this._services[name];
9273      if (!service) {
9274        throw new Error('Service is not being managed with name: ' + name);
9275      }
9276
9277      return service;
9278    },
9279
9280    /**
9281     * Sets the {@link Service} implementation to be managed for the specified <code>name</code> to the
9282     * <code>service</code> provided.
9283     *
9284     * @param {string} name - the name of the {@link Service} to be managed with <code>name</code>
9285     * @param {Service} service - the {@link Service} implementation to be managed
9286     * @return {void}
9287     * @throws {Error} If a {@link Service} is already being managed with the same <code>name</code>.
9288     * @public
9289     * @memberof ServiceManager#
9290     */
9291    setService: function(name, service) {
9292      if (this._services[name]) {
9293        throw new Error('Service is already managed with name: ' + name);
9294      }
9295
9296      if (service) {
9297        this._services[name] = service;
9298      }
9299    }
9300
9301  });
9302
9303  var ServiceManager_1 = ServiceManager;
9304
9305  var optionManager = new OptionManager_1([
9306    new Option_1('background', true, 'white'),
9307    new Option_1('backgroundAlpha', true, 1, Utilities_1.abs),
9308    new Option_1('element'),
9309    new Option_1('foreground', true, 'black'),
9310    new Option_1('foregroundAlpha', true, 1, Utilities_1.abs),
9311    new Option_1('level', true, 'L', Utilities_1.toUpperCase),
9312    new Option_1('mime', true, 'image/png'),
9313    new Option_1('padding', true, null, Utilities_1.abs),
9314    new Option_1('size', true, 100, Utilities_1.abs),
9315    new Option_1('value', true, '')
9316  ]);
9317  var serviceManager = new ServiceManager_1();
9318
9319  /**
9320   * Enables configuration of a QR code generator which uses HTML5 <code>canvas</code> for rendering.
9321   *
9322   * @param {QRious~Options} [options] - the options to be used
9323   * @throws {Error} If any <code>options</code> are invalid.
9324   * @public
9325   * @class
9326   * @extends Nevis
9327   */
9328  var QRious = lite.extend(function(options) {
9329    optionManager.init(options, this, this.update.bind(this));
9330
9331    var element = optionManager.get('element', this);
9332    var elementService = serviceManager.getService('element');
9333    var canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas();
9334    var image = element && elementService.isImage(element) ? element : elementService.createImage();
9335
9336    this._canvasRenderer = new CanvasRenderer_1(this, canvas, true);
9337    this._imageRenderer = new ImageRenderer_1(this, image, image === element);
9338
9339    this.update();
9340  }, {
9341
9342    /**
9343     * Returns all of the options configured for this {@link QRious}.
9344     *
9345     * Any changes made to the returned object will not be reflected in the options themselves or their corresponding
9346     * underlying fields.
9347     *
9348     * @return {Object.<string, *>} A copy of the applied options.
9349     * @public
9350     * @memberof QRious#
9351     */
9352    get: function() {
9353      return optionManager.getAll(this);
9354    },
9355
9356    /**
9357     * Sets all of the specified <code>options</code> and automatically updates this {@link QRious} if any of the
9358     * underlying fields are changed as a result.
9359     *
9360     * This is the preferred method for updating multiple options at one time to avoid unnecessary updates between
9361     * changes.
9362     *
9363     * @param {QRious~Options} options - the options to be set
9364     * @return {void}
9365     * @throws {Error} If any <code>options</code> are invalid or cannot be modified.
9366     * @public
9367     * @memberof QRious#
9368     */
9369    set: function(options) {
9370      if (optionManager.setAll(options, this)) {
9371        this.update();
9372      }
9373    },
9374
9375    /**
9376     * Returns the image data URI for the generated QR code using the <code>mime</code> provided.
9377     *
9378     * @param {string} [mime] - the MIME type for the image
9379     * @return {string} The image data URI for the QR code.
9380     * @public
9381     * @memberof QRious#
9382     */
9383    toDataURL: function(mime) {
9384      return this.canvas.toDataURL(mime || this.mime);
9385    },
9386
9387    /**
9388     * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code.
9389     *
9390     * @return {void}
9391     * @protected
9392     * @memberof QRious#
9393     */
9394    update: function() {
9395      var frame = new Frame_1({
9396        level: this.level,
9397        value: this.value
9398      });
9399
9400      this._canvasRenderer.render(frame);
9401      this._imageRenderer.render(frame);
9402    }
9403
9404  }, {
9405
9406    /**
9407     * Configures the <code>service</code> provided to be used by all {@link QRious} instances.
9408     *
9409     * @param {Service} service - the {@link Service} to be configured
9410     * @return {void}
9411     * @throws {Error} If a {@link Service} has already been configured with the same name.
9412     * @public
9413     * @static
9414     * @memberof QRious
9415     */
9416    use: function(service) {
9417      serviceManager.setService(service.getName(), service);
9418    }
9419
9420  });
9421
9422  Object.defineProperties(QRious.prototype, {
9423
9424    canvas: {
9425      /**
9426       * Returns the <code>canvas</code> element being used to render the QR code for this {@link QRious}.
9427       *
9428       * @return {*} The <code>canvas</code> element.
9429       * @public
9430       * @memberof QRious#
9431       * @alias canvas
9432       */
9433      get: function() {
9434        return this._canvasRenderer.getElement();
9435      }
9436    },
9437
9438    image: {
9439      /**
9440       * Returns the <code>img</code> element being used to render the QR code for this {@link QRious}.
9441       *
9442       * @return {*} The <code>img</code> element.
9443       * @public
9444       * @memberof QRious#
9445       * @alias image
9446       */
9447      get: function() {
9448        return this._imageRenderer.getElement();
9449      }
9450    }
9451
9452  });
9453
9454  var QRious_1$2 = QRious;
9455
9456  /**
9457   * The options used by {@link QRious}.
9458   *
9459   * @typedef {Object} QRious~Options
9460   * @property {string} [background="white"] - The background color to be applied to the QR code.
9461   * @property {number} [backgroundAlpha=1] - The background alpha to be applied to the QR code.
9462   * @property {*} [element] - The element to be used to render the QR code which may either be an <code>canvas</code> or
9463   * <code>img</code>. The element(s) will be created if needed.
9464   * @property {string} [foreground="black"] - The foreground color to be applied to the QR code.
9465   * @property {number} [foregroundAlpha=1] - The foreground alpha to be applied to the QR code.
9466   * @property {string} [level="L"] - The error correction level to be applied to the QR code.
9467   * @property {string} [mime="image/png"] - The MIME type to be used to render the image for the QR code.
9468   * @property {number} [padding] - The padding for the QR code in pixels.
9469   * @property {number} [size=100] - The size of the QR code in pixels.
9470   * @property {string} [value=""] - The value to be encoded within the QR code.
9471   */
9472
9473  var index = QRious_1$2;
9474
9475  /**
9476   * Defines a service contract that must be met by all implementations.
9477   *
9478   * @public
9479   * @class
9480   * @extends Nevis
9481   */
9482  var Service = lite.extend({
9483
9484    /**
9485     * Returns the name of this {@link Service}.
9486     *
9487     * @return {string} The service name.
9488     * @public
9489     * @abstract
9490     * @memberof Service#
9491     */
9492    getName: function() {}
9493
9494  });
9495
9496  var Service_1 = Service;
9497
9498  /**
9499   * A service for working with elements.
9500   *
9501   * @public
9502   * @class
9503   * @extends Service
9504   */
9505  var ElementService = Service_1.extend({
9506
9507    /**
9508     * Creates an instance of a canvas element.
9509     *
9510     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
9511     *
9512     * @return {*} The newly created canvas element.
9513     * @public
9514     * @abstract
9515     * @memberof ElementService#
9516     */
9517    createCanvas: function() {},
9518
9519    /**
9520     * Creates an instance of a image element.
9521     *
9522     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
9523     *
9524     * @return {*} The newly created image element.
9525     * @public
9526     * @abstract
9527     * @memberof ElementService#
9528     */
9529    createImage: function() {},
9530
9531    /**
9532     * @override
9533     */
9534    getName: function() {
9535      return 'element';
9536    },
9537
9538    /**
9539     * Returns whether the specified <code>element</code> is a canvas.
9540     *
9541     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
9542     *
9543     * @param {*} element - the element to be checked
9544     * @return {boolean} <code>true</code> if <code>element</code> is a canvas; otherwise <code>false</code>.
9545     * @public
9546     * @abstract
9547     * @memberof ElementService#
9548     */
9549    isCanvas: function(element) {},
9550
9551    /**
9552     * Returns whether the specified <code>element</code> is an image.
9553     *
9554     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
9555     *
9556     * @param {*} element - the element to be checked
9557     * @return {boolean} <code>true</code> if <code>element</code> is an image; otherwise <code>false</code>.
9558     * @public
9559     * @abstract
9560     * @memberof ElementService#
9561     */
9562    isImage: function(element) {}
9563
9564  });
9565
9566  var ElementService_1 = ElementService;
9567
9568  /**
9569   * An implementation of {@link ElementService} intended for use within a browser environment.
9570   *
9571   * @public
9572   * @class
9573   * @extends ElementService
9574   */
9575  var BrowserElementService = ElementService_1.extend({
9576
9577    /**
9578     * @override
9579     */
9580    createCanvas: function() {
9581      return document.createElement('canvas');
9582    },
9583
9584    /**
9585     * @override
9586     */
9587    createImage: function() {
9588      return document.createElement('img');
9589    },
9590
9591    /**
9592     * @override
9593     */
9594    isCanvas: function(element) {
9595      return element instanceof HTMLCanvasElement;
9596    },
9597
9598    /**
9599     * @override
9600     */
9601    isImage: function(element) {
9602      return element instanceof HTMLImageElement;
9603    }
9604
9605  });
9606
9607  var BrowserElementService_1 = BrowserElementService;
9608
9609  index.use(new BrowserElementService_1());
9610
9611  var QRious_1 = index;
9612
9613  return QRious_1;
9614
9615})));
9616
9617//# sourceMappingURL=qrious.js.map
9617</script>
9617
9618
9619    
vendor: 10,163 bytes, lines 9619-10018
9619<script> /* eslint-disable */ 
9620 /* eslint-disable */ 
9621(function webpackUniversalModuleDefinition(root, factory) {
9622	if(typeof exports === 'object' && typeof module === 'object')
9623		module.exports = factory();
9624	else if(typeof define === 'function' && define.amd)
9625		define("ethAccount", [], factory);
9626	else if(typeof exports === 'object')
9627		exports["ethAccount"] = factory();
9628	else
9629		root["ethAccount"] = factory();
9630})(this, function() {
9631return /******/ (function(modules) { // webpackBootstrap
9632/******/ 	// The module cache
9633/******/ 	var installedModules = {};
9634
9635/******/ 	// The require function
9636/******/ 	function __webpack_require__(moduleId) {
9637
9638/******/ 		// Check if module is in cache
9639/******/ 		if(installedModules[moduleId])
9640/******/ 			return installedModules[moduleId].exports;
9641
9642/******/ 		// Create a new module (and put it into the cache)
9643/******/ 		var module = installedModules[moduleId] = {
9644/******/ 			i: moduleId,
9645/******/ 			l: false,
9646/******/ 			exports: {}
9647/******/ 		};
9648
9649/******/ 		// Execute the module function
9650/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
9651
9652/******/ 		// Flag the module as loaded
9653/******/ 		module.l = true;
9654
9655/******/ 		// Return the exports of the module
9656/******/ 		return module.exports;
9657/******/ 	}
9658
9659
9660/******/ 	// expose the modules object (__webpack_modules__)
9661/******/ 	__webpack_require__.m = modules;
9662
9663/******/ 	// expose the module cache
9664/******/ 	__webpack_require__.c = installedModules;
9665
9666/******/ 	// identity function for calling harmory imports with the correct context
9667/******/ 	__webpack_require__.i = function(value) { return value; };
9668
9669/******/ 	// define getter function for harmory exports
9670/******/ 	__webpack_require__.d = function(exports, name, getter) {
9671/******/ 		Object.defineProperty(exports, name, {
9672/******/ 			configurable: false,
9673/******/ 			enumerable: true,
9674/******/ 			get: getter
9675/******/ 		});
9676/******/ 	};
9677
9678/******/ 	// Object.prototype.hasOwnProperty.call
9679/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
9680
9681/******/ 	// __webpack_public_path__
9682/******/ 	__webpack_require__.p = "";
9683
9684/******/ 	// Load entry module and return exports
9685/******/ 	return __webpack_require__(__webpack_require__.s = 38);
9686/******/ })
9687/************************************************************************/
9688/******/ ([
9689/* 0 */
9690/***/ function(module, exports, __webpack_require__) {
9691
9692"use strict";
9693'use strict';
9694
9695var elliptic = exports;
9696
9697elliptic.version = __webpack_require__(34).version;
9698elliptic.utils = __webpack_require__(26);
9699elliptic.rand = __webpack_require__(12);
9700elliptic.hmacDRBG = __webpack_require__(24);
9701elliptic.curve = __webpack_require__(4);
9702elliptic.curves = __webpack_require__(17);
9703
9704// Protocols
9705elliptic.ec = __webpack_require__(18);
9706elliptic.eddsa = __webpack_require__(21);
9707
9708
9709/***/ },
9710/* 1 */
9711/***/ function(module, exports, __webpack_require__) {
9712
9713/* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
9714  'use strict';
9715
9716  // Utils
9717  function assert (val, msg) {
9718    if (!val) throw new Error(msg || 'Assertion failed');
9719  }
9720
9721  // Could use `inherits` module, but don't want to move from single file
9722  // architecture yet.
9723  function inherits (ctor, superCtor) {
9724    ctor.super_ = superCtor;
9725    var TempCtor = function () {};
9726    TempCtor.prototype = superCtor.prototype;
9727    ctor.prototype = new TempCtor();
9728    ctor.prototype.constructor = ctor;
9729  }
9730
9731  // BN
9732
9733  function BN (number, base, endian) {
9734    if (BN.isBN(number)) {
9735      return number;
9736    }
9737
9738    this.negative = 0;
9739    this.words = null;
9740    this.length = 0;
9741
9742    // Reduction context
9743    this.red = null;
9744
9745    if (number !== null) {
9746      if (base === 'le' || base === 'be') {
9747        endian = base;
9748        base = 10;
9749      }
9750
9751      this._init(number || 0, base || 10, endian || 'be');
9752    }
9753  }
9754  if (typeof module === 'object') {
9755    module.exports = BN;
9756  } else {
9757    exports.BN = BN;
9758  }
9759
9760  BN.BN = BN;
9761  BN.wordSize = 26;
9762
9763  var Buffer;
9764  try {
9765    Buffer = __webpack_require__(3).Buffer;
9766  } catch (e) {
9767  }
9768
9769  BN.isBN = function isBN (num) {
9770    if (num instanceof BN) {
9771      return true;
9772    }
9773
9774    return num !== null && typeof num === 'object' &&
9775      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
9776  };
9777
9778  BN.max = function max (left, right) {
9779    if (left.cmp(right) > 0) return left;
9780    return right;
9781  };
9782
9783  BN.min = function min (left, right) {
9784    if (left.cmp(right) < 0) return left;
9785    return right;
9786  };
9787
9788  BN.prototype._init = function init (number, base, endian) {
9789    if (typeof number === 'number') {
9790      return this._initNumber(number, base, endian);
9791    }
9792
9793    if (typeof number === 'object') {
9794      return this._initArray(number, base, endian);
9795    }
9796
9797    if (base === 'hex') {
9798      base = 16;
9799    }
9800    assert(base === (base | 0) && base >= 2 && base <= 36);
9801
9802    number = number.toString().replace(/\s+/g, '');
9803    var start = 0;
9804    if (number[0] === '-') {
9805      start++;
9806    }
9807
9808    if (base === 16) {
9809      this._parseHex(number, start);
9810    } else {
9811      this._parseBase(number, base, start);
9812    }
9813
9814    if (number[0] === '-') {
9815      this.negative = 1;
9816    }
9817
9818    this.strip();
9819
9820    if (endian !== 'le') return;
9821
9822    this._initArray(this.toArray(), base, endian);
9823  };
9824
9825  BN.prototype._initNumber = function _initNumber (number, base, endian) {
9826    if (number < 0) {
9827      this.negative = 1;
9828      number = -number;
9829    }
9830    if (number < 0x4000000) {
9831      this.words = [ number & 0x3ffffff ];
9832      this.length = 1;
9833    } else if (number < 0x10000000000000) {
9834      this.words = [
9835        number & 0x3ffffff,
9836        (number / 0x4000000) & 0x3ffffff
9837      ];
9838      this.length = 2;
9839    } else {
9840      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
9841      this.words = [
9842        number & 0x3ffffff,
9843        (number / 0x4000000) & 0x3ffffff,
9844        1
9845      ];
9846      this.length = 3;
9847    }
9848
9849    if (endian !== 'le') return;
9850
9851    // Reverse the bytes
9852    this._initArray(this.toArray(), base, endian);
9853  };
9854
9855  BN.prototype._initArray = function _initArray (number, base, endian) {
9856    // Perhaps a Uint8Array
9857    assert(typeof number.length === 'number');
9858    if (number.length <= 0) {
9859      this.words = [ 0 ];
9860      this.length = 1;
9861      return this;
9862    }
9863
9864    this.length = Math.ceil(number.length / 3);
9865    this.words = new Array(this.length);
9866    for (var i = 0; i < this.length; i++) {
9867      this.words[i] = 0;
9868    }
9869
9870    var j, w;
9871    var off = 0;
9872    if (endian === 'be') {
9873      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
9874        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
9875        this.words[j] |= (w << off) & 0x3ffffff;
9876        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
9877        off += 24;
9878        if (off >= 26) {
9879          off -= 26;
9880          j++;
9881        }
9882      }
9883    } else if (endian === 'le') {
9884      for (i = 0, j = 0; i < number.length; i += 3) {
9885        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
9886        this.words[j] |= (w << off) & 0x3ffffff;
9887        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
9888        off += 24;
9889        if (off >= 26) {
9890          off -= 26;
9891          j++;
9892        }
9893      }
9894    }
9895    return this.strip();
9896  };
9897
9898  function parseHex (str, start, end) {
9899    var r = 0;
9900    var len = Math.min(str.length, end);
9901    for (var i = start; i < len; i++) {
9902      var c = str.charCodeAt(i) - 48;
9903
9904      r <<= 4;
9905
9906      // 'a' - 'f'
9907      if (c >= 49 && c <= 54) {
9908        r |= c - 49 + 0xa;
9909
9910      // 'A' - 'F'
9911      } else if (c >= 17 && c <= 22) {
9912        r |= c - 17 + 0xa;
9913
9914      // '0' - '9'
9915      } else {
9916        r |= c & 0xf;
9917      }
9918    }
9919    return r;
9920  }
9921
9922  BN.prototype._parseHex = function _parseHex (number, start) {
9923    // Create possibly bigger array to ensure that it fits the number
9924    this.length = Math.ceil((number.length - start) / 6);
9925    this.words = new Array(this.length);
9926    for (var i = 0; i < this.length; i++) {
9927      this.words[i] = 0;
9928    }
9929
9930    var j, w;
9931    // Scan 24-bit chunks and add them to the number
9932    var off = 0;
9933    for (i = number.length - 6, j = 0; i >= start; i -= 6) {
9934      w = parseHex(number, i, i + 6);
9935      this.words[j] |= (w << off) & 0x3ffffff;
9936      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
9937      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
9938      off += 24;
9939      if (off >= 26) {
9940        off -= 26;
9941        j++;
9942      }
9943    }
9944    if (i + 6 !== start) {
9945      w = parseHex(number, start, i + 6);
9946      this.words[j] |= (w << off) & 0x3ffffff;
9947      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
9948    }
9949    this.strip();
9950  };
9951
9952  function parseBase (str, start, end, mul) {
9953    var r = 0;
9954    var len = Math.min(str.length, end);
9955    for (var i = start; i < len; i++) {
9956      var c = str.charCodeAt(i) - 48;
9957
9958      r *= mul;
9959
9960      // 'a'
9961      if (c >= 49) {
9962        r += c - 49 + 0xa;
9963
9964      // 'A'
9965      } else if (c >= 17) {
9966        r += c - 17 + 0xa;
9967
9968      // '0' - '9'
9969      } else {
9970        r += c;
9971      }
9972    }
9973    return r;
9974  }
9975
9976  BN.prototype._parseBase = function _parseBase (number, base, start) {
9977    // Initialize as zero
9978    this.words = [ 0 ];
9979    this.length = 1;
9980
9981    // Find length of limb in base
9982    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
9983      limbLen++;
9984    }
9985    limbLen--;
9986    limbPow = (limbPow / base) | 0;
9987
9988    var total = number.length - start;
9989    var mod = total % limbLen;
9990    var end = Math.min(total, total - mod) + start;
9991
9992    var word = 0;
9993    for (var i = start; i < end; i += limbLen) {
9994      word = parseBase(number, i, i + limbLen, base);
9995
9996      this.imuln(limbPow);
9997      if (this.words[0] + word < 0x4000000) {
9998        this.words[0] += word;
9999      } else {
10000        this._iaddn(word);
10001      }
10002    }
10003
10004    if (mod !== 0) {
10005      var pow = 1;
10006      word = parseBase(number, i, number.length, base);
10007
10008      for (i = 0; i < mod; i++) {
10009        pow *= base;
10010      }
10011
10012      this.imuln(pow);
10013      if (this.words[0] + word < 0x4000000) {
10014        this.words[0] += word;
10015      } else {
10016        this._iaddn(word);
10017      }
10018    }
vendor: 68,018 bytes, lines 10018-12622
10018
10019  };
10020
10021  BN.prototype.copy = function copy (dest) {
10022    dest.words = new Array(this.length);
10023    for (var i = 0; i < this.length; i++) {
10024      dest.words[i] = this.words[i];
10025    }
10026    dest.length = this.length;
10027    dest.negative = this.negative;
10028    dest.red = this.red;
10029  };
10030
10031  BN.prototype.clone = function clone () {
10032    var r = new BN(null);
10033    this.copy(r);
10034    return r;
10035  };
10036
10037  BN.prototype._expand = function _expand (size) {
10038    while (this.length < size) {
10039      this.words[this.length++] = 0;
10040    }
10041    return this;
10042  };
10043
10044  // Remove leading `0` from `this`
10045  BN.prototype.strip = function strip () {
10046    while (this.length > 1 && this.words[this.length - 1] === 0) {
10047      this.length--;
10048    }
10049    return this._normSign();
10050  };
10051
10052  BN.prototype._normSign = function _normSign () {
10053    // -0 = 0
10054    if (this.length === 1 && this.words[0] === 0) {
10055      this.negative = 0;
10056    }
10057    return this;
10058  };
10059
10060  BN.prototype.inspect = function inspect () {
10061    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
10062  };
10063
10064  /*
10065
10066  var zeros = [];
10067  var groupSizes = [];
10068  var groupBases = [];
10069
10070  var s = '';
10071  var i = -1;
10072  while (++i < BN.wordSize) {
10073    zeros[i] = s;
10074    s += '0';
10075  }
10076  groupSizes[0] = 0;
10077  groupSizes[1] = 0;
10078  groupBases[0] = 0;
10079  groupBases[1] = 0;
10080  var base = 2 - 1;
10081  while (++base < 36 + 1) {
10082    var groupSize = 0;
10083    var groupBase = 1;
10084    while (groupBase < (1 << BN.wordSize) / base) {
10085      groupBase *= base;
10086      groupSize += 1;
10087    }
10088    groupSizes[base] = groupSize;
10089    groupBases[base] = groupBase;
10090  }
10091
10092  */
10093
10094  var zeros = [
10095    '',
10096    '0',
10097    '00',
10098    '000',
10099    '0000',
10100    '00000',
10101    '000000',
10102    '0000000',
10103    '00000000',
10104    '000000000',
10105    '0000000000',
10106    '00000000000',
10107    '000000000000',
10108    '0000000000000',
10109    '00000000000000',
10110    '000000000000000',
10111    '0000000000000000',
10112    '00000000000000000',
10113    '000000000000000000',
10114    '0000000000000000000',
10115    '00000000000000000000',
10116    '000000000000000000000',
10117    '0000000000000000000000',
10118    '00000000000000000000000',
10119    '000000000000000000000000',
10120    '0000000000000000000000000'
10121  ];
10122
10123  var groupSizes = [
10124    0, 0,
10125    25, 16, 12, 11, 10, 9, 8,
10126    8, 7, 7, 7, 7, 6, 6,
10127    6, 6, 6, 6, 6, 5, 5,
10128    5, 5, 5, 5, 5, 5, 5,
10129    5, 5, 5, 5, 5, 5, 5
10130  ];
10131
10132  var groupBases = [
10133    0, 0,
10134    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
10135    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
10136    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
10137    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
10138    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
10139  ];
10140
10141  BN.prototype.toString = function toString (base, padding) {
10142    base = base || 10;
10143    padding = padding | 0 || 1;
10144
10145    var out;
10146    if (base === 16 || base === 'hex') {
10147      out = '';
10148      var off = 0;
10149      var carry = 0;
10150      for (var i = 0; i < this.length; i++) {
10151        var w = this.words[i];
10152        var word = (((w << off) | carry) & 0xffffff).toString(16);
10153        carry = (w >>> (24 - off)) & 0xffffff;
10154        if (carry !== 0 || i !== this.length - 1) {
10155          out = zeros[6 - word.length] + word + out;
10156        } else {
10157          out = word + out;
10158        }
10159        off += 2;
10160        if (off >= 26) {
10161          off -= 26;
10162          i--;
10163        }
10164      }
10165      if (carry !== 0) {
10166        out = carry.toString(16) + out;
10167      }
10168      while (out.length % padding !== 0) {
10169        out = '0' + out;
10170      }
10171      if (this.negative !== 0) {
10172        out = '-' + out;
10173      }
10174      return out;
10175    }
10176
10177    if (base === (base | 0) && base >= 2 && base <= 36) {
10178      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
10179      var groupSize = groupSizes[base];
10180      // var groupBase = Math.pow(base, groupSize);
10181      var groupBase = groupBases[base];
10182      out = '';
10183      var c = this.clone();
10184      c.negative = 0;
10185      while (!c.isZero()) {
10186        var r = c.modn(groupBase).toString(base);
10187        c = c.idivn(groupBase);
10188
10189        if (!c.isZero()) {
10190          out = zeros[groupSize - r.length] + r + out;
10191        } else {
10192          out = r + out;
10193        }
10194      }
10195      if (this.isZero()) {
10196        out = '0' + out;
10197      }
10198      while (out.length % padding !== 0) {
10199        out = '0' + out;
10200      }
10201      if (this.negative !== 0) {
10202        out = '-' + out;
10203      }
10204      return out;
10205    }
10206
10207    assert(false, 'Base should be between 2 and 36');
10208  };
10209
10210  BN.prototype.toNumber = function toNumber () {
10211    var ret = this.words[0];
10212    if (this.length === 2) {
10213      ret += this.words[1] * 0x4000000;
10214    } else if (this.length === 3 && this.words[2] === 0x01) {
10215      // NOTE: at this stage it is known that the top bit is set
10216      ret += 0x10000000000000 + (this.words[1] * 0x4000000);
10217    } else if (this.length > 2) {
10218      assert(false, 'Number can only safely store up to 53 bits');
10219    }
10220    return (this.negative !== 0) ? -ret : ret;
10221  };
10222
10223  BN.prototype.toJSON = function toJSON () {
10224    return this.toString(16);
10225  };
10226
10227  BN.prototype.toBuffer = function toBuffer (endian, length) {
10228    assert(typeof Buffer !== 'undefined');
10229    return this.toArrayLike(Buffer, endian, length);
10230  };
10231
10232  BN.prototype.toArray = function toArray (endian, length) {
10233    return this.toArrayLike(Array, endian, length);
10234  };
10235
10236  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
10237    var byteLength = this.byteLength();
10238    var reqLength = length || Math.max(1, byteLength);
10239    assert(byteLength <= reqLength, 'byte array longer than desired length');
10240    assert(reqLength > 0, 'Requested array length <= 0');
10241
10242    this.strip();
10243    var littleEndian = endian === 'le';
10244    var res = new ArrayType(reqLength);
10245
10246    var b, i;
10247    var q = this.clone();
10248    if (!littleEndian) {
10249      // Assume big-endian
10250      for (i = 0; i < reqLength - byteLength; i++) {
10251        res[i] = 0;
10252      }
10253
10254      for (i = 0; !q.isZero(); i++) {
10255        b = q.andln(0xff);
10256        q.iushrn(8);
10257
10258        res[reqLength - i - 1] = b;
10259      }
10260    } else {
10261      for (i = 0; !q.isZero(); i++) {
10262        b = q.andln(0xff);
10263        q.iushrn(8);
10264
10265        res[i] = b;
10266      }
10267
10268      for (; i < reqLength; i++) {
10269        res[i] = 0;
10270      }
10271    }
10272
10273    return res;
10274  };
10275
10276  if (Math.clz32) {
10277    BN.prototype._countBits = function _countBits (w) {
10278      return 32 - Math.clz32(w);
10279    };
10280  } else {
10281    BN.prototype._countBits = function _countBits (w) {
10282      var t = w;
10283      var r = 0;
10284      if (t >= 0x1000) {
10285        r += 13;
10286        t >>>= 13;
10287      }
10288      if (t >= 0x40) {
10289        r += 7;
10290        t >>>= 7;
10291      }
10292      if (t >= 0x8) {
10293        r += 4;
10294        t >>>= 4;
10295      }
10296      if (t >= 0x02) {
10297        r += 2;
10298        t >>>= 2;
10299      }
10300      return r + t;
10301    };
10302  }
10303
10304  BN.prototype._zeroBits = function _zeroBits (w) {
10305    // Short-cut
10306    if (w === 0) return 26;
10307
10308    var t = w;
10309    var r = 0;
10310    if ((t & 0x1fff) === 0) {
10311      r += 13;
10312      t >>>= 13;
10313    }
10314    if ((t & 0x7f) === 0) {
10315      r += 7;
10316      t >>>= 7;
10317    }
10318    if ((t & 0xf) === 0) {
10319      r += 4;
10320      t >>>= 4;
10321    }
10322    if ((t & 0x3) === 0) {
10323      r += 2;
10324      t >>>= 2;
10325    }
10326    if ((t & 0x1) === 0) {
10327      r++;
10328    }
10329    return r;
10330  };
10331
10332  // Return number of used bits in a BN
10333  BN.prototype.bitLength = function bitLength () {
10334    var w = this.words[this.length - 1];
10335    var hi = this._countBits(w);
10336    return (this.length - 1) * 26 + hi;
10337  };
10338
10339  function toBitArray (num) {
10340    var w = new Array(num.bitLength());
10341
10342    for (var bit = 0; bit < w.length; bit++) {
10343      var off = (bit / 26) | 0;
10344      var wbit = bit % 26;
10345
10346      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
10347    }
10348
10349    return w;
10350  }
10351
10352  // Number of trailing zero bits
10353  BN.prototype.zeroBits = function zeroBits () {
10354    if (this.isZero()) return 0;
10355
10356    var r = 0;
10357    for (var i = 0; i < this.length; i++) {
10358      var b = this._zeroBits(this.words[i]);
10359      r += b;
10360      if (b !== 26) break;
10361    }
10362    return r;
10363  };
10364
10365  BN.prototype.byteLength = function byteLength () {
10366    return Math.ceil(this.bitLength() / 8);
10367  };
10368
10369  BN.prototype.toTwos = function toTwos (width) {
10370    if (this.negative !== 0) {
10371      return this.abs().inotn(width).iaddn(1);
10372    }
10373    return this.clone();
10374  };
10375
10376  BN.prototype.fromTwos = function fromTwos (width) {
10377    if (this.testn(width - 1)) {
10378      return this.notn(width).iaddn(1).ineg();
10379    }
10380    return this.clone();
10381  };
10382
10383  BN.prototype.isNeg = function isNeg () {
10384    return this.negative !== 0;
10385  };
10386
10387  // Return negative clone of `this`
10388  BN.prototype.neg = function neg () {
10389    return this.clone().ineg();
10390  };
10391
10392  BN.prototype.ineg = function ineg () {
10393    if (!this.isZero()) {
10394      this.negative ^= 1;
10395    }
10396
10397    return this;
10398  };
10399
10400  // Or `num` with `this` in-place
10401  BN.prototype.iuor = function iuor (num) {
10402    while (this.length < num.length) {
10403      this.words[this.length++] = 0;
10404    }
10405
10406    for (var i = 0; i < num.length; i++) {
10407      this.words[i] = this.words[i] | num.words[i];
10408    }
10409
10410    return this.strip();
10411  };
10412
10413  BN.prototype.ior = function ior (num) {
10414    assert((this.negative | num.negative) === 0);
10415    return this.iuor(num);
10416  };
10417
10418  // Or `num` with `this`
10419  BN.prototype.or = function or (num) {
10420    if (this.length > num.length) return this.clone().ior(num);
10421    return num.clone().ior(this);
10422  };
10423
10424  BN.prototype.uor = function uor (num) {
10425    if (this.length > num.length) return this.clone().iuor(num);
10426    return num.clone().iuor(this);
10427  };
10428
10429  // And `num` with `this` in-place
10430  BN.prototype.iuand = function iuand (num) {
10431    // b = min-length(num, this)
10432    var b;
10433    if (this.length > num.length) {
10434      b = num;
10435    } else {
10436      b = this;
10437    }
10438
10439    for (var i = 0; i < b.length; i++) {
10440      this.words[i] = this.words[i] & num.words[i];
10441    }
10442
10443    this.length = b.length;
10444
10445    return this.strip();
10446  };
10447
10448  BN.prototype.iand = function iand (num) {
10449    assert((this.negative | num.negative) === 0);
10450    return this.iuand(num);
10451  };
10452
10453  // And `num` with `this`
10454  BN.prototype.and = function and (num) {
10455    if (this.length > num.length) return this.clone().iand(num);
10456    return num.clone().iand(this);
10457  };
10458
10459  BN.prototype.uand = function uand (num) {
10460    if (this.length > num.length) return this.clone().iuand(num);
10461    return num.clone().iuand(this);
10462  };
10463
10464  // Xor `num` with `this` in-place
10465  BN.prototype.iuxor = function iuxor (num) {
10466    // a.length > b.length
10467    var a;
10468    var b;
10469    if (this.length > num.length) {
10470      a = this;
10471      b = num;
10472    } else {
10473      a = num;
10474      b = this;
10475    }
10476
10477    for (var i = 0; i < b.length; i++) {
10478      this.words[i] = a.words[i] ^ b.words[i];
10479    }
10480
10481    if (this !== a) {
10482      for (; i < a.length; i++) {
10483        this.words[i] = a.words[i];
10484      }
10485    }
10486
10487    this.length = a.length;
10488
10489    return this.strip();
10490  };
10491
10492  BN.prototype.ixor = function ixor (num) {
10493    assert((this.negative | num.negative) === 0);
10494    return this.iuxor(num);
10495  };
10496
10497  // Xor `num` with `this`
10498  BN.prototype.xor = function xor (num) {
10499    if (this.length > num.length) return this.clone().ixor(num);
10500    return num.clone().ixor(this);
10501  };
10502
10503  BN.prototype.uxor = function uxor (num) {
10504    if (this.length > num.length) return this.clone().iuxor(num);
10505    return num.clone().iuxor(this);
10506  };
10507
10508  // Not ``this`` with ``width`` bitwidth
10509  BN.prototype.inotn = function inotn (width) {
10510    assert(typeof width === 'number' && width >= 0);
10511
10512    var bytesNeeded = Math.ceil(width / 26) | 0;
10513    var bitsLeft = width % 26;
10514
10515    // Extend the buffer with leading zeroes
10516    this._expand(bytesNeeded);
10517
10518    if (bitsLeft > 0) {
10519      bytesNeeded--;
10520    }
10521
10522    // Handle complete words
10523    for (var i = 0; i < bytesNeeded; i++) {
10524      this.words[i] = ~this.words[i] & 0x3ffffff;
10525    }
10526
10527    // Handle the residue
10528    if (bitsLeft > 0) {
10529      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
10530    }
10531
10532    // And remove leading zeroes
10533    return this.strip();
10534  };
10535
10536  BN.prototype.notn = function notn (width) {
10537    return this.clone().inotn(width);
10538  };
10539
10540  // Set `bit` of `this`
10541  BN.prototype.setn = function setn (bit, val) {
10542    assert(typeof bit === 'number' && bit >= 0);
10543
10544    var off = (bit / 26) | 0;
10545    var wbit = bit % 26;
10546
10547    this._expand(off + 1);
10548
10549    if (val) {
10550      this.words[off] = this.words[off] | (1 << wbit);
10551    } else {
10552      this.words[off] = this.words[off] & ~(1 << wbit);
10553    }
10554
10555    return this.strip();
10556  };
10557
10558  // Add `num` to `this` in-place
10559  BN.prototype.iadd = function iadd (num) {
10560    var r;
10561
10562    // negative + positive
10563    if (this.negative !== 0 && num.negative === 0) {
10564      this.negative = 0;
10565      r = this.isub(num);
10566      this.negative ^= 1;
10567      return this._normSign();
10568
10569    // positive + negative
10570    } else if (this.negative === 0 && num.negative !== 0) {
10571      num.negative = 0;
10572      r = this.isub(num);
10573      num.negative = 1;
10574      return r._normSign();
10575    }
10576
10577    // a.length > b.length
10578    var a, b;
10579    if (this.length > num.length) {
10580      a = this;
10581      b = num;
10582    } else {
10583      a = num;
10584      b = this;
10585    }
10586
10587    var carry = 0;
10588    for (var i = 0; i < b.length; i++) {
10589      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
10590      this.words[i] = r & 0x3ffffff;
10591      carry = r >>> 26;
10592    }
10593    for (; carry !== 0 && i < a.length; i++) {
10594      r = (a.words[i] | 0) + carry;
10595      this.words[i] = r & 0x3ffffff;
10596      carry = r >>> 26;
10597    }
10598
10599    this.length = a.length;
10600    if (carry !== 0) {
10601      this.words[this.length] = carry;
10602      this.length++;
10603    // Copy the rest of the words
10604    } else if (a !== this) {
10605      for (; i < a.length; i++) {
10606        this.words[i] = a.words[i];
10607      }
10608    }
10609
10610    return this;
10611  };
10612
10613  // Add `num` to `this`
10614  BN.prototype.add = function add (num) {
10615    var res;
10616    if (num.negative !== 0 && this.negative === 0) {
10617      num.negative = 0;
10618      res = this.sub(num);
10619      num.negative ^= 1;
10620      return res;
10621    } else if (num.negative === 0 && this.negative !== 0) {
10622      this.negative = 0;
10623      res = num.sub(this);
10624      this.negative = 1;
10625      return res;
10626    }
10627
10628    if (this.length > num.length) return this.clone().iadd(num);
10629
10630    return num.clone().iadd(this);
10631  };
10632
10633  // Subtract `num` from `this` in-place
10634  BN.prototype.isub = function isub (num) {
10635    // this - (-num) = this + num
10636    if (num.negative !== 0) {
10637      num.negative = 0;
10638      var r = this.iadd(num);
10639      num.negative = 1;
10640      return r._normSign();
10641
10642    // -this - num = -(this + num)
10643    } else if (this.negative !== 0) {
10644      this.negative = 0;
10645      this.iadd(num);
10646      this.negative = 1;
10647      return this._normSign();
10648    }
10649
10650    // At this point both numbers are positive
10651    var cmp = this.cmp(num);
10652
10653    // Optimization - zeroify
10654    if (cmp === 0) {
10655      this.negative = 0;
10656      this.length = 1;
10657      this.words[0] = 0;
10658      return this;
10659    }
10660
10661    // a > b
10662    var a, b;
10663    if (cmp > 0) {
10664      a = this;
10665      b = num;
10666    } else {
10667      a = num;
10668      b = this;
10669    }
10670
10671    var carry = 0;
10672    for (var i = 0; i < b.length; i++) {
10673      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
10674      carry = r >> 26;
10675      this.words[i] = r & 0x3ffffff;
10676    }
10677    for (; carry !== 0 && i < a.length; i++) {
10678      r = (a.words[i] | 0) + carry;
10679      carry = r >> 26;
10680      this.words[i] = r & 0x3ffffff;
10681    }
10682
10683    // Copy rest of the words
10684    if (carry === 0 && i < a.length && a !== this) {
10685      for (; i < a.length; i++) {
10686        this.words[i] = a.words[i];
10687      }
10688    }
10689
10690    this.length = Math.max(this.length, i);
10691
10692    if (a !== this) {
10693      this.negative = 1;
10694    }
10695
10696    return this.strip();
10697  };
10698
10699  // Subtract `num` from `this`
10700  BN.prototype.sub = function sub (num) {
10701    return this.clone().isub(num);
10702  };
10703
10704  function smallMulTo (self, num, out) {
10705    out.negative = num.negative ^ self.negative;
10706    var len = (self.length + num.length) | 0;
10707    out.length = len;
10708    len = (len - 1) | 0;
10709
10710    // Peel one iteration (compiler can't do it, because of code complexity)
10711    var a = self.words[0] | 0;
10712    var b = num.words[0] | 0;
10713    var r = a * b;
10714
10715    var lo = r & 0x3ffffff;
10716    var carry = (r / 0x4000000) | 0;
10717    out.words[0] = lo;
10718
10719    for (var k = 1; k < len; k++) {
10720      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
10721      // note that ncarry could be >= 0x3ffffff
10722      var ncarry = carry >>> 26;
10723      var rword = carry & 0x3ffffff;
10724      var maxJ = Math.min(k, num.length - 1);
10725      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
10726        var i = (k - j) | 0;
10727        a = self.words[i] | 0;
10728        b = num.words[j] | 0;
10729        r = a * b + rword;
10730        ncarry += (r / 0x4000000) | 0;
10731        rword = r & 0x3ffffff;
10732      }
10733      out.words[k] = rword | 0;
10734      carry = ncarry | 0;
10735    }
10736    if (carry !== 0) {
10737      out.words[k] = carry | 0;
10738    } else {
10739      out.length--;
10740    }
10741
10742    return out.strip();
10743  }
10744
10745  // TODO(indutny): it may be reasonable to omit it for users who don't need
10746  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
10747  // multiplication (like elliptic secp256k1).
10748  var comb10MulTo = function comb10MulTo (self, num, out) {
10749    var a = self.words;
10750    var b = num.words;
10751    var o = out.words;
10752    var c = 0;
10753    var lo;
10754    var mid;
10755    var hi;
10756    var a0 = a[0] | 0;
10757    var al0 = a0 & 0x1fff;
10758    var ah0 = a0 >>> 13;
10759    var a1 = a[1] | 0;
10760    var al1 = a1 & 0x1fff;
10761    var ah1 = a1 >>> 13;
10762    var a2 = a[2] | 0;
10763    var al2 = a2 & 0x1fff;
10764    var ah2 = a2 >>> 13;
10765    var a3 = a[3] | 0;
10766    var al3 = a3 & 0x1fff;
10767    var ah3 = a3 >>> 13;
10768    var a4 = a[4] | 0;
10769    var al4 = a4 & 0x1fff;
10770    var ah4 = a4 >>> 13;
10771    var a5 = a[5] | 0;
10772    var al5 = a5 & 0x1fff;
10773    var ah5 = a5 >>> 13;
10774    var a6 = a[6] | 0;
10775    var al6 = a6 & 0x1fff;
10776    var ah6 = a6 >>> 13;
10777    var a7 = a[7] | 0;
10778    var al7 = a7 & 0x1fff;
10779    var ah7 = a7 >>> 13;
10780    var a8 = a[8] | 0;
10781    var al8 = a8 & 0x1fff;
10782    var ah8 = a8 >>> 13;
10783    var a9 = a[9] | 0;
10784    var al9 = a9 & 0x1fff;
10785    var ah9 = a9 >>> 13;
10786    var b0 = b[0] | 0;
10787    var bl0 = b0 & 0x1fff;
10788    var bh0 = b0 >>> 13;
10789    var b1 = b[1] | 0;
10790    var bl1 = b1 & 0x1fff;
10791    var bh1 = b1 >>> 13;
10792    var b2 = b[2] | 0;
10793    var bl2 = b2 & 0x1fff;
10794    var bh2 = b2 >>> 13;
10795    var b3 = b[3] | 0;
10796    var bl3 = b3 & 0x1fff;
10797    var bh3 = b3 >>> 13;
10798    var b4 = b[4] | 0;
10799    var bl4 = b4 & 0x1fff;
10800    var bh4 = b4 >>> 13;
10801    var b5 = b[5] | 0;
10802    var bl5 = b5 & 0x1fff;
10803    var bh5 = b5 >>> 13;
10804    var b6 = b[6] | 0;
10805    var bl6 = b6 & 0x1fff;
10806    var bh6 = b6 >>> 13;
10807    var b7 = b[7] | 0;
10808    var bl7 = b7 & 0x1fff;
10809    var bh7 = b7 >>> 13;
10810    var b8 = b[8] | 0;
10811    var bl8 = b8 & 0x1fff;
10812    var bh8 = b8 >>> 13;
10813    var b9 = b[9] | 0;
10814    var bl9 = b9 & 0x1fff;
10815    var bh9 = b9 >>> 13;
10816
10817    out.negative = self.negative ^ num.negative;
10818    out.length = 19;
10819    /* k = 0 */
10820    lo = Math.imul(al0, bl0);
10821    mid = Math.imul(al0, bh0);
10822    mid = (mid + Math.imul(ah0, bl0)) | 0;
10823    hi = Math.imul(ah0, bh0);
10824    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10825    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
10826    w0 &= 0x3ffffff;
10827    /* k = 1 */
10828    lo = Math.imul(al1, bl0);
10829    mid = Math.imul(al1, bh0);
10830    mid = (mid + Math.imul(ah1, bl0)) | 0;
10831    hi = Math.imul(ah1, bh0);
10832    lo = (lo + Math.imul(al0, bl1)) | 0;
10833    mid = (mid + Math.imul(al0, bh1)) | 0;
10834    mid = (mid + Math.imul(ah0, bl1)) | 0;
10835    hi = (hi + Math.imul(ah0, bh1)) | 0;
10836    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10837    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
10838    w1 &= 0x3ffffff;
10839    /* k = 2 */
10840    lo = Math.imul(al2, bl0);
10841    mid = Math.imul(al2, bh0);
10842    mid = (mid + Math.imul(ah2, bl0)) | 0;
10843    hi = Math.imul(ah2, bh0);
10844    lo = (lo + Math.imul(al1, bl1)) | 0;
10845    mid = (mid + Math.imul(al1, bh1)) | 0;
10846    mid = (mid + Math.imul(ah1, bl1)) | 0;
10847    hi = (hi + Math.imul(ah1, bh1)) | 0;
10848    lo = (lo + Math.imul(al0, bl2)) | 0;
10849    mid = (mid + Math.imul(al0, bh2)) | 0;
10850    mid = (mid + Math.imul(ah0, bl2)) | 0;
10851    hi = (hi + Math.imul(ah0, bh2)) | 0;
10852    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10853    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
10854    w2 &= 0x3ffffff;
10855    /* k = 3 */
10856    lo = Math.imul(al3, bl0);
10857    mid = Math.imul(al3, bh0);
10858    mid = (mid + Math.imul(ah3, bl0)) | 0;
10859    hi = Math.imul(ah3, bh0);
10860    lo = (lo + Math.imul(al2, bl1)) | 0;
10861    mid = (mid + Math.imul(al2, bh1)) | 0;
10862    mid = (mid + Math.imul(ah2, bl1)) | 0;
10863    hi = (hi + Math.imul(ah2, bh1)) | 0;
10864    lo = (lo + Math.imul(al1, bl2)) | 0;
10865    mid = (mid + Math.imul(al1, bh2)) | 0;
10866    mid = (mid + Math.imul(ah1, bl2)) | 0;
10867    hi = (hi + Math.imul(ah1, bh2)) | 0;
10868    lo = (lo + Math.imul(al0, bl3)) | 0;
10869    mid = (mid + Math.imul(al0, bh3)) | 0;
10870    mid = (mid + Math.imul(ah0, bl3)) | 0;
10871    hi = (hi + Math.imul(ah0, bh3)) | 0;
10872    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10873    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
10874    w3 &= 0x3ffffff;
10875    /* k = 4 */
10876    lo = Math.imul(al4, bl0);
10877    mid = Math.imul(al4, bh0);
10878    mid = (mid + Math.imul(ah4, bl0)) | 0;
10879    hi = Math.imul(ah4, bh0);
10880    lo = (lo + Math.imul(al3, bl1)) | 0;
10881    mid = (mid + Math.imul(al3, bh1)) | 0;
10882    mid = (mid + Math.imul(ah3, bl1)) | 0;
10883    hi = (hi + Math.imul(ah3, bh1)) | 0;
10884    lo = (lo + Math.imul(al2, bl2)) | 0;
10885    mid = (mid + Math.imul(al2, bh2)) | 0;
10886    mid = (mid + Math.imul(ah2, bl2)) | 0;
10887    hi = (hi + Math.imul(ah2, bh2)) | 0;
10888    lo = (lo + Math.imul(al1, bl3)) | 0;
10889    mid = (mid + Math.imul(al1, bh3)) | 0;
10890    mid = (mid + Math.imul(ah1, bl3)) | 0;
10891    hi = (hi + Math.imul(ah1, bh3)) | 0;
10892    lo = (lo + Math.imul(al0, bl4)) | 0;
10893    mid = (mid + Math.imul(al0, bh4)) | 0;
10894    mid = (mid + Math.imul(ah0, bl4)) | 0;
10895    hi = (hi + Math.imul(ah0, bh4)) | 0;
10896    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10897    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
10898    w4 &= 0x3ffffff;
10899    /* k = 5 */
10900    lo = Math.imul(al5, bl0);
10901    mid = Math.imul(al5, bh0);
10902    mid = (mid + Math.imul(ah5, bl0)) | 0;
10903    hi = Math.imul(ah5, bh0);
10904    lo = (lo + Math.imul(al4, bl1)) | 0;
10905    mid = (mid + Math.imul(al4, bh1)) | 0;
10906    mid = (mid + Math.imul(ah4, bl1)) | 0;
10907    hi = (hi + Math.imul(ah4, bh1)) | 0;
10908    lo = (lo + Math.imul(al3, bl2)) | 0;
10909    mid = (mid + Math.imul(al3, bh2)) | 0;
10910    mid = (mid + Math.imul(ah3, bl2)) | 0;
10911    hi = (hi + Math.imul(ah3, bh2)) | 0;
10912    lo = (lo + Math.imul(al2, bl3)) | 0;
10913    mid = (mid + Math.imul(al2, bh3)) | 0;
10914    mid = (mid + Math.imul(ah2, bl3)) | 0;
10915    hi = (hi + Math.imul(ah2, bh3)) | 0;
10916    lo = (lo + Math.imul(al1, bl4)) | 0;
10917    mid = (mid + Math.imul(al1, bh4)) | 0;
10918    mid = (mid + Math.imul(ah1, bl4)) | 0;
10919    hi = (hi + Math.imul(ah1, bh4)) | 0;
10920    lo = (lo + Math.imul(al0, bl5)) | 0;
10921    mid = (mid + Math.imul(al0, bh5)) | 0;
10922    mid = (mid + Math.imul(ah0, bl5)) | 0;
10923    hi = (hi + Math.imul(ah0, bh5)) | 0;
10924    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10925    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
10926    w5 &= 0x3ffffff;
10927    /* k = 6 */
10928    lo = Math.imul(al6, bl0);
10929    mid = Math.imul(al6, bh0);
10930    mid = (mid + Math.imul(ah6, bl0)) | 0;
10931    hi = Math.imul(ah6, bh0);
10932    lo = (lo + Math.imul(al5, bl1)) | 0;
10933    mid = (mid + Math.imul(al5, bh1)) | 0;
10934    mid = (mid + Math.imul(ah5, bl1)) | 0;
10935    hi = (hi + Math.imul(ah5, bh1)) | 0;
10936    lo = (lo + Math.imul(al4, bl2)) | 0;
10937    mid = (mid + Math.imul(al4, bh2)) | 0;
10938    mid = (mid + Math.imul(ah4, bl2)) | 0;
10939    hi = (hi + Math.imul(ah4, bh2)) | 0;
10940    lo = (lo + Math.imul(al3, bl3)) | 0;
10941    mid = (mid + Math.imul(al3, bh3)) | 0;
10942    mid = (mid + Math.imul(ah3, bl3)) | 0;
10943    hi = (hi + Math.imul(ah3, bh3)) | 0;
10944    lo = (lo + Math.imul(al2, bl4)) | 0;
10945    mid = (mid + Math.imul(al2, bh4)) | 0;
10946    mid = (mid + Math.imul(ah2, bl4)) | 0;
10947    hi = (hi + Math.imul(ah2, bh4)) | 0;
10948    lo = (lo + Math.imul(al1, bl5)) | 0;
10949    mid = (mid + Math.imul(al1, bh5)) | 0;
10950    mid = (mid + Math.imul(ah1, bl5)) | 0;
10951    hi = (hi + Math.imul(ah1, bh5)) | 0;
10952    lo = (lo + Math.imul(al0, bl6)) | 0;
10953    mid = (mid + Math.imul(al0, bh6)) | 0;
10954    mid = (mid + Math.imul(ah0, bl6)) | 0;
10955    hi = (hi + Math.imul(ah0, bh6)) | 0;
10956    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10957    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
10958    w6 &= 0x3ffffff;
10959    /* k = 7 */
10960    lo = Math.imul(al7, bl0);
10961    mid = Math.imul(al7, bh0);
10962    mid = (mid + Math.imul(ah7, bl0)) | 0;
10963    hi = Math.imul(ah7, bh0);
10964    lo = (lo + Math.imul(al6, bl1)) | 0;
10965    mid = (mid + Math.imul(al6, bh1)) | 0;
10966    mid = (mid + Math.imul(ah6, bl1)) | 0;
10967    hi = (hi + Math.imul(ah6, bh1)) | 0;
10968    lo = (lo + Math.imul(al5, bl2)) | 0;
10969    mid = (mid + Math.imul(al5, bh2)) | 0;
10970    mid = (mid + Math.imul(ah5, bl2)) | 0;
10971    hi = (hi + Math.imul(ah5, bh2)) | 0;
10972    lo = (lo + Math.imul(al4, bl3)) | 0;
10973    mid = (mid + Math.imul(al4, bh3)) | 0;
10974    mid = (mid + Math.imul(ah4, bl3)) | 0;
10975    hi = (hi + Math.imul(ah4, bh3)) | 0;
10976    lo = (lo + Math.imul(al3, bl4)) | 0;
10977    mid = (mid + Math.imul(al3, bh4)) | 0;
10978    mid = (mid + Math.imul(ah3, bl4)) | 0;
10979    hi = (hi + Math.imul(ah3, bh4)) | 0;
10980    lo = (lo + Math.imul(al2, bl5)) | 0;
10981    mid = (mid + Math.imul(al2, bh5)) | 0;
10982    mid = (mid + Math.imul(ah2, bl5)) | 0;
10983    hi = (hi + Math.imul(ah2, bh5)) | 0;
10984    lo = (lo + Math.imul(al1, bl6)) | 0;
10985    mid = (mid + Math.imul(al1, bh6)) | 0;
10986    mid = (mid + Math.imul(ah1, bl6)) | 0;
10987    hi = (hi + Math.imul(ah1, bh6)) | 0;
10988    lo = (lo + Math.imul(al0, bl7)) | 0;
10989    mid = (mid + Math.imul(al0, bh7)) | 0;
10990    mid = (mid + Math.imul(ah0, bl7)) | 0;
10991    hi = (hi + Math.imul(ah0, bh7)) | 0;
10992    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
10993    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
10994    w7 &= 0x3ffffff;
10995    /* k = 8 */
10996    lo = Math.imul(al8, bl0);
10997    mid = Math.imul(al8, bh0);
10998    mid = (mid + Math.imul(ah8, bl0)) | 0;
10999    hi = Math.imul(ah8, bh0);
11000    lo = (lo + Math.imul(al7, bl1)) | 0;
11001    mid = (mid + Math.imul(al7, bh1)) | 0;
11002    mid = (mid + Math.imul(ah7, bl1)) | 0;
11003    hi = (hi + Math.imul(ah7, bh1)) | 0;
11004    lo = (lo + Math.imul(al6, bl2)) | 0;
11005    mid = (mid + Math.imul(al6, bh2)) | 0;
11006    mid = (mid + Math.imul(ah6, bl2)) | 0;
11007    hi = (hi + Math.imul(ah6, bh2)) | 0;
11008    lo = (lo + Math.imul(al5, bl3)) | 0;
11009    mid = (mid + Math.imul(al5, bh3)) | 0;
11010    mid = (mid + Math.imul(ah5, bl3)) | 0;
11011    hi = (hi + Math.imul(ah5, bh3)) | 0;
11012    lo = (lo + Math.imul(al4, bl4)) | 0;
11013    mid = (mid + Math.imul(al4, bh4)) | 0;
11014    mid = (mid + Math.imul(ah4, bl4)) | 0;
11015    hi = (hi + Math.imul(ah4, bh4)) | 0;
11016    lo = (lo + Math.imul(al3, bl5)) | 0;
11017    mid = (mid + Math.imul(al3, bh5)) | 0;
11018    mid = (mid + Math.imul(ah3, bl5)) | 0;
11019    hi = (hi + Math.imul(ah3, bh5)) | 0;
11020    lo = (lo + Math.imul(al2, bl6)) | 0;
11021    mid = (mid + Math.imul(al2, bh6)) | 0;
11022    mid = (mid + Math.imul(ah2, bl6)) | 0;
11023    hi = (hi + Math.imul(ah2, bh6)) | 0;
11024    lo = (lo + Math.imul(al1, bl7)) | 0;
11025    mid = (mid + Math.imul(al1, bh7)) | 0;
11026    mid = (mid + Math.imul(ah1, bl7)) | 0;
11027    hi = (hi + Math.imul(ah1, bh7)) | 0;
11028    lo = (lo + Math.imul(al0, bl8)) | 0;
11029    mid = (mid + Math.imul(al0, bh8)) | 0;
11030    mid = (mid + Math.imul(ah0, bl8)) | 0;
11031    hi = (hi + Math.imul(ah0, bh8)) | 0;
11032    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11033    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
11034    w8 &= 0x3ffffff;
11035    /* k = 9 */
11036    lo = Math.imul(al9, bl0);
11037    mid = Math.imul(al9, bh0);
11038    mid = (mid + Math.imul(ah9, bl0)) | 0;
11039    hi = Math.imul(ah9, bh0);
11040    lo = (lo + Math.imul(al8, bl1)) | 0;
11041    mid = (mid + Math.imul(al8, bh1)) | 0;
11042    mid = (mid + Math.imul(ah8, bl1)) | 0;
11043    hi = (hi + Math.imul(ah8, bh1)) | 0;
11044    lo = (lo + Math.imul(al7, bl2)) | 0;
11045    mid = (mid + Math.imul(al7, bh2)) | 0;
11046    mid = (mid + Math.imul(ah7, bl2)) | 0;
11047    hi = (hi + Math.imul(ah7, bh2)) | 0;
11048    lo = (lo + Math.imul(al6, bl3)) | 0;
11049    mid = (mid + Math.imul(al6, bh3)) | 0;
11050    mid = (mid + Math.imul(ah6, bl3)) | 0;
11051    hi = (hi + Math.imul(ah6, bh3)) | 0;
11052    lo = (lo + Math.imul(al5, bl4)) | 0;
11053    mid = (mid + Math.imul(al5, bh4)) | 0;
11054    mid = (mid + Math.imul(ah5, bl4)) | 0;
11055    hi = (hi + Math.imul(ah5, bh4)) | 0;
11056    lo = (lo + Math.imul(al4, bl5)) | 0;
11057    mid = (mid + Math.imul(al4, bh5)) | 0;
11058    mid = (mid + Math.imul(ah4, bl5)) | 0;
11059    hi = (hi + Math.imul(ah4, bh5)) | 0;
11060    lo = (lo + Math.imul(al3, bl6)) | 0;
11061    mid = (mid + Math.imul(al3, bh6)) | 0;
11062    mid = (mid + Math.imul(ah3, bl6)) | 0;
11063    hi = (hi + Math.imul(ah3, bh6)) | 0;
11064    lo = (lo + Math.imul(al2, bl7)) | 0;
11065    mid = (mid + Math.imul(al2, bh7)) | 0;
11066    mid = (mid + Math.imul(ah2, bl7)) | 0;
11067    hi = (hi + Math.imul(ah2, bh7)) | 0;
11068    lo = (lo + Math.imul(al1, bl8)) | 0;
11069    mid = (mid + Math.imul(al1, bh8)) | 0;
11070    mid = (mid + Math.imul(ah1, bl8)) | 0;
11071    hi = (hi + Math.imul(ah1, bh8)) | 0;
11072    lo = (lo + Math.imul(al0, bl9)) | 0;
11073    mid = (mid + Math.imul(al0, bh9)) | 0;
11074    mid = (mid + Math.imul(ah0, bl9)) | 0;
11075    hi = (hi + Math.imul(ah0, bh9)) | 0;
11076    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11077    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
11078    w9 &= 0x3ffffff;
11079    /* k = 10 */
11080    lo = Math.imul(al9, bl1);
11081    mid = Math.imul(al9, bh1);
11082    mid = (mid + Math.imul(ah9, bl1)) | 0;
11083    hi = Math.imul(ah9, bh1);
11084    lo = (lo + Math.imul(al8, bl2)) | 0;
11085    mid = (mid + Math.imul(al8, bh2)) | 0;
11086    mid = (mid + Math.imul(ah8, bl2)) | 0;
11087    hi = (hi + Math.imul(ah8, bh2)) | 0;
11088    lo = (lo + Math.imul(al7, bl3)) | 0;
11089    mid = (mid + Math.imul(al7, bh3)) | 0;
11090    mid = (mid + Math.imul(ah7, bl3)) | 0;
11091    hi = (hi + Math.imul(ah7, bh3)) | 0;
11092    lo = (lo + Math.imul(al6, bl4)) | 0;
11093    mid = (mid + Math.imul(al6, bh4)) | 0;
11094    mid = (mid + Math.imul(ah6, bl4)) | 0;
11095    hi = (hi + Math.imul(ah6, bh4)) | 0;
11096    lo = (lo + Math.imul(al5, bl5)) | 0;
11097    mid = (mid + Math.imul(al5, bh5)) | 0;
11098    mid = (mid + Math.imul(ah5, bl5)) | 0;
11099    hi = (hi + Math.imul(ah5, bh5)) | 0;
11100    lo = (lo + Math.imul(al4, bl6)) | 0;
11101    mid = (mid + Math.imul(al4, bh6)) | 0;
11102    mid = (mid + Math.imul(ah4, bl6)) | 0;
11103    hi = (hi + Math.imul(ah4, bh6)) | 0;
11104    lo = (lo + Math.imul(al3, bl7)) | 0;
11105    mid = (mid + Math.imul(al3, bh7)) | 0;
11106    mid = (mid + Math.imul(ah3, bl7)) | 0;
11107    hi = (hi + Math.imul(ah3, bh7)) | 0;
11108    lo = (lo + Math.imul(al2, bl8)) | 0;
11109    mid = (mid + Math.imul(al2, bh8)) | 0;
11110    mid = (mid + Math.imul(ah2, bl8)) | 0;
11111    hi = (hi + Math.imul(ah2, bh8)) | 0;
11112    lo = (lo + Math.imul(al1, bl9)) | 0;
11113    mid = (mid + Math.imul(al1, bh9)) | 0;
11114    mid = (mid + Math.imul(ah1, bl9)) | 0;
11115    hi = (hi + Math.imul(ah1, bh9)) | 0;
11116    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11117    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
11118    w10 &= 0x3ffffff;
11119    /* k = 11 */
11120    lo = Math.imul(al9, bl2);
11121    mid = Math.imul(al9, bh2);
11122    mid = (mid + Math.imul(ah9, bl2)) | 0;
11123    hi = Math.imul(ah9, bh2);
11124    lo = (lo + Math.imul(al8, bl3)) | 0;
11125    mid = (mid + Math.imul(al8, bh3)) | 0;
11126    mid = (mid + Math.imul(ah8, bl3)) | 0;
11127    hi = (hi + Math.imul(ah8, bh3)) | 0;
11128    lo = (lo + Math.imul(al7, bl4)) | 0;
11129    mid = (mid + Math.imul(al7, bh4)) | 0;
11130    mid = (mid + Math.imul(ah7, bl4)) | 0;
11131    hi = (hi + Math.imul(ah7, bh4)) | 0;
11132    lo = (lo + Math.imul(al6, bl5)) | 0;
11133    mid = (mid + Math.imul(al6, bh5)) | 0;
11134    mid = (mid + Math.imul(ah6, bl5)) | 0;
11135    hi = (hi + Math.imul(ah6, bh5)) | 0;
11136    lo = (lo + Math.imul(al5, bl6)) | 0;
11137    mid = (mid + Math.imul(al5, bh6)) | 0;
11138    mid = (mid + Math.imul(ah5, bl6)) | 0;
11139    hi = (hi + Math.imul(ah5, bh6)) | 0;
11140    lo = (lo + Math.imul(al4, bl7)) | 0;
11141    mid = (mid + Math.imul(al4, bh7)) | 0;
11142    mid = (mid + Math.imul(ah4, bl7)) | 0;
11143    hi = (hi + Math.imul(ah4, bh7)) | 0;
11144    lo = (lo + Math.imul(al3, bl8)) | 0;
11145    mid = (mid + Math.imul(al3, bh8)) | 0;
11146    mid = (mid + Math.imul(ah3, bl8)) | 0;
11147    hi = (hi + Math.imul(ah3, bh8)) | 0;
11148    lo = (lo + Math.imul(al2, bl9)) | 0;
11149    mid = (mid + Math.imul(al2, bh9)) | 0;
11150    mid = (mid + Math.imul(ah2, bl9)) | 0;
11151    hi = (hi + Math.imul(ah2, bh9)) | 0;
11152    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11153    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
11154    w11 &= 0x3ffffff;
11155    /* k = 12 */
11156    lo = Math.imul(al9, bl3);
11157    mid = Math.imul(al9, bh3);
11158    mid = (mid + Math.imul(ah9, bl3)) | 0;
11159    hi = Math.imul(ah9, bh3);
11160    lo = (lo + Math.imul(al8, bl4)) | 0;
11161    mid = (mid + Math.imul(al8, bh4)) | 0;
11162    mid = (mid + Math.imul(ah8, bl4)) | 0;
11163    hi = (hi + Math.imul(ah8, bh4)) | 0;
11164    lo = (lo + Math.imul(al7, bl5)) | 0;
11165    mid = (mid + Math.imul(al7, bh5)) | 0;
11166    mid = (mid + Math.imul(ah7, bl5)) | 0;
11167    hi = (hi + Math.imul(ah7, bh5)) | 0;
11168    lo = (lo + Math.imul(al6, bl6)) | 0;
11169    mid = (mid + Math.imul(al6, bh6)) | 0;
11170    mid = (mid + Math.imul(ah6, bl6)) | 0;
11171    hi = (hi + Math.imul(ah6, bh6)) | 0;
11172    lo = (lo + Math.imul(al5, bl7)) | 0;
11173    mid = (mid + Math.imul(al5, bh7)) | 0;
11174    mid = (mid + Math.imul(ah5, bl7)) | 0;
11175    hi = (hi + Math.imul(ah5, bh7)) | 0;
11176    lo = (lo + Math.imul(al4, bl8)) | 0;
11177    mid = (mid + Math.imul(al4, bh8)) | 0;
11178    mid = (mid + Math.imul(ah4, bl8)) | 0;
11179    hi = (hi + Math.imul(ah4, bh8)) | 0;
11180    lo = (lo + Math.imul(al3, bl9)) | 0;
11181    mid = (mid + Math.imul(al3, bh9)) | 0;
11182    mid = (mid + Math.imul(ah3, bl9)) | 0;
11183    hi = (hi + Math.imul(ah3, bh9)) | 0;
11184    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11185    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
11186    w12 &= 0x3ffffff;
11187    /* k = 13 */
11188    lo = Math.imul(al9, bl4);
11189    mid = Math.imul(al9, bh4);
11190    mid = (mid + Math.imul(ah9, bl4)) | 0;
11191    hi = Math.imul(ah9, bh4);
11192    lo = (lo + Math.imul(al8, bl5)) | 0;
11193    mid = (mid + Math.imul(al8, bh5)) | 0;
11194    mid = (mid + Math.imul(ah8, bl5)) | 0;
11195    hi = (hi + Math.imul(ah8, bh5)) | 0;
11196    lo = (lo + Math.imul(al7, bl6)) | 0;
11197    mid = (mid + Math.imul(al7, bh6)) | 0;
11198    mid = (mid + Math.imul(ah7, bl6)) | 0;
11199    hi = (hi + Math.imul(ah7, bh6)) | 0;
11200    lo = (lo + Math.imul(al6, bl7)) | 0;
11201    mid = (mid + Math.imul(al6, bh7)) | 0;
11202    mid = (mid + Math.imul(ah6, bl7)) | 0;
11203    hi = (hi + Math.imul(ah6, bh7)) | 0;
11204    lo = (lo + Math.imul(al5, bl8)) | 0;
11205    mid = (mid + Math.imul(al5, bh8)) | 0;
11206    mid = (mid + Math.imul(ah5, bl8)) | 0;
11207    hi = (hi + Math.imul(ah5, bh8)) | 0;
11208    lo = (lo + Math.imul(al4, bl9)) | 0;
11209    mid = (mid + Math.imul(al4, bh9)) | 0;
11210    mid = (mid + Math.imul(ah4, bl9)) | 0;
11211    hi = (hi + Math.imul(ah4, bh9)) | 0;
11212    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11213    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
11214    w13 &= 0x3ffffff;
11215    /* k = 14 */
11216    lo = Math.imul(al9, bl5);
11217    mid = Math.imul(al9, bh5);
11218    mid = (mid + Math.imul(ah9, bl5)) | 0;
11219    hi = Math.imul(ah9, bh5);
11220    lo = (lo + Math.imul(al8, bl6)) | 0;
11221    mid = (mid + Math.imul(al8, bh6)) | 0;
11222    mid = (mid + Math.imul(ah8, bl6)) | 0;
11223    hi = (hi + Math.imul(ah8, bh6)) | 0;
11224    lo = (lo + Math.imul(al7, bl7)) | 0;
11225    mid = (mid + Math.imul(al7, bh7)) | 0;
11226    mid = (mid + Math.imul(ah7, bl7)) | 0;
11227    hi = (hi + Math.imul(ah7, bh7)) | 0;
11228    lo = (lo + Math.imul(al6, bl8)) | 0;
11229    mid = (mid + Math.imul(al6, bh8)) | 0;
11230    mid = (mid + Math.imul(ah6, bl8)) | 0;
11231    hi = (hi + Math.imul(ah6, bh8)) | 0;
11232    lo = (lo + Math.imul(al5, bl9)) | 0;
11233    mid = (mid + Math.imul(al5, bh9)) | 0;
11234    mid = (mid + Math.imul(ah5, bl9)) | 0;
11235    hi = (hi + Math.imul(ah5, bh9)) | 0;
11236    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11237    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
11238    w14 &= 0x3ffffff;
11239    /* k = 15 */
11240    lo = Math.imul(al9, bl6);
11241    mid = Math.imul(al9, bh6);
11242    mid = (mid + Math.imul(ah9, bl6)) | 0;
11243    hi = Math.imul(ah9, bh6);
11244    lo = (lo + Math.imul(al8, bl7)) | 0;
11245    mid = (mid + Math.imul(al8, bh7)) | 0;
11246    mid = (mid + Math.imul(ah8, bl7)) | 0;
11247    hi = (hi + Math.imul(ah8, bh7)) | 0;
11248    lo = (lo + Math.imul(al7, bl8)) | 0;
11249    mid = (mid + Math.imul(al7, bh8)) | 0;
11250    mid = (mid + Math.imul(ah7, bl8)) | 0;
11251    hi = (hi + Math.imul(ah7, bh8)) | 0;
11252    lo = (lo + Math.imul(al6, bl9)) | 0;
11253    mid = (mid + Math.imul(al6, bh9)) | 0;
11254    mid = (mid + Math.imul(ah6, bl9)) | 0;
11255    hi = (hi + Math.imul(ah6, bh9)) | 0;
11256    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11257    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
11258    w15 &= 0x3ffffff;
11259    /* k = 16 */
11260    lo = Math.imul(al9, bl7);
11261    mid = Math.imul(al9, bh7);
11262    mid = (mid + Math.imul(ah9, bl7)) | 0;
11263    hi = Math.imul(ah9, bh7);
11264    lo = (lo + Math.imul(al8, bl8)) | 0;
11265    mid = (mid + Math.imul(al8, bh8)) | 0;
11266    mid = (mid + Math.imul(ah8, bl8)) | 0;
11267    hi = (hi + Math.imul(ah8, bh8)) | 0;
11268    lo = (lo + Math.imul(al7, bl9)) | 0;
11269    mid = (mid + Math.imul(al7, bh9)) | 0;
11270    mid = (mid + Math.imul(ah7, bl9)) | 0;
11271    hi = (hi + Math.imul(ah7, bh9)) | 0;
11272    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11273    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
11274    w16 &= 0x3ffffff;
11275    /* k = 17 */
11276    lo = Math.imul(al9, bl8);
11277    mid = Math.imul(al9, bh8);
11278    mid = (mid + Math.imul(ah9, bl8)) | 0;
11279    hi = Math.imul(ah9, bh8);
11280    lo = (lo + Math.imul(al8, bl9)) | 0;
11281    mid = (mid + Math.imul(al8, bh9)) | 0;
11282    mid = (mid + Math.imul(ah8, bl9)) | 0;
11283    hi = (hi + Math.imul(ah8, bh9)) | 0;
11284    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11285    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
11286    w17 &= 0x3ffffff;
11287    /* k = 18 */
11288    lo = Math.imul(al9, bl9);
11289    mid = Math.imul(al9, bh9);
11290    mid = (mid + Math.imul(ah9, bl9)) | 0;
11291    hi = Math.imul(ah9, bh9);
11292    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11293    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
11294    w18 &= 0x3ffffff;
11295    o[0] = w0;
11296    o[1] = w1;
11297    o[2] = w2;
11298    o[3] = w3;
11299    o[4] = w4;
11300    o[5] = w5;
11301    o[6] = w6;
11302    o[7] = w7;
11303    o[8] = w8;
11304    o[9] = w9;
11305    o[10] = w10;
11306    o[11] = w11;
11307    o[12] = w12;
11308    o[13] = w13;
11309    o[14] = w14;
11310    o[15] = w15;
11311    o[16] = w16;
11312    o[17] = w17;
11313    o[18] = w18;
11314    if (c !== 0) {
11315      o[19] = c;
11316      out.length++;
11317    }
11318    return out;
11319  };
11320
11321  // Polyfill comb
11322  if (!Math.imul) {
11323    comb10MulTo = smallMulTo;
11324  }
11325
11326  function bigMulTo (self, num, out) {
11327    out.negative = num.negative ^ self.negative;
11328    out.length = self.length + num.length;
11329
11330    var carry = 0;
11331    var hncarry = 0;
11332    for (var k = 0; k < out.length - 1; k++) {
11333      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
11334      // note that ncarry could be >= 0x3ffffff
11335      var ncarry = hncarry;
11336      hncarry = 0;
11337      var rword = carry & 0x3ffffff;
11338      var maxJ = Math.min(k, num.length - 1);
11339      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
11340        var i = k - j;
11341        var a = self.words[i] | 0;
11342        var b = num.words[j] | 0;
11343        var r = a * b;
11344
11345        var lo = r & 0x3ffffff;
11346        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
11347        lo = (lo + rword) | 0;
11348        rword = lo & 0x3ffffff;
11349        ncarry = (ncarry + (lo >>> 26)) | 0;
11350
11351        hncarry += ncarry >>> 26;
11352        ncarry &= 0x3ffffff;
11353      }
11354      out.words[k] = rword;
11355      carry = ncarry;
11356      ncarry = hncarry;
11357    }
11358    if (carry !== 0) {
11359      out.words[k] = carry;
11360    } else {
11361      out.length--;
11362    }
11363
11364    return out.strip();
11365  }
11366
11367  function jumboMulTo (self, num, out) {
11368    var fftm = new FFTM();
11369    return fftm.mulp(self, num, out);
11370  }
11371
11372  BN.prototype.mulTo = function mulTo (num, out) {
11373    var res;
11374    var len = this.length + num.length;
11375    if (this.length === 10 && num.length === 10) {
11376      res = comb10MulTo(this, num, out);
11377    } else if (len < 63) {
11378      res = smallMulTo(this, num, out);
11379    } else if (len < 1024) {
11380      res = bigMulTo(this, num, out);
11381    } else {
11382      res = jumboMulTo(this, num, out);
11383    }
11384
11385    return res;
11386  };
11387
11388  // Cooley-Tukey algorithm for FFT
11389  // slightly revisited to rely on looping instead of recursion
11390
11391  function FFTM (x, y) {
11392    this.x = x;
11393    this.y = y;
11394  }
11395
11396  FFTM.prototype.makeRBT = function makeRBT (N) {
11397    var t = new Array(N);
11398    var l = BN.prototype._countBits(N) - 1;
11399    for (var i = 0; i < N; i++) {
11400      t[i] = this.revBin(i, l, N);
11401    }
11402
11403    return t;
11404  };
11405
11406  // Returns binary-reversed representation of `x`
11407  FFTM.prototype.revBin = function revBin (x, l, N) {
11408    if (x === 0 || x === N - 1) return x;
11409
11410    var rb = 0;
11411    for (var i = 0; i < l; i++) {
11412      rb |= (x & 1) << (l - i - 1);
11413      x >>= 1;
11414    }
11415
11416    return rb;
11417  };
11418
11419  // Performs "tweedling" phase, therefore 'emulating'
11420  // behaviour of the recursive algorithm
11421  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
11422    for (var i = 0; i < N; i++) {
11423      rtws[i] = rws[rbt[i]];
11424      itws[i] = iws[rbt[i]];
11425    }
11426  };
11427
11428  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
11429    this.permute(rbt, rws, iws, rtws, itws, N);
11430
11431    for (var s = 1; s < N; s <<= 1) {
11432      var l = s << 1;
11433
11434      var rtwdf = Math.cos(2 * Math.PI / l);
11435      var itwdf = Math.sin(2 * Math.PI / l);
11436
11437      for (var p = 0; p < N; p += l) {
11438        var rtwdf_ = rtwdf;
11439        var itwdf_ = itwdf;
11440
11441        for (var j = 0; j < s; j++) {
11442          var re = rtws[p + j];
11443          var ie = itws[p + j];
11444
11445          var ro = rtws[p + j + s];
11446          var io = itws[p + j + s];
11447
11448          var rx = rtwdf_ * ro - itwdf_ * io;
11449
11450          io = rtwdf_ * io + itwdf_ * ro;
11451          ro = rx;
11452
11453          rtws[p + j] = re + ro;
11454          itws[p + j] = ie + io;
11455
11456          rtws[p + j + s] = re - ro;
11457          itws[p + j + s] = ie - io;
11458
11459          /* jshint maxdepth : false */
11460          if (j !== l) {
11461            rx = rtwdf * rtwdf_ - itwdf * itwdf_;
11462
11463            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
11464            rtwdf_ = rx;
11465          }
11466        }
11467      }
11468    }
11469  };
11470
11471  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
11472    var N = Math.max(m, n) | 1;
11473    var odd = N & 1;
11474    var i = 0;
11475    for (N = N / 2 | 0; N; N = N >>> 1) {
11476      i++;
11477    }
11478
11479    return 1 << i + 1 + odd;
11480  };
11481
11482  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
11483    if (N <= 1) return;
11484
11485    for (var i = 0; i < N / 2; i++) {
11486      var t = rws[i];
11487
11488      rws[i] = rws[N - i - 1];
11489      rws[N - i - 1] = t;
11490
11491      t = iws[i];
11492
11493      iws[i] = -iws[N - i - 1];
11494      iws[N - i - 1] = -t;
11495    }
11496  };
11497
11498  FFTM.prototype.normalize13b = function normalize13b (ws, N) {
11499    var carry = 0;
11500    for (var i = 0; i < N / 2; i++) {
11501      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
11502        Math.round(ws[2 * i] / N) +
11503        carry;
11504
11505      ws[i] = w & 0x3ffffff;
11506
11507      if (w < 0x4000000) {
11508        carry = 0;
11509      } else {
11510        carry = w / 0x4000000 | 0;
11511      }
11512    }
11513
11514    return ws;
11515  };
11516
11517  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
11518    var carry = 0;
11519    for (var i = 0; i < len; i++) {
11520      carry = carry + (ws[i] | 0);
11521
11522      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
11523      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
11524    }
11525
11526    // Pad with zeroes
11527    for (i = 2 * len; i < N; ++i) {
11528      rws[i] = 0;
11529    }
11530
11531    assert(carry === 0);
11532    assert((carry & ~0x1fff) === 0);
11533  };
11534
11535  FFTM.prototype.stub = function stub (N) {
11536    var ph = new Array(N);
11537    for (var i = 0; i < N; i++) {
11538      ph[i] = 0;
11539    }
11540
11541    return ph;
11542  };
11543
11544  FFTM.prototype.mulp = function mulp (x, y, out) {
11545    var N = 2 * this.guessLen13b(x.length, y.length);
11546
11547    var rbt = this.makeRBT(N);
11548
11549    var _ = this.stub(N);
11550
11551    var rws = new Array(N);
11552    var rwst = new Array(N);
11553    var iwst = new Array(N);
11554
11555    var nrws = new Array(N);
11556    var nrwst = new Array(N);
11557    var niwst = new Array(N);
11558
11559    var rmws = out.words;
11560    rmws.length = N;
11561
11562    this.convert13b(x.words, x.length, rws, N);
11563    this.convert13b(y.words, y.length, nrws, N);
11564
11565    this.transform(rws, _, rwst, iwst, N, rbt);
11566    this.transform(nrws, _, nrwst, niwst, N, rbt);
11567
11568    for (var i = 0; i < N; i++) {
11569      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
11570      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
11571      rwst[i] = rx;
11572    }
11573
11574    this.conjugate(rwst, iwst, N);
11575    this.transform(rwst, iwst, rmws, _, N, rbt);
11576    this.conjugate(rmws, _, N);
11577    this.normalize13b(rmws, N);
11578
11579    out.negative = x.negative ^ y.negative;
11580    out.length = x.length + y.length;
11581    return out.strip();
11582  };
11583
11584  // Multiply `this` by `num`
11585  BN.prototype.mul = function mul (num) {
11586    var out = new BN(null);
11587    out.words = new Array(this.length + num.length);
11588    return this.mulTo(num, out);
11589  };
11590
11591  // Multiply employing FFT
11592  BN.prototype.mulf = function mulf (num) {
11593    var out = new BN(null);
11594    out.words = new Array(this.length + num.length);
11595    return jumboMulTo(this, num, out);
11596  };
11597
11598  // In-place Multiplication
11599  BN.prototype.imul = function imul (num) {
11600    return this.clone().mulTo(num, this);
11601  };
11602
11603  BN.prototype.imuln = function imuln (num) {
11604    assert(typeof num === 'number');
11605    assert(num < 0x4000000);
11606
11607    // Carry
11608    var carry = 0;
11609    for (var i = 0; i < this.length; i++) {
11610      var w = (this.words[i] | 0) * num;
11611      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
11612      carry >>= 26;
11613      carry += (w / 0x4000000) | 0;
11614      // NOTE: lo is 27bit maximum
11615      carry += lo >>> 26;
11616      this.words[i] = lo & 0x3ffffff;
11617    }
11618
11619    if (carry !== 0) {
11620      this.words[i] = carry;
11621      this.length++;
11622    }
11623
11624    return this;
11625  };
11626
11627  BN.prototype.muln = function muln (num) {
11628    return this.clone().imuln(num);
11629  };
11630
11631  // `this` * `this`
11632  BN.prototype.sqr = function sqr () {
11633    return this.mul(this);
11634  };
11635
11636  // `this` * `this` in-place
11637  BN.prototype.isqr = function isqr () {
11638    return this.imul(this.clone());
11639  };
11640
11641  // Math.pow(`this`, `num`)
11642  BN.prototype.pow = function pow (num) {
11643    var w = toBitArray(num);
11644    if (w.length === 0) return new BN(1);
11645
11646    // Skip leading zeroes
11647    var res = this;
11648    for (var i = 0; i < w.length; i++, res = res.sqr()) {
11649      if (w[i] !== 0) break;
11650    }
11651
11652    if (++i < w.length) {
11653      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
11654        if (w[i] === 0) continue;
11655
11656        res = res.mul(q);
11657      }
11658    }
11659
11660    return res;
11661  };
11662
11663  // Shift-left in-place
11664  BN.prototype.iushln = function iushln (bits) {
11665    assert(typeof bits === 'number' && bits >= 0);
11666    var r = bits % 26;
11667    var s = (bits - r) / 26;
11668    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
11669    var i;
11670
11671    if (r !== 0) {
11672      var carry = 0;
11673
11674      for (i = 0; i < this.length; i++) {
11675        var newCarry = this.words[i] & carryMask;
11676        var c = ((this.words[i] | 0) - newCarry) << r;
11677        this.words[i] = c | carry;
11678        carry = newCarry >>> (26 - r);
11679      }
11680
11681      if (carry) {
11682        this.words[i] = carry;
11683        this.length++;
11684      }
11685    }
11686
11687    if (s !== 0) {
11688      for (i = this.length - 1; i >= 0; i--) {
11689        this.words[i + s] = this.words[i];
11690      }
11691
11692      for (i = 0; i < s; i++) {
11693        this.words[i] = 0;
11694      }
11695
11696      this.length += s;
11697    }
11698
11699    return this.strip();
11700  };
11701
11702  BN.prototype.ishln = function ishln (bits) {
11703    // TODO(indutny): implement me
11704    assert(this.negative === 0);
11705    return this.iushln(bits);
11706  };
11707
11708  // Shift-right in-place
11709  // NOTE: `hint` is a lowest bit before trailing zeroes
11710  // NOTE: if `extended` is present - it will be filled with destroyed bits
11711  BN.prototype.iushrn = function iushrn (bits, hint, extended) {
11712    assert(typeof bits === 'number' && bits >= 0);
11713    var h;
11714    if (hint) {
11715      h = (hint - (hint % 26)) / 26;
11716    } else {
11717      h = 0;
11718    }
11719
11720    var r = bits % 26;
11721    var s = Math.min((bits - r) / 26, this.length);
11722    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
11723    var maskedWords = extended;
11724
11725    h -= s;
11726    h = Math.max(0, h);
11727
11728    // Extended mode, copy masked part
11729    if (maskedWords) {
11730      for (var i = 0; i < s; i++) {
11731        maskedWords.words[i] = this.words[i];
11732      }
11733      maskedWords.length = s;
11734    }
11735
11736    if (s === 0) {
11737      // No-op, we should not move anything at all
11738    } else if (this.length > s) {
11739      this.length -= s;
11740      for (i = 0; i < this.length; i++) {
11741        this.words[i] = this.words[i + s];
11742      }
11743    } else {
11744      this.words[0] = 0;
11745      this.length = 1;
11746    }
11747
11748    var carry = 0;
11749    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
11750      var word = this.words[i] | 0;
11751      this.words[i] = (carry << (26 - r)) | (word >>> r);
11752      carry = word & mask;
11753    }
11754
11755    // Push carried bits as a mask
11756    if (maskedWords && carry !== 0) {
11757      maskedWords.words[maskedWords.length++] = carry;
11758    }
11759
11760    if (this.length === 0) {
11761      this.words[0] = 0;
11762      this.length = 1;
11763    }
11764
11765    return this.strip();
11766  };
11767
11768  BN.prototype.ishrn = function ishrn (bits, hint, extended) {
11769    // TODO(indutny): implement me
11770    assert(this.negative === 0);
11771    return this.iushrn(bits, hint, extended);
11772  };
11773
11774  // Shift-left
11775  BN.prototype.shln = function shln (bits) {
11776    return this.clone().ishln(bits);
11777  };
11778
11779  BN.prototype.ushln = function ushln (bits) {
11780    return this.clone().iushln(bits);
11781  };
11782
11783  // Shift-right
11784  BN.prototype.shrn = function shrn (bits) {
11785    return this.clone().ishrn(bits);
11786  };
11787
11788  BN.prototype.ushrn = function ushrn (bits) {
11789    return this.clone().iushrn(bits);
11790  };
11791
11792  // Test if n bit is set
11793  BN.prototype.testn = function testn (bit) {
11794    assert(typeof bit === 'number' && bit >= 0);
11795    var r = bit % 26;
11796    var s = (bit - r) / 26;
11797    var q = 1 << r;
11798
11799    // Fast case: bit is much higher than all existing words
11800    if (this.length <= s) return false;
11801
11802    // Check bit and return
11803    var w = this.words[s];
11804
11805    return !!(w & q);
11806  };
11807
11808  // Return only lowers bits of number (in-place)
11809  BN.prototype.imaskn = function imaskn (bits) {
11810    assert(typeof bits === 'number' && bits >= 0);
11811    var r = bits % 26;
11812    var s = (bits - r) / 26;
11813
11814    assert(this.negative === 0, 'imaskn works only with positive numbers');
11815
11816    if (this.length <= s) {
11817      return this;
11818    }
11819
11820    if (r !== 0) {
11821      s++;
11822    }
11823    this.length = Math.min(s, this.length);
11824
11825    if (r !== 0) {
11826      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
11827      this.words[this.length - 1] &= mask;
11828    }
11829
11830    return this.strip();
11831  };
11832
11833  // Return only lowers bits of number
11834  BN.prototype.maskn = function maskn (bits) {
11835    return this.clone().imaskn(bits);
11836  };
11837
11838  // Add plain number `num` to `this`
11839  BN.prototype.iaddn = function iaddn (num) {
11840    assert(typeof num === 'number');
11841    assert(num < 0x4000000);
11842    if (num < 0) return this.isubn(-num);
11843
11844    // Possible sign change
11845    if (this.negative !== 0) {
11846      if (this.length === 1 && (this.words[0] | 0) < num) {
11847        this.words[0] = num - (this.words[0] | 0);
11848        this.negative = 0;
11849        return this;
11850      }
11851
11852      this.negative = 0;
11853      this.isubn(num);
11854      this.negative = 1;
11855      return this;
11856    }
11857
11858    // Add without checks
11859    return this._iaddn(num);
11860  };
11861
11862  BN.prototype._iaddn = function _iaddn (num) {
11863    this.words[0] += num;
11864
11865    // Carry
11866    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
11867      this.words[i] -= 0x4000000;
11868      if (i === this.length - 1) {
11869        this.words[i + 1] = 1;
11870      } else {
11871        this.words[i + 1]++;
11872      }
11873    }
11874    this.length = Math.max(this.length, i + 1);
11875
11876    return this;
11877  };
11878
11879  // Subtract plain number `num` from `this`
11880  BN.prototype.isubn = function isubn (num) {
11881    assert(typeof num === 'number');
11882    assert(num < 0x4000000);
11883    if (num < 0) return this.iaddn(-num);
11884
11885    if (this.negative !== 0) {
11886      this.negative = 0;
11887      this.iaddn(num);
11888      this.negative = 1;
11889      return this;
11890    }
11891
11892    this.words[0] -= num;
11893
11894    if (this.length === 1 && this.words[0] < 0) {
11895      this.words[0] = -this.words[0];
11896      this.negative = 1;
11897    } else {
11898      // Carry
11899      for (var i = 0; i < this.length && this.words[i] < 0; i++) {
11900        this.words[i] += 0x4000000;
11901        this.words[i + 1] -= 1;
11902      }
11903    }
11904
11905    return this.strip();
11906  };
11907
11908  BN.prototype.addn = function addn (num) {
11909    return this.clone().iaddn(num);
11910  };
11911
11912  BN.prototype.subn = function subn (num) {
11913    return this.clone().isubn(num);
11914  };
11915
11916  BN.prototype.iabs = function iabs () {
11917    this.negative = 0;
11918
11919    return this;
11920  };
11921
11922  BN.prototype.abs = function abs () {
11923    return this.clone().iabs();
11924  };
11925
11926  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
11927    var len = num.length + shift;
11928    var i;
11929
11930    this._expand(len);
11931
11932    var w;
11933    var carry = 0;
11934    for (i = 0; i < num.length; i++) {
11935      w = (this.words[i + shift] | 0) + carry;
11936      var right = (num.words[i] | 0) * mul;
11937      w -= right & 0x3ffffff;
11938      carry = (w >> 26) - ((right / 0x4000000) | 0);
11939      this.words[i + shift] = w & 0x3ffffff;
11940    }
11941    for (; i < this.length - shift; i++) {
11942      w = (this.words[i + shift] | 0) + carry;
11943      carry = w >> 26;
11944      this.words[i + shift] = w & 0x3ffffff;
11945    }
11946
11947    if (carry === 0) return this.strip();
11948
11949    // Subtraction overflow
11950    assert(carry === -1);
11951    carry = 0;
11952    for (i = 0; i < this.length; i++) {
11953      w = -(this.words[i] | 0) + carry;
11954      carry = w >> 26;
11955      this.words[i] = w & 0x3ffffff;
11956    }
11957    this.negative = 1;
11958
11959    return this.strip();
11960  };
11961
11962  BN.prototype._wordDiv = function _wordDiv (num, mode) {
11963    var shift = this.length - num.length;
11964
11965    var a = this.clone();
11966    var b = num;
11967
11968    // Normalize
11969    var bhi = b.words[b.length - 1] | 0;
11970    var bhiBits = this._countBits(bhi);
11971    shift = 26 - bhiBits;
11972    if (shift !== 0) {
11973      b = b.ushln(shift);
11974      a.iushln(shift);
11975      bhi = b.words[b.length - 1] | 0;
11976    }
11977
11978    // Initialize quotient
11979    var m = a.length - b.length;
11980    var q;
11981
11982    if (mode !== 'mod') {
11983      q = new BN(null);
11984      q.length = m + 1;
11985      q.words = new Array(q.length);
11986      for (var i = 0; i < q.length; i++) {
11987        q.words[i] = 0;
11988      }
11989    }
11990
11991    var diff = a.clone()._ishlnsubmul(b, 1, m);
11992    if (diff.negative === 0) {
11993      a = diff;
11994      if (q) {
11995        q.words[m] = 1;
11996      }
11997    }
11998
11999    for (var j = m - 1; j >= 0; j--) {
12000      var qj = (a.words[b.length + j] | 0) * 0x4000000 +
12001        (a.words[b.length + j - 1] | 0);
12002
12003      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
12004      // (0x7ffffff)
12005      qj = Math.min((qj / bhi) | 0, 0x3ffffff);
12006
12007      a._ishlnsubmul(b, qj, j);
12008      while (a.negative !== 0) {
12009        qj--;
12010        a.negative = 0;
12011        a._ishlnsubmul(b, 1, j);
12012        if (!a.isZero()) {
12013          a.negative ^= 1;
12014        }
12015      }
12016      if (q) {
12017        q.words[j] = qj;
12018      }
12019    }
12020    if (q) {
12021      q.strip();
12022    }
12023    a.strip();
12024
12025    // Denormalize
12026    if (mode !== 'div' && shift !== 0) {
12027      a.iushrn(shift);
12028    }
12029
12030    return {
12031      div: q || null,
12032      mod: a
12033    };
12034  };
12035
12036  // NOTE: 1) `mode` can be set to `mod` to request mod only,
12037  //       to `div` to request div only, or be absent to
12038  //       request both div & mod
12039  //       2) `positive` is true if unsigned mod is requested
12040  BN.prototype.divmod = function divmod (num, mode, positive) {
12041    assert(!num.isZero());
12042
12043    if (this.isZero()) {
12044      return {
12045        div: new BN(0),
12046        mod: new BN(0)
12047      };
12048    }
12049
12050    var div, mod, res;
12051    if (this.negative !== 0 && num.negative === 0) {
12052      res = this.neg().divmod(num, mode);
12053
12054      if (mode !== 'mod') {
12055        div = res.div.neg();
12056      }
12057
12058      if (mode !== 'div') {
12059        mod = res.mod.neg();
12060        if (positive && mod.negative !== 0) {
12061          mod.iadd(num);
12062        }
12063      }
12064
12065      return {
12066        div: div,
12067        mod: mod
12068      };
12069    }
12070
12071    if (this.negative === 0 && num.negative !== 0) {
12072      res = this.divmod(num.neg(), mode);
12073
12074      if (mode !== 'mod') {
12075        div = res.div.neg();
12076      }
12077
12078      return {
12079        div: div,
12080        mod: res.mod
12081      };
12082    }
12083
12084    if ((this.negative & num.negative) !== 0) {
12085      res = this.neg().divmod(num.neg(), mode);
12086
12087      if (mode !== 'div') {
12088        mod = res.mod.neg();
12089        if (positive && mod.negative !== 0) {
12090          mod.isub(num);
12091        }
12092      }
12093
12094      return {
12095        div: res.div,
12096        mod: mod
12097      };
12098    }
12099
12100    // Both numbers are positive at this point
12101
12102    // Strip both numbers to approximate shift value
12103    if (num.length > this.length || this.cmp(num) < 0) {
12104      return {
12105        div: new BN(0),
12106        mod: this
12107      };
12108    }
12109
12110    // Very short reduction
12111    if (num.length === 1) {
12112      if (mode === 'div') {
12113        return {
12114          div: this.divn(num.words[0]),
12115          mod: null
12116        };
12117      }
12118
12119      if (mode === 'mod') {
12120        return {
12121          div: null,
12122          mod: new BN(this.modn(num.words[0]))
12123        };
12124      }
12125
12126      return {
12127        div: this.divn(num.words[0]),
12128        mod: new BN(this.modn(num.words[0]))
12129      };
12130    }
12131
12132    return this._wordDiv(num, mode);
12133  };
12134
12135  // Find `this` / `num`
12136  BN.prototype.div = function div (num) {
12137    return this.divmod(num, 'div', false).div;
12138  };
12139
12140  // Find `this` % `num`
12141  BN.prototype.mod = function mod (num) {
12142    return this.divmod(num, 'mod', false).mod;
12143  };
12144
12145  BN.prototype.umod = function umod (num) {
12146    return this.divmod(num, 'mod', true).mod;
12147  };
12148
12149  // Find Round(`this` / `num`)
12150  BN.prototype.divRound = function divRound (num) {
12151    var dm = this.divmod(num);
12152
12153    // Fast case - exact division
12154    if (dm.mod.isZero()) return dm.div;
12155
12156    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
12157
12158    var half = num.ushrn(1);
12159    var r2 = num.andln(1);
12160    var cmp = mod.cmp(half);
12161
12162    // Round down
12163    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
12164
12165    // Round up
12166    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
12167  };
12168
12169  BN.prototype.modn = function modn (num) {
12170    assert(num <= 0x3ffffff);
12171    var p = (1 << 26) % num;
12172
12173    var acc = 0;
12174    for (var i = this.length - 1; i >= 0; i--) {
12175      acc = (p * acc + (this.words[i] | 0)) % num;
12176    }
12177
12178    return acc;
12179  };
12180
12181  // In-place division by number
12182  BN.prototype.idivn = function idivn (num) {
12183    assert(num <= 0x3ffffff);
12184
12185    var carry = 0;
12186    for (var i = this.length - 1; i >= 0; i--) {
12187      var w = (this.words[i] | 0) + carry * 0x4000000;
12188      this.words[i] = (w / num) | 0;
12189      carry = w % num;
12190    }
12191
12192    return this.strip();
12193  };
12194
12195  BN.prototype.divn = function divn (num) {
12196    return this.clone().idivn(num);
12197  };
12198
12199  BN.prototype.egcd = function egcd (p) {
12200    assert(p.negative === 0);
12201    assert(!p.isZero());
12202
12203    var x = this;
12204    var y = p.clone();
12205
12206    if (x.negative !== 0) {
12207      x = x.umod(p);
12208    } else {
12209      x = x.clone();
12210    }
12211
12212    // A * x + B * y = x
12213    var A = new BN(1);
12214    var B = new BN(0);
12215
12216    // C * x + D * y = y
12217    var C = new BN(0);
12218    var D = new BN(1);
12219
12220    var g = 0;
12221
12222    while (x.isEven() && y.isEven()) {
12223      x.iushrn(1);
12224      y.iushrn(1);
12225      ++g;
12226    }
12227
12228    var yp = y.clone();
12229    var xp = x.clone();
12230
12231    while (!x.isZero()) {
12232      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
12233      if (i > 0) {
12234        x.iushrn(i);
12235        while (i-- > 0) {
12236          if (A.isOdd() || B.isOdd()) {
12237            A.iadd(yp);
12238            B.isub(xp);
12239          }
12240
12241          A.iushrn(1);
12242          B.iushrn(1);
12243        }
12244      }
12245
12246      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
12247      if (j > 0) {
12248        y.iushrn(j);
12249        while (j-- > 0) {
12250          if (C.isOdd() || D.isOdd()) {
12251            C.iadd(yp);
12252            D.isub(xp);
12253          }
12254
12255          C.iushrn(1);
12256          D.iushrn(1);
12257        }
12258      }
12259
12260      if (x.cmp(y) >= 0) {
12261        x.isub(y);
12262        A.isub(C);
12263        B.isub(D);
12264      } else {
12265        y.isub(x);
12266        C.isub(A);
12267        D.isub(B);
12268      }
12269    }
12270
12271    return {
12272      a: C,
12273      b: D,
12274      gcd: y.iushln(g)
12275    };
12276  };
12277
12278  // This is reduced incarnation of the binary EEA
12279  // above, designated to invert members of the
12280  // _prime_ fields F(p) at a maximal speed
12281  BN.prototype._invmp = function _invmp (p) {
12282    assert(p.negative === 0);
12283    assert(!p.isZero());
12284
12285    var a = this;
12286    var b = p.clone();
12287
12288    if (a.negative !== 0) {
12289      a = a.umod(p);
12290    } else {
12291      a = a.clone();
12292    }
12293
12294    var x1 = new BN(1);
12295    var x2 = new BN(0);
12296
12297    var delta = b.clone();
12298
12299    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
12300      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
12301      if (i > 0) {
12302        a.iushrn(i);
12303        while (i-- > 0) {
12304          if (x1.isOdd()) {
12305            x1.iadd(delta);
12306          }
12307
12308          x1.iushrn(1);
12309        }
12310      }
12311
12312      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
12313      if (j > 0) {
12314        b.iushrn(j);
12315        while (j-- > 0) {
12316          if (x2.isOdd()) {
12317            x2.iadd(delta);
12318          }
12319
12320          x2.iushrn(1);
12321        }
12322      }
12323
12324      if (a.cmp(b) >= 0) {
12325        a.isub(b);
12326        x1.isub(x2);
12327      } else {
12328        b.isub(a);
12329        x2.isub(x1);
12330      }
12331    }
12332
12333    var res;
12334    if (a.cmpn(1) === 0) {
12335      res = x1;
12336    } else {
12337      res = x2;
12338    }
12339
12340    if (res.cmpn(0) < 0) {
12341      res.iadd(p);
12342    }
12343
12344    return res;
12345  };
12346
12347  BN.prototype.gcd = function gcd (num) {
12348    if (this.isZero()) return num.abs();
12349    if (num.isZero()) return this.abs();
12350
12351    var a = this.clone();
12352    var b = num.clone();
12353    a.negative = 0;
12354    b.negative = 0;
12355
12356    // Remove common factor of two
12357    for (var shift = 0; a.isEven() && b.isEven(); shift++) {
12358      a.iushrn(1);
12359      b.iushrn(1);
12360    }
12361
12362    do {
12363      while (a.isEven()) {
12364        a.iushrn(1);
12365      }
12366      while (b.isEven()) {
12367        b.iushrn(1);
12368      }
12369
12370      var r = a.cmp(b);
12371      if (r < 0) {
12372        // Swap `a` and `b` to make `a` always bigger than `b`
12373        var t = a;
12374        a = b;
12375        b = t;
12376      } else if (r === 0 || b.cmpn(1) === 0) {
12377        break;
12378      }
12379
12380      a.isub(b);
12381    } while (true);
12382
12383    return b.iushln(shift);
12384  };
12385
12386  // Invert number in the field F(num)
12387  BN.prototype.invm = function invm (num) {
12388    return this.egcd(num).a.umod(num);
12389  };
12390
12391  BN.prototype.isEven = function isEven () {
12392    return (this.words[0] & 1) === 0;
12393  };
12394
12395  BN.prototype.isOdd = function isOdd () {
12396    return (this.words[0] & 1) === 1;
12397  };
12398
12399  // And first word and num
12400  BN.prototype.andln = function andln (num) {
12401    return this.words[0] & num;
12402  };
12403
12404  // Increment at the bit position in-line
12405  BN.prototype.bincn = function bincn (bit) {
12406    assert(typeof bit === 'number');
12407    var r = bit % 26;
12408    var s = (bit - r) / 26;
12409    var q = 1 << r;
12410
12411    // Fast case: bit is much higher than all existing words
12412    if (this.length <= s) {
12413      this._expand(s + 1);
12414      this.words[s] |= q;
12415      return this;
12416    }
12417
12418    // Add bit and propagate, if needed
12419    var carry = q;
12420    for (var i = s; carry !== 0 && i < this.length; i++) {
12421      var w = this.words[i] | 0;
12422      w += carry;
12423      carry = w >>> 26;
12424      w &= 0x3ffffff;
12425      this.words[i] = w;
12426    }
12427    if (carry !== 0) {
12428      this.words[i] = carry;
12429      this.length++;
12430    }
12431    return this;
12432  };
12433
12434  BN.prototype.isZero = function isZero () {
12435    return this.length === 1 && this.words[0] === 0;
12436  };
12437
12438  BN.prototype.cmpn = function cmpn (num) {
12439    var negative = num < 0;
12440
12441    if (this.negative !== 0 && !negative) return -1;
12442    if (this.negative === 0 && negative) return 1;
12443
12444    this.strip();
12445
12446    var res;
12447    if (this.length > 1) {
12448      res = 1;
12449    } else {
12450      if (negative) {
12451        num = -num;
12452      }
12453
12454      assert(num <= 0x3ffffff, 'Number is too big');
12455
12456      var w = this.words[0] | 0;
12457      res = w === num ? 0 : w < num ? -1 : 1;
12458    }
12459    if (this.negative !== 0) return -res | 0;
12460    return res;
12461  };
12462
12463  // Compare two numbers and return:
12464  // 1 - if `this` > `num`
12465  // 0 - if `this` == `num`
12466  // -1 - if `this` < `num`
12467  BN.prototype.cmp = function cmp (num) {
12468    if (this.negative !== 0 && num.negative === 0) return -1;
12469    if (this.negative === 0 && num.negative !== 0) return 1;
12470
12471    var res = this.ucmp(num);
12472    if (this.negative !== 0) return -res | 0;
12473    return res;
12474  };
12475
12476  // Unsigned comparison
12477  BN.prototype.ucmp = function ucmp (num) {
12478    // At this point both numbers have the same sign
12479    if (this.length > num.length) return 1;
12480    if (this.length < num.length) return -1;
12481
12482    var res = 0;
12483    for (var i = this.length - 1; i >= 0; i--) {
12484      var a = this.words[i] | 0;
12485      var b = num.words[i] | 0;
12486
12487      if (a === b) continue;
12488      if (a < b) {
12489        res = -1;
12490      } else if (a > b) {
12491        res = 1;
12492      }
12493      break;
12494    }
12495    return res;
12496  };
12497
12498  BN.prototype.gtn = function gtn (num) {
12499    return this.cmpn(num) === 1;
12500  };
12501
12502  BN.prototype.gt = function gt (num) {
12503    return this.cmp(num) === 1;
12504  };
12505
12506  BN.prototype.gten = function gten (num) {
12507    return this.cmpn(num) >= 0;
12508  };
12509
12510  BN.prototype.gte = function gte (num) {
12511    return this.cmp(num) >= 0;
12512  };
12513
12514  BN.prototype.ltn = function ltn (num) {
12515    return this.cmpn(num) === -1;
12516  };
12517
12518  BN.prototype.lt = function lt (num) {
12519    return this.cmp(num) === -1;
12520  };
12521
12522  BN.prototype.lten = function lten (num) {
12523    return this.cmpn(num) <= 0;
12524  };
12525
12526  BN.prototype.lte = function lte (num) {
12527    return this.cmp(num) <= 0;
12528  };
12529
12530  BN.prototype.eqn = function eqn (num) {
12531    return this.cmpn(num) === 0;
12532  };
12533
12534  BN.prototype.eq = function eq (num) {
12535    return this.cmp(num) === 0;
12536  };
12537
12538  //
12539  // A reduce context, could be using montgomery or something better, depending
12540  // on the `m` itself.
12541  //
12542  BN.red = function red (num) {
12543    return new Red(num);
12544  };
12545
12546  BN.prototype.toRed = function toRed (ctx) {
12547    assert(!this.red, 'Already a number in reduction context');
12548    assert(this.negative === 0, 'red works only with positives');
12549    return ctx.convertTo(this)._forceRed(ctx);
12550  };
12551
12552  BN.prototype.fromRed = function fromRed () {
12553    assert(this.red, 'fromRed works only with numbers in reduction context');
12554    return this.red.convertFrom(this);
12555  };
12556
12557  BN.prototype._forceRed = function _forceRed (ctx) {
12558    this.red = ctx;
12559    return this;
12560  };
12561
12562  BN.prototype.forceRed = function forceRed (ctx) {
12563    assert(!this.red, 'Already a number in reduction context');
12564    return this._forceRed(ctx);
12565  };
12566
12567  BN.prototype.redAdd = function redAdd (num) {
12568    assert(this.red, 'redAdd works only with red numbers');
12569    return this.red.add(this, num);
12570  };
12571
12572  BN.prototype.redIAdd = function redIAdd (num) {
12573    assert(this.red, 'redIAdd works only with red numbers');
12574    return this.red.iadd(this, num);
12575  };
12576
12577  BN.prototype.redSub = function redSub (num) {
12578    assert(this.red, 'redSub works only with red numbers');
12579    return this.red.sub(this, num);
12580  };
12581
12582  BN.prototype.redISub = function redISub (num) {
12583    assert(this.red, 'redISub works only with red numbers');
12584    return this.red.isub(this, num);
12585  };
12586
12587  BN.prototype.redShl = function redShl (num) {
12588    assert(this.red, 'redShl works only with red numbers');
12589    return this.red.shl(this, num);
12590  };
12591
12592  BN.prototype.redMul = function redMul (num) {
12593    assert(this.red, 'redMul works only with red numbers');
12594    this.red._verify2(this, num);
12595    return this.red.mul(this, num);
12596  };
12597
12598  BN.prototype.redIMul = function redIMul (num) {
12599    assert(this.red, 'redMul works only with red numbers');
12600    this.red._verify2(this, num);
12601    return this.red.imul(this, num);
12602  };
12603
12604  BN.prototype.redSqr = function redSqr () {
12605    assert(this.red, 'redSqr works only with red numbers');
12606    this.red._verify1(this);
12607    return this.red.sqr(this);
12608  };
12609
12610  BN.prototype.redISqr = function redISqr () {
12611    assert(this.red, 'redISqr works only with red numbers');
12612    this.red._verify1(this);
12613    return this.red.isqr(this);
12614  };
12615
12616  // Square root over p
12617  BN.prototype.redSqrt = function redSqrt () {
12618    assert(this.red, 'redSqrt works only with red numbers');
12619    this.red._verify1(this);
12620    return this.red.sqrt(this);
12621  };
12622
vendor: 8,763 bytes, lines 12623-13002
12623  BN.prototype.redInvm = function redInvm () {
12624    assert(this.red, 'redInvm works only with red numbers');
12625    this.red._verify1(this);
12626    return this.red.invm(this);
12627  };
12628
12629  // Return negative clone of `this` % `red modulo`
12630  BN.prototype.redNeg = function redNeg () {
12631    assert(this.red, 'redNeg works only with red numbers');
12632    this.red._verify1(this);
12633    return this.red.neg(this);
12634  };
12635
12636  BN.prototype.redPow = function redPow (num) {
12637    assert(this.red && !num.red, 'redPow(normalNum)');
12638    this.red._verify1(this);
12639    return this.red.pow(this, num);
12640  };
12641
12642  // Prime numbers with efficient reduction
12643  var primes = {
12644    k256: null,
12645    p224: null,
12646    p192: null,
12647    p25519: null
12648  };
12649
12650  // Pseudo-Mersenne prime
12651  function MPrime (name, p) {
12652    // P = 2 ^ N - K
12653    this.name = name;
12654    this.p = new BN(p, 16);
12655    this.n = this.p.bitLength();
12656    this.k = new BN(1).iushln(this.n).isub(this.p);
12657
12658    this.tmp = this._tmp();
12659  }
12660
12661  MPrime.prototype._tmp = function _tmp () {
12662    var tmp = new BN(null);
12663    tmp.words = new Array(Math.ceil(this.n / 13));
12664    return tmp;
12665  };
12666
12667  MPrime.prototype.ireduce = function ireduce (num) {
12668    // Assumes that `num` is less than `P^2`
12669    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
12670    var r = num;
12671    var rlen;
12672
12673    do {
12674      this.split(r, this.tmp);
12675      r = this.imulK(r);
12676      r = r.iadd(this.tmp);
12677      rlen = r.bitLength();
12678    } while (rlen > this.n);
12679
12680    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
12681    if (cmp === 0) {
12682      r.words[0] = 0;
12683      r.length = 1;
12684    } else if (cmp > 0) {
12685      r.isub(this.p);
12686    } else {
12687      r.strip();
12688    }
12689
12690    return r;
12691  };
12692
12693  MPrime.prototype.split = function split (input, out) {
12694    input.iushrn(this.n, 0, out);
12695  };
12696
12697  MPrime.prototype.imulK = function imulK (num) {
12698    return num.imul(this.k);
12699  };
12700
12701  function K256 () {
12702    MPrime.call(
12703      this,
12704      'k256',
12705      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
12706  }
12707  inherits(K256, MPrime);
12708
12709  K256.prototype.split = function split (input, output) {
12710    // 256 = 9 * 26 + 22
12711    var mask = 0x3fffff;
12712
12713    var outLen = Math.min(input.length, 9);
12714    for (var i = 0; i < outLen; i++) {
12715      output.words[i] = input.words[i];
12716    }
12717    output.length = outLen;
12718
12719    if (input.length <= 9) {
12720      input.words[0] = 0;
12721      input.length = 1;
12722      return;
12723    }
12724
12725    // Shift by 9 limbs
12726    var prev = input.words[9];
12727    output.words[output.length++] = prev & mask;
12728
12729    for (i = 10; i < input.length; i++) {
12730      var next = input.words[i] | 0;
12731      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
12732      prev = next;
12733    }
12734    prev >>>= 22;
12735    input.words[i - 10] = prev;
12736    if (prev === 0 && input.length > 10) {
12737      input.length -= 10;
12738    } else {
12739      input.length -= 9;
12740    }
12741  };
12742
12743  K256.prototype.imulK = function imulK (num) {
12744    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
12745    num.words[num.length] = 0;
12746    num.words[num.length + 1] = 0;
12747    num.length += 2;
12748
12749    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
12750    var lo = 0;
12751    for (var i = 0; i < num.length; i++) {
12752      var w = num.words[i] | 0;
12753      lo += w * 0x3d1;
12754      num.words[i] = lo & 0x3ffffff;
12755      lo = w * 0x40 + ((lo / 0x4000000) | 0);
12756    }
12757
12758    // Fast length reduction
12759    if (num.words[num.length - 1] === 0) {
12760      num.length--;
12761      if (num.words[num.length - 1] === 0) {
12762        num.length--;
12763      }
12764    }
12765    return num;
12766  };
12767
12768  function P224 () {
12769    MPrime.call(
12770      this,
12771      'p224',
12772      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
12773  }
12774  inherits(P224, MPrime);
12775
12776  function P192 () {
12777    MPrime.call(
12778      this,
12779      'p192',
12780      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
12781  }
12782  inherits(P192, MPrime);
12783
12784  function P25519 () {
12785    // 2 ^ 255 - 19
12786    MPrime.call(
12787      this,
12788      '25519',
12789      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
12790  }
12791  inherits(P25519, MPrime);
12792
12793  P25519.prototype.imulK = function imulK (num) {
12794    // K = 0x13
12795    var carry = 0;
12796    for (var i = 0; i < num.length; i++) {
12797      var hi = (num.words[i] | 0) * 0x13 + carry;
12798      var lo = hi & 0x3ffffff;
12799      hi >>>= 26;
12800
12801      num.words[i] = lo;
12802      carry = hi;
12803    }
12804    if (carry !== 0) {
12805      num.words[num.length++] = carry;
12806    }
12807    return num;
12808  };
12809
12810  // Exported mostly for testing purposes, use plain name instead
12811  BN._prime = function prime (name) {
12812    // Cached version of prime
12813    if (primes[name]) return primes[name];
12814
12815    var prime;
12816    if (name === 'k256') {
12817      prime = new K256();
12818    } else if (name === 'p224') {
12819      prime = new P224();
12820    } else if (name === 'p192') {
12821      prime = new P192();
12822    } else if (name === 'p25519') {
12823      prime = new P25519();
12824    } else {
12825      throw new Error('Unknown prime ' + name);
12826    }
12827    primes[name] = prime;
12828
12829    return prime;
12830  };
12831
12832  //
12833  // Base reduction engine
12834  //
12835  function Red (m) {
12836    if (typeof m === 'string') {
12837      var prime = BN._prime(m);
12838      this.m = prime.p;
12839      this.prime = prime;
12840    } else {
12841      assert(m.gtn(1), 'modulus must be greater than 1');
12842      this.m = m;
12843      this.prime = null;
12844    }
12845  }
12846
12847  Red.prototype._verify1 = function _verify1 (a) {
12848    assert(a.negative === 0, 'red works only with positives');
12849    assert(a.red, 'red works only with red numbers');
12850  };
12851
12852  Red.prototype._verify2 = function _verify2 (a, b) {
12853    assert((a.negative | b.negative) === 0, 'red works only with positives');
12854    assert(a.red && a.red === b.red,
12855      'red works only with red numbers');
12856  };
12857
12858  Red.prototype.imod = function imod (a) {
12859    if (this.prime) return this.prime.ireduce(a)._forceRed(this);
12860    return a.umod(this.m)._forceRed(this);
12861  };
12862
12863  Red.prototype.neg = function neg (a) {
12864    if (a.isZero()) {
12865      return a.clone();
12866    }
12867
12868    return this.m.sub(a)._forceRed(this);
12869  };
12870
12871  Red.prototype.add = function add (a, b) {
12872    this._verify2(a, b);
12873
12874    var res = a.add(b);
12875    if (res.cmp(this.m) >= 0) {
12876      res.isub(this.m);
12877    }
12878    return res._forceRed(this);
12879  };
12880
12881  Red.prototype.iadd = function iadd (a, b) {
12882    this._verify2(a, b);
12883
12884    var res = a.iadd(b);
12885    if (res.cmp(this.m) >= 0) {
12886      res.isub(this.m);
12887    }
12888    return res;
12889  };
12890
12891  Red.prototype.sub = function sub (a, b) {
12892    this._verify2(a, b);
12893
12894    var res = a.sub(b);
12895    if (res.cmpn(0) < 0) {
12896      res.iadd(this.m);
12897    }
12898    return res._forceRed(this);
12899  };
12900
12901  Red.prototype.isub = function isub (a, b) {
12902    this._verify2(a, b);
12903
12904    var res = a.isub(b);
12905    if (res.cmpn(0) < 0) {
12906      res.iadd(this.m);
12907    }
12908    return res;
12909  };
12910
12911  Red.prototype.shl = function shl (a, num) {
12912    this._verify1(a);
12913    return this.imod(a.ushln(num));
12914  };
12915
12916  Red.prototype.imul = function imul (a, b) {
12917    this._verify2(a, b);
12918    return this.imod(a.imul(b));
12919  };
12920
12921  Red.prototype.mul = function mul (a, b) {
12922    this._verify2(a, b);
12923    return this.imod(a.mul(b));
12924  };
12925
12926  Red.prototype.isqr = function isqr (a) {
12927    return this.imul(a, a.clone());
12928  };
12929
12930  Red.prototype.sqr = function sqr (a) {
12931    return this.mul(a, a);
12932  };
12933
12934  Red.prototype.sqrt = function sqrt (a) {
12935    if (a.isZero()) return a.clone();
12936
12937    var mod3 = this.m.andln(3);
12938    assert(mod3 % 2 === 1);
12939
12940    // Fast case
12941    if (mod3 === 3) {
12942      var pow = this.m.add(new BN(1)).iushrn(2);
12943      return this.pow(a, pow);
12944    }
12945
12946    // Tonelli-Shanks algorithm (Totally unoptimized and slow)
12947    //
12948    // Find Q and S, that Q * 2 ^ S = (P - 1)
12949    var q = this.m.subn(1);
12950    var s = 0;
12951    while (!q.isZero() && q.andln(1) === 0) {
12952      s++;
12953      q.iushrn(1);
12954    }
12955    assert(!q.isZero());
12956
12957    var one = new BN(1).toRed(this);
12958    var nOne = one.redNeg();
12959
12960    // Find quadratic non-residue
12961    // NOTE: Max is such because of generalized Riemann hypothesis.
12962    var lpow = this.m.subn(1).iushrn(1);
12963    var z = this.m.bitLength();
12964    z = new BN(2 * z * z).toRed(this);
12965
12966    while (this.pow(z, lpow).cmp(nOne) !== 0) {
12967      z.redIAdd(nOne);
12968    }
12969
12970    var c = this.pow(z, q);
12971    var r = this.pow(a, q.addn(1).iushrn(1));
12972    var t = this.pow(a, q);
12973    var m = s;
12974    while (t.cmp(one) !== 0) {
12975      var tmp = t;
12976      for (var i = 0; tmp.cmp(one) !== 0; i++) {
12977        tmp = tmp.redSqr();
12978      }
12979      assert(i < m);
12980      var b = this.pow(c, new BN(1).iushln(m - i - 1));
12981
12982      r = r.redMul(b);
12983      c = b.redSqr();
12984      t = t.redMul(c);
12985      m = i;
12986    }
12987
12988    return r;
12989  };
12990
12991  Red.prototype.invm = function invm (a) {
12992    var inv = a._invmp(this.m);
12993    if (inv.negative !== 0) {
12994      inv.negative = 0;
12995      return this.imod(inv).redNeg();
12996    } else {
12997      return this.imod(inv);
12998    }
12999  };
13000
13001  Red.prototype.pow = function pow (a, num) {
13002    if (num.isZero()) return new BN(1)
vendor: 4,291 bytes, lines 13002-13181
13002;
13003    if (num.cmpn(1) === 0) return a.clone();
13004
13005    var windowSize = 4;
13006    var wnd = new Array(1 << windowSize);
13007    wnd[0] = new BN(1).toRed(this);
13008    wnd[1] = a;
13009    for (var i = 2; i < wnd.length; i++) {
13010      wnd[i] = this.mul(wnd[i - 1], a);
13011    }
13012
13013    var res = wnd[0];
13014    var current = 0;
13015    var currentLen = 0;
13016    var start = num.bitLength() % 26;
13017    if (start === 0) {
13018      start = 26;
13019    }
13020
13021    for (i = num.length - 1; i >= 0; i--) {
13022      var word = num.words[i];
13023      for (var j = start - 1; j >= 0; j--) {
13024        var bit = (word >> j) & 1;
13025        if (res !== wnd[0]) {
13026          res = this.sqr(res);
13027        }
13028
13029        if (bit === 0 && current === 0) {
13030          currentLen = 0;
13031          continue;
13032        }
13033
13034        current <<= 1;
13035        current |= bit;
13036        currentLen++;
13037        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
13038
13039        res = this.mul(res, wnd[current]);
13040        currentLen = 0;
13041        current = 0;
13042      }
13043      start = 26;
13044    }
13045
13046    return res;
13047  };
13048
13049  Red.prototype.convertTo = function convertTo (num) {
13050    var r = num.umod(this.m);
13051
13052    return r === num ? r.clone() : r;
13053  };
13054
13055  Red.prototype.convertFrom = function convertFrom (num) {
13056    var res = num.clone();
13057    res.red = null;
13058    return res;
13059  };
13060
13061  //
13062  // Montgomery method engine
13063  //
13064
13065  BN.mont = function mont (num) {
13066    return new Mont(num);
13067  };
13068
13069  function Mont (m) {
13070    Red.call(this, m);
13071
13072    this.shift = this.m.bitLength();
13073    if (this.shift % 26 !== 0) {
13074      this.shift += 26 - (this.shift % 26);
13075    }
13076
13077    this.r = new BN(1).iushln(this.shift);
13078    this.r2 = this.imod(this.r.sqr());
13079    this.rinv = this.r._invmp(this.m);
13080
13081    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
13082    this.minv = this.minv.umod(this.r);
13083    this.minv = this.r.sub(this.minv);
13084  }
13085  inherits(Mont, Red);
13086
13087  Mont.prototype.convertTo = function convertTo (num) {
13088    return this.imod(num.ushln(this.shift));
13089  };
13090
13091  Mont.prototype.convertFrom = function convertFrom (num) {
13092    var r = this.imod(num.mul(this.rinv));
13093    r.red = null;
13094    return r;
13095  };
13096
13097  Mont.prototype.imul = function imul (a, b) {
13098    if (a.isZero() || b.isZero()) {
13099      a.words[0] = 0;
13100      a.length = 1;
13101      return a;
13102    }
13103
13104    var t = a.imul(b);
13105    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
13106    var u = t.isub(c).iushrn(this.shift);
13107    var res = u;
13108
13109    if (u.cmp(this.m) >= 0) {
13110      res = u.isub(this.m);
13111    } else if (u.cmpn(0) < 0) {
13112      res = u.iadd(this.m);
13113    }
13114
13115    return res._forceRed(this);
13116  };
13117
13118  Mont.prototype.mul = function mul (a, b) {
13119    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
13120
13121    var t = a.mul(b);
13122    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
13123    var u = t.isub(c).iushrn(this.shift);
13124    var res = u;
13125    if (u.cmp(this.m) >= 0) {
13126      res = u.isub(this.m);
13127    } else if (u.cmpn(0) < 0) {
13128      res = u.iadd(this.m);
13129    }
13130
13131    return res._forceRed(this);
13132  };
13133
13134  Mont.prototype.invm = function invm (a) {
13135    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
13136    var res = this.imod(a._invmp(this.m).mul(this.r2));
13137    return res._forceRed(this);
13138  };
13139})(typeof module === 'undefined' || module, this);
13140
13141/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(36)(module)))
13142
13143/***/ },
13144/* 2 */
13145/***/ function(module, exports, __webpack_require__) {
13146
13147var hash = exports;
13148
13149hash.utils = __webpack_require__(31);
13150hash.common = __webpack_require__(27);
13151hash.sha = __webpack_require__(30);
13152hash.ripemd = __webpack_require__(29);
13153hash.hmac = __webpack_require__(28);
13154
13155// Proxy hash functions to the main object
13156hash.sha1 = hash.sha.sha1;
13157hash.sha256 = hash.sha.sha256;
13158hash.sha224 = hash.sha.sha224;
13159hash.sha384 = hash.sha.sha384;
13160hash.sha512 = hash.sha.sha512;
13161hash.ripemd160 = hash.ripemd.ripemd160;
13162
13163
13164/***/ },
13165/* 3 */
13166/***/ function(module, exports, __webpack_require__) {
13167
13168"use strict";
13169/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
13170 * The buffer module from node.js, for the browser.
13171 *
13172 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
13173 * @license  MIT
13174 */
13175/* eslint-disable no-proto */
13176
13177'use strict'
13178
13179var base64 = __webpack_require__(11)
13180var ieee754 = __webpack_require__(32)
13181var isArray = __webpack_require__(33
vendor: 48,349 bytes, lines 13181-14959
13181)
13182
13183exports.Buffer = Buffer
13184exports.SlowBuffer = SlowBuffer
13185exports.INSPECT_MAX_BYTES = 50
13186
13187/**
13188 * If `Buffer.TYPED_ARRAY_SUPPORT`:
13189 *   === true    Use Uint8Array implementation (fastest)
13190 *   === false   Use Object implementation (most compatible, even IE6)
13191 *
13192 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
13193 * Opera 11.6+, iOS 4.2+.
13194 *
13195 * Due to various browser bugs, sometimes the Object implementation will be used even
13196 * when the browser supports typed arrays.
13197 *
13198 * Note:
13199 *
13200 *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
13201 *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
13202 *
13203 *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
13204 *
13205 *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
13206 *     incorrect length in some situations.
13207
13208 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
13209 * get the Object implementation, which is slower but behaves correctly.
13210 */
13211Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
13212  ? global.TYPED_ARRAY_SUPPORT
13213  : typedArraySupport()
13214
13215/*
13216 * Export kMaxLength after typed array support is determined.
13217 */
13218exports.kMaxLength = kMaxLength()
13219
13220function typedArraySupport () {
13221  try {
13222    var arr = new Uint8Array(1)
13223    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
13224    return arr.foo() === 42 && // typed array instances can be augmented
13225        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
13226        arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
13227  } catch (e) {
13228    return false
13229  }
13230}
13231
13232function kMaxLength () {
13233  return Buffer.TYPED_ARRAY_SUPPORT
13234    ? 0x7fffffff
13235    : 0x3fffffff
13236}
13237
13238function createBuffer (that, length) {
13239  if (kMaxLength() < length) {
13240    throw new RangeError('Invalid typed array length')
13241  }
13242  if (Buffer.TYPED_ARRAY_SUPPORT) {
13243    // Return an augmented `Uint8Array` instance, for best performance
13244    that = new Uint8Array(length)
13245    that.__proto__ = Buffer.prototype
13246  } else {
13247    // Fallback: Return an object instance of the Buffer class
13248    if (that === null) {
13249      that = new Buffer(length)
13250    }
13251    that.length = length
13252  }
13253
13254  return that
13255}
13256
13257/**
13258 * The Buffer constructor returns instances of `Uint8Array` that have their
13259 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
13260 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
13261 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
13262 * returns a single octet.
13263 *
13264 * The `Uint8Array` prototype remains unmodified.
13265 */
13266
13267function Buffer (arg, encodingOrOffset, length) {
13268  if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
13269    return new Buffer(arg, encodingOrOffset, length)
13270  }
13271
13272  // Common case.
13273  if (typeof arg === 'number') {
13274    if (typeof encodingOrOffset === 'string') {
13275      throw new Error(
13276        'If encoding is specified then the first argument must be a string'
13277      )
13278    }
13279    return allocUnsafe(this, arg)
13280  }
13281  return from(this, arg, encodingOrOffset, length)
13282}
13283
13284Buffer.poolSize = 8192 // not used by this implementation
13285
13286// TODO: Legacy, not needed anymore. Remove in next major version.
13287Buffer._augment = function (arr) {
13288  arr.__proto__ = Buffer.prototype
13289  return arr
13290}
13291
13292function from (that, value, encodingOrOffset, length) {
13293  if (typeof value === 'number') {
13294    throw new TypeError('"value" argument must not be a number')
13295  }
13296
13297  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
13298    return fromArrayBuffer(that, value, encodingOrOffset, length)
13299  }
13300
13301  if (typeof value === 'string') {
13302    return fromString(that, value, encodingOrOffset)
13303  }
13304
13305  return fromObject(that, value)
13306}
13307
13308/**
13309 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
13310 * if value is a number.
13311 * Buffer.from(str[, encoding])
13312 * Buffer.from(array)
13313 * Buffer.from(buffer)
13314 * Buffer.from(arrayBuffer[, byteOffset[, length]])
13315 **/
13316Buffer.from = function (value, encodingOrOffset, length) {
13317  return from(null, value, encodingOrOffset, length)
13318}
13319
13320if (Buffer.TYPED_ARRAY_SUPPORT) {
13321  Buffer.prototype.__proto__ = Uint8Array.prototype
13322  Buffer.__proto__ = Uint8Array
13323  if (typeof Symbol !== 'undefined' && Symbol.species &&
13324      Buffer[Symbol.species] === Buffer) {
13325    // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
13326    Object.defineProperty(Buffer, Symbol.species, {
13327      value: null,
13328      configurable: true
13329    })
13330  }
13331}
13332
13333function assertSize (size) {
13334  if (typeof size !== 'number') {
13335    throw new TypeError('"size" argument must be a number')
13336  } else if (size < 0) {
13337    throw new RangeError('"size" argument must not be negative')
13338  }
13339}
13340
13341function alloc (that, size, fill, encoding) {
13342  assertSize(size)
13343  if (size <= 0) {
13344    return createBuffer(that, size)
13345  }
13346  if (fill !== undefined) {
13347    // Only pay attention to encoding if it's a string. This
13348    // prevents accidentally sending in a number that would
13349    // be interpretted as a start offset.
13350    return typeof encoding === 'string'
13351      ? createBuffer(that, size).fill(fill, encoding)
13352      : createBuffer(that, size).fill(fill)
13353  }
13354  return createBuffer(that, size)
13355}
13356
13357/**
13358 * Creates a new filled Buffer instance.
13359 * alloc(size[, fill[, encoding]])
13360 **/
13361Buffer.alloc = function (size, fill, encoding) {
13362  return alloc(null, size, fill, encoding)
13363}
13364
13365function allocUnsafe (that, size) {
13366  assertSize(size)
13367  that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
13368  if (!Buffer.TYPED_ARRAY_SUPPORT) {
13369    for (var i = 0; i < size; ++i) {
13370      that[i] = 0
13371    }
13372  }
13373  return that
13374}
13375
13376/**
13377 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
13378 * */
13379Buffer.allocUnsafe = function (size) {
13380  return allocUnsafe(null, size)
13381}
13382/**
13383 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
13384 */
13385Buffer.allocUnsafeSlow = function (size) {
13386  return allocUnsafe(null, size)
13387}
13388
13389function fromString (that, string, encoding) {
13390  if (typeof encoding !== 'string' || encoding === '') {
13391    encoding = 'utf8'
13392  }
13393
13394  if (!Buffer.isEncoding(encoding)) {
13395    throw new TypeError('"encoding" must be a valid string encoding')
13396  }
13397
13398  var length = byteLength(string, encoding) | 0
13399  that = createBuffer(that, length)
13400
13401  var actual = that.write(string, encoding)
13402
13403  if (actual !== length) {
13404    // Writing a hex string, for example, that contains invalid characters will
13405    // cause everything after the first invalid character to be ignored. (e.g.
13406    // 'abxxcd' will be treated as 'ab')
13407    that = that.slice(0, actual)
13408  }
13409
13410  return that
13411}
13412
13413function fromArrayLike (that, array) {
13414  var length = array.length < 0 ? 0 : checked(array.length) | 0
13415  that = createBuffer(that, length)
13416  for (var i = 0; i < length; i += 1) {
13417    that[i] = array[i] & 255
13418  }
13419  return that
13420}
13421
13422function fromArrayBuffer (that, array, byteOffset, length) {
13423  array.byteLength // this throws if `array` is not a valid ArrayBuffer
13424
13425  if (byteOffset < 0 || array.byteLength < byteOffset) {
13426    throw new RangeError('\'offset\' is out of bounds')
13427  }
13428
13429  if (array.byteLength < byteOffset + (length || 0)) {
13430    throw new RangeError('\'length\' is out of bounds')
13431  }
13432
13433  if (byteOffset === undefined && length === undefined) {
13434    array = new Uint8Array(array)
13435  } else if (length === undefined) {
13436    array = new Uint8Array(array, byteOffset)
13437  } else {
13438    array = new Uint8Array(array, byteOffset, length)
13439  }
13440
13441  if (Buffer.TYPED_ARRAY_SUPPORT) {
13442    // Return an augmented `Uint8Array` instance, for best performance
13443    that = array
13444    that.__proto__ = Buffer.prototype
13445  } else {
13446    // Fallback: Return an object instance of the Buffer class
13447    that = fromArrayLike(that, array)
13448  }
13449  return that
13450}
13451
13452function fromObject (that, obj) {
13453  if (Buffer.isBuffer(obj)) {
13454    var len = checked(obj.length) | 0
13455    that = createBuffer(that, len)
13456
13457    if (that.length === 0) {
13458      return that
13459    }
13460
13461    obj.copy(that, 0, 0, len)
13462    return that
13463  }
13464
13465  if (obj) {
13466    if ((typeof ArrayBuffer !== 'undefined' &&
13467        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
13468      if (typeof obj.length !== 'number' || isnan(obj.length)) {
13469        return createBuffer(that, 0)
13470      }
13471      return fromArrayLike(that, obj)
13472    }
13473
13474    if (obj.type === 'Buffer' && isArray(obj.data)) {
13475      return fromArrayLike(that, obj.data)
13476    }
13477  }
13478
13479  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
13480}
13481
13482function checked (length) {
13483  // Note: cannot use `length < kMaxLength()` here because that fails when
13484  // length is NaN (which is otherwise coerced to zero.)
13485  if (length >= kMaxLength()) {
13486    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
13487                         'size: 0x' + kMaxLength().toString(16) + ' bytes')
13488  }
13489  return length | 0
13490}
13491
13492function SlowBuffer (length) {
13493  if (+length != length) { // eslint-disable-line eqeqeq
13494    length = 0
13495  }
13496  return Buffer.alloc(+length)
13497}
13498
13499Buffer.isBuffer = function isBuffer (b) {
13500  return !!(b != null && b._isBuffer)
13501}
13502
13503Buffer.compare = function compare (a, b) {
13504  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
13505    throw new TypeError('Arguments must be Buffers')
13506  }
13507
13508  if (a === b) return 0
13509
13510  var x = a.length
13511  var y = b.length
13512
13513  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
13514    if (a[i] !== b[i]) {
13515      x = a[i]
13516      y = b[i]
13517      break
13518    }
13519  }
13520
13521  if (x < y) return -1
13522  if (y < x) return 1
13523  return 0
13524}
13525
13526Buffer.isEncoding = function isEncoding (encoding) {
13527  switch (String(encoding).toLowerCase()) {
13528    case 'hex':
13529    case 'utf8':
13530    case 'utf-8':
13531    case 'ascii':
13532    case 'latin1':
13533    case 'binary':
13534    case 'base64':
13535    case 'ucs2':
13536    case 'ucs-2':
13537    case 'utf16le':
13538    case 'utf-16le':
13539      return true
13540    default:
13541      return false
13542  }
13543}
13544
13545Buffer.concat = function concat (list, length) {
13546  if (!isArray(list)) {
13547    throw new TypeError('"list" argument must be an Array of Buffers')
13548  }
13549
13550  if (list.length === 0) {
13551    return Buffer.alloc(0)
13552  }
13553
13554  var i
13555  if (length === undefined) {
13556    length = 0
13557    for (i = 0; i < list.length; ++i) {
13558      length += list[i].length
13559    }
13560  }
13561
13562  var buffer = Buffer.allocUnsafe(length)
13563  var pos = 0
13564  for (i = 0; i < list.length; ++i) {
13565    var buf = list[i]
13566    if (!Buffer.isBuffer(buf)) {
13567      throw new TypeError('"list" argument must be an Array of Buffers')
13568    }
13569    buf.copy(buffer, pos)
13570    pos += buf.length
13571  }
13572  return buffer
13573}
13574
13575function byteLength (string, encoding) {
13576  if (Buffer.isBuffer(string)) {
13577    return string.length
13578  }
13579  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
13580      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
13581    return string.byteLength
13582  }
13583  if (typeof string !== 'string') {
13584    string = '' + string
13585  }
13586
13587  var len = string.length
13588  if (len === 0) return 0
13589
13590  // Use a for loop to avoid recursion
13591  var loweredCase = false
13592  for (;;) {
13593    switch (encoding) {
13594      case 'ascii':
13595      case 'latin1':
13596      case 'binary':
13597        return len
13598      case 'utf8':
13599      case 'utf-8':
13600      case undefined:
13601        return utf8ToBytes(string).length
13602      case 'ucs2':
13603      case 'ucs-2':
13604      case 'utf16le':
13605      case 'utf-16le':
13606        return len * 2
13607      case 'hex':
13608        return len >>> 1
13609      case 'base64':
13610        return base64ToBytes(string).length
13611      default:
13612        if (loweredCase) return utf8ToBytes(string).length // assume utf8
13613        encoding = ('' + encoding).toLowerCase()
13614        loweredCase = true
13615    }
13616  }
13617}
13618Buffer.byteLength = byteLength
13619
13620function slowToString (encoding, start, end) {
13621  var loweredCase = false
13622
13623  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
13624  // property of a typed array.
13625
13626  // This behaves neither like String nor Uint8Array in that we set start/end
13627  // to their upper/lower bounds if the value passed is out of range.
13628  // undefined is handled specially as per ECMA-262 6th Edition,
13629  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
13630  if (start === undefined || start < 0) {
13631    start = 0
13632  }
13633  // Return early if start > this.length. Done here to prevent potential uint32
13634  // coercion fail below.
13635  if (start > this.length) {
13636    return ''
13637  }
13638
13639  if (end === undefined || end > this.length) {
13640    end = this.length
13641  }
13642
13643  if (end <= 0) {
13644    return ''
13645  }
13646
13647  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
13648  end >>>= 0
13649  start >>>= 0
13650
13651  if (end <= start) {
13652    return ''
13653  }
13654
13655  if (!encoding) encoding = 'utf8'
13656
13657  while (true) {
13658    switch (encoding) {
13659      case 'hex':
13660        return hexSlice(this, start, end)
13661
13662      case 'utf8':
13663      case 'utf-8':
13664        return utf8Slice(this, start, end)
13665
13666      case 'ascii':
13667        return asciiSlice(this, start, end)
13668
13669      case 'latin1':
13670      case 'binary':
13671        return latin1Slice(this, start, end)
13672
13673      case 'base64':
13674        return base64Slice(this, start, end)
13675
13676      case 'ucs2':
13677      case 'ucs-2':
13678      case 'utf16le':
13679      case 'utf-16le':
13680        return utf16leSlice(this, start, end)
13681
13682      default:
13683        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
13684        encoding = (encoding + '').toLowerCase()
13685        loweredCase = true
13686    }
13687  }
13688}
13689
13690// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
13691// Buffer instances.
13692Buffer.prototype._isBuffer = true
13693
13694function swap (b, n, m) {
13695  var i = b[n]
13696  b[n] = b[m]
13697  b[m] = i
13698}
13699
13700Buffer.prototype.swap16 = function swap16 () {
13701  var len = this.length
13702  if (len % 2 !== 0) {
13703    throw new RangeError('Buffer size must be a multiple of 16-bits')
13704  }
13705  for (var i = 0; i < len; i += 2) {
13706    swap(this, i, i + 1)
13707  }
13708  return this
13709}
13710
13711Buffer.prototype.swap32 = function swap32 () {
13712  var len = this.length
13713  if (len % 4 !== 0) {
13714    throw new RangeError('Buffer size must be a multiple of 32-bits')
13715  }
13716  for (var i = 0; i < len; i += 4) {
13717    swap(this, i, i + 3)
13718    swap(this, i + 1, i + 2)
13719  }
13720  return this
13721}
13722
13723Buffer.prototype.swap64 = function swap64 () {
13724  var len = this.length
13725  if (len % 8 !== 0) {
13726    throw new RangeError('Buffer size must be a multiple of 64-bits')
13727  }
13728  for (var i = 0; i < len; i += 8) {
13729    swap(this, i, i + 7)
13730    swap(this, i + 1, i + 6)
13731    swap(this, i + 2, i + 5)
13732    swap(this, i + 3, i + 4)
13733  }
13734  return this
13735}
13736
13737Buffer.prototype.toString = function toString () {
13738  var length = this.length | 0
13739  if (length === 0) return ''
13740  if (arguments.length === 0) return utf8Slice(this, 0, length)
13741  return slowToString.apply(this, arguments)
13742}
13743
13744Buffer.prototype.equals = function equals (b) {
13745  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
13746  if (this === b) return true
13747  return Buffer.compare(this, b) === 0
13748}
13749
13750Buffer.prototype.inspect = function inspect () {
13751  var str = ''
13752  var max = exports.INSPECT_MAX_BYTES
13753  if (this.length > 0) {
13754    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
13755    if (this.length > max) str += ' ... '
13756  }
13757  return '<Buffer ' + str + '>'
13758}
13759
13760Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
13761  if (!Buffer.isBuffer(target)) {
13762    throw new TypeError('Argument must be a Buffer')
13763  }
13764
13765  if (start === undefined) {
13766    start = 0
13767  }
13768  if (end === undefined) {
13769    end = target ? target.length : 0
13770  }
13771  if (thisStart === undefined) {
13772    thisStart = 0
13773  }
13774  if (thisEnd === undefined) {
13775    thisEnd = this.length
13776  }
13777
13778  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
13779    throw new RangeError('out of range index')
13780  }
13781
13782  if (thisStart >= thisEnd && start >= end) {
13783    return 0
13784  }
13785  if (thisStart >= thisEnd) {
13786    return -1
13787  }
13788  if (start >= end) {
13789    return 1
13790  }
13791
13792  start >>>= 0
13793  end >>>= 0
13794  thisStart >>>= 0
13795  thisEnd >>>= 0
13796
13797  if (this === target) return 0
13798
13799  var x = thisEnd - thisStart
13800  var y = end - start
13801  var len = Math.min(x, y)
13802
13803  var thisCopy = this.slice(thisStart, thisEnd)
13804  var targetCopy = target.slice(start, end)
13805
13806  for (var i = 0; i < len; ++i) {
13807    if (thisCopy[i] !== targetCopy[i]) {
13808      x = thisCopy[i]
13809      y = targetCopy[i]
13810      break
13811    }
13812  }
13813
13814  if (x < y) return -1
13815  if (y < x) return 1
13816  return 0
13817}
13818
13819// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
13820// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
13821//
13822// Arguments:
13823// - buffer - a Buffer to search
13824// - val - a string, Buffer, or number
13825// - byteOffset - an index into `buffer`; will be clamped to an int32
13826// - encoding - an optional encoding, relevant is val is a string
13827// - dir - true for indexOf, false for lastIndexOf
13828function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
13829  // Empty buffer means no match
13830  if (buffer.length === 0) return -1
13831
13832  // Normalize byteOffset
13833  if (typeof byteOffset === 'string') {
13834    encoding = byteOffset
13835    byteOffset = 0
13836  } else if (byteOffset > 0x7fffffff) {
13837    byteOffset = 0x7fffffff
13838  } else if (byteOffset < -0x80000000) {
13839    byteOffset = -0x80000000
13840  }
13841  byteOffset = +byteOffset  // Coerce to Number.
13842  if (isNaN(byteOffset)) {
13843    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
13844    byteOffset = dir ? 0 : (buffer.length - 1)
13845  }
13846
13847  // Normalize byteOffset: negative offsets start from the end of the buffer
13848  if (byteOffset < 0) byteOffset = buffer.length + byteOffset
13849  if (byteOffset >= buffer.length) {
13850    if (dir) return -1
13851    else byteOffset = buffer.length - 1
13852  } else if (byteOffset < 0) {
13853    if (dir) byteOffset = 0
13854    else return -1
13855  }
13856
13857  // Normalize val
13858  if (typeof val === 'string') {
13859    val = Buffer.from(val, encoding)
13860  }
13861
13862  // Finally, search either indexOf (if dir is true) or lastIndexOf
13863  if (Buffer.isBuffer(val)) {
13864    // Special case: looking for empty string/buffer always fails
13865    if (val.length === 0) {
13866      return -1
13867    }
13868    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
13869  } else if (typeof val === 'number') {
13870    val = val & 0xFF // Search for a byte value [0-255]
13871    if (Buffer.TYPED_ARRAY_SUPPORT &&
13872        typeof Uint8Array.prototype.indexOf === 'function') {
13873      if (dir) {
13874        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
13875      } else {
13876        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
13877      }
13878    }
13879    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
13880  }
13881
13882  throw new TypeError('val must be string, number or Buffer')
13883}
13884
13885function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
13886  var indexSize = 1
13887  var arrLength = arr.length
13888  var valLength = val.length
13889
13890  if (encoding !== undefined) {
13891    encoding = String(encoding).toLowerCase()
13892    if (encoding === 'ucs2' || encoding === 'ucs-2' ||
13893        encoding === 'utf16le' || encoding === 'utf-16le') {
13894      if (arr.length < 2 || val.length < 2) {
13895        return -1
13896      }
13897      indexSize = 2
13898      arrLength /= 2
13899      valLength /= 2
13900      byteOffset /= 2
13901    }
13902  }
13903
13904  function read (buf, i) {
13905    if (indexSize === 1) {
13906      return buf[i]
13907    } else {
13908      return buf.readUInt16BE(i * indexSize)
13909    }
13910  }
13911
13912  var i
13913  if (dir) {
13914    var foundIndex = -1
13915    for (i = byteOffset; i < arrLength; i++) {
13916      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
13917        if (foundIndex === -1) foundIndex = i
13918        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
13919      } else {
13920        if (foundIndex !== -1) i -= i - foundIndex
13921        foundIndex = -1
13922      }
13923    }
13924  } else {
13925    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
13926    for (i = byteOffset; i >= 0; i--) {
13927      var found = true
13928      for (var j = 0; j < valLength; j++) {
13929        if (read(arr, i + j) !== read(val, j)) {
13930          found = false
13931          break
13932        }
13933      }
13934      if (found) return i
13935    }
13936  }
13937
13938  return -1
13939}
13940
13941Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
13942  return this.indexOf(val, byteOffset, encoding) !== -1
13943}
13944
13945Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
13946  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
13947}
13948
13949Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
13950  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
13951}
13952
13953function hexWrite (buf, string, offset, length) {
13954  offset = Number(offset) || 0
13955  var remaining = buf.length - offset
13956  if (!length) {
13957    length = remaining
13958  } else {
13959    length = Number(length)
13960    if (length > remaining) {
13961      length = remaining
13962    }
13963  }
13964
13965  // must be an even number of digits
13966  var strLen = string.length
13967  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
13968
13969  if (length > strLen / 2) {
13970    length = strLen / 2
13971  }
13972  for (var i = 0; i < length; ++i) {
13973    var parsed = parseInt(string.substr(i * 2, 2), 16)
13974    if (isNaN(parsed)) return i
13975    buf[offset + i] = parsed
13976  }
13977  return i
13978}
13979
13980function utf8Write (buf, string, offset, length) {
13981  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
13982}
13983
13984function asciiWrite (buf, string, offset, length) {
13985  return blitBuffer(asciiToBytes(string), buf, offset, length)
13986}
13987
13988function latin1Write (buf, string, offset, length) {
13989  return asciiWrite(buf, string, offset, length)
13990}
13991
13992function base64Write (buf, string, offset, length) {
13993  return blitBuffer(base64ToBytes(string), buf, offset, length)
13994}
13995
13996function ucs2Write (buf, string, offset, length) {
13997  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
13998}
13999
14000Buffer.prototype.write = function write (string, offset, length, encoding) {
14001  // Buffer#write(string)
14002  if (offset === undefined) {
14003    encoding = 'utf8'
14004    length = this.length
14005    offset = 0
14006  // Buffer#write(string, encoding)
14007  } else if (length === undefined && typeof offset === 'string') {
14008    encoding = offset
14009    length = this.length
14010    offset = 0
14011  // Buffer#write(string, offset[, length][, encoding])
14012  } else if (isFinite(offset)) {
14013    offset = offset | 0
14014    if (isFinite(length)) {
14015      length = length | 0
14016      if (encoding === undefined) encoding = 'utf8'
14017    } else {
14018      encoding = length
14019      length = undefined
14020    }
14021  // legacy write(string, encoding, offset, length) - remove in v0.13
14022  } else {
14023    throw new Error(
14024      'Buffer.write(string, encoding, offset[, length]) is no longer supported'
14025    )
14026  }
14027
14028  var remaining = this.length - offset
14029  if (length === undefined || length > remaining) length = remaining
14030
14031  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
14032    throw new RangeError('Attempt to write outside buffer bounds')
14033  }
14034
14035  if (!encoding) encoding = 'utf8'
14036
14037  var loweredCase = false
14038  for (;;) {
14039    switch (encoding) {
14040      case 'hex':
14041        return hexWrite(this, string, offset, length)
14042
14043      case 'utf8':
14044      case 'utf-8':
14045        return utf8Write(this, string, offset, length)
14046
14047      case 'ascii':
14048        return asciiWrite(this, string, offset, length)
14049
14050      case 'latin1':
14051      case 'binary':
14052        return latin1Write(this, string, offset, length)
14053
14054      case 'base64':
14055        // Warning: maxLength not taken into account in base64Write
14056        return base64Write(this, string, offset, length)
14057
14058      case 'ucs2':
14059      case 'ucs-2':
14060      case 'utf16le':
14061      case 'utf-16le':
14062        return ucs2Write(this, string, offset, length)
14063
14064      default:
14065        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
14066        encoding = ('' + encoding).toLowerCase()
14067        loweredCase = true
14068    }
14069  }
14070}
14071
14072Buffer.prototype.toJSON = function toJSON () {
14073  return {
14074    type: 'Buffer',
14075    data: Array.prototype.slice.call(this._arr || this, 0)
14076  }
14077}
14078
14079function base64Slice (buf, start, end) {
14080  if (start === 0 && end === buf.length) {
14081    return base64.fromByteArray(buf)
14082  } else {
14083    return base64.fromByteArray(buf.slice(start, end))
14084  }
14085}
14086
14087function utf8Slice (buf, start, end) {
14088  end = Math.min(buf.length, end)
14089  var res = []
14090
14091  var i = start
14092  while (i < end) {
14093    var firstByte = buf[i]
14094    var codePoint = null
14095    var bytesPerSequence = (firstByte > 0xEF) ? 4
14096      : (firstByte > 0xDF) ? 3
14097      : (firstByte > 0xBF) ? 2
14098      : 1
14099
14100    if (i + bytesPerSequence <= end) {
14101      var secondByte, thirdByte, fourthByte, tempCodePoint
14102
14103      switch (bytesPerSequence) {
14104        case 1:
14105          if (firstByte < 0x80) {
14106            codePoint = firstByte
14107          }
14108          break
14109        case 2:
14110          secondByte = buf[i + 1]
14111          if ((secondByte & 0xC0) === 0x80) {
14112            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
14113            if (tempCodePoint > 0x7F) {
14114              codePoint = tempCodePoint
14115            }
14116          }
14117          break
14118        case 3:
14119          secondByte = buf[i + 1]
14120          thirdByte = buf[i + 2]
14121          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
14122            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
14123            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
14124              codePoint = tempCodePoint
14125            }
14126          }
14127          break
14128        case 4:
14129          secondByte = buf[i + 1]
14130          thirdByte = buf[i + 2]
14131          fourthByte = buf[i + 3]
14132          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
14133            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
14134            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
14135              codePoint = tempCodePoint
14136            }
14137          }
14138      }
14139    }
14140
14141    if (codePoint === null) {
14142      // we did not generate a valid codePoint so insert a
14143      // replacement char (U+FFFD) and advance only 1 byte
14144      codePoint = 0xFFFD
14145      bytesPerSequence = 1
14146    } else if (codePoint > 0xFFFF) {
14147      // encode to utf16 (surrogate pair dance)
14148      codePoint -= 0x10000
14149      res.push(codePoint >>> 10 & 0x3FF | 0xD800)
14150      codePoint = 0xDC00 | codePoint & 0x3FF
14151    }
14152
14153    res.push(codePoint)
14154    i += bytesPerSequence
14155  }
14156
14157  return decodeCodePointsArray(res)
14158}
14159
14160// Based on http://stackoverflow.com/a/22747272/680742, the browser with
14161// the lowest limit is Chrome, with 0x10000 args.
14162// We go 1 magnitude less, for safety
14163var MAX_ARGUMENTS_LENGTH = 0x1000
14164
14165function decodeCodePointsArray (codePoints) {
14166  var len = codePoints.length
14167  if (len <= MAX_ARGUMENTS_LENGTH) {
14168    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
14169  }
14170
14171  // Decode in chunks to avoid "call stack size exceeded".
14172  var res = ''
14173  var i = 0
14174  while (i < len) {
14175    res += String.fromCharCode.apply(
14176      String,
14177      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
14178    )
14179  }
14180  return res
14181}
14182
14183function asciiSlice (buf, start, end) {
14184  var ret = ''
14185  end = Math.min(buf.length, end)
14186
14187  for (var i = start; i < end; ++i) {
14188    ret += String.fromCharCode(buf[i] & 0x7F)
14189  }
14190  return ret
14191}
14192
14193function latin1Slice (buf, start, end) {
14194  var ret = ''
14195  end = Math.min(buf.length, end)
14196
14197  for (var i = start; i < end; ++i) {
14198    ret += String.fromCharCode(buf[i])
14199  }
14200  return ret
14201}
14202
14203function hexSlice (buf, start, end) {
14204  var len = buf.length
14205
14206  if (!start || start < 0) start = 0
14207  if (!end || end < 0 || end > len) end = len
14208
14209  var out = ''
14210  for (var i = start; i < end; ++i) {
14211    out += toHex(buf[i])
14212  }
14213  return out
14214}
14215
14216function utf16leSlice (buf, start, end) {
14217  var bytes = buf.slice(start, end)
14218  var res = ''
14219  for (var i = 0; i < bytes.length; i += 2) {
14220    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
14221  }
14222  return res
14223}
14224
14225Buffer.prototype.slice = function slice (start, end) {
14226  var len = this.length
14227  start = ~~start
14228  end = end === undefined ? len : ~~end
14229
14230  if (start < 0) {
14231    start += len
14232    if (start < 0) start = 0
14233  } else if (start > len) {
14234    start = len
14235  }
14236
14237  if (end < 0) {
14238    end += len
14239    if (end < 0) end = 0
14240  } else if (end > len) {
14241    end = len
14242  }
14243
14244  if (end < start) end = start
14245
14246  var newBuf
14247  if (Buffer.TYPED_ARRAY_SUPPORT) {
14248    newBuf = this.subarray(start, end)
14249    newBuf.__proto__ = Buffer.prototype
14250  } else {
14251    var sliceLen = end - start
14252    newBuf = new Buffer(sliceLen, undefined)
14253    for (var i = 0; i < sliceLen; ++i) {
14254      newBuf[i] = this[i + start]
14255    }
14256  }
14257
14258  return newBuf
14259}
14260
14261/*
14262 * Need to make sure that buffer isn't trying to write out of bounds.
14263 */
14264function checkOffset (offset, ext, length) {
14265  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
14266  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
14267}
14268
14269Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
14270  offset = offset | 0
14271  byteLength = byteLength | 0
14272  if (!noAssert) checkOffset(offset, byteLength, this.length)
14273
14274  var val = this[offset]
14275  var mul = 1
14276  var i = 0
14277  while (++i < byteLength && (mul *= 0x100)) {
14278    val += this[offset + i] * mul
14279  }
14280
14281  return val
14282}
14283
14284Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
14285  offset = offset | 0
14286  byteLength = byteLength | 0
14287  if (!noAssert) {
14288    checkOffset(offset, byteLength, this.length)
14289  }
14290
14291  var val = this[offset + --byteLength]
14292  var mul = 1
14293  while (byteLength > 0 && (mul *= 0x100)) {
14294    val += this[offset + --byteLength] * mul
14295  }
14296
14297  return val
14298}
14299
14300Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
14301  if (!noAssert) checkOffset(offset, 1, this.length)
14302  return this[offset]
14303}
14304
14305Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
14306  if (!noAssert) checkOffset(offset, 2, this.length)
14307  return this[offset] | (this[offset + 1] << 8)
14308}
14309
14310Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
14311  if (!noAssert) checkOffset(offset, 2, this.length)
14312  return (this[offset] << 8) | this[offset + 1]
14313}
14314
14315Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
14316  if (!noAssert) checkOffset(offset, 4, this.length)
14317
14318  return ((this[offset]) |
14319      (this[offset + 1] << 8) |
14320      (this[offset + 2] << 16)) +
14321      (this[offset + 3] * 0x1000000)
14322}
14323
14324Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
14325  if (!noAssert) checkOffset(offset, 4, this.length)
14326
14327  return (this[offset] * 0x1000000) +
14328    ((this[offset + 1] << 16) |
14329    (this[offset + 2] << 8) |
14330    this[offset + 3])
14331}
14332
14333Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
14334  offset = offset | 0
14335  byteLength = byteLength | 0
14336  if (!noAssert) checkOffset(offset, byteLength, this.length)
14337
14338  var val = this[offset]
14339  var mul = 1
14340  var i = 0
14341  while (++i < byteLength && (mul *= 0x100)) {
14342    val += this[offset + i] * mul
14343  }
14344  mul *= 0x80
14345
14346  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
14347
14348  return val
14349}
14350
14351Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
14352  offset = offset | 0
14353  byteLength = byteLength | 0
14354  if (!noAssert) checkOffset(offset, byteLength, this.length)
14355
14356  var i = byteLength
14357  var mul = 1
14358  var val = this[offset + --i]
14359  while (i > 0 && (mul *= 0x100)) {
14360    val += this[offset + --i] * mul
14361  }
14362  mul *= 0x80
14363
14364  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
14365
14366  return val
14367}
14368
14369Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
14370  if (!noAssert) checkOffset(offset, 1, this.length)
14371  if (!(this[offset] & 0x80)) return (this[offset])
14372  return ((0xff - this[offset] + 1) * -1)
14373}
14374
14375Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
14376  if (!noAssert) checkOffset(offset, 2, this.length)
14377  var val = this[offset] | (this[offset + 1] << 8)
14378  return (val & 0x8000) ? val | 0xFFFF0000 : val
14379}
14380
14381Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
14382  if (!noAssert) checkOffset(offset, 2, this.length)
14383  var val = this[offset + 1] | (this[offset] << 8)
14384  return (val & 0x8000) ? val | 0xFFFF0000 : val
14385}
14386
14387Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
14388  if (!noAssert) checkOffset(offset, 4, this.length)
14389
14390  return (this[offset]) |
14391    (this[offset + 1] << 8) |
14392    (this[offset + 2] << 16) |
14393    (this[offset + 3] << 24)
14394}
14395
14396Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
14397  if (!noAssert) checkOffset(offset, 4, this.length)
14398
14399  return (this[offset] << 24) |
14400    (this[offset + 1] << 16) |
14401    (this[offset + 2] << 8) |
14402    (this[offset + 3])
14403}
14404
14405Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
14406  if (!noAssert) checkOffset(offset, 4, this.length)
14407  return ieee754.read(this, offset, true, 23, 4)
14408}
14409
14410Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
14411  if (!noAssert) checkOffset(offset, 4, this.length)
14412  return ieee754.read(this, offset, false, 23, 4)
14413}
14414
14415Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
14416  if (!noAssert) checkOffset(offset, 8, this.length)
14417  return ieee754.read(this, offset, true, 52, 8)
14418}
14419
14420Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
14421  if (!noAssert) checkOffset(offset, 8, this.length)
14422  return ieee754.read(this, offset, false, 52, 8)
14423}
14424
14425function checkInt (buf, value, offset, ext, max, min) {
14426  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
14427  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
14428  if (offset + ext > buf.length) throw new RangeError('Index out of range')
14429}
14430
14431Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
14432  value = +value
14433  offset = offset | 0
14434  byteLength = byteLength | 0
14435  if (!noAssert) {
14436    var maxBytes = Math.pow(2, 8 * byteLength) - 1
14437    checkInt(this, value, offset, byteLength, maxBytes, 0)
14438  }
14439
14440  var mul = 1
14441  var i = 0
14442  this[offset] = value & 0xFF
14443  while (++i < byteLength && (mul *= 0x100)) {
14444    this[offset + i] = (value / mul) & 0xFF
14445  }
14446
14447  return offset + byteLength
14448}
14449
14450Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
14451  value = +value
14452  offset = offset | 0
14453  byteLength = byteLength | 0
14454  if (!noAssert) {
14455    var maxBytes = Math.pow(2, 8 * byteLength) - 1
14456    checkInt(this, value, offset, byteLength, maxBytes, 0)
14457  }
14458
14459  var i = byteLength - 1
14460  var mul = 1
14461  this[offset + i] = value & 0xFF
14462  while (--i >= 0 && (mul *= 0x100)) {
14463    this[offset + i] = (value / mul) & 0xFF
14464  }
14465
14466  return offset + byteLength
14467}
14468
14469Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
14470  value = +value
14471  offset = offset | 0
14472  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
14473  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
14474  this[offset] = (value & 0xff)
14475  return offset + 1
14476}
14477
14478function objectWriteUInt16 (buf, value, offset, littleEndian) {
14479  if (value < 0) value = 0xffff + value + 1
14480  for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
14481    buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
14482      (littleEndian ? i : 1 - i) * 8
14483  }
14484}
14485
14486Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
14487  value = +value
14488  offset = offset | 0
14489  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
14490  if (Buffer.TYPED_ARRAY_SUPPORT) {
14491    this[offset] = (value & 0xff)
14492    this[offset + 1] = (value >>> 8)
14493  } else {
14494    objectWriteUInt16(this, value, offset, true)
14495  }
14496  return offset + 2
14497}
14498
14499Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
14500  value = +value
14501  offset = offset | 0
14502  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
14503  if (Buffer.TYPED_ARRAY_SUPPORT) {
14504    this[offset] = (value >>> 8)
14505    this[offset + 1] = (value & 0xff)
14506  } else {
14507    objectWriteUInt16(this, value, offset, false)
14508  }
14509  return offset + 2
14510}
14511
14512function objectWriteUInt32 (buf, value, offset, littleEndian) {
14513  if (value < 0) value = 0xffffffff + value + 1
14514  for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
14515    buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
14516  }
14517}
14518
14519Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
14520  value = +value
14521  offset = offset | 0
14522  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
14523  if (Buffer.TYPED_ARRAY_SUPPORT) {
14524    this[offset + 3] = (value >>> 24)
14525    this[offset + 2] = (value >>> 16)
14526    this[offset + 1] = (value >>> 8)
14527    this[offset] = (value & 0xff)
14528  } else {
14529    objectWriteUInt32(this, value, offset, true)
14530  }
14531  return offset + 4
14532}
14533
14534Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
14535  value = +value
14536  offset = offset | 0
14537  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
14538  if (Buffer.TYPED_ARRAY_SUPPORT) {
14539    this[offset] = (value >>> 24)
14540    this[offset + 1] = (value >>> 16)
14541    this[offset + 2] = (value >>> 8)
14542    this[offset + 3] = (value & 0xff)
14543  } else {
14544    objectWriteUInt32(this, value, offset, false)
14545  }
14546  return offset + 4
14547}
14548
14549Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
14550  value = +value
14551  offset = offset | 0
14552  if (!noAssert) {
14553    var limit = Math.pow(2, 8 * byteLength - 1)
14554
14555    checkInt(this, value, offset, byteLength, limit - 1, -limit)
14556  }
14557
14558  var i = 0
14559  var mul = 1
14560  var sub = 0
14561  this[offset] = value & 0xFF
14562  while (++i < byteLength && (mul *= 0x100)) {
14563    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
14564      sub = 1
14565    }
14566    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
14567  }
14568
14569  return offset + byteLength
14570}
14571
14572Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
14573  value = +value
14574  offset = offset | 0
14575  if (!noAssert) {
14576    var limit = Math.pow(2, 8 * byteLength - 1)
14577
14578    checkInt(this, value, offset, byteLength, limit - 1, -limit)
14579  }
14580
14581  var i = byteLength - 1
14582  var mul = 1
14583  var sub = 0
14584  this[offset + i] = value & 0xFF
14585  while (--i >= 0 && (mul *= 0x100)) {
14586    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
14587      sub = 1
14588    }
14589    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
14590  }
14591
14592  return offset + byteLength
14593}
14594
14595Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
14596  value = +value
14597  offset = offset | 0
14598  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
14599  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
14600  if (value < 0) value = 0xff + value + 1
14601  this[offset] = (value & 0xff)
14602  return offset + 1
14603}
14604
14605Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
14606  value = +value
14607  offset = offset | 0
14608  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
14609  if (Buffer.TYPED_ARRAY_SUPPORT) {
14610    this[offset] = (value & 0xff)
14611    this[offset + 1] = (value >>> 8)
14612  } else {
14613    objectWriteUInt16(this, value, offset, true)
14614  }
14615  return offset + 2
14616}
14617
14618Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
14619  value = +value
14620  offset = offset | 0
14621  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
14622  if (Buffer.TYPED_ARRAY_SUPPORT) {
14623    this[offset] = (value >>> 8)
14624    this[offset + 1] = (value & 0xff)
14625  } else {
14626    objectWriteUInt16(this, value, offset, false)
14627  }
14628  return offset + 2
14629}
14630
14631Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
14632  value = +value
14633  offset = offset | 0
14634  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
14635  if (Buffer.TYPED_ARRAY_SUPPORT) {
14636    this[offset] = (value & 0xff)
14637    this[offset + 1] = (value >>> 8)
14638    this[offset + 2] = (value >>> 16)
14639    this[offset + 3] = (value >>> 24)
14640  } else {
14641    objectWriteUInt32(this, value, offset, true)
14642  }
14643  return offset + 4
14644}
14645
14646Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
14647  value = +value
14648  offset = offset | 0
14649  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
14650  if (value < 0) value = 0xffffffff + value + 1
14651  if (Buffer.TYPED_ARRAY_SUPPORT) {
14652    this[offset] = (value >>> 24)
14653    this[offset + 1] = (value >>> 16)
14654    this[offset + 2] = (value >>> 8)
14655    this[offset + 3] = (value & 0xff)
14656  } else {
14657    objectWriteUInt32(this, value, offset, false)
14658  }
14659  return offset + 4
14660}
14661
14662function checkIEEE754 (buf, value, offset, ext, max, min) {
14663  if (offset + ext > buf.length) throw new RangeError('Index out of range')
14664  if (offset < 0) throw new RangeError('Index out of range')
14665}
14666
14667function writeFloat (buf, value, offset, littleEndian, noAssert) {
14668  if (!noAssert) {
14669    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
14670  }
14671  ieee754.write(buf, value, offset, littleEndian, 23, 4)
14672  return offset + 4
14673}
14674
14675Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
14676  return writeFloat(this, value, offset, true, noAssert)
14677}
14678
14679Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
14680  return writeFloat(this, value, offset, false, noAssert)
14681}
14682
14683function writeDouble (buf, value, offset, littleEndian, noAssert) {
14684  if (!noAssert) {
14685    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
14686  }
14687  ieee754.write(buf, value, offset, littleEndian, 52, 8)
14688  return offset + 8
14689}
14690
14691Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
14692  return writeDouble(this, value, offset, true, noAssert)
14693}
14694
14695Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
14696  return writeDouble(this, value, offset, false, noAssert)
14697}
14698
14699// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
14700Buffer.prototype.copy = function copy (target, targetStart, start, end) {
14701  if (!start) start = 0
14702  if (!end && end !== 0) end = this.length
14703  if (targetStart >= target.length) targetStart = target.length
14704  if (!targetStart) targetStart = 0
14705  if (end > 0 && end < start) end = start
14706
14707  // Copy 0 bytes; we're done
14708  if (end === start) return 0
14709  if (target.length === 0 || this.length === 0) return 0
14710
14711  // Fatal error conditions
14712  if (targetStart < 0) {
14713    throw new RangeError('targetStart out of bounds')
14714  }
14715  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
14716  if (end < 0) throw new RangeError('sourceEnd out of bounds')
14717
14718  // Are we oob?
14719  if (end > this.length) end = this.length
14720  if (target.length - targetStart < end - start) {
14721    end = target.length - targetStart + start
14722  }
14723
14724  var len = end - start
14725  var i
14726
14727  if (this === target && start < targetStart && targetStart < end) {
14728    // descending copy from end
14729    for (i = len - 1; i >= 0; --i) {
14730      target[i + targetStart] = this[i + start]
14731    }
14732  } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
14733    // ascending copy from start
14734    for (i = 0; i < len; ++i) {
14735      target[i + targetStart] = this[i + start]
14736    }
14737  } else {
14738    Uint8Array.prototype.set.call(
14739      target,
14740      this.subarray(start, start + len),
14741      targetStart
14742    )
14743  }
14744
14745  return len
14746}
14747
14748// Usage:
14749//    buffer.fill(number[, offset[, end]])
14750//    buffer.fill(buffer[, offset[, end]])
14751//    buffer.fill(string[, offset[, end]][, encoding])
14752Buffer.prototype.fill = function fill (val, start, end, encoding) {
14753  // Handle string cases:
14754  if (typeof val === 'string') {
14755    if (typeof start === 'string') {
14756      encoding = start
14757      start = 0
14758      end = this.length
14759    } else if (typeof end === 'string') {
14760      encoding = end
14761      end = this.length
14762    }
14763    if (val.length === 1) {
14764      var code = val.charCodeAt(0)
14765      if (code < 256) {
14766        val = code
14767      }
14768    }
14769    if (encoding !== undefined && typeof encoding !== 'string') {
14770      throw new TypeError('encoding must be a string')
14771    }
14772    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
14773      throw new TypeError('Unknown encoding: ' + encoding)
14774    }
14775  } else if (typeof val === 'number') {
14776    val = val & 255
14777  }
14778
14779  // Invalid ranges are not set to a default, so can range check early.
14780  if (start < 0 || this.length < start || this.length < end) {
14781    throw new RangeError('Out of range index')
14782  }
14783
14784  if (end <= start) {
14785    return this
14786  }
14787
14788  start = start >>> 0
14789  end = end === undefined ? this.length : end >>> 0
14790
14791  if (!val) val = 0
14792
14793  var i
14794  if (typeof val === 'number') {
14795    for (i = start; i < end; ++i) {
14796      this[i] = val
14797    }
14798  } else {
14799    var bytes = Buffer.isBuffer(val)
14800      ? val
14801      : utf8ToBytes(new Buffer(val, encoding).toString())
14802    var len = bytes.length
14803    for (i = 0; i < end - start; ++i) {
14804      this[i + start] = bytes[i % len]
14805    }
14806  }
14807
14808  return this
14809}
14810
14811// HELPER FUNCTIONS
14812// ================
14813
14814var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
14815
14816function base64clean (str) {
14817  // Node strips out invalid characters like \n and \t from the string, base64-js does not
14818  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
14819  // Node converts strings with length < 2 to ''
14820  if (str.length < 2) return ''
14821  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
14822  while (str.length % 4 !== 0) {
14823    str = str + '='
14824  }
14825  return str
14826}
14827
14828function stringtrim (str) {
14829  if (str.trim) return str.trim()
14830  return str.replace(/^\s+|\s+$/g, '')
14831}
14832
14833function toHex (n) {
14834  if (n < 16) return '0' + n.toString(16)
14835  return n.toString(16)
14836}
14837
14838function utf8ToBytes (string, units) {
14839  units = units || Infinity
14840  var codePoint
14841  var length = string.length
14842  var leadSurrogate = null
14843  var bytes = []
14844
14845  for (var i = 0; i < length; ++i) {
14846    codePoint = string.charCodeAt(i)
14847
14848    // is surrogate component
14849    if (codePoint > 0xD7FF && codePoint < 0xE000) {
14850      // last char was a lead
14851      if (!leadSurrogate) {
14852        // no lead yet
14853        if (codePoint > 0xDBFF) {
14854          // unexpected trail
14855          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14856          continue
14857        } else if (i + 1 === length) {
14858          // unpaired lead
14859          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14860          continue
14861        }
14862
14863        // valid lead
14864        leadSurrogate = codePoint
14865
14866        continue
14867      }
14868
14869      // 2 leads in a row
14870      if (codePoint < 0xDC00) {
14871        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14872        leadSurrogate = codePoint
14873        continue
14874      }
14875
14876      // valid surrogate pair
14877      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
14878    } else if (leadSurrogate) {
14879      // valid bmp char, but last char was a lead
14880      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14881    }
14882
14883    leadSurrogate = null
14884
14885    // encode utf8
14886    if (codePoint < 0x80) {
14887      if ((units -= 1) < 0) break
14888      bytes.push(codePoint)
14889    } else if (codePoint < 0x800) {
14890      if ((units -= 2) < 0) break
14891      bytes.push(
14892        codePoint >> 0x6 | 0xC0,
14893        codePoint & 0x3F | 0x80
14894      )
14895    } else if (codePoint < 0x10000) {
14896      if ((units -= 3) < 0) break
14897      bytes.push(
14898        codePoint >> 0xC | 0xE0,
14899        codePoint >> 0x6 & 0x3F | 0x80,
14900        codePoint & 0x3F | 0x80
14901      )
14902    } else if (codePoint < 0x110000) {
14903      if ((units -= 4) < 0) break
14904      bytes.push(
14905        codePoint >> 0x12 | 0xF0,
14906        codePoint >> 0xC & 0x3F | 0x80,
14907        codePoint >> 0x6 & 0x3F | 0x80,
14908        codePoint & 0x3F | 0x80
14909      )
14910    } else {
14911      throw new Error('Invalid code point')
14912    }
14913  }
14914
14915  return bytes
14916}
14917
14918function asciiToBytes (str) {
14919  var byteArray = []
14920  for (var i = 0; i < str.length; ++i) {
14921    // Node's code seems to be doing this and not & 0x7F..
14922    byteArray.push(str.charCodeAt(i) & 0xFF)
14923  }
14924  return byteArray
14925}
14926
14927function utf16leToBytes (str, units) {
14928  var c, hi, lo
14929  var byteArray = []
14930  for (var i = 0; i < str.length; ++i) {
14931    if ((units -= 2) < 0) break
14932
14933    c = str.charCodeAt(i)
14934    hi = c >> 8
14935    lo = c % 256
14936    byteArray.push(lo)
14937    byteArray.push(hi)
14938  }
14939
14940  return byteArray
14941}
14942
14943function base64ToBytes (str) {
14944  return base64.toByteArray(base64clean(str))
14945}
14946
14947function blitBuffer (src, dst, offset, length) {
14948  for (var i = 0; i < length; ++i) {
14949    if ((i + offset >= dst.length) || (i >= src.length)) break
14950    dst[i + offset] = src[i]
14951  }
14952  return i
14953}
14954
14955function isnan (val) {
14956  return val !== val // eslint-disable-line no-self-compare
14957}
14958
14959/* WEBPACK VAR INJECTION */}.call(
14959exports, __webpack_require__(3).Buffer, __webpack_require__(6)))
14960
14961/***/ },
14962/* 4 */
14963/***/ function(module, exports, __webpack_require__) {
14964
14965"use strict";
14966'use strict';
14967
14968var curve = exports;
14969
14970curve.base = __webpack_require__(13);
14971curve.short = __webpack_require__(16);
14972curve.mont = __webpack_require__(15);
14973curve.edwards = __webpack_require__(14);
14974
14975
14976/***/ },
14977/* 5 */
14978/***/ function(module, exports) {
14979
14980if (typeof Object.create === 'function') {
14981  // implementation from standard node.js 'util' module
14982  module.exports = function inherits(ctor, superCtor) {
14983    ctor.super_ = superCtor
14984    ctor.prototype = Object.create(superCtor.prototype, {
14985      constructor: {
14986        value: ctor,
14987        enumerable: false,
14988        writable: true,
14989        configurable: true
14990      }
14991    });
14992  };
14993} else {
14994  // old school shim for old browsers
14995  module.exports = function inherits(ctor, superCtor) {
14996    ctor.super_ = superCtor
14997    var TempCtor = function () {}
14998    TempCtor.prototype = superCtor.prototype
14999    ctor.prototype = new TempCtor()
15000    ctor.prototype.constructor = ctor
15001  }
15002}
15003
15004
15005/***/ },
15006/* 6 */
15007/***/ function(module, exports) {
15008
15009var g;
15010
15011// This works in non-strict mode
15012g = (function() { return this; })();
15013
15014try {
15015	// This works if eval is allowed (see CSP)
15016	g = g || Function("return this")() || (1,eval)("this");
15017} catch(e) {
15018	// This works if the window reference is available
15019	if(typeof window === "object")
15020		g = window;
15021}
15022
15023// g can still be undefined, but nothing to do about it...
15024// We return undefined, instead of nothing here, so it's
15025// easier to handle this case. if(!global) { ...}
15026
15027module.exports = g;
15028
15029
15030/***/ },
15031/* 7 */
15032/***/ function(module, exports, __webpack_require__) {
15033
15034/* WEBPACK VAR INJECTION */(function(process, global) {/**
15035 * [js-sha3]{@link https://github.com/emn178/js-sha3}
15036 *
15037 * @version 0.5.5
15038 * @author Chen, Yi-Cyuan [[email protected]]
15039 * @copyright Chen, Yi-Cyuan 2015-2016
15040 * @license MIT
15041 */
15042(function (root) {
15043  'use strict';
15044
15045  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
15046  if (NODE_JS) {
15047    root = global;
15048  }
15049  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;
15050  var HEX_CHARS = '0123456789abcdef'.split('');
15051  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
15052  var KECCAK_PADDING = [1, 256, 65536, 16777216];
15053  var PADDING = [6, 1536, 393216, 100663296];
15054  var SHIFT = [0, 8, 16, 24];
15055  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
15056            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 
15057            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 
15058            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
15059            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
15060  var BITS = [224, 256, 384, 512];
15061  var SHAKE_BITS = [128, 256];
15062  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];
15063
15064  var createOutputMethod = function (bits, padding, outputType) {
15065    return function (message) {
15066      return new Keccak(bits, padding, bits).update(message)[outputType]();
15067    }
15068  };
15069
15070  var createShakeOutputMethod = function (bits, padding, outputType) {
15071    return function (message, outputBits) {
15072      return new Keccak(bits, padding, outputBits).update(message)[outputType]();
15073    }
15074  };
15075
15076  var createMethod = function (bits, padding) {
15077    var method = createOutputMethod(bits, padding, 'hex');
15078    method.create = function () {
15079      return new Keccak(bits, padding, bits);
15080    };
15081    method.update = function (message) {
15082      return method.create().update(message);
15083    };
15084    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
15085      var type = OUTPUT_TYPES[i];
15086      method[type] = createOutputMethod(bits, padding, type);
15087    }
15088    return method;
15089  };
15090
15091  var createShakeMethod = function (bits, padding) {
15092    var method = createShakeOutputMethod(bits, padding, 'hex');
15093    method.create = function (outputBits) {
15094      return new Keccak(bits, padding, outputBits);
15095    };
15096    method.update = function (message, outputBits) {
15097      return method.create(outputBits).update(message);
15098    };
15099    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
15100      var type = OUTPUT_TYPES[i];
15101      method[type] = createShakeOutputMethod(bits, padding, type);
15102    }
15103    return method;
15104  };
15105
15106  var algorithms = [
15107    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},
15108    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},
vendor: 11,326 bytes, lines 15109-15457
15109    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}
15110  ];
15111
15112  var methods = {};
15113
15114  for (var i = 0;i < algorithms.length;++i) {
15115    var algorithm = algorithms[i];
15116    var bits  = algorithm.bits;
15117    for (var j = 0;j < bits.length;++j) {
15118      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);
15119    }
15120  }
15121
15122  function Keccak(bits, padding, outputBits) {
15123    this.blocks = [];
15124    this.s = [];
15125    this.padding = padding;
15126    this.outputBits = outputBits;
15127    this.reset = true;
15128    this.block = 0;
15129    this.start = 0;
15130    this.blockCount = (1600 - (bits << 1)) >> 5;
15131    this.byteCount = this.blockCount << 2;
15132    this.outputBlocks = outputBits >> 5;
15133    this.extraBytes = (outputBits & 31) >> 3;
15134
15135    for (var i = 0;i < 50;++i) {
15136      this.s[i] = 0;
15137    }
15138  };
15139
15140  Keccak.prototype.update = function (message) {
15141    var notString = typeof message != 'string';
15142    if (notString && message.constructor == root.ArrayBuffer) {
15143      message = new Uint8Array(message);
15144    }
15145    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, 
15146        blockCount = this.blockCount, index = 0, s = this.s, i, code;
15147    
15148    while (index < length) {
15149      if (this.reset) {
15150        this.reset = false;
15151        blocks[0] = this.block;
15152        for (i = 1;i < blockCount + 1;++i) {
15153          blocks[i] = 0;
15154        }
15155      }
15156      if (notString) {
15157        for (i = this.start;index < length && i < byteCount;++index) {
15158          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
15159        }
15160      } else {
15161        for (i = this.start;index < length && i < byteCount;++index) {
15162          code = message.charCodeAt(index);
15163          if (code < 0x80) {
15164            blocks[i >> 2] |= code << SHIFT[i++ & 3];
15165          } else if (code < 0x800) {
15166            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
15167            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
15168          } else if (code < 0xd800 || code >= 0xe000) {
15169            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
15170            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
15171            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
15172          } else {
15173            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
15174            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
15175            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
15176            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
15177            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
15178          }
15179        }
15180      }
15181      this.lastByteIndex = i;
15182      if (i >= byteCount) {
15183        this.start = i - byteCount;
15184        this.block = blocks[blockCount];
15185        for (i = 0;i < blockCount;++i) {
15186          s[i] ^= blocks[i];
15187        }
15188        f(s);
15189        this.reset = true;
15190      } else {
15191        this.start = i;
15192      }
15193    }
15194    return this;
15195  };
15196
15197  Keccak.prototype.finalize = function () {
15198    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
15199    blocks[i >> 2] |= this.padding[i & 3];
15200    if (this.lastByteIndex == this.byteCount) {
15201      blocks[0] = blocks[blockCount];
15202      for (i = 1;i < blockCount + 1;++i) {
15203        blocks[i] = 0;
15204      }
15205    }
15206    blocks[blockCount - 1] |= 0x80000000;
15207    for (i = 0;i < blockCount;++i) {
15208      s[i] ^= blocks[i];
15209    }
15210    f(s);
15211  };
15212
15213  Keccak.prototype.toString = Keccak.prototype.hex = function () {
15214    this.finalize();
15215
15216    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
15217        extraBytes = this.extraBytes, i = 0, j = 0;
15218    var hex = '', block;
15219    while (j < outputBlocks) {
15220      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
15221        block = s[i];
15222        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
15223               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
15224               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
15225               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
15226      }
15227      if (j % blockCount == 0) {
15228        f(s);
15229        i = 0;
15230      }
15231    }
15232    if (extraBytes) {
15233      block = s[i];
15234      if (extraBytes > 0) {
15235        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
15236      }
15237      if (extraBytes > 1) {
15238        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
15239      }
15240      if (extraBytes > 2) {
15241        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
15242      }
15243    }
15244    return hex;
15245  };
15246
15247  Keccak.prototype.arrayBuffer = function () {
15248    this.finalize();
15249
15250    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
15251        extraBytes = this.extraBytes, i = 0, j = 0;
15252    var bytes = this.outputBits >> 3;
15253    var buffer;
15254    if (extraBytes) {
15255      buffer = new ArrayBuffer((outputBlocks + 1) << 2);
15256    } else {
15257      buffer = new ArrayBuffer(bytes);
15258    }
15259    var array = new Uint32Array(buffer);
15260    while (j < outputBlocks) {
15261      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
15262        array[j] = s[i];
15263      }
15264      if (j % blockCount == 0) {
15265        f(s);
15266      }
15267    }
15268    if (extraBytes) {
15269      array[i] = s[i];
15270      buffer = buffer.slice(0, bytes);
15271    }
15272    return buffer;
15273  };
15274
15275  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
15276
15277  Keccak.prototype.digest = Keccak.prototype.array = function () {
15278    this.finalize();
15279
15280    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
15281        extraBytes = this.extraBytes, i = 0, j = 0;
15282    var array = [], offset, block;
15283    while (j < outputBlocks) {
15284      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
15285        offset = j << 2;
15286        block = s[i];
15287        array[offset] = block & 0xFF;
15288        array[offset + 1] = (block >> 8) & 0xFF;
15289        array[offset + 2] = (block >> 16) & 0xFF;
15290        array[offset + 3] = (block >> 24) & 0xFF;
15291      }
15292      if (j % blockCount == 0) {
15293        f(s);
15294      }
15295    }
15296    if (extraBytes) {
15297      offset = j << 2;
15298      block = s[i];
15299      if (extraBytes > 0) {
15300        array[offset] = block & 0xFF;
15301      }
15302      if (extraBytes > 1) {
15303        array[offset + 1] = (block >> 8) & 0xFF;
15304      }
15305      if (extraBytes > 2) {
15306        array[offset + 2] = (block >> 16) & 0xFF;
15307      }
15308    }
15309    return array;
15310  };
15311
15312  var f = function (s) {
15313    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, 
15314        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, 
15315        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, 
15316        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
15317    for (n = 0;n < 48;n += 2) {
15318      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
15319      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
15320      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
15321      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
15322      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
15323      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
15324      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
15325      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
15326      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
15327      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
15328
15329      h = c8 ^ ((c2 << 1) | (c3 >>> 31));
15330      l = c9 ^ ((c3 << 1) | (c2 >>> 31));
15331      s[0] ^= h;
15332      s[1] ^= l;
15333      s[10] ^= h;
15334      s[11] ^= l;
15335      s[20] ^= h;
15336      s[21] ^= l;
15337      s[30] ^= h;
15338      s[31] ^= l;
15339      s[40] ^= h;
15340      s[41] ^= l;
15341      h = c0 ^ ((c4 << 1) | (c5 >>> 31));
15342      l = c1 ^ ((c5 << 1) | (c4 >>> 31));
15343      s[2] ^= h;
15344      s[3] ^= l;
15345      s[12] ^= h;
15346      s[13] ^= l;
15347      s[22] ^= h;
15348      s[23] ^= l;
15349      s[32] ^= h;
15350      s[33] ^= l;
15351      s[42] ^= h;
15352      s[43] ^= l;
15353      h = c2 ^ ((c6 << 1) | (c7 >>> 31));
15354      l = c3 ^ ((c7 << 1) | (c6 >>> 31));
15355      s[4] ^= h;
15356      s[5] ^= l;
15357      s[14] ^= h;
15358      s[15] ^= l;
15359      s[24] ^= h;
15360      s[25] ^= l;
15361      s[34] ^= h;
15362      s[35] ^= l;
15363      s[44] ^= h;
15364      s[45] ^= l;
15365      h = c4 ^ ((c8 << 1) | (c9 >>> 31));
15366      l = c5 ^ ((c9 << 1) | (c8 >>> 31));
15367      s[6] ^= h;
15368      s[7] ^= l;
15369      s[16] ^= h;
15370      s[17] ^= l;
15371      s[26] ^= h;
15372      s[27] ^= l;
15373      s[36] ^= h;
15374      s[37] ^= l;
15375      s[46] ^= h;
15376      s[47] ^= l;
15377      h = c6 ^ ((c0 << 1) | (c1 >>> 31));
15378      l = c7 ^ ((c1 << 1) | (c0 >>> 31));
15379      s[8] ^= h;
15380      s[9] ^= l;
15381      s[18] ^= h;
15382      s[19] ^= l;
15383      s[28] ^= h;
15384      s[29] ^= l;
15385      s[38] ^= h;
15386      s[39] ^= l;
15387      s[48] ^= h;
15388      s[49] ^= l;
15389
15390      b0 = s[0];
15391      b1 = s[1];
15392      b32 = (s[11] << 4) | (s[10] >>> 28);
15393      b33 = (s[10] << 4) | (s[11] >>> 28);
15394      b14 = (s[20] << 3) | (s[21] >>> 29);
15395      b15 = (s[21] << 3) | (s[20] >>> 29);
15396      b46 = (s[31] << 9) | (s[30] >>> 23);
15397      b47 = (s[30] << 9) | (s[31] >>> 23);
15398      b28 = (s[40] << 18) | (s[41] >>> 14);
15399      b29 = (s[41] << 18) | (s[40] >>> 14);
15400      b20 = (s[2] << 1) | (s[3] >>> 31);
15401      b21 = (s[3] << 1) | (s[2] >>> 31);
15402      b2 = (s[13] << 12) | (s[12] >>> 20);
15403      b3 = (s[12] << 12) | (s[13] >>> 20);
15404      b34 = (s[22] << 10) | (s[23] >>> 22);
15405      b35 = (s[23] << 10) | (s[22] >>> 22);
15406      b16 = (s[33] << 13) | (s[32] >>> 19);
15407      b17 = (s[32] << 13) | (s[33] >>> 19);
15408      b48 = (s[42] << 2) | (s[43] >>> 30);
15409      b49 = (s[43] << 2) | (s[42] >>> 30);
15410      b40 = (s[5] << 30) | (s[4] >>> 2);
15411      b41 = (s[4] << 30) | (s[5] >>> 2);
15412      b22 = (s[14] << 6) | (s[15] >>> 26);
15413      b23 = (s[15] << 6) | (s[14] >>> 26);
15414      b4 = (s[25] << 11) | (s[24] >>> 21);
15415      b5 = (s[24] << 11) | (s[25] >>> 21);
15416      b36 = (s[34] << 15) | (s[35] >>> 17);
15417      b37 = (s[35] << 15) | (s[34] >>> 17);
15418      b18 = (s[45] << 29) | (s[44] >>> 3);
15419      b19 = (s[44] << 29) | (s[45] >>> 3);
15420      b10 = (s[6] << 28) | (s[7] >>> 4);
15421      b11 = (s[7] << 28) | (s[6] >>> 4);
15422      b42 = (s[17] << 23) | (s[16] >>> 9);
15423      b43 = (s[16] << 23) | (s[17] >>> 9);
15424      b24 = (s[26] << 25) | (s[27] >>> 7);
15425      b25 = (s[27] << 25) | (s[26] >>> 7);
15426      b6 = (s[36] << 21) | (s[37] >>> 11);
15427      b7 = (s[37] << 21) | (s[36] >>> 11);
15428      b38 = (s[47] << 24) | (s[46] >>> 8);
15429      b39 = (s[46] << 24) | (s[47] >>> 8);
15430      b30 = (s[8] << 27) | (s[9] >>> 5);
15431      b31 = (s[9] << 27) | (s[8] >>> 5);
15432      b12 = (s[18] << 20) | (s[19] >>> 12);
15433      b13 = (s[19] << 20) | (s[18] >>> 12);
15434      b44 = (s[29] << 7) | (s[28] >>> 25);
15435      b45 = (s[28] << 7) | (s[29] >>> 25);
15436      b26 = (s[38] << 8) | (s[39] >>> 24);
15437      b27 = (s[39] << 8) | (s[38] >>> 24);
15438      b8 = (s[48] << 14) | (s[49] >>> 18);
15439      b9 = (s[49] << 14) | (s[48] >>> 18);
15440
15441      s[0] = b0 ^ (~b2 & b4);
15442      s[1] = b1 ^ (~b3 & b5);
15443      s[10] = b10 ^ (~b12 & b14);
15444      s[11] = b11 ^ (~b13 & b15);
15445      s[20] = b20 ^ (~b22 & b24);
15446      s[21] = b21 ^ (~b23 & b25);
15447      s[30] = b30 ^ (~b32 & b34);
15448      s[31] = b31 ^ (~b33 & b35);
15449      s[40] = b40 ^ (~b42 & b44);
15450      s[41] = b41 ^ (~b43 & b45);
15451      s[2] = b2 ^ (~b4 & b6);
15452      s[3] = b3 ^ (~b5 & b7);
15453      s[12] = b12 ^ (~b14 & b16);
15454      s[13] = b13 ^ (~b15 & b17);
15455      s[22] = b22 ^ (~b24 & b26);
15456      s[23] = b23 ^ (~b25 & b27);
15457      s[32] = b32 ^ (~b34 & b36);
vendor: 4,749 bytes, lines 15458-15602
15458      s[33] = b33 ^ (~b35 & b37);
15459      s[42] = b42 ^ (~b44 & b46);
15460      s[43] = b43 ^ (~b45 & b47);
15461      s[4] = b4 ^ (~b6 & b8);
15462      s[5] = b5 ^ (~b7 & b9);
15463      s[14] = b14 ^ (~b16 & b18);
15464      s[15] = b15 ^ (~b17 & b19);
15465      s[24] = b24 ^ (~b26 & b28);
15466      s[25] = b25 ^ (~b27 & b29);
15467      s[34] = b34 ^ (~b36 & b38);
15468      s[35] = b35 ^ (~b37 & b39);
15469      s[44] = b44 ^ (~b46 & b48);
15470      s[45] = b45 ^ (~b47 & b49);
15471      s[6] = b6 ^ (~b8 & b0);
15472      s[7] = b7 ^ (~b9 & b1);
15473      s[16] = b16 ^ (~b18 & b10);
15474      s[17] = b17 ^ (~b19 & b11);
15475      s[26] = b26 ^ (~b28 & b20);
15476      s[27] = b27 ^ (~b29 & b21);
15477      s[36] = b36 ^ (~b38 & b30);
15478      s[37] = b37 ^ (~b39 & b31);
15479      s[46] = b46 ^ (~b48 & b40);
15480      s[47] = b47 ^ (~b49 & b41);
15481      s[8] = b8 ^ (~b0 & b2);
15482      s[9] = b9 ^ (~b1 & b3);
15483      s[18] = b18 ^ (~b10 & b12);
15484      s[19] = b19 ^ (~b11 & b13);
15485      s[28] = b28 ^ (~b20 & b22);
15486      s[29] = b29 ^ (~b21 & b23);
15487      s[38] = b38 ^ (~b30 & b32);
15488      s[39] = b39 ^ (~b31 & b33);
15489      s[48] = b48 ^ (~b40 & b42);
15490      s[49] = b49 ^ (~b41 & b43);
15491
15492      s[0] ^= RC[n];
15493      s[1] ^= RC[n + 1];
15494    }
15495  }
15496
15497  if (COMMON_JS) {
15498    module.exports = methods;
15499  } else if (root) {
15500    for (var key in methods) {
15501      root[key] = methods[key];
15502    }
15503  }
15504}(this));
15505
15506/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(6)))
15507
15508/***/ },
15509/* 8 */
15510/***/ function(module, exports) {
15511
15512// shim for using process in browser
15513var process = module.exports = {};
15514
15515// cached from whatever global is present so that test runners that stub it
15516// don't break things.  But we need to wrap it in a try catch in case it is
15517// wrapped in strict mode code which doesn't define any globals.  It's inside a
15518// function because try/catches deoptimize in certain engines.
15519
15520var cachedSetTimeout;
15521var cachedClearTimeout;
15522
15523function defaultSetTimout() {
15524    throw new Error('setTimeout has not been defined');
15525}
15526function defaultClearTimeout () {
15527    throw new Error('clearTimeout has not been defined');
15528}
15529(function () {
15530    try {
15531        if (typeof setTimeout === 'function') {
15532            cachedSetTimeout = setTimeout;
15533        } else {
15534            cachedSetTimeout = defaultSetTimout;
15535        }
15536    } catch (e) {
15537        cachedSetTimeout = defaultSetTimout;
15538    }
15539    try {
15540        if (typeof clearTimeout === 'function') {
15541            cachedClearTimeout = clearTimeout;
15542        } else {
15543            cachedClearTimeout = defaultClearTimeout;
15544        }
15545    } catch (e) {
15546        cachedClearTimeout = defaultClearTimeout;
15547    }
15548} ())
15549function runTimeout(fun) {
15550    if (cachedSetTimeout === setTimeout) {
15551        //normal enviroments in sane situations
15552        return setTimeout(fun, 0);
15553    }
15554    // if setTimeout wasn't available but was latter defined
15555    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
15556        cachedSetTimeout = setTimeout;
15557        return setTimeout(fun, 0);
15558    }
15559    try {
15560        // when when somebody has screwed with setTimeout but no I.E. maddness
15561        return cachedSetTimeout(fun, 0);
15562    } catch(e){
15563        try {
15564            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
15565            return cachedSetTimeout.call(null, fun, 0);
15566        } catch(e){
15567            // 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
15568            return cachedSetTimeout.call(this, fun, 0);
15569        }
15570    }
15571
15572
15573}
15574function runClearTimeout(marker) {
15575    if (cachedClearTimeout === clearTimeout) {
15576        //normal enviroments in sane situations
15577        return clearTimeout(marker);
15578    }
15579    // if clearTimeout wasn't available but was latter defined
15580    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
15581        cachedClearTimeout = clearTimeout;
15582        return clearTimeout(marker);
15583    }
15584    try {
15585        // when when somebody has screwed with setTimeout but no I.E. maddness
15586        return cachedClearTimeout(marker);
15587    } catch (e){
15588        try {
15589            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
15590            return cachedClearTimeout.call(null, marker);
15591        } catch (e){
15592            // 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.
15593            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
15594            return cachedClearTimeout.call(this, marker);
15595        }
15596    }
15597
15598
15599
15600}
15601var queue = [];
15602var draining = false;
15603var currentQueue;
15604var queueIndex = -1;
15605
15606function cleanUpNextTick() {
15607    if (!draining || !currentQueue) {
15608        return;
15609    }
15610    draining = false;
15611    if (currentQueue.length) {
15612        queue = currentQueue.concat(queue);
15613    } else {
15614        queueIndex = -1;
15615    }
15616    if (queue.length) {
15617        drainQueue();
15618    }
15619}
15620
15621function drainQueue() {
15622    if (draining) {
15623        return;
15624    }
15625    var timeout = runTimeout(cleanUpNextTick);
15626    draining = true;
15627
15628    var len = queue.length;
15629    while(len) {
15630        currentQueue = queue;
15631        queue = [];
15632        while (++queueIndex < len) {
15633            if (currentQueue) {
15634                currentQueue[queueIndex].run();
15635            }
15636        }
15637        queueIndex = -1;
15638        len = queue.length;
15639    }
15640    currentQueue = null;
15641    draining = false;
15642    runClearTimeout(timeout);
15643}
15644
15645process.nextTick = function (fun) {
15646    var args = new Array(arguments.length - 1);
15647    if (arguments.length > 1) {
15648        for (var i = 1; i < arguments.length; i++) {
15649            args[i - 1] = arguments[i];
15650        }
15651    }
15652    queue.push(new Item(fun, args));
15653    if (queue.length === 1 && !draining) {
15654        runTimeout(drainQueue);
15655    }
15656};
15657
15658// v8 likes predictible objects
15659function Item(fun, array) {
15660    this.fun = fun;
15661    this.array = array;
15662}
15663Item.prototype.run = function () {
15664    this.fun.apply(null, this.array);
15665};
15666process.title = 'browser';
15667process.browser = true;
15668process.env = {};
15669process.argv = [];
15670process.version = ''; // empty string to avoid regexp issues
15671process.versions = {};
15672
15673function noop() {}
15674
15675process.on = noop;
15676process.addListener = noop;
15677process.once = noop;
15678process.off = noop;
15679process.removeListener = noop;
15680process.removeAllListeners = noop;
15681process.emit = noop;
15682
15683process.binding = function (name) {
15684    throw new Error('process.binding is not supported');
15685};
15686
15687process.cwd = function () { return '/' };
15688process.chdir = function (dir) {
15689    throw new Error('process.chdir is not supported');
15690};
15691process.umask = function() { return 0; };
15692
15693
15694/***/ },
15695/* 9 */
15696/***/ function(module, exports, __webpack_require__) {
15697
15698"use strict";
15699/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
15700
15701var elliptic = __webpack_require__(0);
15702var keccak256 = __webpack_require__(7).keccak_256;
15703var randomBytes = __webpack_require__(35);
15704var secp256k1 = new elliptic.ec('secp256k1'); // eslint-disable-line
15705var getChecksumAddress = __webpack_require__(10);
15706
15707/**
15708 * Get the address from a public key
15709 *
15710 * @method getAddress
15711 * @param {String} addressInput
15712 * @returns {String} output the string is a hex string
15713 */
15714
15715function getAddress(addressInput) {
15716  var address = addressInput; // eslint-disable-line
15717  var result = null; // eslint-disable-line
15718
15719  if (typeof address !== 'string') {
15720    throw new Error('[ethjs-account] invalid address value ' + JSON.stringify(address) + ' not a valid hex string');
15721  }
15722
15723  // Missing the 0x prefix
15724  if (address.substring(0, 2) !== '0x' && address.substring(0, 2) !== 'XE') {
15725    address = '0x' + address;
15726  }
15727
15728  if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
15729    result = getChecksumAddress(address);
15730
15731    // It is a checksummed address with a bad checksum
15732    if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
15733      throw new Error('[ethjs-account] invalid address checksum');
15734    }
15735
15736    // Maybe ICAP? (we only support direct mode)
15737  } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
15738    throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..');
15739
15740    /*
15741    // It is an ICAP address with a bad checksum
15742    if (address.substring(2, 4) !== ibanChecksum(address)) {
15743      throw new Error('invalid address icap checksum');
15744    }
15745     result = (new BN(address.substring(4), 36)).toString(16);
15746    while (result.length < 40) { result = '0' + result; }
15747    result = getChecksumAddress('0x' + result);
15748    */
15749  } else {
15750    throw new Error('[ethjs-account] invalid address value ' + JSON.stringify(address) + ' not a valid hex string');
15751  }
15752
15753  return result;
15754}
15755
15756/**
15757 * Returns the public key for this private key.
15758 *
15759 * @method privateToPublic
15760 * @param {String} privateKey a valid private key hex
15761 * @returns {Object} publicKey the sepk 160 byte public key for this private key
15762 */
15763
15764function privateToPublic(privateKey) {
15765  if (typeof privateKey !== 'string') {
15766    throw new Error('[ethjs-account] private key must be type Str
15766ing, got ' + typeof privateKey);
15767  }
15768  if (!privateKey.match(/^(0x)?[0-9a-fA-F]{64}$/)) {
15769    throw new Error('[ethjs-account] private key must be an alphanumeric hex string that is 32 bytes long.');
15770  }
15771
15772  return new Buffer(secp256k1.keyFromPrivate(new Buffer(privateKey.slice(2), 'hex')).getPublic(false, 'hex'), 'hex').slice(1);
15773}
15774
15775/**
15776 * Returns the Ethereum standard address of a public sepk key.
15777 *
15778 * @method publicToAddress
15779 * @param {Object} publicKey a single public key Buffer object
15780 * @returns {String} address the 20 byte Ethereum address
15781 */
15782
15783function publicToAddress(publicKey) {
15784  if (!Buffer.isBuffer(publicKey)) {
15785    throw new Error('[ethjs-account] public key must be a buffer object in order to get public key address');
15786  }
15787
15788  return getAddress(new Buffer(keccak256(publicKey), 'hex').slice(12).toString('hex'));
15789}
15790
15791/**
15792 * Returns an Ethereum account address, private and public key based on the public key.
15793 *
15794 * @method privateToAccount
15795 * @param {String} privateKey a single string of entropy longer than 32 chars
15796 * @returns {Object} output the Ethereum account address, and keys as hex strings
15797 */
15798
15799function privateToAccount(privateKey) {
15800  var publicKey = privateToPublic(privateKey, true);
15801
15802  return {
15803    privateKey: privateKey,
15804    publicKey: '0x' + publicKey.toString('hex'),
15805    address: publicToAddress(publicKey)
15806  };
15807}
15808
15809/**
15810 * Create a single Ethereum account address, private and public key.
15811 *
15812 * @method generate
15813 * @param {String} entropy a single string of entropy longer than 32 chars
15814 * @returns {Object} output the Ethereum account address, and keys
15815 */
15816
15817function generate(entropy) {
15818  if (typeof entropy !== 'string') {
15819    throw new Error('[ethjs-account] while generating account, invalid input type: \'' + typeof entropy + '\' should be type \'String\'.');
15820  }
15821  if (entropy.length < 32) {
15822    throw new Error('[ethjs-account] while generating account, entropy value not random and long enough, should be at least 32 characters of random information, is only ' + entropy.length);
15823  }
15824
15825  return privateToAccount('0x' + keccak256('' + randomBytes(16).toString('hex') + keccak256('' + randomBytes(32).toString('hex') + entropy) + randomBytes(32).toString('hex')));
15826}
15827
15828// exports
15829module.exports = {
15830  keccak256: keccak256,
15831  generate: generate,
15832  getAddress: getAddress,
15833  privateToAccount: privateToAccount,
15834  getChecksumAddress: getChecksumAddress,
15835  publicToAddress: publicToAddress,
15836  privateToPublic: privateToPublic
15837};
15838/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
15839
15840/***/ },
15841/* 10 */
15842/***/ function(module, exports, __webpack_require__) {
15843
15844"use strict";
15845/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
15846
15847var elliptic = __webpack_require__(0);
15848// const sha3 = require('ethjs-sha3');
15849var keccak256 = __webpack_require__(7).keccak_256;
15850var secp256k1 = new elliptic.ec('secp256k1'); // eslint-disable-line
15851
15852/**
15853 * Get the checksum address of a address value
15854 *
15855 * @method getChecksumAddress
15856 * @param {String} addressInput
15857 * @returns {String} output hex string value
15858 */
15859
15860module.exports = function getChecksumAddress(addressInput) {
15861  var address = addressInput; // eslint-disable-line
15862
15863  if (typeof address !== 'string' || !address.match(/^0x[0-9A-Fa-f]{40}$/)) {
15864    throw new Error('[ethjs-account] invalid address value ' + JSON.stringify(address) + ' not a valid hex string');
15865  }
15866
15867  address = address.substring(2).toLowerCase();
15868  var hashed = new Buffer(keccak256(address), 'hex');
15869
15870  address = address.split('');
15871  for (var i = 0; i < 40; i += 2) {
15872    // eslint-disable-line
15873    if (hashed[i >> 1] >> 4 >= 8) {
15874      address[i] = address[i].toUpperCase();
15875    }
15876    if ((hashed[i >> 1] & 0x0f) >= 8) {
15877      address[i + 1] = address[i + 1].toUpperCase();
15878    }
15879  }
15880
15881  return '0x' + address.join('');
15882};
15883/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
15884
15885/***/ },
15886/* 11 */
15887/***/ function(module, exports) {
15888
15889"use strict";
15890'use strict'
15891
15892exports.byteLength = byteLength
15893exports.toByteArray = toByteArray
15894exports.fromByteArray = fromByteArray
15895
15896var lookup = []
15897var revLookup = []
15898var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
15899
15900var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
vendor: 4,743 bytes, lines 15900-16077
15900+/'
15901for (var i = 0, len = code.length; i < len; ++i) {
15902  lookup[i] = code[i]
15903  revLookup[code.charCodeAt(i)] = i
15904}
15905
15906revLookup['-'.charCodeAt(0)] = 62
15907revLookup['_'.charCodeAt(0)] = 63
15908
15909function placeHoldersCount (b64) {
15910  var len = b64.length
15911  if (len % 4 > 0) {
15912    throw new Error('Invalid string. Length must be a multiple of 4')
15913  }
15914
15915  // the number of equal signs (place holders)
15916  // if there are two placeholders, than the two characters before it
15917  // represent one byte
15918  // if there is only one, then the three characters before it represent 2 bytes
15919  // this is just a cheap hack to not do indexOf twice
15920  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
15921}
15922
15923function byteLength (b64) {
15924  // base64 is 4/3 + up to two characters of the original data
15925  return b64.length * 3 / 4 - placeHoldersCount(b64)
15926}
15927
15928function toByteArray (b64) {
15929  var i, j, l, tmp, placeHolders, arr
15930  var len = b64.length
15931  placeHolders = placeHoldersCount(b64)
15932
15933  arr = new Arr(len * 3 / 4 - placeHolders)
15934
15935  // if there are placeholders, only get up to the last complete 4 chars
15936  l = placeHolders > 0 ? len - 4 : len
15937
15938  var L = 0
15939
15940  for (i = 0, j = 0; i < l; i += 4, j += 3) {
15941    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
15942    arr[L++] = (tmp >> 16) & 0xFF
15943    arr[L++] = (tmp >> 8) & 0xFF
15944    arr[L++] = tmp & 0xFF
15945  }
15946
15947  if (placeHolders === 2) {
15948    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
15949    arr[L++] = tmp & 0xFF
15950  } else if (placeHolders === 1) {
15951    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
15952    arr[L++] = (tmp >> 8) & 0xFF
15953    arr[L++] = tmp & 0xFF
15954  }
15955
15956  return arr
15957}
15958
15959function tripletToBase64 (num) {
15960  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
15961}
15962
15963function encodeChunk (uint8, start, end) {
15964  var tmp
15965  var output = []
15966  for (var i = start; i < end; i += 3) {
15967    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
15968    output.push(tripletToBase64(tmp))
15969  }
15970  return output.join('')
15971}
15972
15973function fromByteArray (uint8) {
15974  var tmp
15975  var len = uint8.length
15976  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
15977  var output = ''
15978  var parts = []
15979  var maxChunkLength = 16383 // must be multiple of 3
15980
15981  // go through the array every three bytes, we'll deal with trailing stuff later
15982  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
15983    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
15984  }
15985
15986  // pad the end with zeros, but make sure to not forget the extra bytes
15987  if (extraBytes === 1) {
15988    tmp = uint8[len - 1]
15989    output += lookup[tmp >> 2]
15990    output += lookup[(tmp << 4) & 0x3F]
15991    output += '=='
15992  } else if (extraBytes === 2) {
15993    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
15994    output += lookup[tmp >> 10]
15995    output += lookup[(tmp >> 4) & 0x3F]
15996    output += lookup[(tmp << 2) & 0x3F]
15997    output += '='
15998  }
15999
16000  parts.push(output)
16001
16002  return parts.join('')
16003}
16004
16005
16006/***/ },
16007/* 12 */
16008/***/ function(module, exports, __webpack_require__) {
16009
16010var r;
16011
16012module.exports = function rand(len) {
16013  if (!r)
16014    r = new Rand(null);
16015
16016  return r.generate(len);
16017};
16018
16019function Rand(rand) {
16020  this.rand = rand;
16021}
16022module.exports.Rand = Rand;
16023
16024Rand.prototype.generate = function generate(len) {
16025  return this._rand(len);
16026};
16027
16028if (typeof window === 'object') {
16029  if (window.crypto && window.crypto.getRandomValues) {
16030    // Modern browsers
16031    Rand.prototype._rand = function _rand(n) {
16032      var arr = new Uint8Array(n);
16033      window.crypto.getRandomValues(arr);
16034      return arr;
16035    };
16036  } else if (window.msCrypto && window.msCrypto.getRandomValues) {
16037    // IE
16038    Rand.prototype._rand = function _rand(n) {
16039      var arr = new Uint8Array(n);
16040      window.msCrypto.getRandomValues(arr);
16041      return arr;
16042    };
16043  } else {
16044    // Old junk
16045    Rand.prototype._rand = function() {
16046      throw new Error('Not implemented yet');
16047    };
16048  }
16049} else {
16050  // Node.js or Web worker
16051  try {
16052    var crypto = __webpack_require__(37);
16053
16054    Rand.prototype._rand = function _rand(n) {
16055      return crypto.randomBytes(n);
16056    };
16057  } catch (e) {
16058    // Emulate crypto API using randy
16059    Rand.prototype._rand = function _rand(n) {
16060      var res = new Uint8Array(n);
16061      for (var i = 0; i < res.length; i++)
16062        res[i] = this.rand.getByte();
16063      return res;
16064    };
16065  }
16066}
16067
16068
16069/***/ },
16070/* 13 */
16071/***/ function(module, exports, __webpack_require__) {
16072
16073"use strict";
16074'use strict';
16075
16076var BN = __webpack_require__(1);
16077var elliptic = __webpack_require__(0
vendor: 9,277 bytes, lines 16077-16451
16077);
16078var utils = elliptic.utils;
16079var getNAF = utils.getNAF;
16080var getJSF = utils.getJSF;
16081var assert = utils.assert;
16082
16083function BaseCurve(type, conf) {
16084  this.type = type;
16085  this.p = new BN(conf.p, 16);
16086
16087  // Use Montgomery, when there is no fast reduction for the prime
16088  this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
16089
16090  // Useful for many curves
16091  this.zero = new BN(0).toRed(this.red);
16092  this.one = new BN(1).toRed(this.red);
16093  this.two = new BN(2).toRed(this.red);
16094
16095  // Curve configuration, optional
16096  this.n = conf.n && new BN(conf.n, 16);
16097  this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
16098
16099  // Temporary arrays
16100  this._wnafT1 = new Array(4);
16101  this._wnafT2 = new Array(4);
16102  this._wnafT3 = new Array(4);
16103  this._wnafT4 = new Array(4);
16104
16105  // Generalized Greg Maxwell's trick
16106  var adjustCount = this.n && this.p.div(this.n);
16107  if (!adjustCount || adjustCount.cmpn(100) > 0) {
16108    this.redN = null;
16109  } else {
16110    this._maxwellTrick = true;
16111    this.redN = this.n.toRed(this.red);
16112  }
16113}
16114module.exports = BaseCurve;
16115
16116BaseCurve.prototype.point = function point() {
16117  throw new Error('Not implemented');
16118};
16119
16120BaseCurve.prototype.validate = function validate() {
16121  throw new Error('Not implemented');
16122};
16123
16124BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
16125  assert(p.precomputed);
16126  var doubles = p._getDoubles();
16127
16128  var naf = getNAF(k, 1);
16129  var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
16130  I /= 3;
16131
16132  // Translate into more windowed form
16133  var repr = [];
16134  for (var j = 0; j < naf.length; j += doubles.step) {
16135    var nafW = 0;
16136    for (var k = j + doubles.step - 1; k >= j; k--)
16137      nafW = (nafW << 1) + naf[k];
16138    repr.push(nafW);
16139  }
16140
16141  var a = this.jpoint(null, null, null);
16142  var b = this.jpoint(null, null, null);
16143  for (var i = I; i > 0; i--) {
16144    for (var j = 0; j < repr.length; j++) {
16145      var nafW = repr[j];
16146      if (nafW === i)
16147        b = b.mixedAdd(doubles.points[j]);
16148      else if (nafW === -i)
16149        b = b.mixedAdd(doubles.points[j].neg());
16150    }
16151    a = a.add(b);
16152  }
16153  return a.toP();
16154};
16155
16156BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
16157  var w = 4;
16158
16159  // Precompute window
16160  var nafPoints = p._getNAFPoints(w);
16161  w = nafPoints.wnd;
16162  var wnd = nafPoints.points;
16163
16164  // Get NAF form
16165  var naf = getNAF(k, w);
16166
16167  // Add `this`*(N+1) for every w-NAF index
16168  var acc = this.jpoint(null, null, null);
16169  for (var i = naf.length - 1; i >= 0; i--) {
16170    // Count zeroes
16171    for (var k = 0; i >= 0 && naf[i] === 0; i--)
16172      k++;
16173    if (i >= 0)
16174      k++;
16175    acc = acc.dblp(k);
16176
16177    if (i < 0)
16178      break;
16179    var z = naf[i];
16180    assert(z !== 0);
16181    if (p.type === 'affine') {
16182      // J +- P
16183      if (z > 0)
16184        acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
16185      else
16186        acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
16187    } else {
16188      // J +- J
16189      if (z > 0)
16190        acc = acc.add(wnd[(z - 1) >> 1]);
16191      else
16192        acc = acc.add(wnd[(-z - 1) >> 1].neg());
16193    }
16194  }
16195  return p.type === 'affine' ? acc.toP() : acc;
16196};
16197
16198BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
16199                                                       points,
16200                                                       coeffs,
16201                                                       len,
16202                                                       jacobianResult) {
16203  var wndWidth = this._wnafT1;
16204  var wnd = this._wnafT2;
16205  var naf = this._wnafT3;
16206
16207  // Fill all arrays
16208  var max = 0;
16209  for (var i = 0; i < len; i++) {
16210    var p = points[i];
16211    var nafPoints = p._getNAFPoints(defW);
16212    wndWidth[i] = nafPoints.wnd;
16213    wnd[i] = nafPoints.points;
16214  }
16215
16216  // Comb small window NAFs
16217  for (var i = len - 1; i >= 1; i -= 2) {
16218    var a = i - 1;
16219    var b = i;
16220    if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
16221      naf[a] = getNAF(coeffs[a], wndWidth[a]);
16222      naf[b] = getNAF(coeffs[b], wndWidth[b]);
16223      max = Math.max(naf[a].length, max);
16224      max = Math.max(naf[b].length, max);
16225      continue;
16226    }
16227
16228    var comb = [
16229      points[a], /* 1 */
16230      null, /* 3 */
16231      null, /* 5 */
16232      points[b] /* 7 */
16233    ];
16234
16235    // Try to avoid Projective points, if possible
16236    if (points[a].y.cmp(points[b].y) === 0) {
16237      comb[1] = points[a].add(points[b]);
16238      comb[2] = points[a].toJ().mixedAdd(points[b].neg());
16239    } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
16240      comb[1] = points[a].toJ().mixedAdd(points[b]);
16241      comb[2] = points[a].add(points[b].neg());
16242    } else {
16243      comb[1] = points[a].toJ().mixedAdd(points[b]);
16244      comb[2] = points[a].toJ().mixedAdd(points[b].neg());
16245    }
16246
16247    var index = [
16248      -3, /* -1 -1 */
16249      -1, /* -1 0 */
16250      -5, /* -1 1 */
16251      -7, /* 0 -1 */
16252      0, /* 0 0 */
16253      7, /* 0 1 */
16254      5, /* 1 -1 */
16255      1, /* 1 0 */
16256      3  /* 1 1 */
16257    ];
16258
16259    var jsf = getJSF(coeffs[a], coeffs[b]);
16260    max = Math.max(jsf[0].length, max);
16261    naf[a] = new Array(max);
16262    naf[b] = new Array(max);
16263    for (var j = 0; j < max; j++) {
16264      var ja = jsf[0][j] | 0;
16265      var jb = jsf[1][j] | 0;
16266
16267      naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
16268      naf[b][j] = 0;
16269      wnd[a] = comb;
16270    }
16271  }
16272
16273  var acc = this.jpoint(null, null, null);
16274  var tmp = this._wnafT4;
16275  for (var i = max; i >= 0; i--) {
16276    var k = 0;
16277
16278    while (i >= 0) {
16279      var zero = true;
16280      for (var j = 0; j < len; j++) {
16281        tmp[j] = naf[j][i] | 0;
16282        if (tmp[j] !== 0)
16283          zero = false;
16284      }
16285      if (!zero)
16286        break;
16287      k++;
16288      i--;
16289    }
16290    if (i >= 0)
16291      k++;
16292    acc = acc.dblp(k);
16293    if (i < 0)
16294      break;
16295
16296    for (var j = 0; j < len; j++) {
16297      var z = tmp[j];
16298      var p;
16299      if (z === 0)
16300        continue;
16301      else if (z > 0)
16302        p = wnd[j][(z - 1) >> 1];
16303      else if (z < 0)
16304        p = wnd[j][(-z - 1) >> 1].neg();
16305
16306      if (p.type === 'affine')
16307        acc = acc.mixedAdd(p);
16308      else
16309        acc = acc.add(p);
16310    }
16311  }
16312  // Zeroify references
16313  for (var i = 0; i < len; i++)
16314    wnd[i] = null;
16315
16316  if (jacobianResult)
16317    return acc;
16318  else
16319    return acc.toP();
16320};
16321
16322function BasePoint(curve, type) {
16323  this.curve = curve;
16324  this.type = type;
16325  this.precomputed = null;
16326}
16327BaseCurve.BasePoint = BasePoint;
16328
16329BasePoint.prototype.eq = function eq(/*other*/) {
16330  throw new Error('Not implemented');
16331};
16332
16333BasePoint.prototype.validate = function validate() {
16334  return this.curve.validate(this);
16335};
16336
16337BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
16338  bytes = utils.toArray(bytes, enc);
16339
16340  var len = this.p.byteLength();
16341
16342  // uncompressed, hybrid-odd, hybrid-even
16343  if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
16344      bytes.length - 1 === 2 * len) {
16345    if (bytes[0] === 0x06)
16346      assert(bytes[bytes.length - 1] % 2 === 0);
16347    else if (bytes[0] === 0x07)
16348      assert(bytes[bytes.length - 1] % 2 === 1);
16349
16350    var res =  this.point(bytes.slice(1, 1 + len),
16351                          bytes.slice(1 + len, 1 + 2 * len));
16352
16353    return res;
16354  } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
16355              bytes.length - 1 === len) {
16356    return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
16357  }
16358  throw new Error('Unknown point format');
16359};
16360
16361BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
16362  return this.encode(enc, true);
16363};
16364
16365BasePoint.prototype._encode = function _encode(compact) {
16366  var len = this.curve.p.byteLength();
16367  var x = this.getX().toArray('be', len);
16368
16369  if (compact)
16370    return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
16371
16372  return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
16373};
16374
16375BasePoint.prototype.encode = function encode(enc, compact) {
16376  return utils.encode(this._encode(compact), enc);
16377};
16378
16379BasePoint.prototype.precompute = function precompute(power) {
16380  if (this.precomputed)
16381    return this;
16382
16383  var precomputed = {
16384    doubles: null,
16385    naf: null,
16386    beta: null
16387  };
16388  precomputed.naf = this._getNAFPoints(8);
16389  precomputed.doubles = this._getDoubles(4, power);
16390  precomputed.beta = this._getBeta();
16391  this.precomputed = precomputed;
16392
16393  return this;
16394};
16395
16396BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
16397  if (!this.precomputed)
16398    return false;
16399
16400  var doubles = this.precomputed.doubles;
16401  if (!doubles)
16402    return false;
16403
16404  return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
16405};
16406
16407BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
16408  if (this.precomputed && this.precomputed.doubles)
16409    return this.precomputed.doubles;
16410
16411  var doubles = [ this ];
16412  var acc = this;
16413  for (var i = 0; i < power; i += step) {
16414    for (var j = 0; j < step; j++)
16415      acc = acc.dbl();
16416    doubles.push(acc);
16417  }
16418  return {
16419    step: step,
16420    points: doubles
16421  };
16422};
16423
16424BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
16425  if (this.precomputed && this.precomputed.naf)
16426    return this.precomputed.naf;
16427
16428  var res = [ this ];
16429  var max = (1 << wnd) - 1;
16430  var dbl = max === 1 ? null : this.dbl();
16431  for (var i = 1; i < max; i++)
16432    res[i] = res[i - 1].add(dbl);
16433  return {
16434    wnd: wnd,
16435    points: res
16436  };
16437};
16438
16439BasePoint.prototype._getBeta = function _getBeta() {
16440  return null;
16441};
16442
16443BasePoint.prototype.dblp = function dblp(k) {
16444  var r = this;
16445  for (var i = 0; i < k; i++)
16446    r = r.dbl();
16447  return r;
16448};
16449
16450
16451/***/ }
vendor: 16,049 bytes, lines 16451-17088
16451,
16452/* 14 */
16453/***/ function(module, exports, __webpack_require__) {
16454
16455"use strict";
16456'use strict';
16457
16458var curve = __webpack_require__(4);
16459var elliptic = __webpack_require__(0);
16460var BN = __webpack_require__(1);
16461var inherits = __webpack_require__(5);
16462var Base = curve.base;
16463
16464var assert = elliptic.utils.assert;
16465
16466function EdwardsCurve(conf) {
16467  // NOTE: Important as we are creating point in Base.call()
16468  this.twisted = (conf.a | 0) !== 1;
16469  this.mOneA = this.twisted && (conf.a | 0) === -1;
16470  this.extended = this.mOneA;
16471
16472  Base.call(this, 'edwards', conf);
16473
16474  this.a = new BN(conf.a, 16).umod(this.red.m);
16475  this.a = this.a.toRed(this.red);
16476  this.c = new BN(conf.c, 16).toRed(this.red);
16477  this.c2 = this.c.redSqr();
16478  this.d = new BN(conf.d, 16).toRed(this.red);
16479  this.dd = this.d.redAdd(this.d);
16480
16481  assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
16482  this.oneC = (conf.c | 0) === 1;
16483}
16484inherits(EdwardsCurve, Base);
16485module.exports = EdwardsCurve;
16486
16487EdwardsCurve.prototype._mulA = function _mulA(num) {
16488  if (this.mOneA)
16489    return num.redNeg();
16490  else
16491    return this.a.redMul(num);
16492};
16493
16494EdwardsCurve.prototype._mulC = function _mulC(num) {
16495  if (this.oneC)
16496    return num;
16497  else
16498    return this.c.redMul(num);
16499};
16500
16501// Just for compatibility with Short curve
16502EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
16503  return this.point(x, y, z, t);
16504};
16505
16506EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
16507  x = new BN(x, 16);
16508  if (!x.red)
16509    x = x.toRed(this.red);
16510
16511  var x2 = x.redSqr();
16512  var rhs = this.c2.redSub(this.a.redMul(x2));
16513  var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
16514
16515  var y2 = rhs.redMul(lhs.redInvm());
16516  var y = y2.redSqrt();
16517  if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
16518    throw new Error('invalid point');
16519
16520  var isOdd = y.fromRed().isOdd();
16521  if (odd && !isOdd || !odd && isOdd)
16522    y = y.redNeg();
16523
16524  return this.point(x, y);
16525};
16526
16527EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
16528  y = new BN(y, 16);
16529  if (!y.red)
16530    y = y.toRed(this.red);
16531
16532  // x^2 = (y^2 - 1) / (d y^2 + 1)
16533  var y2 = y.redSqr();
16534  var lhs = y2.redSub(this.one);
16535  var rhs = y2.redMul(this.d).redAdd(this.one);
16536  var x2 = lhs.redMul(rhs.redInvm());
16537
16538  if (x2.cmp(this.zero) === 0) {
16539    if (odd)
16540      throw new Error('invalid point');
16541    else
16542      return this.point(this.zero, y);
16543  }
16544
16545  var x = x2.redSqrt();
16546  if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
16547    throw new Error('invalid point');
16548
16549  if (x.isOdd() !== odd)
16550    x = x.redNeg();
16551
16552  return this.point(x, y);
16553};
16554
16555EdwardsCurve.prototype.validate = function validate(point) {
16556  if (point.isInfinity())
16557    return true;
16558
16559  // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
16560  point.normalize();
16561
16562  var x2 = point.x.redSqr();
16563  var y2 = point.y.redSqr();
16564  var lhs = x2.redMul(this.a).redAdd(y2);
16565  var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
16566
16567  return lhs.cmp(rhs) === 0;
16568};
16569
16570function Point(curve, x, y, z, t) {
16571  Base.BasePoint.call(this, curve, 'projective');
16572  if (x === null && y === null && z === null) {
16573    this.x = this.curve.zero;
16574    this.y = this.curve.one;
16575    this.z = this.curve.one;
16576    this.t = this.curve.zero;
16577    this.zOne = true;
16578  } else {
16579    this.x = new BN(x, 16);
16580    this.y = new BN(y, 16);
16581    this.z = z ? new BN(z, 16) : this.curve.one;
16582    this.t = t && new BN(t, 16);
16583    if (!this.x.red)
16584      this.x = this.x.toRed(this.curve.red);
16585    if (!this.y.red)
16586      this.y = this.y.toRed(this.curve.red);
16587    if (!this.z.red)
16588      this.z = this.z.toRed(this.curve.red);
16589    if (this.t && !this.t.red)
16590      this.t = this.t.toRed(this.curve.red);
16591    this.zOne = this.z === this.curve.one;
16592
16593    // Use extended coordinates
16594    if (this.curve.extended && !this.t) {
16595      this.t = this.x.redMul(this.y);
16596      if (!this.zOne)
16597        this.t = this.t.redMul(this.z.redInvm());
16598    }
16599  }
16600}
16601inherits(Point, Base.BasePoint);
16602
16603EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
16604  return Point.fromJSON(this, obj);
16605};
16606
16607EdwardsCurve.prototype.point = function point(x, y, z, t) {
16608  return new Point(this, x, y, z, t);
16609};
16610
16611Point.fromJSON = function fromJSON(curve, obj) {
16612  return new Point(curve, obj[0], obj[1], obj[2]);
16613};
16614
16615Point.prototype.inspect = function inspect() {
16616  if (this.isInfinity())
16617    return '<EC Point Infinity>';
16618  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
16619      ' y: ' + this.y.fromRed().toString(16, 2) +
16620      ' z: ' + this.z.fromRed().toString(16, 2) + '>';
16621};
16622
16623Point.prototype.isInfinity = function isInfinity() {
16624  // XXX This code assumes that zero is always zero in red
16625  return this.x.cmpn(0) === 0 &&
16626         this.y.cmp(this.z) === 0;
16627};
16628
16629Point.prototype._extDbl = function _extDbl() {
16630  // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
16631  //     #doubling-dbl-2008-hwcd
16632  // 4M + 4S
16633
16634  // A = X1^2
16635  var a = this.x.redSqr();
16636  // B = Y1^2
16637  var b = this.y.redSqr();
16638  // C = 2 * Z1^2
16639  var c = this.z.redSqr();
16640  c = c.redIAdd(c);
16641  // D = a * A
16642  var d = this.curve._mulA(a);
16643  // E = (X1 + Y1)^2 - A - B
16644  var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
16645  // G = D + B
16646  var g = d.redAdd(b);
16647  // F = G - C
16648  var f = g.redSub(c);
16649  // H = D - B
16650  var h = d.redSub(b);
16651  // X3 = E * F
16652  var nx = e.redMul(f);
16653  // Y3 = G * H
16654  var ny = g.redMul(h);
16655  // T3 = E * H
16656  var nt = e.redMul(h);
16657  // Z3 = F * G
16658  var nz = f.redMul(g);
16659  return this.curve.point(nx, ny, nz, nt);
16660};
16661
16662Point.prototype._projDbl = function _projDbl() {
16663  // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
16664  //     #doubling-dbl-2008-bbjlp
16665  //     #doubling-dbl-2007-bl
16666  // and others
16667  // Generally 3M + 4S or 2M + 4S
16668
16669  // B = (X1 + Y1)^2
16670  var b = this.x.redAdd(this.y).redSqr();
16671  // C = X1^2
16672  var c = this.x.redSqr();
16673  // D = Y1^2
16674  var d = this.y.redSqr();
16675
16676  var nx;
16677  var ny;
16678  var nz;
16679  if (this.curve.twisted) {
16680    // E = a * C
16681    var e = this.curve._mulA(c);
16682    // F = E + D
16683    var f = e.redAdd(d);
16684    if (this.zOne) {
16685      // X3 = (B - C - D) * (F - 2)
16686      nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
16687      // Y3 = F * (E - D)
16688      ny = f.redMul(e.redSub(d));
16689      // Z3 = F^2 - 2 * F
16690      nz = f.redSqr().redSub(f).redSub(f);
16691    } else {
16692      // H = Z1^2
16693      var h = this.z.redSqr();
16694      // J = F - 2 * H
16695      var j = f.redSub(h).redISub(h);
16696      // X3 = (B-C-D)*J
16697      nx = b.redSub(c).redISub(d).redMul(j);
16698      // Y3 = F * (E - D)
16699      ny = f.redMul(e.redSub(d));
16700      // Z3 = F * J
16701      nz = f.redMul(j);
16702    }
16703  } else {
16704    // E = C + D
16705    var e = c.redAdd(d);
16706    // H = (c * Z1)^2
16707    var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
16708    // J = E - 2 * H
16709    var j = e.redSub(h).redSub(h);
16710    // X3 = c * (B - E) * J
16711    nx = this.curve._mulC(b.redISub(e)).redMul(j);
16712    // Y3 = c * E * (C - D)
16713    ny = this.curve._mulC(e).redMul(c.redISub(d));
16714    // Z3 = E * J
16715    nz = e.redMul(j);
16716  }
16717  return this.curve.point(nx, ny, nz);
16718};
16719
16720Point.prototype.dbl = function dbl() {
16721  if (this.isInfinity())
16722    return this;
16723
16724  // Double in extended coordinates
16725  if (this.curve.extended)
16726    return this._extDbl();
16727  else
16728    return this._projDbl();
16729};
16730
16731Point.prototype._extAdd = function _extAdd(p) {
16732  // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
16733  //     #addition-add-2008-hwcd-3
16734  // 8M
16735
16736  // A = (Y1 - X1) * (Y2 - X2)
16737  var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
16738  // B = (Y1 + X1) * (Y2 + X2)
16739  var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
16740  // C = T1 * k * T2
16741  var c = this.t.redMul(this.curve.dd).redMul(p.t);
16742  // D = Z1 * 2 * Z2
16743  var d = this.z.redMul(p.z.redAdd(p.z));
16744  // E = B - A
16745  var e = b.redSub(a);
16746  // F = D - C
16747  var f = d.redSub(c);
16748  // G = D + C
16749  var g = d.redAdd(c);
16750  // H = B + A
16751  var h = b.redAdd(a);
16752  // X3 = E * F
16753  var nx = e.redMul(f);
16754  // Y3 = G * H
16755  var ny = g.redMul(h);
16756  // T3 = E * H
16757  var nt = e.redMul(h);
16758  // Z3 = F * G
16759  var nz = f.redMul(g);
16760  return this.curve.point(nx, ny, nz, nt);
16761};
16762
16763Point.prototype._projAdd = function _projAdd(p) {
16764  // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
16765  //     #addition-add-2008-bbjlp
16766  //     #addition-add-2007-bl
16767  // 10M + 1S
16768
16769  // A = Z1 * Z2
16770  var a = this.z.redMul(p.z);
16771  // B = A^2
16772  var b = a.redSqr();
16773  // C = X1 * X2
16774  var c = this.x.redMul(p.x);
16775  // D = Y1 * Y2
16776  var d = this.y.redMul(p.y);
16777  // E = d * C * D
16778  var e = this.curve.d.redMul(c).redMul(d);
16779  // F = B - E
16780  var f = b.redSub(e);
16781  // G = B + E
16782  var g = b.redAdd(e);
16783  // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
16784  var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
16785  var nx = a.redMul(f).redMul(tmp);
16786  var ny;
16787  var nz;
16788  if (this.curve.twisted) {
16789    // Y3 = A * G * (D - a * C)
16790    ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
16791    // Z3 = F * G
16792    nz = f.redMul(g);
16793  } else {
16794    // Y3 = A * G * (D - C)
16795    ny = a.redMul(g).redMul(d.redSub(c));
16796    // Z3 = c * F * G
16797    nz = this.curve._mulC(f).redMul(g);
16798  }
16799  return this.curve.point(nx, ny, nz);
16800};
16801
16802Point.prototype.add = function add(p) {
16803  if (this.isInfinity())
16804    return p;
16805  if (p.isInfinity())
16806    return this;
16807
16808  if (this.curve.extended)
16809    return this._extAdd(p);
16810  else
16811    return this._projAdd(p);
16812};
16813
16814Point.prototype.mul = function mul(k) {
16815  if (this._hasDoubles(k))
16816    return this.curve._fixedNafMul(this, k);
16817  else
16818    return this.curve._wnafMul(this, k);
16819};
16820
16821Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
16822  return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
16823};
16824
16825Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
16826  return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
16827};
16828
16829Point.prototype.normalize = function normalize() {
16830  if (this.zOne)
16831    return this;
16832
16833  // Normalize coordinates
16834  var zi = this.z.redInvm();
16835  this.x = this.x.redMul(zi);
16836  this.y = this.y.redMul(zi);
16837  if (this.t)
16838    this.t = this.t.redMul(zi);
16839  this.z = this.curve.one;
16840  this.zOne = true;
16841  return this;
16842};
16843
16844Point.prototype.neg = function neg() {
16845  return this.curve.point(this.x.redNeg(),
16846                          this.y,
16847                          this.z,
16848                          this.t && this.t.redNeg());
16849};
16850
16851Point.prototype.getX = function getX() {
16852  this.normalize();
16853  return this.x.fromRed();
16854};
16855
16856Point.prototype.getY = function getY() {
16857  this.normalize();
16858  return this.y.fromRed();
16859};
16860
16861Point.prototype.eq = function eq(other) {
16862  return this === other ||
16863         this.getX().cmp(other.getX()) === 0 &&
16864         this.getY().cmp(other.getY()) === 0;
16865};
16866
16867Point.prototype.eqXToP = function eqXToP(x) {
16868  var rx = x.toRed(this.curve.red).redMul(this.z);
16869  if (this.x.cmp(rx) === 0)
16870    return true;
16871
16872  var xc = x.clone();
16873  var t = this.curve.redN.redMul(this.z);
16874  for (;;) {
16875    xc.iadd(this.curve.n);
16876    if (xc.cmp(this.curve.p) >= 0)
16877      return false;
16878
16879    rx.redIAdd(t);
16880    if (this.x.cmp(rx) === 0)
16881      return true;
16882  }
16883  return false;
16884};
16885
16886// Compatibility with BaseCurve
16887Point.prototype.toP = Point.prototype.normalize;
16888Point.prototype.mixedAdd = Point.prototype.add;
16889
16890
16891/***/ },
16892/* 15 */
16893/***/ function(module, exports, __webpack_require__) {
16894
16895"use strict";
16896'use strict';
16897
16898var curve = __webpack_require__(4);
16899var BN = __webpack_require__(1);
16900var inherits = __webpack_require__(5);
16901var Base = curve.base;
16902
16903var elliptic = __webpack_require__(0);
16904var utils = elliptic.utils;
16905
16906function MontCurve(conf) {
16907  Base.call(this, 'mont', conf);
16908
16909  this.a = new BN(conf.a, 16).toRed(this.red);
16910  this.b = new BN(conf.b, 16).toRed(this.red);
16911  this.i4 = new BN(4).toRed(this.red).redInvm();
16912  this.two = new BN(2).toRed(this.red);
16913  this.a24 = this.i4.redMul(this.a.redAdd(this.two));
16914}
16915inherits(MontCurve, Base);
16916module.exports = MontCurve;
16917
16918MontCurve.prototype.validate = function validate(point) {
16919  var x = point.normalize().x;
16920  var x2 = x.redSqr();
16921  var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
16922  var y = rhs.redSqrt();
16923
16924  return y.redSqr().cmp(rhs) === 0;
16925};
16926
16927function Point(curve, x, z) {
16928  Base.BasePoint.call(this, curve, 'projective');
16929  if (x === null && z === null) {
16930    this.x = this.curve.one;
16931    this.z = this.curve.zero;
16932  } else {
16933    this.x = new BN(x, 16);
16934    this.z = new BN(z, 16);
16935    if (!this.x.red)
16936      this.x = this.x.toRed(this.curve.red);
16937    if (!this.z.red)
16938      this.z = this.z.toRed(this.curve.red);
16939  }
16940}
16941inherits(Point, Base.BasePoint);
16942
16943MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
16944  return this.point(utils.toArray(bytes, enc), 1);
16945};
16946
16947MontCurve.prototype.point = function point(x, z) {
16948  return new Point(this, x, z);
16949};
16950
16951MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
16952  return Point.fromJSON(this, obj);
16953};
16954
16955Point.prototype.precompute = function precompute() {
16956  // No-op
16957};
16958
16959Point.prototype._encode = function _encode() {
16960  return this.getX().toArray('be', this.curve.p.byteLength());
16961};
16962
16963Point.fromJSON = function fromJSON(curve, obj) {
16964  return new Point(curve, obj[0], obj[1] || curve.one);
16965};
16966
16967Point.prototype.inspect = function inspect() {
16968  if (this.isInfinity())
16969    return '<EC Point Infinity>';
16970  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
16971      ' z: ' + this.z.fromRed().toString(16, 2) + '>';
16972};
16973
16974Point.prototype.isInfinity = function isInfinity() {
16975  // XXX This code assumes that zero is always zero in red
16976  return this.z.cmpn(0) === 0;
16977};
16978
16979Point.prototype.dbl = function dbl() {
16980  // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
16981  // 2M + 2S + 4A
16982
16983  // A = X1 + Z1
16984  var a = this.x.redAdd(this.z);
16985  // AA = A^2
16986  var aa = a.redSqr();
16987  // B = X1 - Z1
16988  var b = this.x.redSub(this.z);
16989  // BB = B^2
16990  var bb = b.redSqr();
16991  // C = AA - BB
16992  var c = aa.redSub(bb);
16993  // X3 = AA * BB
16994  var nx = aa.redMul(bb);
16995  // Z3 = C * (BB + A24 * C)
16996  var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
16997  return this.curve.point(nx, nz);
16998};
16999
17000Point.prototype.add = function add() {
17001  throw new Error('Not supported on Montgomery curve');
17002};
17003
17004Point.prototype.diffAdd = function diffAdd(p, diff) {
17005  // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
17006  // 4M + 2S + 6A
17007
17008  // A = X2 + Z2
17009  var a = this.x.redAdd(this.z);
17010  // B = X2 - Z2
17011  var b = this.x.redSub(this.z);
17012  // C = X3 + Z3
17013  var c = p.x.redAdd(p.z);
17014  // D = X3 - Z3
17015  var d = p.x.redSub(p.z);
17016  // DA = D * A
17017  var da = d.redMul(a);
17018  // CB = C * B
17019  var cb = c.redMul(b);
17020  // X5 = Z1 * (DA + CB)^2
17021  var nx = diff.z.redMul(da.redAdd(cb).redSqr());
17022  // Z5 = X1 * (DA - CB)^2
17023  var nz = diff.x.redMul(da.redISub(cb).redSqr());
17024  return this.curve.point(nx, nz);
17025};
17026
17027Point.prototype.mul = function mul(k) {
17028  var t = k.clone();
17029  var a = this; // (N / 2) * Q + Q
17030  var b = this.curve.point(null, null); // (N / 2) * Q
17031  var c = this; // Q
17032
17033  for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
17034    bits.push(t.andln(1));
17035
17036  for (var i = bits.length - 1; i >= 0; i--) {
17037    if (bits[i] === 0) {
17038      // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
17039      a = a.diffAdd(b, c);
17040      // N * Q = 2 * ((N / 2) * Q + Q))
17041      b = b.dbl();
17042    } else {
17043      // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
17044      b = a.diffAdd(b, c);
17045      // N * Q + Q = 2 * ((N / 2) * Q + Q)
17046      a = a.dbl();
17047    }
17048  }
17049  return b;
17050};
17051
17052Point.prototype.mulAdd = function mulAdd() {
17053  throw new Error('Not supported on Montgomery curve');
17054};
17055
17056Point.prototype.jumlAdd = function jumlAdd() {
17057  throw new Error('Not supported on Montgomery curve');
17058};
17059
17060Point.prototype.eq = function eq(other) {
17061  return this.getX().cmp(other.getX()) === 0;
17062};
17063
17064Point.prototype.normalize = function normalize() {
17065  this.x = this.x.redMul(this.z.redInvm());
17066  this.z = this.curve.one;
17067  return this;
17068};
17069
17070Point.prototype.getX = function getX() {
17071  // Normalize coordinates
17072  this.normalize();
17073
17074  return this.x.fromRed();
17075};
17076
17077
17078/***/ },
17079/* 16 */
17080/***/ function(module, exports, __webpack_require__) {
17081
17082"use strict";
17083'use strict';
17084
17085var curve = __webpack_require__(4);
17086var elliptic = __webpack_require__(0);
17087var BN = __webpack_require__(1);
17088var inherits = __webpack_require__(5
vendor: 22,718 bytes, lines 17088-18023
17088);
17089var Base = curve.base;
17090
17091var assert = elliptic.utils.assert;
17092
17093function ShortCurve(conf) {
17094  Base.call(this, 'short', conf);
17095
17096  this.a = new BN(conf.a, 16).toRed(this.red);
17097  this.b = new BN(conf.b, 16).toRed(this.red);
17098  this.tinv = this.two.redInvm();
17099
17100  this.zeroA = this.a.fromRed().cmpn(0) === 0;
17101  this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
17102
17103  // If the curve is endomorphic, precalculate beta and lambda
17104  this.endo = this._getEndomorphism(conf);
17105  this._endoWnafT1 = new Array(4);
17106  this._endoWnafT2 = new Array(4);
17107}
17108inherits(ShortCurve, Base);
17109module.exports = ShortCurve;
17110
17111ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
17112  // No efficient endomorphism
17113  if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
17114    return;
17115
17116  // Compute beta and lambda, that lambda * P = (beta * Px; Py)
17117  var beta;
17118  var lambda;
17119  if (conf.beta) {
17120    beta = new BN(conf.beta, 16).toRed(this.red);
17121  } else {
17122    var betas = this._getEndoRoots(this.p);
17123    // Choose the smallest beta
17124    beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
17125    beta = beta.toRed(this.red);
17126  }
17127  if (conf.lambda) {
17128    lambda = new BN(conf.lambda, 16);
17129  } else {
17130    // Choose the lambda that is matching selected beta
17131    var lambdas = this._getEndoRoots(this.n);
17132    if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
17133      lambda = lambdas[0];
17134    } else {
17135      lambda = lambdas[1];
17136      assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
17137    }
17138  }
17139
17140  // Get basis vectors, used for balanced length-two representation
17141  var basis;
17142  if (conf.basis) {
17143    basis = conf.basis.map(function(vec) {
17144      return {
17145        a: new BN(vec.a, 16),
17146        b: new BN(vec.b, 16)
17147      };
17148    });
17149  } else {
17150    basis = this._getEndoBasis(lambda);
17151  }
17152
17153  return {
17154    beta: beta,
17155    lambda: lambda,
17156    basis: basis
17157  };
17158};
17159
17160ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
17161  // Find roots of for x^2 + x + 1 in F
17162  // Root = (-1 +- Sqrt(-3)) / 2
17163  //
17164  var red = num === this.p ? this.red : BN.mont(num);
17165  var tinv = new BN(2).toRed(red).redInvm();
17166  var ntinv = tinv.redNeg();
17167
17168  var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
17169
17170  var l1 = ntinv.redAdd(s).fromRed();
17171  var l2 = ntinv.redSub(s).fromRed();
17172  return [ l1, l2 ];
17173};
17174
17175ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
17176  // aprxSqrt >= sqrt(this.n)
17177  var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
17178
17179  // 3.74
17180  // Run EGCD, until r(L + 1) < aprxSqrt
17181  var u = lambda;
17182  var v = this.n.clone();
17183  var x1 = new BN(1);
17184  var y1 = new BN(0);
17185  var x2 = new BN(0);
17186  var y2 = new BN(1);
17187
17188  // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
17189  var a0;
17190  var b0;
17191  // First vector
17192  var a1;
17193  var b1;
17194  // Second vector
17195  var a2;
17196  var b2;
17197
17198  var prevR;
17199  var i = 0;
17200  var r;
17201  var x;
17202  while (u.cmpn(0) !== 0) {
17203    var q = v.div(u);
17204    r = v.sub(q.mul(u));
17205    x = x2.sub(q.mul(x1));
17206    var y = y2.sub(q.mul(y1));
17207
17208    if (!a1 && r.cmp(aprxSqrt) < 0) {
17209      a0 = prevR.neg();
17210      b0 = x1;
17211      a1 = r.neg();
17212      b1 = x;
17213    } else if (a1 && ++i === 2) {
17214      break;
17215    }
17216    prevR = r;
17217
17218    v = u;
17219    u = r;
17220    x2 = x1;
17221    x1 = x;
17222    y2 = y1;
17223    y1 = y;
17224  }
17225  a2 = r.neg();
17226  b2 = x;
17227
17228  var len1 = a1.sqr().add(b1.sqr());
17229  var len2 = a2.sqr().add(b2.sqr());
17230  if (len2.cmp(len1) >= 0) {
17231    a2 = a0;
17232    b2 = b0;
17233  }
17234
17235  // Normalize signs
17236  if (a1.negative) {
17237    a1 = a1.neg();
17238    b1 = b1.neg();
17239  }
17240  if (a2.negative) {
17241    a2 = a2.neg();
17242    b2 = b2.neg();
17243  }
17244
17245  return [
17246    { a: a1, b: b1 },
17247    { a: a2, b: b2 }
17248  ];
17249};
17250
17251ShortCurve.prototype._endoSplit = function _endoSplit(k) {
17252  var basis = this.endo.basis;
17253  var v1 = basis[0];
17254  var v2 = basis[1];
17255
17256  var c1 = v2.b.mul(k).divRound(this.n);
17257  var c2 = v1.b.neg().mul(k).divRound(this.n);
17258
17259  var p1 = c1.mul(v1.a);
17260  var p2 = c2.mul(v2.a);
17261  var q1 = c1.mul(v1.b);
17262  var q2 = c2.mul(v2.b);
17263
17264  // Calculate answer
17265  var k1 = k.sub(p1).sub(p2);
17266  var k2 = q1.add(q2).neg();
17267  return { k1: k1, k2: k2 };
17268};
17269
17270ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
17271  x = new BN(x, 16);
17272  if (!x.red)
17273    x = x.toRed(this.red);
17274
17275  var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
17276  var y = y2.redSqrt();
17277  if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
17278    throw new Error('invalid point');
17279
17280  // XXX Is there any way to tell if the number is odd without converting it
17281  // to non-red form?
17282  var isOdd = y.fromRed().isOdd();
17283  if (odd && !isOdd || !odd && isOdd)
17284    y = y.redNeg();
17285
17286  return this.point(x, y);
17287};
17288
17289ShortCurve.prototype.validate = function validate(point) {
17290  if (point.inf)
17291    return true;
17292
17293  var x = point.x;
17294  var y = point.y;
17295
17296  var ax = this.a.redMul(x);
17297  var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
17298  return y.redSqr().redISub(rhs).cmpn(0) === 0;
17299};
17300
17301ShortCurve.prototype._endoWnafMulAdd =
17302    function _endoWnafMulAdd(points, coeffs, jacobianResult) {
17303  var npoints = this._endoWnafT1;
17304  var ncoeffs = this._endoWnafT2;
17305  for (var i = 0; i < points.length; i++) {
17306    var split = this._endoSplit(coeffs[i]);
17307    var p = points[i];
17308    var beta = p._getBeta();
17309
17310    if (split.k1.negative) {
17311      split.k1.ineg();
17312      p = p.neg(true);
17313    }
17314    if (split.k2.negative) {
17315      split.k2.ineg();
17316      beta = beta.neg(true);
17317    }
17318
17319    npoints[i * 2] = p;
17320    npoints[i * 2 + 1] = beta;
17321    ncoeffs[i * 2] = split.k1;
17322    ncoeffs[i * 2 + 1] = split.k2;
17323  }
17324  var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
17325
17326  // Clean-up references to points and coefficients
17327  for (var j = 0; j < i * 2; j++) {
17328    npoints[j] = null;
17329    ncoeffs[j] = null;
17330  }
17331  return res;
17332};
17333
17334function Point(curve, x, y, isRed) {
17335  Base.BasePoint.call(this, curve, 'affine');
17336  if (x === null && y === null) {
17337    this.x = null;
17338    this.y = null;
17339    this.inf = true;
17340  } else {
17341    this.x = new BN(x, 16);
17342    this.y = new BN(y, 16);
17343    // Force redgomery representation when loading from JSON
17344    if (isRed) {
17345      this.x.forceRed(this.curve.red);
17346      this.y.forceRed(this.curve.red);
17347    }
17348    if (!this.x.red)
17349      this.x = this.x.toRed(this.curve.red);
17350    if (!this.y.red)
17351      this.y = this.y.toRed(this.curve.red);
17352    this.inf = false;
17353  }
17354}
17355inherits(Point, Base.BasePoint);
17356
17357ShortCurve.prototype.point = function point(x, y, isRed) {
17358  return new Point(this, x, y, isRed);
17359};
17360
17361ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
17362  return Point.fromJSON(this, obj, red);
17363};
17364
17365Point.prototype._getBeta = function _getBeta() {
17366  if (!this.curve.endo)
17367    return;
17368
17369  var pre = this.precomputed;
17370  if (pre && pre.beta)
17371    return pre.beta;
17372
17373  var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
17374  if (pre) {
17375    var curve = this.curve;
17376    var endoMul = function(p) {
17377      return curve.point(p.x.redMul(curve.endo.beta), p.y);
17378    };
17379    pre.beta = beta;
17380    beta.precomputed = {
17381      beta: null,
17382      naf: pre.naf && {
17383        wnd: pre.naf.wnd,
17384        points: pre.naf.points.map(endoMul)
17385      },
17386      doubles: pre.doubles && {
17387        step: pre.doubles.step,
17388        points: pre.doubles.points.map(endoMul)
17389      }
17390    };
17391  }
17392  return beta;
17393};
17394
17395Point.prototype.toJSON = function toJSON() {
17396  if (!this.precomputed)
17397    return [ this.x, this.y ];
17398
17399  return [ this.x, this.y, this.precomputed && {
17400    doubles: this.precomputed.doubles && {
17401      step: this.precomputed.doubles.step,
17402      points: this.precomputed.doubles.points.slice(1)
17403    },
17404    naf: this.precomputed.naf && {
17405      wnd: this.precomputed.naf.wnd,
17406      points: this.precomputed.naf.points.slice(1)
17407    }
17408  } ];
17409};
17410
17411Point.fromJSON = function fromJSON(curve, obj, red) {
17412  if (typeof obj === 'string')
17413    obj = JSON.parse(obj);
17414  var res = curve.point(obj[0], obj[1], red);
17415  if (!obj[2])
17416    return res;
17417
17418  function obj2point(obj) {
17419    return curve.point(obj[0], obj[1], red);
17420  }
17421
17422  var pre = obj[2];
17423  res.precomputed = {
17424    beta: null,
17425    doubles: pre.doubles && {
17426      step: pre.doubles.step,
17427      points: [ res ].concat(pre.doubles.points.map(obj2point))
17428    },
17429    naf: pre.naf && {
17430      wnd: pre.naf.wnd,
17431      points: [ res ].concat(pre.naf.points.map(obj2point))
17432    }
17433  };
17434  return res;
17435};
17436
17437Point.prototype.inspect = function inspect() {
17438  if (this.isInfinity())
17439    return '<EC Point Infinity>';
17440  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
17441      ' y: ' + this.y.fromRed().toString(16, 2) + '>';
17442};
17443
17444Point.prototype.isInfinity = function isInfinity() {
17445  return this.inf;
17446};
17447
17448Point.prototype.add = function add(p) {
17449  // O + P = P
17450  if (this.inf)
17451    return p;
17452
17453  // P + O = P
17454  if (p.inf)
17455    return this;
17456
17457  // P + P = 2P
17458  if (this.eq(p))
17459    return this.dbl();
17460
17461  // P + (-P) = O
17462  if (this.neg().eq(p))
17463    return this.curve.point(null, null);
17464
17465  // P + Q = O
17466  if (this.x.cmp(p.x) === 0)
17467    return this.curve.point(null, null);
17468
17469  var c = this.y.redSub(p.y);
17470  if (c.cmpn(0) !== 0)
17471    c = c.redMul(this.x.redSub(p.x).redInvm());
17472  var nx = c.redSqr().redISub(this.x).redISub(p.x);
17473  var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
17474  return this.curve.point(nx, ny);
17475};
17476
17477Point.prototype.dbl = function dbl() {
17478  if (this.inf)
17479    return this;
17480
17481  // 2P = O
17482  var ys1 = this.y.redAdd(this.y);
17483  if (ys1.cmpn(0) === 0)
17484    return this.curve.point(null, null);
17485
17486  var a = this.curve.a;
17487
17488  var x2 = this.x.redSqr();
17489  var dyinv = ys1.redInvm();
17490  var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
17491
17492  var nx = c.redSqr().redISub(this.x.redAdd(this.x));
17493  var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
17494  return this.curve.point(nx, ny);
17495};
17496
17497Point.prototype.getX = function getX() {
17498  return this.x.fromRed();
17499};
17500
17501Point.prototype.getY = function getY() {
17502  return this.y.fromRed();
17503};
17504
17505Point.prototype.mul = function mul(k) {
17506  k = new BN(k, 16);
17507
17508  if (this._hasDoubles(k))
17509    return this.curve._fixedNafMul(this, k);
17510  else if (this.curve.endo)
17511    return this.curve._endoWnafMulAdd([ this ], [ k ]);
17512  else
17513    return this.curve._wnafMul(this, k);
17514};
17515
17516Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
17517  var points = [ this, p2 ];
17518  var coeffs = [ k1, k2 ];
17519  if (this.curve.endo)
17520    return this.curve._endoWnafMulAdd(points, coeffs);
17521  else
17522    return this.curve._wnafMulAdd(1, points, coeffs, 2);
17523};
17524
17525Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
17526  var points = [ this, p2 ];
17527  var coeffs = [ k1, k2 ];
17528  if (this.curve.endo)
17529    return this.curve._endoWnafMulAdd(points, coeffs, true);
17530  else
17531    return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
17532};
17533
17534Point.prototype.eq = function eq(p) {
17535  return this === p ||
17536         this.inf === p.inf &&
17537             (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
17538};
17539
17540Point.prototype.neg = function neg(_precompute) {
17541  if (this.inf)
17542    return this;
17543
17544  var res = this.curve.point(this.x, this.y.redNeg());
17545  if (_precompute && this.precomputed) {
17546    var pre = this.precomputed;
17547    var negate = function(p) {
17548      return p.neg();
17549    };
17550    res.precomputed = {
17551      naf: pre.naf && {
17552        wnd: pre.naf.wnd,
17553        points: pre.naf.points.map(negate)
17554      },
17555      doubles: pre.doubles && {
17556        step: pre.doubles.step,
17557        points: pre.doubles.points.map(negate)
17558      }
17559    };
17560  }
17561  return res;
17562};
17563
17564Point.prototype.toJ = function toJ() {
17565  if (this.inf)
17566    return this.curve.jpoint(null, null, null);
17567
17568  var res = this.curve.jpoint(this.x, this.y, this.curve.one);
17569  return res;
17570};
17571
17572function JPoint(curve, x, y, z) {
17573  Base.BasePoint.call(this, curve, 'jacobian');
17574  if (x === null && y === null && z === null) {
17575    this.x = this.curve.one;
17576    this.y = this.curve.one;
17577    this.z = new BN(0);
17578  } else {
17579    this.x = new BN(x, 16);
17580    this.y = new BN(y, 16);
17581    this.z = new BN(z, 16);
17582  }
17583  if (!this.x.red)
17584    this.x = this.x.toRed(this.curve.red);
17585  if (!this.y.red)
17586    this.y = this.y.toRed(this.curve.red);
17587  if (!this.z.red)
17588    this.z = this.z.toRed(this.curve.red);
17589
17590  this.zOne = this.z === this.curve.one;
17591}
17592inherits(JPoint, Base.BasePoint);
17593
17594ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
17595  return new JPoint(this, x, y, z);
17596};
17597
17598JPoint.prototype.toP = function toP() {
17599  if (this.isInfinity())
17600    return this.curve.point(null, null);
17601
17602  var zinv = this.z.redInvm();
17603  var zinv2 = zinv.redSqr();
17604  var ax = this.x.redMul(zinv2);
17605  var ay = this.y.redMul(zinv2).redMul(zinv);
17606
17607  return this.curve.point(ax, ay);
17608};
17609
17610JPoint.prototype.neg = function neg() {
17611  return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
17612};
17613
17614JPoint.prototype.add = function add(p) {
17615  // O + P = P
17616  if (this.isInfinity())
17617    return p;
17618
17619  // P + O = P
17620  if (p.isInfinity())
17621    return this;
17622
17623  // 12M + 4S + 7A
17624  var pz2 = p.z.redSqr();
17625  var z2 = this.z.redSqr();
17626  var u1 = this.x.redMul(pz2);
17627  var u2 = p.x.redMul(z2);
17628  var s1 = this.y.redMul(pz2.redMul(p.z));
17629  var s2 = p.y.redMul(z2.redMul(this.z));
17630
17631  var h = u1.redSub(u2);
17632  var r = s1.redSub(s2);
17633  if (h.cmpn(0) === 0) {
17634    if (r.cmpn(0) !== 0)
17635      return this.curve.jpoint(null, null, null);
17636    else
17637      return this.dbl();
17638  }
17639
17640  var h2 = h.redSqr();
17641  var h3 = h2.redMul(h);
17642  var v = u1.redMul(h2);
17643
17644  var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
17645  var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
17646  var nz = this.z.redMul(p.z).redMul(h);
17647
17648  return this.curve.jpoint(nx, ny, nz);
17649};
17650
17651JPoint.prototype.mixedAdd = function mixedAdd(p) {
17652  // O + P = P
17653  if (this.isInfinity())
17654    return p.toJ();
17655
17656  // P + O = P
17657  if (p.isInfinity())
17658    return this;
17659
17660  // 8M + 3S + 7A
17661  var z2 = this.z.redSqr();
17662  var u1 = this.x;
17663  var u2 = p.x.redMul(z2);
17664  var s1 = this.y;
17665  var s2 = p.y.redMul(z2).redMul(this.z);
17666
17667  var h = u1.redSub(u2);
17668  var r = s1.redSub(s2);
17669  if (h.cmpn(0) === 0) {
17670    if (r.cmpn(0) !== 0)
17671      return this.curve.jpoint(null, null, null);
17672    else
17673      return this.dbl();
17674  }
17675
17676  var h2 = h.redSqr();
17677  var h3 = h2.redMul(h);
17678  var v = u1.redMul(h2);
17679
17680  var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
17681  var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
17682  var nz = this.z.redMul(h);
17683
17684  return this.curve.jpoint(nx, ny, nz);
17685};
17686
17687JPoint.prototype.dblp = function dblp(pow) {
17688  if (pow === 0)
17689    return this;
17690  if (this.isInfinity())
17691    return this;
17692  if (!pow)
17693    return this.dbl();
17694
17695  if (this.curve.zeroA || this.curve.threeA) {
17696    var r = this;
17697    for (var i = 0; i < pow; i++)
17698      r = r.dbl();
17699    return r;
17700  }
17701
17702  // 1M + 2S + 1A + N * (4S + 5M + 8A)
17703  // N = 1 => 6M + 6S + 9A
17704  var a = this.curve.a;
17705  var tinv = this.curve.tinv;
17706
17707  var jx = this.x;
17708  var jy = this.y;
17709  var jz = this.z;
17710  var jz4 = jz.redSqr().redSqr();
17711
17712  // Reuse results
17713  var jyd = jy.redAdd(jy);
17714  for (var i = 0; i < pow; i++) {
17715    var jx2 = jx.redSqr();
17716    var jyd2 = jyd.redSqr();
17717    var jyd4 = jyd2.redSqr();
17718    var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
17719
17720    var t1 = jx.redMul(jyd2);
17721    var nx = c.redSqr().redISub(t1.redAdd(t1));
17722    var t2 = t1.redISub(nx);
17723    var dny = c.redMul(t2);
17724    dny = dny.redIAdd(dny).redISub(jyd4);
17725    var nz = jyd.redMul(jz);
17726    if (i + 1 < pow)
17727      jz4 = jz4.redMul(jyd4);
17728
17729    jx = nx;
17730    jz = nz;
17731    jyd = dny;
17732  }
17733
17734  return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
17735};
17736
17737JPoint.prototype.dbl = function dbl() {
17738  if (this.isInfinity())
17739    return this;
17740
17741  if (this.curve.zeroA)
17742    return this._zeroDbl();
17743  else if (this.curve.threeA)
17744    return this._threeDbl();
17745  else
17746    return this._dbl();
17747};
17748
17749JPoint.prototype._zeroDbl = function _zeroDbl() {
17750  var nx;
17751  var ny;
17752  var nz;
17753  // Z = 1
17754  if (this.zOne) {
17755    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
17756    //     #doubling-mdbl-2007-bl
17757    // 1M + 5S + 14A
17758
17759    // XX = X1^2
17760    var xx = this.x.redSqr();
17761    // YY = Y1^2
17762    var yy = this.y.redSqr();
17763    // YYYY = YY^2
17764    var yyyy = yy.redSqr();
17765    // S = 2 * ((X1 + YY)^2 - XX - YYYY)
17766    var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
17767    s = s.redIAdd(s);
17768    // M = 3 * XX + a; a = 0
17769    var m = xx.redAdd(xx).redIAdd(xx);
17770    // T = M ^ 2 - 2*S
17771    var t = m.redSqr().redISub(s).redISub(s);
17772
17773    // 8 * YYYY
17774    var yyyy8 = yyyy.redIAdd(yyyy);
17775    yyyy8 = yyyy8.redIAdd(yyyy8);
17776    yyyy8 = yyyy8.redIAdd(yyyy8);
17777
17778    // X3 = T
17779    nx = t;
17780    // Y3 = M * (S - T) - 8 * YYYY
17781    ny = m.redMul(s.redISub(t)).redISub(yyyy8);
17782    // Z3 = 2*Y1
17783    nz = this.y.redAdd(this.y);
17784  } else {
17785    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
17786    //     #doubling-dbl-2009-l
17787    // 2M + 5S + 13A
17788
17789    // A = X1^2
17790    var a = this.x.redSqr();
17791    // B = Y1^2
17792    var b = this.y.redSqr();
17793    // C = B^2
17794    var c = b.redSqr();
17795    // D = 2 * ((X1 + B)^2 - A - C)
17796    var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
17797    d = d.redIAdd(d);
17798    // E = 3 * A
17799    var e = a.redAdd(a).redIAdd(a);
17800    // F = E^2
17801    var f = e.redSqr();
17802
17803    // 8 * C
17804    var c8 = c.redIAdd(c);
17805    c8 = c8.redIAdd(c8);
17806    c8 = c8.redIAdd(c8);
17807
17808    // X3 = F - 2 * D
17809    nx = f.redISub(d).redISub(d);
17810    // Y3 = E * (D - X3) - 8 * C
17811    ny = e.redMul(d.redISub(nx)).redISub(c8);
17812    // Z3 = 2 * Y1 * Z1
17813    nz = this.y.redMul(this.z);
17814    nz = nz.redIAdd(nz);
17815  }
17816
17817  return this.curve.jpoint(nx, ny, nz);
17818};
17819
17820JPoint.prototype._threeDbl = function _threeDbl() {
17821  var nx;
17822  var ny;
17823  var nz;
17824  // Z = 1
17825  if (this.zOne) {
17826    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
17827    //     #doubling-mdbl-2007-bl
17828    // 1M + 5S + 15A
17829
17830    // XX = X1^2
17831    var xx = this.x.redSqr();
17832    // YY = Y1^2
17833    var yy = this.y.redSqr();
17834    // YYYY = YY^2
17835    var yyyy = yy.redSqr();
17836    // S = 2 * ((X1 + YY)^2 - XX - YYYY)
17837    var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
17838    s = s.redIAdd(s);
17839    // M = 3 * XX + a
17840    var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
17841    // T = M^2 - 2 * S
17842    var t = m.redSqr().redISub(s).redISub(s);
17843    // X3 = T
17844    nx = t;
17845    // Y3 = M * (S - T) - 8 * YYYY
17846    var yyyy8 = yyyy.redIAdd(yyyy);
17847    yyyy8 = yyyy8.redIAdd(yyyy8);
17848    yyyy8 = yyyy8.redIAdd(yyyy8);
17849    ny = m.redMul(s.redISub(t)).redISub(yyyy8);
17850    // Z3 = 2 * Y1
17851    nz = this.y.redAdd(this.y);
17852  } else {
17853    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
17854    // 3M + 5S
17855
17856    // delta = Z1^2
17857    var delta = this.z.redSqr();
17858    // gamma = Y1^2
17859    var gamma = this.y.redSqr();
17860    // beta = X1 * gamma
17861    var beta = this.x.redMul(gamma);
17862    // alpha = 3 * (X1 - delta) * (X1 + delta)
17863    var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
17864    alpha = alpha.redAdd(alpha).redIAdd(alpha);
17865    // X3 = alpha^2 - 8 * beta
17866    var beta4 = beta.redIAdd(beta);
17867    beta4 = beta4.redIAdd(beta4);
17868    var beta8 = beta4.redAdd(beta4);
17869    nx = alpha.redSqr().redISub(beta8);
17870    // Z3 = (Y1 + Z1)^2 - gamma - delta
17871    nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
17872    // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
17873    var ggamma8 = gamma.redSqr();
17874    ggamma8 = ggamma8.redIAdd(ggamma8);
17875    ggamma8 = ggamma8.redIAdd(ggamma8);
17876    ggamma8 = ggamma8.redIAdd(ggamma8);
17877    ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
17878  }
17879
17880  return this.curve.jpoint(nx, ny, nz);
17881};
17882
17883JPoint.prototype._dbl = function _dbl() {
17884  var a = this.curve.a;
17885
17886  // 4M + 6S + 10A
17887  var jx = this.x;
17888  var jy = this.y;
17889  var jz = this.z;
17890  var jz4 = jz.redSqr().redSqr();
17891
17892  var jx2 = jx.redSqr();
17893  var jy2 = jy.redSqr();
17894
17895  var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
17896
17897  var jxd4 = jx.redAdd(jx);
17898  jxd4 = jxd4.redIAdd(jxd4);
17899  var t1 = jxd4.redMul(jy2);
17900  var nx = c.redSqr().redISub(t1.redAdd(t1));
17901  var t2 = t1.redISub(nx);
17902
17903  var jyd8 = jy2.redSqr();
17904  jyd8 = jyd8.redIAdd(jyd8);
17905  jyd8 = jyd8.redIAdd(jyd8);
17906  jyd8 = jyd8.redIAdd(jyd8);
17907  var ny = c.redMul(t2).redISub(jyd8);
17908  var nz = jy.redAdd(jy).redMul(jz);
17909
17910  return this.curve.jpoint(nx, ny, nz);
17911};
17912
17913JPoint.prototype.trpl = function trpl() {
17914  if (!this.curve.zeroA)
17915    return this.dbl().add(this);
17916
17917  // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
17918  // 5M + 10S + ...
17919
17920  // XX = X1^2
17921  var xx = this.x.redSqr();
17922  // YY = Y1^2
17923  var yy = this.y.redSqr();
17924  // ZZ = Z1^2
17925  var zz = this.z.redSqr();
17926  // YYYY = YY^2
17927  var yyyy = yy.redSqr();
17928  // M = 3 * XX + a * ZZ2; a = 0
17929  var m = xx.redAdd(xx).redIAdd(xx);
17930  // MM = M^2
17931  var mm = m.redSqr();
17932  // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
17933  var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
17934  e = e.redIAdd(e);
17935  e = e.redAdd(e).redIAdd(e);
17936  e = e.redISub(mm);
17937  // EE = E^2
17938  var ee = e.redSqr();
17939  // T = 16*YYYY
17940  var t = yyyy.redIAdd(yyyy);
17941  t = t.redIAdd(t);
17942  t = t.redIAdd(t);
17943  t = t.redIAdd(t);
17944  // U = (M + E)^2 - MM - EE - T
17945  var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
17946  // X3 = 4 * (X1 * EE - 4 * YY * U)
17947  var yyu4 = yy.redMul(u);
17948  yyu4 = yyu4.redIAdd(yyu4);
17949  yyu4 = yyu4.redIAdd(yyu4);
17950  var nx = this.x.redMul(ee).redISub(yyu4);
17951  nx = nx.redIAdd(nx);
17952  nx = nx.redIAdd(nx);
17953  // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
17954  var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
17955  ny = ny.redIAdd(ny);
17956  ny = ny.redIAdd(ny);
17957  ny = ny.redIAdd(ny);
17958  // Z3 = (Z1 + E)^2 - ZZ - EE
17959  var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
17960
17961  return this.curve.jpoint(nx, ny, nz);
17962};
17963
17964JPoint.prototype.mul = function mul(k, kbase) {
17965  k = new BN(k, kbase);
17966
17967  return this.curve._wnafMul(this, k);
17968};
17969
17970JPoint.prototype.eq = function eq(p) {
17971  if (p.type === 'affine')
17972    return this.eq(p.toJ());
17973
17974  if (this === p)
17975    return true;
17976
17977  // x1 * z2^2 == x2 * z1^2
17978  var z2 = this.z.redSqr();
17979  var pz2 = p.z.redSqr();
17980  if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
17981    return false;
17982
17983  // y1 * z2^3 == y2 * z1^3
17984  var z3 = z2.redMul(this.z);
17985  var pz3 = pz2.redMul(p.z);
17986  return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
17987};
17988
17989JPoint.prototype.eqXToP = function eqXToP(x) {
17990  var zs = this.z.redSqr();
17991  var rx = x.toRed(this.curve.red).redMul(zs);
17992  if (this.x.cmp(rx) === 0)
17993    return true;
17994
17995  var xc = x.clone();
17996  var t = this.curve.redN.redMul(zs);
17997  for (;;) {
17998    xc.iadd(this.curve.n);
17999    if (xc.cmp(this.curve.p) >= 0)
18000      return false;
18001
18002    rx.redIAdd(t);
18003    if (this.x.cmp(rx) === 0)
18004      return true;
18005  }
18006  return false;
18007};
18008
18009JPoint.prototype.inspect = function inspect() {
18010  if (this.isInfinity())
18011    return '<EC JPoint Infinity>';
18012  return '<EC JPoint x: ' + this.x.toString(16, 2) +
18013      ' y: ' + this.y.toString(16, 2) +
18014      ' z: ' + this.z.toString(16, 2) + '>';
18015};
18016
18017JPoint.prototype.isInfinity = function isInfinity() {
18018  // XXX This code assumes that zero is always zero in red
18019  return this.z.cmpn(0) === 0;
18020};
18021
18022
18023/***/ }
vendor: 29,460 bytes, lines 18023-19159
18023,
18024/* 17 */
18025/***/ function(module, exports, __webpack_require__) {
18026
18027"use strict";
18028'use strict';
18029
18030var curves = exports;
18031
18032var hash = __webpack_require__(2);
18033var elliptic = __webpack_require__(0);
18034
18035var assert = elliptic.utils.assert;
18036
18037function PresetCurve(options) {
18038  if (options.type === 'short')
18039    this.curve = new elliptic.curve.short(options);
18040  else if (options.type === 'edwards')
18041    this.curve = new elliptic.curve.edwards(options);
18042  else
18043    this.curve = new elliptic.curve.mont(options);
18044  this.g = this.curve.g;
18045  this.n = this.curve.n;
18046  this.hash = options.hash;
18047
18048  assert(this.g.validate(), 'Invalid curve');
18049  assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
18050}
18051curves.PresetCurve = PresetCurve;
18052
18053function defineCurve(name, options) {
18054  Object.defineProperty(curves, name, {
18055    configurable: true,
18056    enumerable: true,
18057    get: function() {
18058      var curve = new PresetCurve(options);
18059      Object.defineProperty(curves, name, {
18060        configurable: true,
18061        enumerable: true,
18062        value: curve
18063      });
18064      return curve;
18065    }
18066  });
18067}
18068
18069defineCurve('p192', {
18070  type: 'short',
18071  prime: 'p192',
18072  p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
18073  a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
18074  b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
18075  n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
18076  hash: hash.sha256,
18077  gRed: false,
18078  g: [
18079    '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
18080    '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
18081  ]
18082});
18083
18084defineCurve('p224', {
18085  type: 'short',
18086  prime: 'p224',
18087  p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
18088  a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
18089  b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
18090  n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
18091  hash: hash.sha256,
18092  gRed: false,
18093  g: [
18094    'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
18095    'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
18096  ]
18097});
18098
18099defineCurve('p256', {
18100  type: 'short',
18101  prime: null,
18102  p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
18103  a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
18104  b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
18105  n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
18106  hash: hash.sha256,
18107  gRed: false,
18108  g: [
18109    '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
18110    '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
18111  ]
18112});
18113
18114defineCurve('p384', {
18115  type: 'short',
18116  prime: null,
18117  p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18118     'fffffffe ffffffff 00000000 00000000 ffffffff',
18119  a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18120     'fffffffe ffffffff 00000000 00000000 fffffffc',
18121  b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
18122     '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
18123  n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
18124     'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
18125  hash: hash.sha384,
18126  gRed: false,
18127  g: [
18128    'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
18129    '5502f25d bf55296c 3a545e38 72760ab7',
18130    '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
18131    '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
18132  ]
18133});
18134
18135defineCurve('p521', {
18136  type: 'short',
18137  prime: null,
18138  p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18139     'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18140     'ffffffff ffffffff ffffffff ffffffff ffffffff',
18141  a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18142     'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18143     'ffffffff ffffffff ffffffff ffffffff fffffffc',
18144  b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
18145     '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
18146     '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
18147  n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
18148     'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
18149     'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
18150  hash: hash.sha512,
18151  gRed: false,
18152  g: [
18153    '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
18154    '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
18155    'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
18156    '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
18157    '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
18158    '3fad0761 353c7086 a272c240 88be9476 9fd16650'
18159  ]
18160});
18161
18162defineCurve('curve25519', {
18163  type: 'mont',
18164  prime: 'p25519',
18165  p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
18166  a: '76d06',
18167  b: '0',
18168  n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
18169  hash: hash.sha256,
18170  gRed: false,
18171  g: [
18172    '9'
18173  ]
18174});
18175
18176defineCurve('ed25519', {
18177  type: 'edwards',
18178  prime: 'p25519',
18179  p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
18180  a: '-1',
18181  c: '1',
18182  // -121665 * (121666^(-1)) (mod P)
18183  d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
18184  n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
18185  hash: hash.sha256,
18186  gRed: false,
18187  g: [
18188    '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
18189
18190    // 4/5
18191    '6666666666666666666666666666666666666666666666666666666666666658'
18192  ]
18193});
18194
18195var pre;
18196try {
18197  pre = __webpack_require__(25);
18198} catch (e) {
18199  pre = undefined;
18200}
18201
18202defineCurve('secp256k1', {
18203  type: 'short',
18204  prime: 'k256',
18205  p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
18206  a: '0',
18207  b: '7',
18208  n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
18209  h: '1',
18210  hash: hash.sha256,
18211
18212  // Precomputed endomorphism
18213  beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
18214  lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
18215  basis: [
18216    {
18217      a: '3086d221a7d46bcde86c90e49284eb15',
18218      b: '-e4437ed6010e88286f547fa90abfe4c3'
18219    },
18220    {
18221      a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
18222      b: '3086d221a7d46bcde86c90e49284eb15'
18223    }
18224  ],
18225
18226  gRed: false,
18227  g: [
18228    '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
18229    '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
18230    pre
18231  ]
18232});
18233
18234
18235/***/ },
18236/* 18 */
18237/***/ function(module, exports, __webpack_require__) {
18238
18239"use strict";
18240'use strict';
18241
18242var BN = __webpack_require__(1);
18243var elliptic = __webpack_require__(0);
18244var utils = elliptic.utils;
18245var assert = utils.assert;
18246
18247var KeyPair = __webpack_require__(19);
18248var Signature = __webpack_require__(20);
18249
18250function EC(options) {
18251  if (!(this instanceof EC))
18252    return new EC(options);
18253
18254  // Shortcut `elliptic.ec(curve-name)`
18255  if (typeof options === 'string') {
18256    assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
18257
18258    options = elliptic.curves[options];
18259  }
18260
18261  // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
18262  if (options instanceof elliptic.curves.PresetCurve)
18263    options = { curve: options };
18264
18265  this.curve = options.curve.curve;
18266  this.n = this.curve.n;
18267  this.nh = this.n.ushrn(1);
18268  this.g = this.curve.g;
18269
18270  // Point on curve
18271  this.g = options.curve.g;
18272  this.g.precompute(options.curve.n.bitLength() + 1);
18273
18274  // Hash for function for DRBG
18275  this.hash = options.hash || options.curve.hash;
18276}
18277module.exports = EC;
18278
18279EC.prototype.keyPair = function keyPair(options) {
18280  return new KeyPair(this, options);
18281};
18282
18283EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
18284  return KeyPair.fromPrivate(this, priv, enc);
18285};
18286
18287EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
18288  return KeyPair.fromPublic(this, pub, enc);
18289};
18290
18291EC.prototype.genKeyPair = function genKeyPair(options) {
18292  if (!options)
18293    options = {};
18294
18295  // Instantiate Hmac_DRBG
18296  var drbg = new elliptic.hmacDRBG({
18297    hash: this.hash,
18298    pers: options.pers,
18299    entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
18300    nonce: this.n.toArray()
18301  });
18302
18303  var bytes = this.n.byteLength();
18304  var ns2 = this.n.sub(new BN(2));
18305  do {
18306    var priv = new BN(drbg.generate(bytes));
18307    if (priv.cmp(ns2) > 0)
18308      continue;
18309
18310    priv.iaddn(1);
18311    return this.keyFromPrivate(priv);
18312  } while (true);
18313};
18314
18315EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
18316  var delta = msg.byteLength() * 8 - this.n.bitLength();
18317  if (delta > 0)
18318    msg = msg.ushrn(delta);
18319  if (!truncOnly && msg.cmp(this.n) >= 0)
18320    return msg.sub(this.n);
18321  else
18322    return msg;
18323};
18324
18325EC.prototype.sign = function sign(msg, key, enc, options) {
18326  if (typeof enc === 'object') {
18327    options = enc;
18328    enc = null;
18329  }
18330  if (!options)
18331    options = {};
18332
18333  key = this.keyFromPrivate(key, enc);
18334  msg = this._truncateToN(new BN(msg, 16));
18335
18336  // Zero-extend key to provide enough entropy
18337  var bytes = this.n.byteLength();
18338  var bkey = key.getPrivate().toArray('be', bytes);
18339
18340  // Zero-extend nonce to have the same byte size as N
18341  var nonce = msg.toArray('be', bytes);
18342
18343  // Instantiate Hmac_DRBG
18344  var drbg = new elliptic.hmacDRBG({
18345    hash: this.hash,
18346    entropy: bkey,
18347    nonce: nonce,
18348    pers: options.pers,
18349    persEnc: options.persEnc
18350  });
18351
18352  // Number of bytes to generate
18353  var ns1 = this.n.sub(new BN(1));
18354
18355  for (var iter = 0; true; iter++) {
18356    var k = options.k ?
18357        options.k(iter) :
18358        new BN(drbg.generate(this.n.byteLength()));
18359    k = this._truncateToN(k, true);
18360    if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
18361      continue;
18362
18363    var kp = this.g.mul(k);
18364    if (kp.isInfinity())
18365      continue;
18366
18367    var kpX = kp.getX();
18368    var r = kpX.umod(this.n);
18369    if (r.cmpn(0) === 0)
18370      continue;
18371
18372    var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
18373    s = s.umod(this.n);
18374    if (s.cmpn(0) === 0)
18375      continue;
18376
18377    var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
18378                        (kpX.cmp(r) !== 0 ? 2 : 0);
18379
18380    // Use complement of `s`, if it is > `n / 2`
18381    if (options.canonical && s.cmp(this.nh) > 0) {
18382      s = this.n.sub(s);
18383      recoveryParam ^= 1;
18384    }
18385
18386    return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
18387  }
18388};
18389
18390EC.prototype.verify = function verify(msg, signature, key, enc) {
18391  msg = this._truncateToN(new BN(msg, 16));
18392  key = this.keyFromPublic(key, enc);
18393  signature = new Signature(signature, 'hex');
18394
18395  // Perform primitive values validation
18396  var r = signature.r;
18397  var s = signature.s;
18398  if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
18399    return false;
18400  if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
18401    return false;
18402
18403  // Validate signature
18404  var sinv = s.invm(this.n);
18405  var u1 = sinv.mul(msg).umod(this.n);
18406  var u2 = sinv.mul(r).umod(this.n);
18407
18408  if (!this.curve._maxwellTrick) {
18409    var p = this.g.mulAdd(u1, key.getPublic(), u2);
18410    if (p.isInfinity())
18411      return false;
18412
18413    return p.getX().umod(this.n).cmp(r) === 0;
18414  }
18415
18416  // NOTE: Greg Maxwell's trick, inspired by:
18417  // https://git.io/vad3K
18418
18419  var p = this.g.jmulAdd(u1, key.getPublic(), u2);
18420  if (p.isInfinity())
18421    return false;
18422
18423  // Compare `p.x` of Jacobian point with `r`,
18424  // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
18425  // inverse of `p.z^2`
18426  return p.eqXToP(r);
18427};
18428
18429EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
18430  assert((3 & j) === j, 'The recovery param is more than two bits');
18431  signature = new Signature(signature, enc);
18432
18433  var n = this.n;
18434  var e = new BN(msg);
18435  var r = signature.r;
18436  var s = signature.s;
18437
18438  // A set LSB signifies that the y-coordinate is odd
18439  var isYOdd = j & 1;
18440  var isSecondKey = j >> 1;
18441  if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
18442    throw new Error('Unable to find sencond key candinate');
18443
18444  // 1.1. Let x = r + jn.
18445  if (isSecondKey)
18446    r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
18447  else
18448    r = this.curve.pointFromX(r, isYOdd);
18449
18450  var rInv = signature.r.invm(n);
18451  var s1 = n.sub(e).mul(rInv).umod(n);
18452  var s2 = s.mul(rInv).umod(n);
18453
18454  // 1.6.1 Compute Q = r^-1 (sR -  eG)
18455  //               Q = r^-1 (sR + -eG)
18456  return this.g.mulAdd(s1, r, s2);
18457};
18458
18459EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
18460  signature = new Signature(signature, enc);
18461  if (signature.recoveryParam !== null)
18462    return signature.recoveryParam;
18463
18464  for (var i = 0; i < 4; i++) {
18465    var Qprime;
18466    try {
18467      Qprime = this.recoverPubKey(e, signature, i);
18468    } catch (e) {
18469      continue;
18470    }
18471
18472    if (Qprime.eq(Q))
18473      return i;
18474  }
18475  throw new Error('Unable to find valid recovery factor');
18476};
18477
18478
18479/***/ },
18480/* 19 */
18481/***/ function(module, exports, __webpack_require__) {
18482
18483"use strict";
18484'use strict';
18485
18486var BN = __webpack_require__(1);
18487
18488function KeyPair(ec, options) {
18489  this.ec = ec;
18490  this.priv = null;
18491  this.pub = null;
18492
18493  // KeyPair(ec, { priv: ..., pub: ... })
18494  if (options.priv)
18495    this._importPrivate(options.priv, options.privEnc);
18496  if (options.pub)
18497    this._importPublic(options.pub, options.pubEnc);
18498}
18499module.exports = KeyPair;
18500
18501KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
18502  if (pub instanceof KeyPair)
18503    return pub;
18504
18505  return new KeyPair(ec, {
18506    pub: pub,
18507    pubEnc: enc
18508  });
18509};
18510
18511KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
18512  if (priv instanceof KeyPair)
18513    return priv;
18514
18515  return new KeyPair(ec, {
18516    priv: priv,
18517    privEnc: enc
18518  });
18519};
18520
18521KeyPair.prototype.validate = function validate() {
18522  var pub = this.getPublic();
18523
18524  if (pub.isInfinity())
18525    return { result: false, reason: 'Invalid public key' };
18526  if (!pub.validate())
18527    return { result: false, reason: 'Public key is not a point' };
18528  if (!pub.mul(this.ec.curve.n).isInfinity())
18529    return { result: false, reason: 'Public key * N != O' };
18530
18531  return { result: true, reason: null };
18532};
18533
18534KeyPair.prototype.getPublic = function getPublic(compact, enc) {
18535  // compact is optional argument
18536  if (typeof compact === 'string') {
18537    enc = compact;
18538    compact = null;
18539  }
18540
18541  if (!this.pub)
18542    this.pub = this.ec.g.mul(this.priv);
18543
18544  if (!enc)
18545    return this.pub;
18546
18547  return this.pub.encode(enc, compact);
18548};
18549
18550KeyPair.prototype.getPrivate = function getPrivate(enc) {
18551  if (enc === 'hex')
18552    return this.priv.toString(16, 2);
18553  else
18554    return this.priv;
18555};
18556
18557KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
18558  this.priv = new BN(key, enc || 16);
18559
18560  // Ensure that the priv won't be bigger than n, otherwise we may fail
18561  // in fixed multiplication method
18562  this.priv = this.priv.umod(this.ec.curve.n);
18563};
18564
18565KeyPair.prototype._importPublic = function _importPublic(key, enc) {
18566  if (key.x || key.y) {
18567    this.pub = this.ec.curve.point(key.x, key.y);
18568    return;
18569  }
18570  this.pub = this.ec.curve.decodePoint(key, enc);
18571};
18572
18573// ECDH
18574KeyPair.prototype.derive = function derive(pub) {
18575  return pub.mul(this.priv).getX();
18576};
18577
18578// ECDSA
18579KeyPair.prototype.sign = function sign(msg, enc, options) {
18580  return this.ec.sign(msg, this, enc, options);
18581};
18582
18583KeyPair.prototype.verify = function verify(msg, signature) {
18584  return this.ec.verify(msg, signature, this);
18585};
18586
18587KeyPair.prototype.inspect = function inspect() {
18588  return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
18589         ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
18590};
18591
18592
18593/***/ },
18594/* 20 */
18595/***/ function(module, exports, __webpack_require__) {
18596
18597"use strict";
18598'use strict';
18599
18600var BN = __webpack_require__(1);
18601
18602var elliptic = __webpack_require__(0);
18603var utils = elliptic.utils;
18604var assert = utils.assert;
18605
18606function Signature(options, enc) {
18607  if (options instanceof Signature)
18608    return options;
18609
18610  if (this._importDER(options, enc))
18611    return;
18612
18613  assert(options.r && options.s, 'Signature without r or s');
18614  this.r = new BN(options.r, 16);
18615  this.s = new BN(options.s, 16);
18616  if (options.recoveryParam === undefined)
18617    this.recoveryParam = null;
18618  else
18619    this.recoveryParam = options.recoveryParam;
18620}
18621module.exports = Signature;
18622
18623function Position() {
18624  this.place = 0;
18625}
18626
18627function getLength(buf, p) {
18628  var initial = buf[p.place++];
18629  if (!(initial & 0x80)) {
18630    return initial;
18631  }
18632  var octetLen = initial & 0xf;
18633  var val = 0;
18634  for (var i = 0, off = p.place; i < octetLen; i++, off++) {
18635    val <<= 8;
18636    val |= buf[off];
18637  }
18638  p.place = off;
18639  return val;
18640}
18641
18642function rmPadding(buf) {
18643  var i = 0;
18644  var len = buf.length - 1;
18645  while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
18646    i++;
18647  }
18648  if (i === 0) {
18649    return buf;
18650  }
18651  return buf.slice(i);
18652}
18653
18654Signature.prototype._importDER = function _importDER(data, enc) {
18655  data = utils.toArray(data, enc);
18656  var p = new Position();
18657  if (data[p.place++] !== 0x30) {
18658    return false;
18659  }
18660  var len = getLength(data, p);
18661  if ((len + p.place) !== data.length) {
18662    return false;
18663  }
18664  if (data[p.place++] !== 0x02) {
18665    return false;
18666  }
18667  var rlen = getLength(data, p);
18668  var r = data.slice(p.place, rlen + p.place);
18669  p.place += rlen;
18670  if (data[p.place++] !== 0x02) {
18671    return false;
18672  }
18673  var slen = getLength(data, p);
18674  if (data.length !== slen + p.place) {
18675    return false;
18676  }
18677  var s = data.slice(p.place, slen + p.place);
18678  if (r[0] === 0 && (r[1] & 0x80)) {
18679    r = r.slice(1);
18680  }
18681  if (s[0] === 0 && (s[1] & 0x80)) {
18682    s = s.slice(1);
18683  }
18684
18685  this.r = new BN(r);
18686  this.s = new BN(s);
18687  this.recoveryParam = null;
18688
18689  return true;
18690};
18691
18692function constructLength(arr, len) {
18693  if (len < 0x80) {
18694    arr.push(len);
18695    return;
18696  }
18697  var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
18698  arr.push(octets | 0x80);
18699  while (--octets) {
18700    arr.push((len >>> (octets << 3)) & 0xff);
18701  }
18702  arr.push(len);
18703}
18704
18705Signature.prototype.toDER = function toDER(enc) {
18706  var r = this.r.toArray();
18707  var s = this.s.toArray();
18708
18709  // Pad values
18710  if (r[0] & 0x80)
18711    r = [ 0 ].concat(r);
18712  // Pad values
18713  if (s[0] & 0x80)
18714    s = [ 0 ].concat(s);
18715
18716  r = rmPadding(r);
18717  s = rmPadding(s);
18718
18719  while (!s[0] && !(s[1] & 0x80)) {
18720    s = s.slice(1);
18721  }
18722  var arr = [ 0x02 ];
18723  constructLength(arr, r.length);
18724  arr = arr.concat(r);
18725  arr.push(0x02);
18726  constructLength(arr, s.length);
18727  var backHalf = arr.concat(s);
18728  var res = [ 0x30 ];
18729  constructLength(res, backHalf.length);
18730  res = res.concat(backHalf);
18731  return utils.encode(res, enc);
18732};
18733
18734
18735/***/ },
18736/* 21 */
18737/***/ function(module, exports, __webpack_require__) {
18738
18739"use strict";
18740'use strict';
18741
18742var hash = __webpack_require__(2);
18743var elliptic = __webpack_require__(0);
18744var utils = elliptic.utils;
18745var assert = utils.assert;
18746var parseBytes = utils.parseBytes;
18747var KeyPair = __webpack_require__(22);
18748var Signature = __webpack_require__(23);
18749
18750function EDDSA(curve) {
18751  assert(curve === 'ed25519', 'only tested with ed25519 so far');
18752
18753  if (!(this instanceof EDDSA))
18754    return new EDDSA(curve);
18755
18756  var curve = elliptic.curves[curve].curve;
18757  this.curve = curve;
18758  this.g = curve.g;
18759  this.g.precompute(curve.n.bitLength() + 1);
18760
18761  this.pointClass = curve.point().constructor;
18762  this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
18763  this.hash = hash.sha512;
18764}
18765
18766module.exports = EDDSA;
18767
18768/**
18769* @param {Array|String} message - message bytes
18770* @param {Array|String|KeyPair} secret - secret bytes or a keypair
18771* @returns {Signature} - signature
18772*/
18773EDDSA.prototype.sign = function sign(message, secret) {
18774  message = parseBytes(message);
18775  var key = this.keyFromSecret(secret);
18776  var r = this.hashInt(key.messagePrefix(), message);
18777  var R = this.g.mul(r);
18778  var Rencoded = this.encodePoint(R);
18779  var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
18780               .mul(key.priv());
18781  var S = r.add(s_).umod(this.curve.n);
18782  return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
18783};
18784
18785/**
18786* @param {Array} message - message bytes
18787* @param {Array|String|Signature} sig - sig bytes
18788* @param {Array|String|Point|KeyPair} pub - public key
18789* @returns {Boolean} - true if public key matches sig of message
18790*/
18791EDDSA.prototype.verify = function verify(message, sig, pub) {
18792  message = parseBytes(message);
18793  sig = this.makeSignature(sig);
18794  var key = this.keyFromPublic(pub);
18795  var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
18796  var SG = this.g.mul(sig.S());
18797  var RplusAh = sig.R().add(key.pub().mul(h));
18798  return RplusAh.eq(SG);
18799};
18800
18801EDDSA.prototype.hashInt = function hashInt() {
18802  var hash = this.hash();
18803  for (var i = 0; i < arguments.length; i++)
18804    hash.update(arguments[i]);
18805  return utils.intFromLE(hash.digest()).umod(this.curve.n);
18806};
18807
18808EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
18809  return KeyPair.fromPublic(this, pub);
18810};
18811
18812EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
18813  return KeyPair.fromSecret(this, secret);
18814};
18815
18816EDDSA.prototype.makeSignature = function makeSignature(sig) {
18817  if (sig instanceof Signature)
18818    return sig;
18819  return new Signature(this, sig);
18820};
18821
18822/**
18823* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
18824*
18825* EDDSA defines methods for encoding and decoding points and integers. These are
18826* helper convenience methods, that pass along to utility functions implied
18827* parameters.
18828*
18829*/
18830EDDSA.prototype.encodePoint = function encodePoint(point) {
18831  var enc = point.getY().toArray('le', this.encodingLength);
18832  enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
18833  return enc;
18834};
18835
18836EDDSA.prototype.decodePoint = function decodePoint(bytes) {
18837  bytes = utils.parseBytes(bytes);
18838
18839  var lastIx = bytes.length - 1;
18840  var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
18841  var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
18842
18843  var y = utils.intFromLE(normed);
18844  return this.curve.pointFromY(y, xIsOdd);
18845};
18846
18847EDDSA.prototype.encodeInt = function encodeInt(num) {
18848  return num.toArray('le', this.encodingLength);
18849};
18850
18851EDDSA.prototype.decodeInt = function decodeInt(bytes) {
18852  return utils.intFromLE(bytes);
18853};
18854
18855EDDSA.prototype.isPoint = function isPoint(val) {
18856  return val instanceof this.pointClass;
18857};
18858
18859
18860/***/ },
18861/* 22 */
18862/***/ function(module, exports, __webpack_require__) {
18863
18864"use strict";
18865'use strict';
18866
18867var elliptic = __webpack_require__(0);
18868var utils = elliptic.utils;
18869var assert = utils.assert;
18870var parseBytes = utils.parseBytes;
18871var cachedProperty = utils.cachedProperty;
18872
18873/**
18874* @param {EDDSA} eddsa - instance
18875* @param {Object} params - public/private key parameters
18876*
18877* @param {Array<Byte>} [params.secret] - secret seed bytes
18878* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
18879* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
18880*
18881*/
18882function KeyPair(eddsa, params) {
18883  this.eddsa = eddsa;
18884  this._secret = parseBytes(params.secret);
18885  if (eddsa.isPoint(params.pub))
18886    this._pub = params.pub;
18887  else
18888    this._pubBytes = parseBytes(params.pub);
18889}
18890
18891KeyPair.fromPublic = function fromPublic(eddsa, pub) {
18892  if (pub instanceof KeyPair)
18893    return pub;
18894  return new KeyPair(eddsa, { pub: pub });
18895};
18896
18897KeyPair.fromSecret = function fromSecret(eddsa, secret) {
18898  if (secret instanceof KeyPair)
18899    return secret;
18900  return new KeyPair(eddsa, { secret: secret });
18901};
18902
18903KeyPair.prototype.secret = function secret() {
18904  return this._secret;
18905};
18906
18907cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
18908  return this.eddsa.encodePoint(this.pub());
18909});
18910
18911cachedProperty(KeyPair, 'pub', function pub() {
18912  if (this._pubBytes)
18913    return this.eddsa.decodePoint(this._pubBytes);
18914  return this.eddsa.g.mul(this.priv());
18915});
18916
18917cachedProperty(KeyPair, 'privBytes', function privBytes() {
18918  var eddsa = this.eddsa;
18919  var hash = this.hash();
18920  var lastIx = eddsa.encodingLength - 1;
18921
18922  var a = hash.slice(0, eddsa.encodingLength);
18923  a[0] &= 248;
18924  a[lastIx] &= 127;
18925  a[lastIx] |= 64;
18926
18927  return a;
18928});
18929
18930cachedProperty(KeyPair, 'priv', function priv() {
18931  return this.eddsa.decodeInt(this.privBytes());
18932});
18933
18934cachedProperty(KeyPair, 'hash', function hash() {
18935  return this.eddsa.hash().update(this.secret()).digest();
18936});
18937
18938cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
18939  return this.hash().slice(this.eddsa.encodingLength);
18940});
18941
18942KeyPair.prototype.sign = function sign(message) {
18943  assert(this._secret, 'KeyPair can only verify');
18944  return this.eddsa.sign(message, this);
18945};
18946
18947KeyPair.prototype.verify = function verify(message, sig) {
18948  return this.eddsa.verify(message, sig, this);
18949};
18950
18951KeyPair.prototype.getSecret = function getSecret(enc) {
18952  assert(this._secret, 'KeyPair is public only');
18953  return utils.encode(this.secret(), enc);
18954};
18955
18956KeyPair.prototype.getPublic = function getPublic(enc) {
18957  return utils.encode(this.pubBytes(), enc);
18958};
18959
18960module.exports = KeyPair;
18961
18962
18963/***/ },
18964/* 23 */
18965/***/ function(module, exports, __webpack_require__) {
18966
18967"use strict";
18968'use strict';
18969
18970var BN = __webpack_require__(1);
18971var elliptic = __webpack_require__(0);
18972var utils = elliptic.utils;
18973var assert = utils.assert;
18974var cachedProperty = utils.cachedProperty;
18975var parseBytes = utils.parseBytes;
18976
18977/**
18978* @param {EDDSA} eddsa - eddsa instance
18979* @param {Array<Bytes>|Object} sig -
18980* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
18981* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
18982* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
18983* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
18984*/
18985function Signature(eddsa, sig) {
18986  this.eddsa = eddsa;
18987
18988  if (typeof sig !== 'object')
18989    sig = parseBytes(sig);
18990
18991  if (Array.isArray(sig)) {
18992    sig = {
18993      R: sig.slice(0, eddsa.encodingLength),
18994      S: sig.slice(eddsa.encodingLength)
18995    };
18996  }
18997
18998  assert(sig.R && sig.S, 'Signature without R or S');
18999
19000  if (eddsa.isPoint(sig.R))
19001    this._R = sig.R;
19002  if (sig.S instanceof BN)
19003    this._S = sig.S;
19004
19005  this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
19006  this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
19007}
19008
19009cachedProperty(Signature, 'S', function S() {
19010  return this.eddsa.decodeInt(this.Sencoded());
19011});
19012
19013cachedProperty(Signature, 'R', function R() {
19014  return this.eddsa.decodePoint(this.Rencoded());
19015});
19016
19017cachedProperty(Signature, 'Rencoded', function Rencoded() {
19018  return this.eddsa.encodePoint(this.R());
19019});
19020
19021cachedProperty(Signature, 'Sencoded', function Sencoded() {
19022  return this.eddsa.encodeInt(this.S());
19023});
19024
19025Signature.prototype.toBytes = function toBytes() {
19026  return this.Rencoded().concat(this.Sencoded());
19027};
19028
19029Signature.prototype.toHex = function toHex() {
19030  return utils.encode(this.toBytes(), 'hex').toUpperCase();
19031};
19032
19033module.exports = Signature;
19034
19035
19036/***/ },
19037/* 24 */
19038/***/ function(module, exports, __webpack_require__) {
19039
19040"use strict";
19041'use strict';
19042
19043var hash = __webpack_require__(2);
19044var elliptic = __webpack_require__(0);
19045var utils = elliptic.utils;
19046var assert = utils.assert;
19047
19048function HmacDRBG(options) {
19049  if (!(this instanceof HmacDRBG))
19050    return new HmacDRBG(options);
19051  this.hash = options.hash;
19052  this.predResist = !!options.predResist;
19053
19054  this.outLen = this.hash.outSize;
19055  this.minEntropy = options.minEntropy || this.hash.hmacStrength;
19056
19057  this.reseed = null;
19058  this.reseedInterval = null;
19059  this.K = null;
19060  this.V = null;
19061
19062  var entropy = utils.toArray(options.entropy, options.entropyEnc);
19063  var nonce = utils.toArray(options.nonce, options.nonceEnc);
19064  var pers = utils.toArray(options.pers, options.persEnc);
19065  assert(entropy.length >= (this.minEntropy / 8),
19066         'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
19067  this._init(entropy, nonce, pers);
19068}
19069module.exports = HmacDRBG;
19070
19071HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
19072  var seed = entropy.concat(nonce).concat(pers);
19073
19074  this.K = new Array(this.outLen / 8);
19075  this.V = new Array(this.outLen / 8);
19076  for (var i = 0; i < this.V.length; i++) {
19077    this.K[i] = 0x00;
19078    this.V[i] = 0x01;
19079  }
19080
19081  this._update(seed);
19082  this.reseed = 1;
19083  this.reseedInterval = 0x1000000000000;  // 2^48
19084};
19085
19086HmacDRBG.prototype._hmac = function hmac() {
19087  return new hash.hmac(this.hash, this.K);
19088};
19089
19090HmacDRBG.prototype._update = function update(seed) {
19091  var kmac = this._hmac()
19092                 .update(this.V)
19093                 .update([ 0x00 ]);
19094  if (seed)
19095    kmac = kmac.update(seed);
19096  this.K = kmac.digest();
19097  this.V = this._hmac().update(this.V).digest();
19098  if (!seed)
19099    return;
19100
19101  this.K = this._hmac()
19102               .update(this.V)
19103               .update([ 0x01 ])
19104               .update(seed)
19105               .digest();
19106  this.V = this._hmac().update(this.V).digest();
19107};
19108
19109HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
19110  // Optional entropy enc
19111  if (typeof entropyEnc !== 'string') {
19112    addEnc = add;
19113    add = entropyEnc;
19114    entropyEnc = null;
19115  }
19116
19117  entropy = utils.toBuffer(entropy, entropyEnc);
19118  add = utils.toBuffer(add, addEnc);
19119
19120  assert(entropy.length >= (this.minEntropy / 8),
19121         'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
19122
19123  this._update(entropy.concat(add || []));
19124  this.reseed = 1;
19125};
19126
19127HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
19128  if (this.reseed > this.reseedInterval)
19129    throw new Error('Reseed is required');
19130
19131  // Optional encoding
19132  if (typeof enc !== 'string') {
19133    addEnc = add;
19134    add = enc;
19135    enc = null;
19136  }
19137
19138  // Optional additional data
19139  if (add) {
19140    add = utils.toArray(add, addEnc);
19141    this._update(add);
19142  }
19143
19144  var temp = [];
19145  while (temp.length < len) {
19146    this.V = this._hmac().update(this.V).digest();
19147    temp = temp.concat(this.V);
19148  }
19149
19150  var res = temp.slice(0, len);
19151  this._update(add);
19152  this.reseed++;
19153  return utils.encode(res, enc);
19154};
19155
19156
19157/***/ },
19158/* 25 */
19159/***/ 
vendor: 32,376 bytes, lines 19159-19943
19159function(module, exports) {
19160
19161module.exports = {
19162  doubles: {
19163    step: 4,
19164    points: [
19165      [
19166        'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
19167        'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
19168      ],
19169      [
19170        '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
19171        '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
19172      ],
19173      [
19174        '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
19175        'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
19176      ],
19177      [
19178        '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
19179        '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
19180      ],
19181      [
19182        '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
19183        '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
19184      ],
19185      [
19186        '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
19187        '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
19188      ],
19189      [
19190        'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
19191        '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
19192      ],
19193      [
19194        '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
19195        'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
19196      ],
19197      [
19198        'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
19199        '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
19200      ],
19201      [
19202        'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
19203        'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
19204      ],
19205      [
19206        'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
19207        '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
19208      ],
19209      [
19210        '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
19211        '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
19212      ],
19213      [
19214        '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
19215        '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
19216      ],
19217      [
19218        '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
19219        '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
19220      ],
19221      [
19222        '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
19223        '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
19224      ],
19225      [
19226        '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
19227        '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
19228      ],
19229      [
19230        '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
19231        '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
19232      ],
19233      [
19234        '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
19235        '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
19236      ],
19237      [
19238        '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
19239        'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
19240      ],
19241      [
19242        'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
19243        '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
19244      ],
19245      [
19246        'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
19247        '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
19248      ],
19249      [
19250        '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
19251        '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
19252      ],
19253      [
19254        '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
19255        '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
19256      ],
19257      [
19258        'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
19259        '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
19260      ],
19261      [
19262        '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
19263        'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
19264      ],
19265      [
19266        'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
19267        '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
19268      ],
19269      [
19270        'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
19271        'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
19272      ],
19273      [
19274        'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
19275        '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
19276      ],
19277      [
19278        'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
19279        'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
19280      ],
19281      [
19282        'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
19283        '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
19284      ],
19285      [
19286        '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
19287        'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
19288      ],
19289      [
19290        '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
19291        '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
19292      ],
19293      [
19294        'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
19295        '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
19296      ],
19297      [
19298        '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
19299        'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
19300      ],
19301      [
19302        'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
19303        '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
19304      ],
19305      [
19306        'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
19307        '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
19308      ],
19309      [
19310        'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
19311        'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
19312      ],
19313      [
19314        '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
19315        '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
19316      ],
19317      [
19318        '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
19319        '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
19320      ],
19321      [
19322        '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
19323        'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
19324      ],
19325      [
19326        '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
19327        '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
19328      ],
19329      [
19330        'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
19331        '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
19332      ],
19333      [
19334        '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
19335        '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
19336      ],
19337      [
19338        '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
19339        'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
19340      ],
19341      [
19342        '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
19343        '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
19344      ],
19345      [
19346        'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
19347        '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
19348      ],
19349      [
19350        '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
19351        'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
19352      ],
19353      [
19354        'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
19355        'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
19356      ],
19357      [
19358        'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
19359        '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
19360      ],
19361      [
19362        '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
19363        'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
19364      ],
19365      [
19366        '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
19367        'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
19368      ],
19369      [
19370        'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
19371        '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
19372      ],
19373      [
19374        'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
19375        '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
19376      ],
19377      [
19378        'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
19379        '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
19380      ],
19381      [
19382        '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
19383        'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
19384      ],
19385      [
19386        '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
19387        '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
19388      ],
19389      [
19390        'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
19391        'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
19392      ],
19393      [
19394        '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
19395        'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
19396      ],
19397      [
19398        '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
19399        '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
19400      ],
19401      [
19402        '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
19403        '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
19404      ],
19405      [
19406        'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
19407        'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
19408      ],
19409      [
19410        '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
19411        '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
19412      ],
19413      [
19414        '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
19415        '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
19416      ],
19417      [
19418        'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
19419        '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
19420      ],
19421      [
19422        'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
19423        'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
19424      ]
19425    ]
19426  },
19427  naf: {
19428    wnd: 7,
19429    points: [
19430      [
19431        'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
19432        '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
19433      ],
19434      [
19435        '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
19436        'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
19437      ],
19438      [
19439        '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
19440        '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
19441      ],
19442      [
19443        'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
19444        'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
19445      ],
19446      [
19447        '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
19448        'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
19449      ],
19450      [
19451        'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
19452        'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
19453      ],
19454      [
19455        'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
19456        '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
19457      ],
19458      [
19459        'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
19460        '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
19461      ],
19462      [
19463        '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
19464        '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
19465      ],
19466      [
19467        '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
19468        '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
19469      ],
19470      [
19471        '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
19472        '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
19473      ],
19474      [
19475        '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
19476        '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
19477      ],
19478      [
19479        'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
19480        'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
19481      ],
19482      [
19483        'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
19484        '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
19485      ],
19486      [
19487        '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
19488        'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
19489      ],
19490      [
19491        '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
19492        'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
19493      ],
19494      [
19495        '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
19496        '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
19497      ],
19498      [
19499        '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
19500        '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
19501      ],
19502      [
19503        '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
19504        '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
19505      ],
19506      [
19507        '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
19508        'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
19509      ],
19510      [
19511        'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
19512        'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
19513      ],
19514      [
19515        '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
19516        '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
19517      ],
19518      [
19519        '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
19520        '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
19521      ],
19522      [
19523        'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
19524        'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
19525      ],
19526      [
19527        '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
19528        '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
19529      ],
19530      [
19531        'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
19532        'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
19533      ],
19534      [
19535        'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
19536        'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
19537      ],
19538      [
19539        '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
19540        '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
19541      ],
19542      [
19543        '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
19544        '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
19545      ],
19546      [
19547        '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
19548        '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
19549      ],
19550      [
19551        'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
19552        '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
19553      ],
19554      [
19555        '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
19556        '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
19557      ],
19558      [
19559        'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
19560        '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
19561      ],
19562      [
19563        '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
19564        'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
19565      ],
19566      [
19567        '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
19568        'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
19569      ],
19570      [
19571        'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
19572        'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
19573      ],
19574      [
19575        '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
19576        '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
19577      ],
19578      [
19579        '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
19580        'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
19581      ],
19582      [
19583        'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
19584        'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
19585      ],
19586      [
19587        '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
19588        '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
19589      ],
19590      [
19591        '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
19592        'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
19593      ],
19594      [
19595        '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
19596        '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
19597      ],
19598      [
19599        '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
19600        'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
19601      ],
19602      [
19603        'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
19604        '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
19605      ],
19606      [
19607        '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
19608        '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
19609      ],
19610      [
19611        '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
19612        'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
19613      ],
19614      [
19615        '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
19616        'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
19617      ],
19618      [
19619        'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
19620        'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
19621      ],
19622      [
19623        'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
19624        'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
19625      ],
19626      [
19627        '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
19628        '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
19629      ],
19630      [
19631        '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
19632        '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
19633      ],
19634      [
19635        'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
19636        '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
19637      ],
19638      [
19639        'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
19640        'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
19641      ],
19642      [
19643        '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
19644        '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
19645      ],
19646      [
19647        '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
19648        '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
19649      ],
19650      [
19651        'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
19652        '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
19653      ],
19654      [
19655        '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
19656        '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
19657      ],
19658      [
19659        'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
19660        'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
19661      ],
19662      [
19663        '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
19664        'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
19665      ],
19666      [
19667        '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
19668        '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
19669      ],
19670      [
19671        'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
19672        '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
19673      ],
19674      [
19675        'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
19676        '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
19677      ],
19678      [
19679        '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
19680        '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
19681      ],
19682      [
19683        '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
19684        '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
19685      ],
19686      [
19687        '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
19688        'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
19689      ],
19690      [
19691        '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
19692        'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
19693      ],
19694      [
19695        '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
19696        '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
19697      ],
19698      [
19699        '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
19700        '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
19701      ],
19702      [
19703        '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
19704        '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
19705      ],
19706      [
19707        '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
19708        'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
19709      ],
19710      [
19711        'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
19712        'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
19713      ],
19714      [
19715        '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
19716        'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
19717      ],
19718      [
19719        'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
19720        '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
19721      ],
19722      [
19723        'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
19724        '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
19725      ],
19726      [
19727        'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
19728        '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
19729      ],
19730      [
19731        'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
19732        '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
19733      ],
19734      [
19735        '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
19736        'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
19737      ],
19738      [
19739        '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
19740        '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
19741      ],
19742      [
19743        '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
19744        'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
19745      ],
19746      [
19747        'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
19748        'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
19749      ],
19750      [
19751        'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
19752        '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
19753      ],
19754      [
19755        'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
19756        'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
19757      ],
19758      [
19759        'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
19760        '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
19761      ],
19762      [
19763        '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
19764        '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
19765      ],
19766      [
19767        'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
19768        '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
19769      ],
19770      [
19771        'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
19772        '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
19773      ],
19774      [
19775        '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
19776        '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
19777      ],
19778      [
19779        '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
19780        'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
19781      ],
19782      [
19783        'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
19784        '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
19785      ],
19786      [
19787        'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
19788        '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
19789      ],
19790      [
19791        'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
19792        '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
19793      ],
19794      [
19795        '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
19796        '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
19797      ],
19798      [
19799        'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
19800        'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
19801      ],
19802      [
19803        '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
19804        'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
19805      ],
19806      [
19807        'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
19808        'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
19809      ],
19810      [
19811        'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
19812        '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
19813      ],
19814      [
19815        '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
19816        'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
19817      ],
19818      [
19819        'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
19820        '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
19821      ],
19822      [
19823        'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
19824        '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
19825      ],
19826      [
19827        'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
19828        '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
19829      ],
19830      [
19831        '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
19832        'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
19833      ],
19834      [
19835        '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
19836        'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
19837      ],
19838      [
19839        'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
19840        '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
19841      ],
19842      [
19843        '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
19844        'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
19845      ],
19846      [
19847        '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
19848        '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
19849      ],
19850      [
19851        '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
19852        'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
19853      ],
19854      [
19855        'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
19856        'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
19857      ],
19858      [
19859        '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
19860        'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
19861      ],
19862      [
19863        '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
19864        '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
19865      ],
19866      [
19867        '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
19868        'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
19869      ],
19870      [
19871        '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
19872        '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
19873      ],
19874      [
19875        'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
19876        'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
19877      ],
19878      [
19879        '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
19880        '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
19881      ],
19882      [
19883        'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
19884        '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
19885      ],
19886      [
19887        '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
19888        '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
19889      ],
19890      [
19891        'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
19892        'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
19893      ],
19894      [
19895        'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
19896        '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
19897      ],
19898      [
19899        'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
19900        'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
19901      ],
19902      [
19903        '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
19904        'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
19905      ],
19906      [
19907        '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
19908        '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
19909      ],
19910      [
19911        '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
19912        'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
19913      ],
19914      [
19915        '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
19916        '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
19917      ],
19918      [
19919        '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
19920        '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
19921      ],
19922      [
19923        '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
19924        'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
19925      ],
19926      [
19927        '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
19928        '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
19929      ],
19930      [
19931        '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
19932        '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
19933      ],
19934      [
19935        '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
19936        '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
19937      ]
19938    ]
19939  }
19940};
19941
19942
19943/***/ }
19943,
19944/* 26 */
19945/***/ function(module, exports, __webpack_require__) {
19946
19947"use strict";
19948'use strict';
19949
19950var utils = exports;
19951var BN = __webpack_require__(1);
19952
19953utils.assert = function assert(val, msg) {
19954  if (!val)
19955    throw new Error(msg || 'Assertion failed');
19956};
19957
19958function toArray(msg, enc) {
19959  if (Array.isArray(msg))
19960    return msg.slice();
19961  if (!msg)
19962    return [];
19963  var res = [];
19964  if (typeof msg !== 'string') {
19965    for (var i = 0; i < msg.length; i++)
19966      res[i] = msg[i] | 0;
19967    return res;
19968  }
19969  if (!enc) {
19970    for (var i = 0; i < msg.length; i++) {
19971      var c = msg.charCodeAt(i);
19972      var hi = c >> 8;
19973      var lo = c & 0xff;
vendor: 11,310 bytes, lines 19974-20458
19974      if (hi)
19975        res.push(hi, lo);
19976      else
19977        res.push(lo);
19978    }
19979  } else if (enc === 'hex') {
19980    msg = msg.replace(/[^a-z0-9]+/ig, '');
19981    if (msg.length % 2 !== 0)
19982      msg = '0' + msg;
19983    for (var i = 0; i < msg.length; i += 2)
19984      res.push(parseInt(msg[i] + msg[i + 1], 16));
19985  }
19986  return res;
19987}
19988utils.toArray = toArray;
19989
19990function zero2(word) {
19991  if (word.length === 1)
19992    return '0' + word;
19993  else
19994    return word;
19995}
19996utils.zero2 = zero2;
19997
19998function toHex(msg) {
19999  var res = '';
20000  for (var i = 0; i < msg.length; i++)
20001    res += zero2(msg[i].toString(16));
20002  return res;
20003}
20004utils.toHex = toHex;
20005
20006utils.encode = function encode(arr, enc) {
20007  if (enc === 'hex')
20008    return toHex(arr);
20009  else
20010    return arr;
20011};
20012
20013// Represent num in a w-NAF form
20014function getNAF(num, w) {
20015  var naf = [];
20016  var ws = 1 << (w + 1);
20017  var k = num.clone();
20018  while (k.cmpn(1) >= 0) {
20019    var z;
20020    if (k.isOdd()) {
20021      var mod = k.andln(ws - 1);
20022      if (mod > (ws >> 1) - 1)
20023        z = (ws >> 1) - mod;
20024      else
20025        z = mod;
20026      k.isubn(z);
20027    } else {
20028      z = 0;
20029    }
20030    naf.push(z);
20031
20032    // Optimization, shift by word if possible
20033    var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
20034    for (var i = 1; i < shift; i++)
20035      naf.push(0);
20036    k.iushrn(shift);
20037  }
20038
20039  return naf;
20040}
20041utils.getNAF = getNAF;
20042
20043// Represent k1, k2 in a Joint Sparse Form
20044function getJSF(k1, k2) {
20045  var jsf = [
20046    [],
20047    []
20048  ];
20049
20050  k1 = k1.clone();
20051  k2 = k2.clone();
20052  var d1 = 0;
20053  var d2 = 0;
20054  while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
20055
20056    // First phase
20057    var m14 = (k1.andln(3) + d1) & 3;
20058    var m24 = (k2.andln(3) + d2) & 3;
20059    if (m14 === 3)
20060      m14 = -1;
20061    if (m24 === 3)
20062      m24 = -1;
20063    var u1;
20064    if ((m14 & 1) === 0) {
20065      u1 = 0;
20066    } else {
20067      var m8 = (k1.andln(7) + d1) & 7;
20068      if ((m8 === 3 || m8 === 5) && m24 === 2)
20069        u1 = -m14;
20070      else
20071        u1 = m14;
20072    }
20073    jsf[0].push(u1);
20074
20075    var u2;
20076    if ((m24 & 1) === 0) {
20077      u2 = 0;
20078    } else {
20079      var m8 = (k2.andln(7) + d2) & 7;
20080      if ((m8 === 3 || m8 === 5) && m14 === 2)
20081        u2 = -m24;
20082      else
20083        u2 = m24;
20084    }
20085    jsf[1].push(u2);
20086
20087    // Second phase
20088    if (2 * d1 === u1 + 1)
20089      d1 = 1 - d1;
20090    if (2 * d2 === u2 + 1)
20091      d2 = 1 - d2;
20092    k1.iushrn(1);
20093    k2.iushrn(1);
20094  }
20095
20096  return jsf;
20097}
20098utils.getJSF = getJSF;
20099
20100function cachedProperty(obj, name, computer) {
20101  var key = '_' + name;
20102  obj.prototype[name] = function cachedProperty() {
20103    return this[key] !== undefined ? this[key] :
20104           this[key] = computer.call(this);
20105  };
20106}
20107utils.cachedProperty = cachedProperty;
20108
20109function parseBytes(bytes) {
20110  return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
20111                                     bytes;
20112}
20113utils.parseBytes = parseBytes;
20114
20115function intFromLE(bytes) {
20116  return new BN(bytes, 'hex', 'le');
20117}
20118utils.intFromLE = intFromLE;
20119
20120
20121
20122/***/ },
20123/* 27 */
20124/***/ function(module, exports, __webpack_require__) {
20125
20126var hash = __webpack_require__(2);
20127var utils = hash.utils;
20128var assert = utils.assert;
20129
20130function BlockHash() {
20131  this.pending = null;
20132  this.pendingTotal = 0;
20133  this.blockSize = this.constructor.blockSize;
20134  this.outSize = this.constructor.outSize;
20135  this.hmacStrength = this.constructor.hmacStrength;
20136  this.padLength = this.constructor.padLength / 8;
20137  this.endian = 'big';
20138
20139  this._delta8 = this.blockSize / 8;
20140  this._delta32 = this.blockSize / 32;
20141}
20142exports.BlockHash = BlockHash;
20143
20144BlockHash.prototype.update = function update(msg, enc) {
20145  // Convert message to array, pad it, and join into 32bit blocks
20146  msg = utils.toArray(msg, enc);
20147  if (!this.pending)
20148    this.pending = msg;
20149  else
20150    this.pending = this.pending.concat(msg);
20151  this.pendingTotal += msg.length;
20152
20153  // Enough data, try updating
20154  if (this.pending.length >= this._delta8) {
20155    msg = this.pending;
20156
20157    // Process pending data in blocks
20158    var r = msg.length % this._delta8;
20159    this.pending = msg.slice(msg.length - r, msg.length);
20160    if (this.pending.length === 0)
20161      this.pending = null;
20162
20163    msg = utils.join32(msg, 0, msg.length - r, this.endian);
20164    for (var i = 0; i < msg.length; i += this._delta32)
20165      this._update(msg, i, i + this._delta32);
20166  }
20167
20168  return this;
20169};
20170
20171BlockHash.prototype.digest = function digest(enc) {
20172  this.update(this._pad());
20173  assert(this.pending === null);
20174
20175  return this._digest(enc);
20176};
20177
20178BlockHash.prototype._pad = function pad() {
20179  var len = this.pendingTotal;
20180  var bytes = this._delta8;
20181  var k = bytes - ((len + this.padLength) % bytes);
20182  var res = new Array(k + this.padLength);
20183  res[0] = 0x80;
20184  for (var i = 1; i < k; i++)
20185    res[i] = 0;
20186
20187  // Append length
20188  len <<= 3;
20189  if (this.endian === 'big') {
20190    for (var t = 8; t < this.padLength; t++)
20191      res[i++] = 0;
20192
20193    res[i++] = 0;
20194    res[i++] = 0;
20195    res[i++] = 0;
20196    res[i++] = 0;
20197    res[i++] = (len >>> 24) & 0xff;
20198    res[i++] = (len >>> 16) & 0xff;
20199    res[i++] = (len >>> 8) & 0xff;
20200    res[i++] = len & 0xff;
20201  } else {
20202    res[i++] = len & 0xff;
20203    res[i++] = (len >>> 8) & 0xff;
20204    res[i++] = (len >>> 16) & 0xff;
20205    res[i++] = (len >>> 24) & 0xff;
20206    res[i++] = 0;
20207    res[i++] = 0;
20208    res[i++] = 0;
20209    res[i++] = 0;
20210
20211    for (var t = 8; t < this.padLength; t++)
20212      res[i++] = 0;
20213  }
20214
20215  return res;
20216};
20217
20218
20219/***/ },
20220/* 28 */
20221/***/ function(module, exports, __webpack_require__) {
20222
20223var hmac = exports;
20224
20225var hash = __webpack_require__(2);
20226var utils = hash.utils;
20227var assert = utils.assert;
20228
20229function Hmac(hash, key, enc) {
20230  if (!(this instanceof Hmac))
20231    return new Hmac(hash, key, enc);
20232  this.Hash = hash;
20233  this.blockSize = hash.blockSize / 8;
20234  this.outSize = hash.outSize / 8;
20235  this.inner = null;
20236  this.outer = null;
20237
20238  this._init(utils.toArray(key, enc));
20239}
20240module.exports = Hmac;
20241
20242Hmac.prototype._init = function init(key) {
20243  // Shorten key, if needed
20244  if (key.length > this.blockSize)
20245    key = new this.Hash().update(key).digest();
20246  assert(key.length <= this.blockSize);
20247
20248  // Add padding to key
20249  for (var i = key.length; i < this.blockSize; i++)
20250    key.push(0);
20251
20252  for (var i = 0; i < key.length; i++)
20253    key[i] ^= 0x36;
20254  this.inner = new this.Hash().update(key);
20255
20256  // 0x36 ^ 0x5c = 0x6a
20257  for (var i = 0; i < key.length; i++)
20258    key[i] ^= 0x6a;
20259  this.outer = new this.Hash().update(key);
20260};
20261
20262Hmac.prototype.update = function update(msg, enc) {
20263  this.inner.update(msg, enc);
20264  return this;
20265};
20266
20267Hmac.prototype.digest = function digest(enc) {
20268  this.outer.update(this.inner.digest());
20269  return this.outer.digest(enc);
20270};
20271
20272
20273/***/ },
20274/* 29 */
20275/***/ function(module, exports, __webpack_require__) {
20276
20277var hash = __webpack_require__(2);
20278var utils = hash.utils;
20279
20280var rotl32 = utils.rotl32;
20281var sum32 = utils.sum32;
20282var sum32_3 = utils.sum32_3;
20283var sum32_4 = utils.sum32_4;
20284var BlockHash = hash.common.BlockHash;
20285
20286function RIPEMD160() {
20287  if (!(this instanceof RIPEMD160))
20288    return new RIPEMD160();
20289
20290  BlockHash.call(this);
20291
20292  this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
20293  this.endian = 'little';
20294}
20295utils.inherits(RIPEMD160, BlockHash);
20296exports.ripemd160 = RIPEMD160;
20297
20298RIPEMD160.blockSize = 512;
20299RIPEMD160.outSize = 160;
20300RIPEMD160.hmacStrength = 192;
20301RIPEMD160.padLength = 64;
20302
20303RIPEMD160.prototype._update = function update(msg, start) {
20304  var A = this.h[0];
20305  var B = this.h[1];
20306  var C = this.h[2];
20307  var D = this.h[3];
20308  var E = this.h[4];
20309  var Ah = A;
20310  var Bh = B;
20311  var Ch = C;
20312  var Dh = D;
20313  var Eh = E;
20314  for (var j = 0; j < 80; j++) {
20315    var T = sum32(
20316      rotl32(
20317        sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
20318        s[j]),
20319      E);
20320    A = E;
20321    E = D;
20322    D = rotl32(C, 10);
20323    C = B;
20324    B = T;
20325    T = sum32(
20326      rotl32(
20327        sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
20328        sh[j]),
20329      Eh);
20330    Ah = Eh;
20331    Eh = Dh;
20332    Dh = rotl32(Ch, 10);
20333    Ch = Bh;
20334    Bh = T;
20335  }
20336  T = sum32_3(this.h[1], C, Dh);
20337  this.h[1] = sum32_3(this.h[2], D, Eh);
20338  this.h[2] = sum32_3(this.h[3], E, Ah);
20339  this.h[3] = sum32_3(this.h[4], A, Bh);
20340  this.h[4] = sum32_3(this.h[0], B, Ch);
20341  this.h[0] = T;
20342};
20343
20344RIPEMD160.prototype._digest = function digest(enc) {
20345  if (enc === 'hex')
20346    return utils.toHex32(this.h, 'little');
20347  else
20348    return utils.split32(this.h, 'little');
20349};
20350
20351function f(j, x, y, z) {
20352  if (j <= 15)
20353    return x ^ y ^ z;
20354  else if (j <= 31)
20355    return (x & y) | ((~x) & z);
20356  else if (j <= 47)
20357    return (x | (~y)) ^ z;
20358  else if (j <= 63)
20359    return (x & z) | (y & (~z));
20360  else
20361    return x ^ (y | (~z));
20362}
20363
20364function K(j) {
20365  if (j <= 15)
20366    return 0x00000000;
20367  else if (j <= 31)
20368    return 0x5a827999;
20369  else if (j <= 47)
20370    return 0x6ed9eba1;
20371  else if (j <= 63)
20372    return 0x8f1bbcdc;
20373  else
20374    return 0xa953fd4e;
20375}
20376
20377function Kh(j) {
20378  if (j <= 15)
20379    return 0x50a28be6;
20380  else if (j <= 31)
20381    return 0x5c4dd124;
20382  else if (j <= 47)
20383    return 0x6d703ef3;
20384  else if (j <= 63)
20385    return 0x7a6d76e9;
20386  else
20387    return 0x00000000;
20388}
20389
20390var r = [
20391  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
20392  7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
20393  3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
20394  1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
20395  4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
20396];
20397
20398var rh = [
20399  5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
20400  6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
20401  15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
20402  8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
20403  12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
20404];
20405
20406var s = [
20407  11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
20408  7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
20409  11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
20410  11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
20411  9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
20412];
20413
20414var sh = [
20415  8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
20416  9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
20417  9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
20418  15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
20419  8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
20420];
20421
20422
20423/***/ },
20424/* 30 */
20425/***/ function(module, exports, __webpack_require__) {
20426
20427var hash = __webpack_require__(2);
20428var utils = hash.utils;
20429var assert = utils.assert;
20430
20431var rotr32 = utils.rotr32;
20432var rotl32 = utils.rotl32;
20433var sum32 = utils.sum32;
20434var sum32_4 = utils.sum32_4;
20435var sum32_5 = utils.sum32_5;
20436var rotr64_hi = utils.rotr64_hi;
20437var rotr64_lo = utils.rotr64_lo;
20438var shr64_hi = utils.shr64_hi;
20439var shr64_lo = utils.shr64_lo;
20440var sum64 = utils.sum64;
20441var sum64_hi = utils.sum64_hi;
20442var sum64_lo = utils.sum64_lo;
20443var sum64_4_hi = utils.sum64_4_hi;
20444var sum64_4_lo = utils.sum64_4_lo;
20445var sum64_5_hi = utils.sum64_5_hi;
20446var sum64_5_lo = utils.sum64_5_lo;
20447var BlockHash = hash.common.BlockHash;
20448
20449var sha256_K = [
20450  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
20451  0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
20452  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
20453  0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
20454  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
20455  0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
20456  0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
20457  0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
20458  0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
vendor: 8,807 bytes, lines 20459-20766
20459  0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
20460  0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
20461  0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
20462  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
20463  0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
20464  0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
20465  0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
20466];
20467
20468var sha512_K = [
20469  0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
20470  0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
20471  0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
20472  0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
20473  0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
20474  0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
20475  0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
20476  0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
20477  0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
20478  0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
20479  0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
20480  0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
20481  0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
20482  0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
20483  0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
20484  0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
20485  0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
20486  0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
20487  0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
20488  0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
20489  0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
20490  0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
20491  0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
20492  0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
20493  0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
20494  0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
20495  0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
20496  0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
20497  0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
20498  0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
20499  0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
20500  0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
20501  0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
20502  0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
20503  0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
20504  0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
20505  0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
20506  0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
20507  0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
20508  0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
20509];
20510
20511var sha1_K = [
20512  0x5A827999, 0x6ED9EBA1,
20513  0x8F1BBCDC, 0xCA62C1D6
20514];
20515
20516function SHA256() {
20517  if (!(this instanceof SHA256))
20518    return new SHA256();
20519
20520  BlockHash.call(this);
20521  this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
20522             0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
20523  this.k = sha256_K;
20524  this.W = new Array(64);
20525}
20526utils.inherits(SHA256, BlockHash);
20527exports.sha256 = SHA256;
20528
20529SHA256.blockSize = 512;
20530SHA256.outSize = 256;
20531SHA256.hmacStrength = 192;
20532SHA256.padLength = 64;
20533
20534SHA256.prototype._update = function _update(msg, start) {
20535  var W = this.W;
20536
20537  for (var i = 0; i < 16; i++)
20538    W[i] = msg[start + i];
20539  for (; i < W.length; i++)
20540    W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
20541
20542  var a = this.h[0];
20543  var b = this.h[1];
20544  var c = this.h[2];
20545  var d = this.h[3];
20546  var e = this.h[4];
20547  var f = this.h[5];
20548  var g = this.h[6];
20549  var h = this.h[7];
20550
20551  assert(this.k.length === W.length);
20552  for (var i = 0; i < W.length; i++) {
20553    var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
20554    var T2 = sum32(s0_256(a), maj32(a, b, c));
20555    h = g;
20556    g = f;
20557    f = e;
20558    e = sum32(d, T1);
20559    d = c;
20560    c = b;
20561    b = a;
20562    a = sum32(T1, T2);
20563  }
20564
20565  this.h[0] = sum32(this.h[0], a);
20566  this.h[1] = sum32(this.h[1], b);
20567  this.h[2] = sum32(this.h[2], c);
20568  this.h[3] = sum32(this.h[3], d);
20569  this.h[4] = sum32(this.h[4], e);
20570  this.h[5] = sum32(this.h[5], f);
20571  this.h[6] = sum32(this.h[6], g);
20572  this.h[7] = sum32(this.h[7], h);
20573};
20574
20575SHA256.prototype._digest = function digest(enc) {
20576  if (enc === 'hex')
20577    return utils.toHex32(this.h, 'big');
20578  else
20579    return utils.split32(this.h, 'big');
20580};
20581
20582function SHA224() {
20583  if (!(this instanceof SHA224))
20584    return new SHA224();
20585
20586  SHA256.call(this);
20587  this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
20588             0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
20589}
20590utils.inherits(SHA224, SHA256);
20591exports.sha224 = SHA224;
20592
20593SHA224.blockSize = 512;
20594SHA224.outSize = 224;
20595SHA224.hmacStrength = 192;
20596SHA224.padLength = 64;
20597
20598SHA224.prototype._digest = function digest(enc) {
20599  // Just truncate output
20600  if (enc === 'hex')
20601    return utils.toHex32(this.h.slice(0, 7), 'big');
20602  else
20603    return utils.split32(this.h.slice(0, 7), 'big');
20604};
20605
20606function SHA512() {
20607  if (!(this instanceof SHA512))
20608    return new SHA512();
20609
20610  BlockHash.call(this);
20611  this.h = [ 0x6a09e667, 0xf3bcc908,
20612             0xbb67ae85, 0x84caa73b,
20613             0x3c6ef372, 0xfe94f82b,
20614             0xa54ff53a, 0x5f1d36f1,
20615             0x510e527f, 0xade682d1,
20616             0x9b05688c, 0x2b3e6c1f,
20617             0x1f83d9ab, 0xfb41bd6b,
20618             0x5be0cd19, 0x137e2179 ];
20619  this.k = sha512_K;
20620  this.W = new Array(160);
20621}
20622utils.inherits(SHA512, BlockHash);
20623exports.sha512 = SHA512;
20624
20625SHA512.blockSize = 1024;
20626SHA512.outSize = 512;
20627SHA512.hmacStrength = 192;
20628SHA512.padLength = 128;
20629
20630SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
20631  var W = this.W;
20632
20633  // 32 x 32bit words
20634  for (var i = 0; i < 32; i++)
20635    W[i] = msg[start + i];
20636  for (; i < W.length; i += 2) {
20637    var c0_hi = g1_512_hi(W[i - 4], W[i - 3]);  // i - 2
20638    var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
20639    var c1_hi = W[i - 14];  // i - 7
20640    var c1_lo = W[i - 13];
20641    var c2_hi = g0_512_hi(W[i - 30], W[i - 29]);  // i - 15
20642    var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
20643    var c3_hi = W[i - 32];  // i - 16
20644    var c3_lo = W[i - 31];
20645
20646    W[i] = sum64_4_hi(c0_hi, c0_lo,
20647                      c1_hi, c1_lo,
20648                      c2_hi, c2_lo,
20649                      c3_hi, c3_lo);
20650    W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
20651                          c1_hi, c1_lo,
20652                          c2_hi, c2_lo,
20653                          c3_hi, c3_lo);
20654  }
20655};
20656
20657SHA512.prototype._update = function _update(msg, start) {
20658  this._prepareBlock(msg, start);
20659
20660  var W = this.W;
20661
20662  var ah = this.h[0];
20663  var al = this.h[1];
20664  var bh = this.h[2];
20665  var bl = this.h[3];
20666  var ch = this.h[4];
20667  var cl = this.h[5];
20668  var dh = this.h[6];
20669  var dl = this.h[7];
20670  var eh = this.h[8];
20671  var el = this.h[9];
20672  var fh = this.h[10];
20673  var fl = this.h[11];
20674  var gh = this.h[12];
20675  var gl = this.h[13];
20676  var hh = this.h[14];
20677  var hl = this.h[15];
20678
20679  assert(this.k.length === W.length);
20680  for (var i = 0; i < W.length; i += 2) {
20681    var c0_hi = hh;
20682    var c0_lo = hl;
20683    var c1_hi = s1_512_hi(eh, el);
20684    var c1_lo = s1_512_lo(eh, el);
20685    var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
20686    var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
20687    var c3_hi = this.k[i];
20688    var c3_lo = this.k[i + 1];
20689    var c4_hi = W[i];
20690    var c4_lo = W[i + 1];
20691
20692    var T1_hi = sum64_5_hi(c0_hi, c0_lo,
20693                           c1_hi, c1_lo,
20694                           c2_hi, c2_lo,
20695                           c3_hi, c3_lo,
20696                           c4_hi, c4_lo);
20697    var T1_lo = sum64_5_lo(c0_hi, c0_lo,
20698                           c1_hi, c1_lo,
20699                           c2_hi, c2_lo,
20700                           c3_hi, c3_lo,
20701                           c4_hi, c4_lo);
20702
20703    var c0_hi = s0_512_hi(ah, al);
20704    var c0_lo = s0_512_lo(ah, al);
20705    var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
20706    var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
20707
20708    var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
20709    var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
20710
20711    hh = gh;
20712    hl = gl;
20713
20714    gh = fh;
20715    gl = fl;
20716
20717    fh = eh;
20718    fl = el;
20719
20720    eh = sum64_hi(dh, dl, T1_hi, T1_lo);
20721    el = sum64_lo(dl, dl, T1_hi, T1_lo);
20722
20723    dh = ch;
20724    dl = cl;
20725
20726    ch = bh;
20727    cl = bl;
20728
20729    bh = ah;
20730    bl = al;
20731
20732    ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
20733    al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
20734  }
20735
20736  sum64(this.h, 0, ah, al);
20737  sum64(this.h, 2, bh, bl);
20738  sum64(this.h, 4, ch, cl);
20739  sum64(this.h, 6, dh, dl);
20740  sum64(this.h, 8, eh, el);
20741  sum64(this.h, 10, fh, fl);
20742  sum64(this.h, 12, gh, gl);
20743  sum64(this.h, 14, hh, hl);
20744};
20745
20746SHA512.prototype._digest = function digest(enc) {
20747  if (enc === 'hex')
20748    return utils.toHex32(this.h, 'big');
20749  else
20750    return utils.split32(this.h, 'big');
20751};
20752
20753function SHA384() {
20754  if (!(this instanceof SHA384))
20755    return new SHA384();
20756
20757  SHA512.call(this);
20758  this.h = [ 0xcbbb9d5d, 0xc1059ed8,
20759             0x629a292a, 0x367cd507,
20760             0x9159015a, 0x3070dd17,
20761             0x152fecd8, 0xf70e5939,
20762             0x67332667, 0xffc00b31,
20763             0x8eb44a87, 0x68581511,
20764             0xdb0c2e0d, 0x64f98fa7,
20765             0x47b5481d, 0xbefa4fa4 ];
20766}
vendor: 12,276 bytes, lines 20767-21340
20767utils.inherits(SHA384, SHA512);
20768exports.sha384 = SHA384;
20769
20770SHA384.blockSize = 1024;
20771SHA384.outSize = 384;
20772SHA384.hmacStrength = 192;
20773SHA384.padLength = 128;
20774
20775SHA384.prototype._digest = function digest(enc) {
20776  if (enc === 'hex')
20777    return utils.toHex32(this.h.slice(0, 12), 'big');
20778  else
20779    return utils.split32(this.h.slice(0, 12), 'big');
20780};
20781
20782function SHA1() {
20783  if (!(this instanceof SHA1))
20784    return new SHA1();
20785
20786  BlockHash.call(this);
20787  this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
20788             0x10325476, 0xc3d2e1f0 ];
20789  this.W = new Array(80);
20790}
20791
20792utils.inherits(SHA1, BlockHash);
20793exports.sha1 = SHA1;
20794
20795SHA1.blockSize = 512;
20796SHA1.outSize = 160;
20797SHA1.hmacStrength = 80;
20798SHA1.padLength = 64;
20799
20800SHA1.prototype._update = function _update(msg, start) {
20801  var W = this.W;
20802
20803  for (var i = 0; i < 16; i++)
20804    W[i] = msg[start + i];
20805
20806  for(; i < W.length; i++)
20807    W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
20808
20809  var a = this.h[0];
20810  var b = this.h[1];
20811  var c = this.h[2];
20812  var d = this.h[3];
20813  var e = this.h[4];
20814
20815  for (var i = 0; i < W.length; i++) {
20816    var s = ~~(i / 20);
20817    var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
20818    e = d;
20819    d = c;
20820    c = rotl32(b, 30);
20821    b = a;
20822    a = t;
20823  }
20824
20825  this.h[0] = sum32(this.h[0], a);
20826  this.h[1] = sum32(this.h[1], b);
20827  this.h[2] = sum32(this.h[2], c);
20828  this.h[3] = sum32(this.h[3], d);
20829  this.h[4] = sum32(this.h[4], e);
20830};
20831
20832SHA1.prototype._digest = function digest(enc) {
20833  if (enc === 'hex')
20834    return utils.toHex32(this.h, 'big');
20835  else
20836    return utils.split32(this.h, 'big');
20837};
20838
20839function ch32(x, y, z) {
20840  return (x & y) ^ ((~x) & z);
20841}
20842
20843function maj32(x, y, z) {
20844  return (x & y) ^ (x & z) ^ (y & z);
20845}
20846
20847function p32(x, y, z) {
20848  return x ^ y ^ z;
20849}
20850
20851function s0_256(x) {
20852  return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
20853}
20854
20855function s1_256(x) {
20856  return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
20857}
20858
20859function g0_256(x) {
20860  return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
20861}
20862
20863function g1_256(x) {
20864  return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
20865}
20866
20867function ft_1(s, x, y, z) {
20868  if (s === 0)
20869    return ch32(x, y, z);
20870  if (s === 1 || s === 3)
20871    return p32(x, y, z);
20872  if (s === 2)
20873    return maj32(x, y, z);
20874}
20875
20876function ch64_hi(xh, xl, yh, yl, zh, zl) {
20877  var r = (xh & yh) ^ ((~xh) & zh);
20878  if (r < 0)
20879    r += 0x100000000;
20880  return r;
20881}
20882
20883function ch64_lo(xh, xl, yh, yl, zh, zl) {
20884  var r = (xl & yl) ^ ((~xl) & zl);
20885  if (r < 0)
20886    r += 0x100000000;
20887  return r;
20888}
20889
20890function maj64_hi(xh, xl, yh, yl, zh, zl) {
20891  var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
20892  if (r < 0)
20893    r += 0x100000000;
20894  return r;
20895}
20896
20897function maj64_lo(xh, xl, yh, yl, zh, zl) {
20898  var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
20899  if (r < 0)
20900    r += 0x100000000;
20901  return r;
20902}
20903
20904function s0_512_hi(xh, xl) {
20905  var c0_hi = rotr64_hi(xh, xl, 28);
20906  var c1_hi = rotr64_hi(xl, xh, 2);  // 34
20907  var c2_hi = rotr64_hi(xl, xh, 7);  // 39
20908
20909  var r = c0_hi ^ c1_hi ^ c2_hi;
20910  if (r < 0)
20911    r += 0x100000000;
20912  return r;
20913}
20914
20915function s0_512_lo(xh, xl) {
20916  var c0_lo = rotr64_lo(xh, xl, 28);
20917  var c1_lo = rotr64_lo(xl, xh, 2);  // 34
20918  var c2_lo = rotr64_lo(xl, xh, 7);  // 39
20919
20920  var r = c0_lo ^ c1_lo ^ c2_lo;
20921  if (r < 0)
20922    r += 0x100000000;
20923  return r;
20924}
20925
20926function s1_512_hi(xh, xl) {
20927  var c0_hi = rotr64_hi(xh, xl, 14);
20928  var c1_hi = rotr64_hi(xh, xl, 18);
20929  var c2_hi = rotr64_hi(xl, xh, 9);  // 41
20930
20931  var r = c0_hi ^ c1_hi ^ c2_hi;
20932  if (r < 0)
20933    r += 0x100000000;
20934  return r;
20935}
20936
20937function s1_512_lo(xh, xl) {
20938  var c0_lo = rotr64_lo(xh, xl, 14);
20939  var c1_lo = rotr64_lo(xh, xl, 18);
20940  var c2_lo = rotr64_lo(xl, xh, 9);  // 41
20941
20942  var r = c0_lo ^ c1_lo ^ c2_lo;
20943  if (r < 0)
20944    r += 0x100000000;
20945  return r;
20946}
20947
20948function g0_512_hi(xh, xl) {
20949  var c0_hi = rotr64_hi(xh, xl, 1);
20950  var c1_hi = rotr64_hi(xh, xl, 8);
20951  var c2_hi = shr64_hi(xh, xl, 7);
20952
20953  var r = c0_hi ^ c1_hi ^ c2_hi;
20954  if (r < 0)
20955    r += 0x100000000;
20956  return r;
20957}
20958
20959function g0_512_lo(xh, xl) {
20960  var c0_lo = rotr64_lo(xh, xl, 1);
20961  var c1_lo = rotr64_lo(xh, xl, 8);
20962  var c2_lo = shr64_lo(xh, xl, 7);
20963
20964  var r = c0_lo ^ c1_lo ^ c2_lo;
20965  if (r < 0)
20966    r += 0x100000000;
20967  return r;
20968}
20969
20970function g1_512_hi(xh, xl) {
20971  var c0_hi = rotr64_hi(xh, xl, 19);
20972  var c1_hi = rotr64_hi(xl, xh, 29);  // 61
20973  var c2_hi = shr64_hi(xh, xl, 6);
20974
20975  var r = c0_hi ^ c1_hi ^ c2_hi;
20976  if (r < 0)
20977    r += 0x100000000;
20978  return r;
20979}
20980
20981function g1_512_lo(xh, xl) {
20982  var c0_lo = rotr64_lo(xh, xl, 19);
20983  var c1_lo = rotr64_lo(xl, xh, 29);  // 61
20984  var c2_lo = shr64_lo(xh, xl, 6);
20985
20986  var r = c0_lo ^ c1_lo ^ c2_lo;
20987  if (r < 0)
20988    r += 0x100000000;
20989  return r;
20990}
20991
20992
20993/***/ },
20994/* 31 */
20995/***/ function(module, exports, __webpack_require__) {
20996
20997var utils = exports;
20998var inherits = __webpack_require__(5);
20999
21000function toArray(msg, enc) {
21001  if (Array.isArray(msg))
21002    return msg.slice();
21003  if (!msg)
21004    return [];
21005  var res = [];
21006  if (typeof msg === 'string') {
21007    if (!enc) {
21008      for (var i = 0; i < msg.length; i++) {
21009        var c = msg.charCodeAt(i);
21010        var hi = c >> 8;
21011        var lo = c & 0xff;
21012        if (hi)
21013          res.push(hi, lo);
21014        else
21015          res.push(lo);
21016      }
21017    } else if (enc === 'hex') {
21018      msg = msg.replace(/[^a-z0-9]+/ig, '');
21019      if (msg.length % 2 !== 0)
21020        msg = '0' + msg;
21021      for (var i = 0; i < msg.length; i += 2)
21022        res.push(parseInt(msg[i] + msg[i + 1], 16));
21023    }
21024  } else {
21025    for (var i = 0; i < msg.length; i++)
21026      res[i] = msg[i] | 0;
21027  }
21028  return res;
21029}
21030utils.toArray = toArray;
21031
21032function toHex(msg) {
21033  var res = '';
21034  for (var i = 0; i < msg.length; i++)
21035    res += zero2(msg[i].toString(16));
21036  return res;
21037}
21038utils.toHex = toHex;
21039
21040function htonl(w) {
21041  var res = (w >>> 24) |
21042            ((w >>> 8) & 0xff00) |
21043            ((w << 8) & 0xff0000) |
21044            ((w & 0xff) << 24);
21045  return res >>> 0;
21046}
21047utils.htonl = htonl;
21048
21049function toHex32(msg, endian) {
21050  var res = '';
21051  for (var i = 0; i < msg.length; i++) {
21052    var w = msg[i];
21053    if (endian === 'little')
21054      w = htonl(w);
21055    res += zero8(w.toString(16));
21056  }
21057  return res;
21058}
21059utils.toHex32 = toHex32;
21060
21061function zero2(word) {
21062  if (word.length === 1)
21063    return '0' + word;
21064  else
21065    return word;
21066}
21067utils.zero2 = zero2;
21068
21069function zero8(word) {
21070  if (word.length === 7)
21071    return '0' + word;
21072  else if (word.length === 6)
21073    return '00' + word;
21074  else if (word.length === 5)
21075    return '000' + word;
21076  else if (word.length === 4)
21077    return '0000' + word;
21078  else if (word.length === 3)
21079    return '00000' + word;
21080  else if (word.length === 2)
21081    return '000000' + word;
21082  else if (word.length === 1)
21083    return '0000000' + word;
21084  else
21085    return word;
21086}
21087utils.zero8 = zero8;
21088
21089function join32(msg, start, end, endian) {
21090  var len = end - start;
21091  assert(len % 4 === 0);
21092  var res = new Array(len / 4);
21093  for (var i = 0, k = start; i < res.length; i++, k += 4) {
21094    var w;
21095    if (endian === 'big')
21096      w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
21097    else
21098      w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
21099    res[i] = w >>> 0;
21100  }
21101  return res;
21102}
21103utils.join32 = join32;
21104
21105function split32(msg, endian) {
21106  var res = new Array(msg.length * 4);
21107  for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
21108    var m = msg[i];
21109    if (endian === 'big') {
21110      res[k] = m >>> 24;
21111      res[k + 1] = (m >>> 16) & 0xff;
21112      res[k + 2] = (m >>> 8) & 0xff;
21113      res[k + 3] = m & 0xff;
21114    } else {
21115      res[k + 3] = m >>> 24;
21116      res[k + 2] = (m >>> 16) & 0xff;
21117      res[k + 1] = (m >>> 8) & 0xff;
21118      res[k] = m & 0xff;
21119    }
21120  }
21121  return res;
21122}
21123utils.split32 = split32;
21124
21125function rotr32(w, b) {
21126  return (w >>> b) | (w << (32 - b));
21127}
21128utils.rotr32 = rotr32;
21129
21130function rotl32(w, b) {
21131  return (w << b) | (w >>> (32 - b));
21132}
21133utils.rotl32 = rotl32;
21134
21135function sum32(a, b) {
21136  return (a + b) >>> 0;
21137}
21138utils.sum32 = sum32;
21139
21140function sum32_3(a, b, c) {
21141  return (a + b + c) >>> 0;
21142}
21143utils.sum32_3 = sum32_3;
21144
21145function sum32_4(a, b, c, d) {
21146  return (a + b + c + d) >>> 0;
21147}
21148utils.sum32_4 = sum32_4;
21149
21150function sum32_5(a, b, c, d, e) {
21151  return (a + b + c + d + e) >>> 0;
21152}
21153utils.sum32_5 = sum32_5;
21154
21155function assert(cond, msg) {
21156  if (!cond)
21157    throw new Error(msg || 'Assertion failed');
21158}
21159utils.assert = assert;
21160
21161utils.inherits = inherits;
21162
21163function sum64(buf, pos, ah, al) {
21164  var bh = buf[pos];
21165  var bl = buf[pos + 1];
21166
21167  var lo = (al + bl) >>> 0;
21168  var hi = (lo < al ? 1 : 0) + ah + bh;
21169  buf[pos] = hi >>> 0;
21170  buf[pos + 1] = lo;
21171}
21172exports.sum64 = sum64;
21173
21174function sum64_hi(ah, al, bh, bl) {
21175  var lo = (al + bl) >>> 0;
21176  var hi = (lo < al ? 1 : 0) + ah + bh;
21177  return hi >>> 0;
21178};
21179exports.sum64_hi = sum64_hi;
21180
21181function sum64_lo(ah, al, bh, bl) {
21182  var lo = al + bl;
21183  return lo >>> 0;
21184};
21185exports.sum64_lo = sum64_lo;
21186
21187function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
21188  var carry = 0;
21189  var lo = al;
21190  lo = (lo + bl) >>> 0;
21191  carry += lo < al ? 1 : 0;
21192  lo = (lo + cl) >>> 0;
21193  carry += lo < cl ? 1 : 0;
21194  lo = (lo + dl) >>> 0;
21195  carry += lo < dl ? 1 : 0;
21196
21197  var hi = ah + bh + ch + dh + carry;
21198  return hi >>> 0;
21199};
21200exports.sum64_4_hi = sum64_4_hi;
21201
21202function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
21203  var lo = al + bl + cl + dl;
21204  return lo >>> 0;
21205};
21206exports.sum64_4_lo = sum64_4_lo;
21207
21208function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
21209  var carry = 0;
21210  var lo = al;
21211  lo = (lo + bl) >>> 0;
21212  carry += lo < al ? 1 : 0;
21213  lo = (lo + cl) >>> 0;
21214  carry += lo < cl ? 1 : 0;
21215  lo = (lo + dl) >>> 0;
21216  carry += lo < dl ? 1 : 0;
21217  lo = (lo + el) >>> 0;
21218  carry += lo < el ? 1 : 0;
21219
21220  var hi = ah + bh + ch + dh + eh + carry;
21221  return hi >>> 0;
21222};
21223exports.sum64_5_hi = sum64_5_hi;
21224
21225function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
21226  var lo = al + bl + cl + dl + el;
21227
21228  return lo >>> 0;
21229};
21230exports.sum64_5_lo = sum64_5_lo;
21231
21232function rotr64_hi(ah, al, num) {
21233  var r = (al << (32 - num)) | (ah >>> num);
21234  return r >>> 0;
21235};
21236exports.rotr64_hi = rotr64_hi;
21237
21238function rotr64_lo(ah, al, num) {
21239  var r = (ah << (32 - num)) | (al >>> num);
21240  return r >>> 0;
21241};
21242exports.rotr64_lo = rotr64_lo;
21243
21244function shr64_hi(ah, al, num) {
21245  return ah >>> num;
21246};
21247exports.shr64_hi = shr64_hi;
21248
21249function shr64_lo(ah, al, num) {
21250  var r = (ah << (32 - num)) | (al >>> num);
21251  return r >>> 0;
21252};
21253exports.shr64_lo = shr64_lo;
21254
21255
21256/***/ },
21257/* 32 */
21258/***/ function(module, exports) {
21259
21260exports.read = function (buffer, offset, isLE, mLen, nBytes) {
21261  var e, m
21262  var eLen = nBytes * 8 - mLen - 1
21263  var eMax = (1 << eLen) - 1
21264  var eBias = eMax >> 1
21265  var nBits = -7
21266  var i = isLE ? (nBytes - 1) : 0
21267  var d = isLE ? -1 : 1
21268  var s = buffer[offset + i]
21269
21270  i += d
21271
21272  e = s & ((1 << (-nBits)) - 1)
21273  s >>= (-nBits)
21274  nBits += eLen
21275  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
21276
21277  m = e & ((1 << (-nBits)) - 1)
21278  e >>= (-nBits)
21279  nBits += mLen
21280  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
21281
21282  if (e === 0) {
21283    e = 1 - eBias
21284  } else if (e === eMax) {
21285    return m ? NaN : ((s ? -1 : 1) * Infinity)
21286  } else {
21287    m = m + Math.pow(2, mLen)
21288    e = e - eBias
21289  }
21290  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
21291}
21292
21293exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
21294  var e, m, c
21295  var eLen = nBytes * 8 - mLen - 1
21296  var eMax = (1 << eLen) - 1
21297  var eBias = eMax >> 1
21298  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
21299  var i = isLE ? 0 : (nBytes - 1)
21300  var d = isLE ? 1 : -1
21301  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
21302
21303  value = Math.abs(value)
21304
21305  if (isNaN(value) || value === Infinity) {
21306    m = isNaN(value) ? 1 : 0
21307    e = eMax
21308  } else {
21309    e = Math.floor(Math.log(value) / Math.LN2)
21310    if (value * (c = Math.pow(2, -e)) < 1) {
21311      e--
21312      c *= 2
21313    }
21314    if (e + eBias >= 1) {
21315      value += rt / c
21316    } else {
21317      value += rt * Math.pow(2, 1 - eBias)
21318    }
21319    if (value * c >= 2) {
21320      e++
21321      c /= 2
21322    }
21323
21324    if (e + eBias >= eMax) {
21325      m = 0
21326      e = eMax
21327    } else if (e + eBias >= 1) {
21328      m = (value * c - 1) * Math.pow(2, mLen)
21329      e = e + eBias
21330    } else {
21331      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
21332      e = 0
21333    }
21334  }
21335
21336  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
21337
21338  e = (e << mLen) | m
21339  eLen += mLen
21340  for (; eLen > 0;
21340 buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
21341
21342  buffer[offset + i - d] |= s * 128
21343}
21344
21345
21346/***/ },
21347/* 33 */
21348/***/ function(module, exports) {
21349
21350var toString = {}.toString;
21351
21352module.exports = Array.isArray || function (arr) {
21353  return toString.call(arr) == '[object Array]';
21354};
21355
21356
21357/***/ },
21358/* 34 */
21359/***/ function(module, exports) {
21360
21361module.exports = {
21362	"_args": [
21363		[
21364			{
21365				"raw": "[email protected]",
21366				"scope": null,
21367				"escapedName": "elliptic",
21368				"name": "elliptic",
21369				"rawSpec": "6.3.2",
21370				"spec": "6.3.2",
21371				"type": "version"
21372			},
21373			"/home/nick/github/ethjs-account"
21374		]
21375	],
21376	"_from": "[email protected]",
21377	"_id": "[email protected]",
21378	"_inCache": true,
21379	"_installable": true,
21380	"_location": "/elliptic",
21381	"_nodeVersion": "6.3.0",
21382	"_npmOperationalInternal": {
21383		"host": "packages-16-east.internal.npmjs.com",
21384		"tmp": "tmp/elliptic-6.3.2.tgz_1473938837205_0.3108903462998569"
21385	},
21386	"_npmUser": {
21387		"name": "indutny",
21388		"email": "[email protected]"
21389	},
21390	"_npmVersion": "3.10.3",
21391	"_phantomChildren": {},
21392	"_requested": {
21393		"raw": "[email protected]",
21394		"scope": null,
21395		"escapedName": "elliptic",
21396		"name": "elliptic",
21397		"rawSpec": "6.3.2",
21398		"spec": "6.3.2",
21399		"type": "version"
21400	},
21401	"_requiredBy": [
21402		"/",
21403		"/browserify-sign",
21404		"/create-ecdh"
21405	],
21406	"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz",
21407	"_shasum": "e4c81e0829cf0a65ab70e998b8232723b5c1bc48",
21408	"_shrinkwrap": null,
21409	"_spec": "[email protected]",
21410	"_where": "/home/nick/github/ethjs-account",
21411	"author": {
21412		"name": "Fedor Indutny",
21413		"email": "[email protected]"
21414	},
21415	"bugs": {
21416		"url": "https://github.com/indutny/elliptic/issues"
21417	},
21418	"dependencies": {
21419		"bn.js": "^4.4.0",
21420		"brorand": "^1.0.1",
21421		"hash.js": "^1.0.0",
21422		"inherits": "^2.0.1"
21423	},
21424	"description": "EC cryptography",
21425	"devDependencies": {
21426		"brfs": "^1.4.3",
21427		"coveralls": "^2.11.3",
21428		"grunt": "^0.4.5",
21429		"grunt-browserify": "^5.0.0",
21430		"grunt-contrib-connect": "^1.0.0",
21431		"grunt-contrib-copy": "^1.0.0",
21432		"grunt-contrib-uglify": "^1.0.1",
21433		"grunt-mocha-istanbul": "^3.0.1",
21434		"grunt-saucelabs": "^8.6.2",
21435		"istanbul": "^0.4.2",
21436		"jscs": "^2.9.0",
21437		"jshint": "^2.6.0",
21438		"mocha": "^2.1.0"
21439	},
21440	"directories": {},
21441	"dist": {
21442		"shasum": "e4c81e0829cf0a65ab70e998b8232723b5c1bc48",
21443		"tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz"
21444	},
21445	"files": [
21446		"lib"
21447	],
21448	"gitHead": "cbace4683a4a548dc0306ef36756151a20299cd5",
21449	"homepage": "https://github.com/indutny/elliptic",
21450	"keywords": [
21451		"EC",
21452		"Elliptic",
21453		"curve",
21454		"Cryptography"
21455	],
21456	"license": "MIT",
21457	"main": "lib/elliptic.js",
21458	"maintainers": [
21459		{
21460			"name": "indutny",
21461			"email": "[email protected]"
21462		}
21463	],
21464	"name": "elliptic",
21465	"optionalDependencies": {},
21466	"readme": "ERROR: No README data found!",
21467	"repository": {
21468		"type": "git",
21469		"url": "git+ssh://[email protected]/indutny/elliptic.git"
21470	},
21471	"scripts": {
21472		"jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
21473		"jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
21474		"lint": "npm run jscs && npm run jshint",
21475		"test": "npm run lint && npm run unit",
21476		"unit": "istanbul test _mocha --reporter=spec test/index.js",
21477		"version": "grunt dist && git add dist/"
21478	},
21479	"version": "6.3.2"
21480};
21481
21482/***/ },
21483/* 35 */
21484/***/ function(module, exports, __webpack_require__) {
21485
21486"use strict";
21487/* WEBPACK VAR INJECTION */(function(global, Buffer, process) {'use strict'
21488
21489function oldBrowser () {
21490  throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
21491}
21492
21493var crypto = global.crypto || global.msCrypto
21494
21495if (crypto && crypto.getRandomValues) {
21496  module.exports = randomBytes
21497} else {
21498  module.exports = oldBrowser
21499}
21500
21501function randomBytes (size, cb) {
21502  // phantomjs needs to throw
21503  if (size > 65536) throw new Error('requested too many random bytes')
21504  // in case browserify  isn't using the Uint8Array version
21505  var rawBytes = new global.Uint8Array(size)
21506
21507  // This will not work in older browsers.
21508  // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
21509  if (size > 0) {  // getRandomValues fails on IE if size == 0
21510    crypto.getRandomValues(rawBytes)
21511  }
21512  // phantomjs doesn't like a buffer being passed here
21513  var bytes = new Buffer(rawBytes.buffer)
21514
21515  if (typeof cb === 'function') {
21516    return process.nextTick(function () {
21517      cb(null, bytes)
21518    })
21519  }
21520
21521  return bytes
21522}
21523
21524/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6), __webpack_require__(3).Buffer, __webpack_require__(8)))
21525
21526/***/ },
21527/* 36 */
21528/***/ function(module, exports) {
21529
21530module.exports = function(module) {
21531	if(!module.webpackPolyfill) {
21532		module.deprecate = function() {};
21533		module.paths = [];
21534		// module.parent = undefined by default
21535		if(!module.children) module.children = [];
21536		Object.defineProperty(module, "loaded", {
21537			enumerable: true,
21538			configurable: false,
21539			get: function() { return module.l; }
21540		});
21541		Object.defineProperty(module, "id", {
21542			enumerable: true,
21543			configurable: false,
21544			get: function() { return module.i; }
21545		});
21546		module.webpackPolyfill = 1;
21547	}
21548	return module;
21549}
21550
21551
21552/***/ },
21553/* 37 */
21554/***/ function(module, exports) {
21555
21556/* (ignored) */
21557
21558/***/ },
21559/* 38 */
21560/***/ function(module, exports, __webpack_require__) {
21561
21562module.exports = __webpack_require__(9);
21563
21564
21565/***/ }
21566/******/ ])
21567});
21568;
21569//# sourceMappingURL=ethjs-account.js.map</script>
21569
21570
21571    
vendor: 10,160 bytes, lines 21571-21970
21571<script> /* eslint-disable */ 
21572 /* eslint-disable */ 
21573(function webpackUniversalModuleDefinition(root, factory) {
21574	if(typeof exports === 'object' && typeof module === 'object')
21575		module.exports = factory();
21576	else if(typeof define === 'function' && define.amd)
21577		define("ethSigner", [], factory);
21578	else if(typeof exports === 'object')
21579		exports["ethSigner"] = factory();
21580	else
21581		root["ethSigner"] = factory();
21582})(this, function() {
21583return /******/ (function(modules) { // webpackBootstrap
21584/******/ 	// The module cache
21585/******/ 	var installedModules = {};
21586
21587/******/ 	// The require function
21588/******/ 	function __webpack_require__(moduleId) {
21589
21590/******/ 		// Check if module is in cache
21591/******/ 		if(installedModules[moduleId])
21592/******/ 			return installedModules[moduleId].exports;
21593
21594/******/ 		// Create a new module (and put it into the cache)
21595/******/ 		var module = installedModules[moduleId] = {
21596/******/ 			i: moduleId,
21597/******/ 			l: false,
21598/******/ 			exports: {}
21599/******/ 		};
21600
21601/******/ 		// Execute the module function
21602/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21603
21604/******/ 		// Flag the module as loaded
21605/******/ 		module.l = true;
21606
21607/******/ 		// Return the exports of the module
21608/******/ 		return module.exports;
21609/******/ 	}
21610
21611
21612/******/ 	// expose the modules object (__webpack_modules__)
21613/******/ 	__webpack_require__.m = modules;
21614
21615/******/ 	// expose the module cache
21616/******/ 	__webpack_require__.c = installedModules;
21617
21618/******/ 	// identity function for calling harmory imports with the correct context
21619/******/ 	__webpack_require__.i = function(value) { return value; };
21620
21621/******/ 	// define getter function for harmory exports
21622/******/ 	__webpack_require__.d = function(exports, name, getter) {
21623/******/ 		Object.defineProperty(exports, name, {
21624/******/ 			configurable: false,
21625/******/ 			enumerable: true,
21626/******/ 			get: getter
21627/******/ 		});
21628/******/ 	};
21629
21630/******/ 	// Object.prototype.hasOwnProperty.call
21631/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
21632
21633/******/ 	// __webpack_public_path__
21634/******/ 	__webpack_require__.p = "";
21635
21636/******/ 	// Load entry module and return exports
21637/******/ 	return __webpack_require__(__webpack_require__.s = 44);
21638/******/ })
21639/************************************************************************/
21640/******/ ([
21641/* 0 */
21642/***/ function(module, exports, __webpack_require__) {
21643
21644"use strict";
21645'use strict';
21646
21647var elliptic = exports;
21648
21649elliptic.version = __webpack_require__(36).version;
21650elliptic.utils = __webpack_require__(27);
21651elliptic.rand = __webpack_require__(13);
21652elliptic.hmacDRBG = __webpack_require__(25);
21653elliptic.curve = __webpack_require__(4);
21654elliptic.curves = __webpack_require__(18);
21655
21656// Protocols
21657elliptic.ec = __webpack_require__(19);
21658elliptic.eddsa = __webpack_require__(22);
21659
21660
21661/***/ },
21662/* 1 */
21663/***/ function(module, exports, __webpack_require__) {
21664
21665/* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
21666  'use strict';
21667
21668  // Utils
21669  function assert (val, msg) {
21670    if (!val) throw new Error(msg || 'Assertion failed');
21671  }
21672
21673  // Could use `inherits` module, but don't want to move from single file
21674  // architecture yet.
21675  function inherits (ctor, superCtor) {
21676    ctor.super_ = superCtor;
21677    var TempCtor = function () {};
21678    TempCtor.prototype = superCtor.prototype;
21679    ctor.prototype = new TempCtor();
21680    ctor.prototype.constructor = ctor;
21681  }
21682
21683  // BN
21684
21685  function BN (number, base, endian) {
21686    if (BN.isBN(number)) {
21687      return number;
21688    }
21689
21690    this.negative = 0;
21691    this.words = null;
21692    this.length = 0;
21693
21694    // Reduction context
21695    this.red = null;
21696
21697    if (number !== null) {
21698      if (base === 'le' || base === 'be') {
21699        endian = base;
21700        base = 10;
21701      }
21702
21703      this._init(number || 0, base || 10, endian || 'be');
21704    }
21705  }
21706  if (typeof module === 'object') {
21707    module.exports = BN;
21708  } else {
21709    exports.BN = BN;
21710  }
21711
21712  BN.BN = BN;
21713  BN.wordSize = 26;
21714
21715  var Buffer;
21716  try {
21717    Buffer = __webpack_require__(3).Buffer;
21718  } catch (e) {
21719  }
21720
21721  BN.isBN = function isBN (num) {
21722    if (num instanceof BN) {
21723      return true;
21724    }
21725
21726    return num !== null && typeof num === 'object' &&
21727      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
21728  };
21729
21730  BN.max = function max (left, right) {
21731    if (left.cmp(right) > 0) return left;
21732    return right;
21733  };
21734
21735  BN.min = function min (left, right) {
21736    if (left.cmp(right) < 0) return left;
21737    return right;
21738  };
21739
21740  BN.prototype._init = function init (number, base, endian) {
21741    if (typeof number === 'number') {
21742      return this._initNumber(number, base, endian);
21743    }
21744
21745    if (typeof number === 'object') {
21746      return this._initArray(number, base, endian);
21747    }
21748
21749    if (base === 'hex') {
21750      base = 16;
21751    }
21752    assert(base === (base | 0) && base >= 2 && base <= 36);
21753
21754    number = number.toString().replace(/\s+/g, '');
21755    var start = 0;
21756    if (number[0] === '-') {
21757      start++;
21758    }
21759
21760    if (base === 16) {
21761      this._parseHex(number, start);
21762    } else {
21763      this._parseBase(number, base, start);
21764    }
21765
21766    if (number[0] === '-') {
21767      this.negative = 1;
21768    }
21769
21770    this.strip();
21771
21772    if (endian !== 'le') return;
21773
21774    this._initArray(this.toArray(), base, endian);
21775  };
21776
21777  BN.prototype._initNumber = function _initNumber (number, base, endian) {
21778    if (number < 0) {
21779      this.negative = 1;
21780      number = -number;
21781    }
21782    if (number < 0x4000000) {
21783      this.words = [ number & 0x3ffffff ];
21784      this.length = 1;
21785    } else if (number < 0x10000000000000) {
21786      this.words = [
21787        number & 0x3ffffff,
21788        (number / 0x4000000) & 0x3ffffff
21789      ];
21790      this.length = 2;
21791    } else {
21792      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
21793      this.words = [
21794        number & 0x3ffffff,
21795        (number / 0x4000000) & 0x3ffffff,
21796        1
21797      ];
21798      this.length = 3;
21799    }
21800
21801    if (endian !== 'le') return;
21802
21803    // Reverse the bytes
21804    this._initArray(this.toArray(), base, endian);
21805  };
21806
21807  BN.prototype._initArray = function _initArray (number, base, endian) {
21808    // Perhaps a Uint8Array
21809    assert(typeof number.length === 'number');
21810    if (number.length <= 0) {
21811      this.words = [ 0 ];
21812      this.length = 1;
21813      return this;
21814    }
21815
21816    this.length = Math.ceil(number.length / 3);
21817    this.words = new Array(this.length);
21818    for (var i = 0; i < this.length; i++) {
21819      this.words[i] = 0;
21820    }
21821
21822    var j, w;
21823    var off = 0;
21824    if (endian === 'be') {
21825      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
21826        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
21827        this.words[j] |= (w << off) & 0x3ffffff;
21828        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
21829        off += 24;
21830        if (off >= 26) {
21831          off -= 26;
21832          j++;
21833        }
21834      }
21835    } else if (endian === 'le') {
21836      for (i = 0, j = 0; i < number.length; i += 3) {
21837        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
21838        this.words[j] |= (w << off) & 0x3ffffff;
21839        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
21840        off += 24;
21841        if (off >= 26) {
21842          off -= 26;
21843          j++;
21844        }
21845      }
21846    }
21847    return this.strip();
21848  };
21849
21850  function parseHex (str, start, end) {
21851    var r = 0;
21852    var len = Math.min(str.length, end);
21853    for (var i = start; i < len; i++) {
21854      var c = str.charCodeAt(i) - 48;
21855
21856      r <<= 4;
21857
21858      // 'a' - 'f'
21859      if (c >= 49 && c <= 54) {
21860        r |= c - 49 + 0xa;
21861
21862      // 'A' - 'F'
21863      } else if (c >= 17 && c <= 22) {
21864        r |= c - 17 + 0xa;
21865
21866      // '0' - '9'
21867      } else {
21868        r |= c & 0xf;
21869      }
21870    }
21871    return r;
21872  }
21873
21874  BN.prototype._parseHex = function _parseHex (number, start) {
21875    // Create possibly bigger array to ensure that it fits the number
21876    this.length = Math.ceil((number.length - start) / 6);
21877    this.words = new Array(this.length);
21878    for (var i = 0; i < this.length; i++) {
21879      this.words[i] = 0;
21880    }
21881
21882    var j, w;
21883    // Scan 24-bit chunks and add them to the number
21884    var off = 0;
21885    for (i = number.length - 6, j = 0; i >= start; i -= 6) {
21886      w = parseHex(number, i, i + 6);
21887      this.words[j] |= (w << off) & 0x3ffffff;
21888      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
21889      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
21890      off += 24;
21891      if (off >= 26) {
21892        off -= 26;
21893        j++;
21894      }
21895    }
21896    if (i + 6 !== start) {
21897      w = parseHex(number, start, i + 6);
21898      this.words[j] |= (w << off) & 0x3ffffff;
21899      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
21900    }
21901    this.strip();
21902  };
21903
21904  function parseBase (str, start, end, mul) {
21905    var r = 0;
21906    var len = Math.min(str.length, end);
21907    for (var i = start; i < len; i++) {
21908      var c = str.charCodeAt(i) - 48;
21909
21910      r *= mul;
21911
21912      // 'a'
21913      if (c >= 49) {
21914        r += c - 49 + 0xa;
21915
21916      // 'A'
21917      } else if (c >= 17) {
21918        r += c - 17 + 0xa;
21919
21920      // '0' - '9'
21921      } else {
21922        r += c;
21923      }
21924    }
21925    return r;
21926  }
21927
21928  BN.prototype._parseBase = function _parseBase (number, base, start) {
21929    // Initialize as zero
21930    this.words = [ 0 ];
21931    this.length = 1;
21932
21933    // Find length of limb in base
21934    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
21935      limbLen++;
21936    }
21937    limbLen--;
21938    limbPow = (limbPow / base) | 0;
21939
21940    var total = number.length - start;
21941    var mod = total % limbLen;
21942    var end = Math.min(total, total - mod) + start;
21943
21944    var word = 0;
21945    for (var i = start; i < end; i += limbLen) {
21946      word = parseBase(number, i, i + limbLen, base);
21947
21948      this.imuln(limbPow);
21949      if (this.words[0] + word < 0x4000000) {
21950        this.words[0] += word;
21951      } else {
21952        this._iaddn(word);
21953      }
21954    }
21955
21956    if (mod !== 0) {
21957      var pow = 1;
21958      word = parseBase(number, i, number.length, base);
21959
21960      for (i = 0; i < mod; i++) {
21961        pow *= base;
21962      }
21963
21964      this.imuln(pow);
21965      if (this.words[0] + word < 0x4000000) {
21966        this.words[0] += word;
21967      } else {
21968        this._iaddn(word);
21969      }
21970    }
vendor: 68,018 bytes, lines 21970-24574
21970
21971  };
21972
21973  BN.prototype.copy = function copy (dest) {
21974    dest.words = new Array(this.length);
21975    for (var i = 0; i < this.length; i++) {
21976      dest.words[i] = this.words[i];
21977    }
21978    dest.length = this.length;
21979    dest.negative = this.negative;
21980    dest.red = this.red;
21981  };
21982
21983  BN.prototype.clone = function clone () {
21984    var r = new BN(null);
21985    this.copy(r);
21986    return r;
21987  };
21988
21989  BN.prototype._expand = function _expand (size) {
21990    while (this.length < size) {
21991      this.words[this.length++] = 0;
21992    }
21993    return this;
21994  };
21995
21996  // Remove leading `0` from `this`
21997  BN.prototype.strip = function strip () {
21998    while (this.length > 1 && this.words[this.length - 1] === 0) {
21999      this.length--;
22000    }
22001    return this._normSign();
22002  };
22003
22004  BN.prototype._normSign = function _normSign () {
22005    // -0 = 0
22006    if (this.length === 1 && this.words[0] === 0) {
22007      this.negative = 0;
22008    }
22009    return this;
22010  };
22011
22012  BN.prototype.inspect = function inspect () {
22013    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
22014  };
22015
22016  /*
22017
22018  var zeros = [];
22019  var groupSizes = [];
22020  var groupBases = [];
22021
22022  var s = '';
22023  var i = -1;
22024  while (++i < BN.wordSize) {
22025    zeros[i] = s;
22026    s += '0';
22027  }
22028  groupSizes[0] = 0;
22029  groupSizes[1] = 0;
22030  groupBases[0] = 0;
22031  groupBases[1] = 0;
22032  var base = 2 - 1;
22033  while (++base < 36 + 1) {
22034    var groupSize = 0;
22035    var groupBase = 1;
22036    while (groupBase < (1 << BN.wordSize) / base) {
22037      groupBase *= base;
22038      groupSize += 1;
22039    }
22040    groupSizes[base] = groupSize;
22041    groupBases[base] = groupBase;
22042  }
22043
22044  */
22045
22046  var zeros = [
22047    '',
22048    '0',
22049    '00',
22050    '000',
22051    '0000',
22052    '00000',
22053    '000000',
22054    '0000000',
22055    '00000000',
22056    '000000000',
22057    '0000000000',
22058    '00000000000',
22059    '000000000000',
22060    '0000000000000',
22061    '00000000000000',
22062    '000000000000000',
22063    '0000000000000000',
22064    '00000000000000000',
22065    '000000000000000000',
22066    '0000000000000000000',
22067    '00000000000000000000',
22068    '000000000000000000000',
22069    '0000000000000000000000',
22070    '00000000000000000000000',
22071    '000000000000000000000000',
22072    '0000000000000000000000000'
22073  ];
22074
22075  var groupSizes = [
22076    0, 0,
22077    25, 16, 12, 11, 10, 9, 8,
22078    8, 7, 7, 7, 7, 6, 6,
22079    6, 6, 6, 6, 6, 5, 5,
22080    5, 5, 5, 5, 5, 5, 5,
22081    5, 5, 5, 5, 5, 5, 5
22082  ];
22083
22084  var groupBases = [
22085    0, 0,
22086    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
22087    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
22088    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
22089    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
22090    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
22091  ];
22092
22093  BN.prototype.toString = function toString (base, padding) {
22094    base = base || 10;
22095    padding = padding | 0 || 1;
22096
22097    var out;
22098    if (base === 16 || base === 'hex') {
22099      out = '';
22100      var off = 0;
22101      var carry = 0;
22102      for (var i = 0; i < this.length; i++) {
22103        var w = this.words[i];
22104        var word = (((w << off) | carry) & 0xffffff).toString(16);
22105        carry = (w >>> (24 - off)) & 0xffffff;
22106        if (carry !== 0 || i !== this.length - 1) {
22107          out = zeros[6 - word.length] + word + out;
22108        } else {
22109          out = word + out;
22110        }
22111        off += 2;
22112        if (off >= 26) {
22113          off -= 26;
22114          i--;
22115        }
22116      }
22117      if (carry !== 0) {
22118        out = carry.toString(16) + out;
22119      }
22120      while (out.length % padding !== 0) {
22121        out = '0' + out;
22122      }
22123      if (this.negative !== 0) {
22124        out = '-' + out;
22125      }
22126      return out;
22127    }
22128
22129    if (base === (base | 0) && base >= 2 && base <= 36) {
22130      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
22131      var groupSize = groupSizes[base];
22132      // var groupBase = Math.pow(base, groupSize);
22133      var groupBase = groupBases[base];
22134      out = '';
22135      var c = this.clone();
22136      c.negative = 0;
22137      while (!c.isZero()) {
22138        var r = c.modn(groupBase).toString(base);
22139        c = c.idivn(groupBase);
22140
22141        if (!c.isZero()) {
22142          out = zeros[groupSize - r.length] + r + out;
22143        } else {
22144          out = r + out;
22145        }
22146      }
22147      if (this.isZero()) {
22148        out = '0' + out;
22149      }
22150      while (out.length % padding !== 0) {
22151        out = '0' + out;
22152      }
22153      if (this.negative !== 0) {
22154        out = '-' + out;
22155      }
22156      return out;
22157    }
22158
22159    assert(false, 'Base should be between 2 and 36');
22160  };
22161
22162  BN.prototype.toNumber = function toNumber () {
22163    var ret = this.words[0];
22164    if (this.length === 2) {
22165      ret += this.words[1] * 0x4000000;
22166    } else if (this.length === 3 && this.words[2] === 0x01) {
22167      // NOTE: at this stage it is known that the top bit is set
22168      ret += 0x10000000000000 + (this.words[1] * 0x4000000);
22169    } else if (this.length > 2) {
22170      assert(false, 'Number can only safely store up to 53 bits');
22171    }
22172    return (this.negative !== 0) ? -ret : ret;
22173  };
22174
22175  BN.prototype.toJSON = function toJSON () {
22176    return this.toString(16);
22177  };
22178
22179  BN.prototype.toBuffer = function toBuffer (endian, length) {
22180    assert(typeof Buffer !== 'undefined');
22181    return this.toArrayLike(Buffer, endian, length);
22182  };
22183
22184  BN.prototype.toArray = function toArray (endian, length) {
22185    return this.toArrayLike(Array, endian, length);
22186  };
22187
22188  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
22189    var byteLength = this.byteLength();
22190    var reqLength = length || Math.max(1, byteLength);
22191    assert(byteLength <= reqLength, 'byte array longer than desired length');
22192    assert(reqLength > 0, 'Requested array length <= 0');
22193
22194    this.strip();
22195    var littleEndian = endian === 'le';
22196    var res = new ArrayType(reqLength);
22197
22198    var b, i;
22199    var q = this.clone();
22200    if (!littleEndian) {
22201      // Assume big-endian
22202      for (i = 0; i < reqLength - byteLength; i++) {
22203        res[i] = 0;
22204      }
22205
22206      for (i = 0; !q.isZero(); i++) {
22207        b = q.andln(0xff);
22208        q.iushrn(8);
22209
22210        res[reqLength - i - 1] = b;
22211      }
22212    } else {
22213      for (i = 0; !q.isZero(); i++) {
22214        b = q.andln(0xff);
22215        q.iushrn(8);
22216
22217        res[i] = b;
22218      }
22219
22220      for (; i < reqLength; i++) {
22221        res[i] = 0;
22222      }
22223    }
22224
22225    return res;
22226  };
22227
22228  if (Math.clz32) {
22229    BN.prototype._countBits = function _countBits (w) {
22230      return 32 - Math.clz32(w);
22231    };
22232  } else {
22233    BN.prototype._countBits = function _countBits (w) {
22234      var t = w;
22235      var r = 0;
22236      if (t >= 0x1000) {
22237        r += 13;
22238        t >>>= 13;
22239      }
22240      if (t >= 0x40) {
22241        r += 7;
22242        t >>>= 7;
22243      }
22244      if (t >= 0x8) {
22245        r += 4;
22246        t >>>= 4;
22247      }
22248      if (t >= 0x02) {
22249        r += 2;
22250        t >>>= 2;
22251      }
22252      return r + t;
22253    };
22254  }
22255
22256  BN.prototype._zeroBits = function _zeroBits (w) {
22257    // Short-cut
22258    if (w === 0) return 26;
22259
22260    var t = w;
22261    var r = 0;
22262    if ((t & 0x1fff) === 0) {
22263      r += 13;
22264      t >>>= 13;
22265    }
22266    if ((t & 0x7f) === 0) {
22267      r += 7;
22268      t >>>= 7;
22269    }
22270    if ((t & 0xf) === 0) {
22271      r += 4;
22272      t >>>= 4;
22273    }
22274    if ((t & 0x3) === 0) {
22275      r += 2;
22276      t >>>= 2;
22277    }
22278    if ((t & 0x1) === 0) {
22279      r++;
22280    }
22281    return r;
22282  };
22283
22284  // Return number of used bits in a BN
22285  BN.prototype.bitLength = function bitLength () {
22286    var w = this.words[this.length - 1];
22287    var hi = this._countBits(w);
22288    return (this.length - 1) * 26 + hi;
22289  };
22290
22291  function toBitArray (num) {
22292    var w = new Array(num.bitLength());
22293
22294    for (var bit = 0; bit < w.length; bit++) {
22295      var off = (bit / 26) | 0;
22296      var wbit = bit % 26;
22297
22298      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
22299    }
22300
22301    return w;
22302  }
22303
22304  // Number of trailing zero bits
22305  BN.prototype.zeroBits = function zeroBits () {
22306    if (this.isZero()) return 0;
22307
22308    var r = 0;
22309    for (var i = 0; i < this.length; i++) {
22310      var b = this._zeroBits(this.words[i]);
22311      r += b;
22312      if (b !== 26) break;
22313    }
22314    return r;
22315  };
22316
22317  BN.prototype.byteLength = function byteLength () {
22318    return Math.ceil(this.bitLength() / 8);
22319  };
22320
22321  BN.prototype.toTwos = function toTwos (width) {
22322    if (this.negative !== 0) {
22323      return this.abs().inotn(width).iaddn(1);
22324    }
22325    return this.clone();
22326  };
22327
22328  BN.prototype.fromTwos = function fromTwos (width) {
22329    if (this.testn(width - 1)) {
22330      return this.notn(width).iaddn(1).ineg();
22331    }
22332    return this.clone();
22333  };
22334
22335  BN.prototype.isNeg = function isNeg () {
22336    return this.negative !== 0;
22337  };
22338
22339  // Return negative clone of `this`
22340  BN.prototype.neg = function neg () {
22341    return this.clone().ineg();
22342  };
22343
22344  BN.prototype.ineg = function ineg () {
22345    if (!this.isZero()) {
22346      this.negative ^= 1;
22347    }
22348
22349    return this;
22350  };
22351
22352  // Or `num` with `this` in-place
22353  BN.prototype.iuor = function iuor (num) {
22354    while (this.length < num.length) {
22355      this.words[this.length++] = 0;
22356    }
22357
22358    for (var i = 0; i < num.length; i++) {
22359      this.words[i] = this.words[i] | num.words[i];
22360    }
22361
22362    return this.strip();
22363  };
22364
22365  BN.prototype.ior = function ior (num) {
22366    assert((this.negative | num.negative) === 0);
22367    return this.iuor(num);
22368  };
22369
22370  // Or `num` with `this`
22371  BN.prototype.or = function or (num) {
22372    if (this.length > num.length) return this.clone().ior(num);
22373    return num.clone().ior(this);
22374  };
22375
22376  BN.prototype.uor = function uor (num) {
22377    if (this.length > num.length) return this.clone().iuor(num);
22378    return num.clone().iuor(this);
22379  };
22380
22381  // And `num` with `this` in-place
22382  BN.prototype.iuand = function iuand (num) {
22383    // b = min-length(num, this)
22384    var b;
22385    if (this.length > num.length) {
22386      b = num;
22387    } else {
22388      b = this;
22389    }
22390
22391    for (var i = 0; i < b.length; i++) {
22392      this.words[i] = this.words[i] & num.words[i];
22393    }
22394
22395    this.length = b.length;
22396
22397    return this.strip();
22398  };
22399
22400  BN.prototype.iand = function iand (num) {
22401    assert((this.negative | num.negative) === 0);
22402    return this.iuand(num);
22403  };
22404
22405  // And `num` with `this`
22406  BN.prototype.and = function and (num) {
22407    if (this.length > num.length) return this.clone().iand(num);
22408    return num.clone().iand(this);
22409  };
22410
22411  BN.prototype.uand = function uand (num) {
22412    if (this.length > num.length) return this.clone().iuand(num);
22413    return num.clone().iuand(this);
22414  };
22415
22416  // Xor `num` with `this` in-place
22417  BN.prototype.iuxor = function iuxor (num) {
22418    // a.length > b.length
22419    var a;
22420    var b;
22421    if (this.length > num.length) {
22422      a = this;
22423      b = num;
22424    } else {
22425      a = num;
22426      b = this;
22427    }
22428
22429    for (var i = 0; i < b.length; i++) {
22430      this.words[i] = a.words[i] ^ b.words[i];
22431    }
22432
22433    if (this !== a) {
22434      for (; i < a.length; i++) {
22435        this.words[i] = a.words[i];
22436      }
22437    }
22438
22439    this.length = a.length;
22440
22441    return this.strip();
22442  };
22443
22444  BN.prototype.ixor = function ixor (num) {
22445    assert((this.negative | num.negative) === 0);
22446    return this.iuxor(num);
22447  };
22448
22449  // Xor `num` with `this`
22450  BN.prototype.xor = function xor (num) {
22451    if (this.length > num.length) return this.clone().ixor(num);
22452    return num.clone().ixor(this);
22453  };
22454
22455  BN.prototype.uxor = function uxor (num) {
22456    if (this.length > num.length) return this.clone().iuxor(num);
22457    return num.clone().iuxor(this);
22458  };
22459
22460  // Not ``this`` with ``width`` bitwidth
22461  BN.prototype.inotn = function inotn (width) {
22462    assert(typeof width === 'number' && width >= 0);
22463
22464    var bytesNeeded = Math.ceil(width / 26) | 0;
22465    var bitsLeft = width % 26;
22466
22467    // Extend the buffer with leading zeroes
22468    this._expand(bytesNeeded);
22469
22470    if (bitsLeft > 0) {
22471      bytesNeeded--;
22472    }
22473
22474    // Handle complete words
22475    for (var i = 0; i < bytesNeeded; i++) {
22476      this.words[i] = ~this.words[i] & 0x3ffffff;
22477    }
22478
22479    // Handle the residue
22480    if (bitsLeft > 0) {
22481      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
22482    }
22483
22484    // And remove leading zeroes
22485    return this.strip();
22486  };
22487
22488  BN.prototype.notn = function notn (width) {
22489    return this.clone().inotn(width);
22490  };
22491
22492  // Set `bit` of `this`
22493  BN.prototype.setn = function setn (bit, val) {
22494    assert(typeof bit === 'number' && bit >= 0);
22495
22496    var off = (bit / 26) | 0;
22497    var wbit = bit % 26;
22498
22499    this._expand(off + 1);
22500
22501    if (val) {
22502      this.words[off] = this.words[off] | (1 << wbit);
22503    } else {
22504      this.words[off] = this.words[off] & ~(1 << wbit);
22505    }
22506
22507    return this.strip();
22508  };
22509
22510  // Add `num` to `this` in-place
22511  BN.prototype.iadd = function iadd (num) {
22512    var r;
22513
22514    // negative + positive
22515    if (this.negative !== 0 && num.negative === 0) {
22516      this.negative = 0;
22517      r = this.isub(num);
22518      this.negative ^= 1;
22519      return this._normSign();
22520
22521    // positive + negative
22522    } else if (this.negative === 0 && num.negative !== 0) {
22523      num.negative = 0;
22524      r = this.isub(num);
22525      num.negative = 1;
22526      return r._normSign();
22527    }
22528
22529    // a.length > b.length
22530    var a, b;
22531    if (this.length > num.length) {
22532      a = this;
22533      b = num;
22534    } else {
22535      a = num;
22536      b = this;
22537    }
22538
22539    var carry = 0;
22540    for (var i = 0; i < b.length; i++) {
22541      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
22542      this.words[i] = r & 0x3ffffff;
22543      carry = r >>> 26;
22544    }
22545    for (; carry !== 0 && i < a.length; i++) {
22546      r = (a.words[i] | 0) + carry;
22547      this.words[i] = r & 0x3ffffff;
22548      carry = r >>> 26;
22549    }
22550
22551    this.length = a.length;
22552    if (carry !== 0) {
22553      this.words[this.length] = carry;
22554      this.length++;
22555    // Copy the rest of the words
22556    } else if (a !== this) {
22557      for (; i < a.length; i++) {
22558        this.words[i] = a.words[i];
22559      }
22560    }
22561
22562    return this;
22563  };
22564
22565  // Add `num` to `this`
22566  BN.prototype.add = function add (num) {
22567    var res;
22568    if (num.negative !== 0 && this.negative === 0) {
22569      num.negative = 0;
22570      res = this.sub(num);
22571      num.negative ^= 1;
22572      return res;
22573    } else if (num.negative === 0 && this.negative !== 0) {
22574      this.negative = 0;
22575      res = num.sub(this);
22576      this.negative = 1;
22577      return res;
22578    }
22579
22580    if (this.length > num.length) return this.clone().iadd(num);
22581
22582    return num.clone().iadd(this);
22583  };
22584
22585  // Subtract `num` from `this` in-place
22586  BN.prototype.isub = function isub (num) {
22587    // this - (-num) = this + num
22588    if (num.negative !== 0) {
22589      num.negative = 0;
22590      var r = this.iadd(num);
22591      num.negative = 1;
22592      return r._normSign();
22593
22594    // -this - num = -(this + num)
22595    } else if (this.negative !== 0) {
22596      this.negative = 0;
22597      this.iadd(num);
22598      this.negative = 1;
22599      return this._normSign();
22600    }
22601
22602    // At this point both numbers are positive
22603    var cmp = this.cmp(num);
22604
22605    // Optimization - zeroify
22606    if (cmp === 0) {
22607      this.negative = 0;
22608      this.length = 1;
22609      this.words[0] = 0;
22610      return this;
22611    }
22612
22613    // a > b
22614    var a, b;
22615    if (cmp > 0) {
22616      a = this;
22617      b = num;
22618    } else {
22619      a = num;
22620      b = this;
22621    }
22622
22623    var carry = 0;
22624    for (var i = 0; i < b.length; i++) {
22625      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
22626      carry = r >> 26;
22627      this.words[i] = r & 0x3ffffff;
22628    }
22629    for (; carry !== 0 && i < a.length; i++) {
22630      r = (a.words[i] | 0) + carry;
22631      carry = r >> 26;
22632      this.words[i] = r & 0x3ffffff;
22633    }
22634
22635    // Copy rest of the words
22636    if (carry === 0 && i < a.length && a !== this) {
22637      for (; i < a.length; i++) {
22638        this.words[i] = a.words[i];
22639      }
22640    }
22641
22642    this.length = Math.max(this.length, i);
22643
22644    if (a !== this) {
22645      this.negative = 1;
22646    }
22647
22648    return this.strip();
22649  };
22650
22651  // Subtract `num` from `this`
22652  BN.prototype.sub = function sub (num) {
22653    return this.clone().isub(num);
22654  };
22655
22656  function smallMulTo (self, num, out) {
22657    out.negative = num.negative ^ self.negative;
22658    var len = (self.length + num.length) | 0;
22659    out.length = len;
22660    len = (len - 1) | 0;
22661
22662    // Peel one iteration (compiler can't do it, because of code complexity)
22663    var a = self.words[0] | 0;
22664    var b = num.words[0] | 0;
22665    var r = a * b;
22666
22667    var lo = r & 0x3ffffff;
22668    var carry = (r / 0x4000000) | 0;
22669    out.words[0] = lo;
22670
22671    for (var k = 1; k < len; k++) {
22672      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
22673      // note that ncarry could be >= 0x3ffffff
22674      var ncarry = carry >>> 26;
22675      var rword = carry & 0x3ffffff;
22676      var maxJ = Math.min(k, num.length - 1);
22677      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
22678        var i = (k - j) | 0;
22679        a = self.words[i] | 0;
22680        b = num.words[j] | 0;
22681        r = a * b + rword;
22682        ncarry += (r / 0x4000000) | 0;
22683        rword = r & 0x3ffffff;
22684      }
22685      out.words[k] = rword | 0;
22686      carry = ncarry | 0;
22687    }
22688    if (carry !== 0) {
22689      out.words[k] = carry | 0;
22690    } else {
22691      out.length--;
22692    }
22693
22694    return out.strip();
22695  }
22696
22697  // TODO(indutny): it may be reasonable to omit it for users who don't need
22698  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
22699  // multiplication (like elliptic secp256k1).
22700  var comb10MulTo = function comb10MulTo (self, num, out) {
22701    var a = self.words;
22702    var b = num.words;
22703    var o = out.words;
22704    var c = 0;
22705    var lo;
22706    var mid;
22707    var hi;
22708    var a0 = a[0] | 0;
22709    var al0 = a0 & 0x1fff;
22710    var ah0 = a0 >>> 13;
22711    var a1 = a[1] | 0;
22712    var al1 = a1 & 0x1fff;
22713    var ah1 = a1 >>> 13;
22714    var a2 = a[2] | 0;
22715    var al2 = a2 & 0x1fff;
22716    var ah2 = a2 >>> 13;
22717    var a3 = a[3] | 0;
22718    var al3 = a3 & 0x1fff;
22719    var ah3 = a3 >>> 13;
22720    var a4 = a[4] | 0;
22721    var al4 = a4 & 0x1fff;
22722    var ah4 = a4 >>> 13;
22723    var a5 = a[5] | 0;
22724    var al5 = a5 & 0x1fff;
22725    var ah5 = a5 >>> 13;
22726    var a6 = a[6] | 0;
22727    var al6 = a6 & 0x1fff;
22728    var ah6 = a6 >>> 13;
22729    var a7 = a[7] | 0;
22730    var al7 = a7 & 0x1fff;
22731    var ah7 = a7 >>> 13;
22732    var a8 = a[8] | 0;
22733    var al8 = a8 & 0x1fff;
22734    var ah8 = a8 >>> 13;
22735    var a9 = a[9] | 0;
22736    var al9 = a9 & 0x1fff;
22737    var ah9 = a9 >>> 13;
22738    var b0 = b[0] | 0;
22739    var bl0 = b0 & 0x1fff;
22740    var bh0 = b0 >>> 13;
22741    var b1 = b[1] | 0;
22742    var bl1 = b1 & 0x1fff;
22743    var bh1 = b1 >>> 13;
22744    var b2 = b[2] | 0;
22745    var bl2 = b2 & 0x1fff;
22746    var bh2 = b2 >>> 13;
22747    var b3 = b[3] | 0;
22748    var bl3 = b3 & 0x1fff;
22749    var bh3 = b3 >>> 13;
22750    var b4 = b[4] | 0;
22751    var bl4 = b4 & 0x1fff;
22752    var bh4 = b4 >>> 13;
22753    var b5 = b[5] | 0;
22754    var bl5 = b5 & 0x1fff;
22755    var bh5 = b5 >>> 13;
22756    var b6 = b[6] | 0;
22757    var bl6 = b6 & 0x1fff;
22758    var bh6 = b6 >>> 13;
22759    var b7 = b[7] | 0;
22760    var bl7 = b7 & 0x1fff;
22761    var bh7 = b7 >>> 13;
22762    var b8 = b[8] | 0;
22763    var bl8 = b8 & 0x1fff;
22764    var bh8 = b8 >>> 13;
22765    var b9 = b[9] | 0;
22766    var bl9 = b9 & 0x1fff;
22767    var bh9 = b9 >>> 13;
22768
22769    out.negative = self.negative ^ num.negative;
22770    out.length = 19;
22771    /* k = 0 */
22772    lo = Math.imul(al0, bl0);
22773    mid = Math.imul(al0, bh0);
22774    mid = (mid + Math.imul(ah0, bl0)) | 0;
22775    hi = Math.imul(ah0, bh0);
22776    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22777    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
22778    w0 &= 0x3ffffff;
22779    /* k = 1 */
22780    lo = Math.imul(al1, bl0);
22781    mid = Math.imul(al1, bh0);
22782    mid = (mid + Math.imul(ah1, bl0)) | 0;
22783    hi = Math.imul(ah1, bh0);
22784    lo = (lo + Math.imul(al0, bl1)) | 0;
22785    mid = (mid + Math.imul(al0, bh1)) | 0;
22786    mid = (mid + Math.imul(ah0, bl1)) | 0;
22787    hi = (hi + Math.imul(ah0, bh1)) | 0;
22788    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22789    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
22790    w1 &= 0x3ffffff;
22791    /* k = 2 */
22792    lo = Math.imul(al2, bl0);
22793    mid = Math.imul(al2, bh0);
22794    mid = (mid + Math.imul(ah2, bl0)) | 0;
22795    hi = Math.imul(ah2, bh0);
22796    lo = (lo + Math.imul(al1, bl1)) | 0;
22797    mid = (mid + Math.imul(al1, bh1)) | 0;
22798    mid = (mid + Math.imul(ah1, bl1)) | 0;
22799    hi = (hi + Math.imul(ah1, bh1)) | 0;
22800    lo = (lo + Math.imul(al0, bl2)) | 0;
22801    mid = (mid + Math.imul(al0, bh2)) | 0;
22802    mid = (mid + Math.imul(ah0, bl2)) | 0;
22803    hi = (hi + Math.imul(ah0, bh2)) | 0;
22804    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22805    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
22806    w2 &= 0x3ffffff;
22807    /* k = 3 */
22808    lo = Math.imul(al3, bl0);
22809    mid = Math.imul(al3, bh0);
22810    mid = (mid + Math.imul(ah3, bl0)) | 0;
22811    hi = Math.imul(ah3, bh0);
22812    lo = (lo + Math.imul(al2, bl1)) | 0;
22813    mid = (mid + Math.imul(al2, bh1)) | 0;
22814    mid = (mid + Math.imul(ah2, bl1)) | 0;
22815    hi = (hi + Math.imul(ah2, bh1)) | 0;
22816    lo = (lo + Math.imul(al1, bl2)) | 0;
22817    mid = (mid + Math.imul(al1, bh2)) | 0;
22818    mid = (mid + Math.imul(ah1, bl2)) | 0;
22819    hi = (hi + Math.imul(ah1, bh2)) | 0;
22820    lo = (lo + Math.imul(al0, bl3)) | 0;
22821    mid = (mid + Math.imul(al0, bh3)) | 0;
22822    mid = (mid + Math.imul(ah0, bl3)) | 0;
22823    hi = (hi + Math.imul(ah0, bh3)) | 0;
22824    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22825    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
22826    w3 &= 0x3ffffff;
22827    /* k = 4 */
22828    lo = Math.imul(al4, bl0);
22829    mid = Math.imul(al4, bh0);
22830    mid = (mid + Math.imul(ah4, bl0)) | 0;
22831    hi = Math.imul(ah4, bh0);
22832    lo = (lo + Math.imul(al3, bl1)) | 0;
22833    mid = (mid + Math.imul(al3, bh1)) | 0;
22834    mid = (mid + Math.imul(ah3, bl1)) | 0;
22835    hi = (hi + Math.imul(ah3, bh1)) | 0;
22836    lo = (lo + Math.imul(al2, bl2)) | 0;
22837    mid = (mid + Math.imul(al2, bh2)) | 0;
22838    mid = (mid + Math.imul(ah2, bl2)) | 0;
22839    hi = (hi + Math.imul(ah2, bh2)) | 0;
22840    lo = (lo + Math.imul(al1, bl3)) | 0;
22841    mid = (mid + Math.imul(al1, bh3)) | 0;
22842    mid = (mid + Math.imul(ah1, bl3)) | 0;
22843    hi = (hi + Math.imul(ah1, bh3)) | 0;
22844    lo = (lo + Math.imul(al0, bl4)) | 0;
22845    mid = (mid + Math.imul(al0, bh4)) | 0;
22846    mid = (mid + Math.imul(ah0, bl4)) | 0;
22847    hi = (hi + Math.imul(ah0, bh4)) | 0;
22848    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22849    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
22850    w4 &= 0x3ffffff;
22851    /* k = 5 */
22852    lo = Math.imul(al5, bl0);
22853    mid = Math.imul(al5, bh0);
22854    mid = (mid + Math.imul(ah5, bl0)) | 0;
22855    hi = Math.imul(ah5, bh0);
22856    lo = (lo + Math.imul(al4, bl1)) | 0;
22857    mid = (mid + Math.imul(al4, bh1)) | 0;
22858    mid = (mid + Math.imul(ah4, bl1)) | 0;
22859    hi = (hi + Math.imul(ah4, bh1)) | 0;
22860    lo = (lo + Math.imul(al3, bl2)) | 0;
22861    mid = (mid + Math.imul(al3, bh2)) | 0;
22862    mid = (mid + Math.imul(ah3, bl2)) | 0;
22863    hi = (hi + Math.imul(ah3, bh2)) | 0;
22864    lo = (lo + Math.imul(al2, bl3)) | 0;
22865    mid = (mid + Math.imul(al2, bh3)) | 0;
22866    mid = (mid + Math.imul(ah2, bl3)) | 0;
22867    hi = (hi + Math.imul(ah2, bh3)) | 0;
22868    lo = (lo + Math.imul(al1, bl4)) | 0;
22869    mid = (mid + Math.imul(al1, bh4)) | 0;
22870    mid = (mid + Math.imul(ah1, bl4)) | 0;
22871    hi = (hi + Math.imul(ah1, bh4)) | 0;
22872    lo = (lo + Math.imul(al0, bl5)) | 0;
22873    mid = (mid + Math.imul(al0, bh5)) | 0;
22874    mid = (mid + Math.imul(ah0, bl5)) | 0;
22875    hi = (hi + Math.imul(ah0, bh5)) | 0;
22876    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22877    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
22878    w5 &= 0x3ffffff;
22879    /* k = 6 */
22880    lo = Math.imul(al6, bl0);
22881    mid = Math.imul(al6, bh0);
22882    mid = (mid + Math.imul(ah6, bl0)) | 0;
22883    hi = Math.imul(ah6, bh0);
22884    lo = (lo + Math.imul(al5, bl1)) | 0;
22885    mid = (mid + Math.imul(al5, bh1)) | 0;
22886    mid = (mid + Math.imul(ah5, bl1)) | 0;
22887    hi = (hi + Math.imul(ah5, bh1)) | 0;
22888    lo = (lo + Math.imul(al4, bl2)) | 0;
22889    mid = (mid + Math.imul(al4, bh2)) | 0;
22890    mid = (mid + Math.imul(ah4, bl2)) | 0;
22891    hi = (hi + Math.imul(ah4, bh2)) | 0;
22892    lo = (lo + Math.imul(al3, bl3)) | 0;
22893    mid = (mid + Math.imul(al3, bh3)) | 0;
22894    mid = (mid + Math.imul(ah3, bl3)) | 0;
22895    hi = (hi + Math.imul(ah3, bh3)) | 0;
22896    lo = (lo + Math.imul(al2, bl4)) | 0;
22897    mid = (mid + Math.imul(al2, bh4)) | 0;
22898    mid = (mid + Math.imul(ah2, bl4)) | 0;
22899    hi = (hi + Math.imul(ah2, bh4)) | 0;
22900    lo = (lo + Math.imul(al1, bl5)) | 0;
22901    mid = (mid + Math.imul(al1, bh5)) | 0;
22902    mid = (mid + Math.imul(ah1, bl5)) | 0;
22903    hi = (hi + Math.imul(ah1, bh5)) | 0;
22904    lo = (lo + Math.imul(al0, bl6)) | 0;
22905    mid = (mid + Math.imul(al0, bh6)) | 0;
22906    mid = (mid + Math.imul(ah0, bl6)) | 0;
22907    hi = (hi + Math.imul(ah0, bh6)) | 0;
22908    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22909    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
22910    w6 &= 0x3ffffff;
22911    /* k = 7 */
22912    lo = Math.imul(al7, bl0);
22913    mid = Math.imul(al7, bh0);
22914    mid = (mid + Math.imul(ah7, bl0)) | 0;
22915    hi = Math.imul(ah7, bh0);
22916    lo = (lo + Math.imul(al6, bl1)) | 0;
22917    mid = (mid + Math.imul(al6, bh1)) | 0;
22918    mid = (mid + Math.imul(ah6, bl1)) | 0;
22919    hi = (hi + Math.imul(ah6, bh1)) | 0;
22920    lo = (lo + Math.imul(al5, bl2)) | 0;
22921    mid = (mid + Math.imul(al5, bh2)) | 0;
22922    mid = (mid + Math.imul(ah5, bl2)) | 0;
22923    hi = (hi + Math.imul(ah5, bh2)) | 0;
22924    lo = (lo + Math.imul(al4, bl3)) | 0;
22925    mid = (mid + Math.imul(al4, bh3)) | 0;
22926    mid = (mid + Math.imul(ah4, bl3)) | 0;
22927    hi = (hi + Math.imul(ah4, bh3)) | 0;
22928    lo = (lo + Math.imul(al3, bl4)) | 0;
22929    mid = (mid + Math.imul(al3, bh4)) | 0;
22930    mid = (mid + Math.imul(ah3, bl4)) | 0;
22931    hi = (hi + Math.imul(ah3, bh4)) | 0;
22932    lo = (lo + Math.imul(al2, bl5)) | 0;
22933    mid = (mid + Math.imul(al2, bh5)) | 0;
22934    mid = (mid + Math.imul(ah2, bl5)) | 0;
22935    hi = (hi + Math.imul(ah2, bh5)) | 0;
22936    lo = (lo + Math.imul(al1, bl6)) | 0;
22937    mid = (mid + Math.imul(al1, bh6)) | 0;
22938    mid = (mid + Math.imul(ah1, bl6)) | 0;
22939    hi = (hi + Math.imul(ah1, bh6)) | 0;
22940    lo = (lo + Math.imul(al0, bl7)) | 0;
22941    mid = (mid + Math.imul(al0, bh7)) | 0;
22942    mid = (mid + Math.imul(ah0, bl7)) | 0;
22943    hi = (hi + Math.imul(ah0, bh7)) | 0;
22944    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22945    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
22946    w7 &= 0x3ffffff;
22947    /* k = 8 */
22948    lo = Math.imul(al8, bl0);
22949    mid = Math.imul(al8, bh0);
22950    mid = (mid + Math.imul(ah8, bl0)) | 0;
22951    hi = Math.imul(ah8, bh0);
22952    lo = (lo + Math.imul(al7, bl1)) | 0;
22953    mid = (mid + Math.imul(al7, bh1)) | 0;
22954    mid = (mid + Math.imul(ah7, bl1)) | 0;
22955    hi = (hi + Math.imul(ah7, bh1)) | 0;
22956    lo = (lo + Math.imul(al6, bl2)) | 0;
22957    mid = (mid + Math.imul(al6, bh2)) | 0;
22958    mid = (mid + Math.imul(ah6, bl2)) | 0;
22959    hi = (hi + Math.imul(ah6, bh2)) | 0;
22960    lo = (lo + Math.imul(al5, bl3)) | 0;
22961    mid = (mid + Math.imul(al5, bh3)) | 0;
22962    mid = (mid + Math.imul(ah5, bl3)) | 0;
22963    hi = (hi + Math.imul(ah5, bh3)) | 0;
22964    lo = (lo + Math.imul(al4, bl4)) | 0;
22965    mid = (mid + Math.imul(al4, bh4)) | 0;
22966    mid = (mid + Math.imul(ah4, bl4)) | 0;
22967    hi = (hi + Math.imul(ah4, bh4)) | 0;
22968    lo = (lo + Math.imul(al3, bl5)) | 0;
22969    mid = (mid + Math.imul(al3, bh5)) | 0;
22970    mid = (mid + Math.imul(ah3, bl5)) | 0;
22971    hi = (hi + Math.imul(ah3, bh5)) | 0;
22972    lo = (lo + Math.imul(al2, bl6)) | 0;
22973    mid = (mid + Math.imul(al2, bh6)) | 0;
22974    mid = (mid + Math.imul(ah2, bl6)) | 0;
22975    hi = (hi + Math.imul(ah2, bh6)) | 0;
22976    lo = (lo + Math.imul(al1, bl7)) | 0;
22977    mid = (mid + Math.imul(al1, bh7)) | 0;
22978    mid = (mid + Math.imul(ah1, bl7)) | 0;
22979    hi = (hi + Math.imul(ah1, bh7)) | 0;
22980    lo = (lo + Math.imul(al0, bl8)) | 0;
22981    mid = (mid + Math.imul(al0, bh8)) | 0;
22982    mid = (mid + Math.imul(ah0, bl8)) | 0;
22983    hi = (hi + Math.imul(ah0, bh8)) | 0;
22984    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
22985    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
22986    w8 &= 0x3ffffff;
22987    /* k = 9 */
22988    lo = Math.imul(al9, bl0);
22989    mid = Math.imul(al9, bh0);
22990    mid = (mid + Math.imul(ah9, bl0)) | 0;
22991    hi = Math.imul(ah9, bh0);
22992    lo = (lo + Math.imul(al8, bl1)) | 0;
22993    mid = (mid + Math.imul(al8, bh1)) | 0;
22994    mid = (mid + Math.imul(ah8, bl1)) | 0;
22995    hi = (hi + Math.imul(ah8, bh1)) | 0;
22996    lo = (lo + Math.imul(al7, bl2)) | 0;
22997    mid = (mid + Math.imul(al7, bh2)) | 0;
22998    mid = (mid + Math.imul(ah7, bl2)) | 0;
22999    hi = (hi + Math.imul(ah7, bh2)) | 0;
23000    lo = (lo + Math.imul(al6, bl3)) | 0;
23001    mid = (mid + Math.imul(al6, bh3)) | 0;
23002    mid = (mid + Math.imul(ah6, bl3)) | 0;
23003    hi = (hi + Math.imul(ah6, bh3)) | 0;
23004    lo = (lo + Math.imul(al5, bl4)) | 0;
23005    mid = (mid + Math.imul(al5, bh4)) | 0;
23006    mid = (mid + Math.imul(ah5, bl4)) | 0;
23007    hi = (hi + Math.imul(ah5, bh4)) | 0;
23008    lo = (lo + Math.imul(al4, bl5)) | 0;
23009    mid = (mid + Math.imul(al4, bh5)) | 0;
23010    mid = (mid + Math.imul(ah4, bl5)) | 0;
23011    hi = (hi + Math.imul(ah4, bh5)) | 0;
23012    lo = (lo + Math.imul(al3, bl6)) | 0;
23013    mid = (mid + Math.imul(al3, bh6)) | 0;
23014    mid = (mid + Math.imul(ah3, bl6)) | 0;
23015    hi = (hi + Math.imul(ah3, bh6)) | 0;
23016    lo = (lo + Math.imul(al2, bl7)) | 0;
23017    mid = (mid + Math.imul(al2, bh7)) | 0;
23018    mid = (mid + Math.imul(ah2, bl7)) | 0;
23019    hi = (hi + Math.imul(ah2, bh7)) | 0;
23020    lo = (lo + Math.imul(al1, bl8)) | 0;
23021    mid = (mid + Math.imul(al1, bh8)) | 0;
23022    mid = (mid + Math.imul(ah1, bl8)) | 0;
23023    hi = (hi + Math.imul(ah1, bh8)) | 0;
23024    lo = (lo + Math.imul(al0, bl9)) | 0;
23025    mid = (mid + Math.imul(al0, bh9)) | 0;
23026    mid = (mid + Math.imul(ah0, bl9)) | 0;
23027    hi = (hi + Math.imul(ah0, bh9)) | 0;
23028    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23029    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
23030    w9 &= 0x3ffffff;
23031    /* k = 10 */
23032    lo = Math.imul(al9, bl1);
23033    mid = Math.imul(al9, bh1);
23034    mid = (mid + Math.imul(ah9, bl1)) | 0;
23035    hi = Math.imul(ah9, bh1);
23036    lo = (lo + Math.imul(al8, bl2)) | 0;
23037    mid = (mid + Math.imul(al8, bh2)) | 0;
23038    mid = (mid + Math.imul(ah8, bl2)) | 0;
23039    hi = (hi + Math.imul(ah8, bh2)) | 0;
23040    lo = (lo + Math.imul(al7, bl3)) | 0;
23041    mid = (mid + Math.imul(al7, bh3)) | 0;
23042    mid = (mid + Math.imul(ah7, bl3)) | 0;
23043    hi = (hi + Math.imul(ah7, bh3)) | 0;
23044    lo = (lo + Math.imul(al6, bl4)) | 0;
23045    mid = (mid + Math.imul(al6, bh4)) | 0;
23046    mid = (mid + Math.imul(ah6, bl4)) | 0;
23047    hi = (hi + Math.imul(ah6, bh4)) | 0;
23048    lo = (lo + Math.imul(al5, bl5)) | 0;
23049    mid = (mid + Math.imul(al5, bh5)) | 0;
23050    mid = (mid + Math.imul(ah5, bl5)) | 0;
23051    hi = (hi + Math.imul(ah5, bh5)) | 0;
23052    lo = (lo + Math.imul(al4, bl6)) | 0;
23053    mid = (mid + Math.imul(al4, bh6)) | 0;
23054    mid = (mid + Math.imul(ah4, bl6)) | 0;
23055    hi = (hi + Math.imul(ah4, bh6)) | 0;
23056    lo = (lo + Math.imul(al3, bl7)) | 0;
23057    mid = (mid + Math.imul(al3, bh7)) | 0;
23058    mid = (mid + Math.imul(ah3, bl7)) | 0;
23059    hi = (hi + Math.imul(ah3, bh7)) | 0;
23060    lo = (lo + Math.imul(al2, bl8)) | 0;
23061    mid = (mid + Math.imul(al2, bh8)) | 0;
23062    mid = (mid + Math.imul(ah2, bl8)) | 0;
23063    hi = (hi + Math.imul(ah2, bh8)) | 0;
23064    lo = (lo + Math.imul(al1, bl9)) | 0;
23065    mid = (mid + Math.imul(al1, bh9)) | 0;
23066    mid = (mid + Math.imul(ah1, bl9)) | 0;
23067    hi = (hi + Math.imul(ah1, bh9)) | 0;
23068    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23069    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
23070    w10 &= 0x3ffffff;
23071    /* k = 11 */
23072    lo = Math.imul(al9, bl2);
23073    mid = Math.imul(al9, bh2);
23074    mid = (mid + Math.imul(ah9, bl2)) | 0;
23075    hi = Math.imul(ah9, bh2);
23076    lo = (lo + Math.imul(al8, bl3)) | 0;
23077    mid = (mid + Math.imul(al8, bh3)) | 0;
23078    mid = (mid + Math.imul(ah8, bl3)) | 0;
23079    hi = (hi + Math.imul(ah8, bh3)) | 0;
23080    lo = (lo + Math.imul(al7, bl4)) | 0;
23081    mid = (mid + Math.imul(al7, bh4)) | 0;
23082    mid = (mid + Math.imul(ah7, bl4)) | 0;
23083    hi = (hi + Math.imul(ah7, bh4)) | 0;
23084    lo = (lo + Math.imul(al6, bl5)) | 0;
23085    mid = (mid + Math.imul(al6, bh5)) | 0;
23086    mid = (mid + Math.imul(ah6, bl5)) | 0;
23087    hi = (hi + Math.imul(ah6, bh5)) | 0;
23088    lo = (lo + Math.imul(al5, bl6)) | 0;
23089    mid = (mid + Math.imul(al5, bh6)) | 0;
23090    mid = (mid + Math.imul(ah5, bl6)) | 0;
23091    hi = (hi + Math.imul(ah5, bh6)) | 0;
23092    lo = (lo + Math.imul(al4, bl7)) | 0;
23093    mid = (mid + Math.imul(al4, bh7)) | 0;
23094    mid = (mid + Math.imul(ah4, bl7)) | 0;
23095    hi = (hi + Math.imul(ah4, bh7)) | 0;
23096    lo = (lo + Math.imul(al3, bl8)) | 0;
23097    mid = (mid + Math.imul(al3, bh8)) | 0;
23098    mid = (mid + Math.imul(ah3, bl8)) | 0;
23099    hi = (hi + Math.imul(ah3, bh8)) | 0;
23100    lo = (lo + Math.imul(al2, bl9)) | 0;
23101    mid = (mid + Math.imul(al2, bh9)) | 0;
23102    mid = (mid + Math.imul(ah2, bl9)) | 0;
23103    hi = (hi + Math.imul(ah2, bh9)) | 0;
23104    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23105    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
23106    w11 &= 0x3ffffff;
23107    /* k = 12 */
23108    lo = Math.imul(al9, bl3);
23109    mid = Math.imul(al9, bh3);
23110    mid = (mid + Math.imul(ah9, bl3)) | 0;
23111    hi = Math.imul(ah9, bh3);
23112    lo = (lo + Math.imul(al8, bl4)) | 0;
23113    mid = (mid + Math.imul(al8, bh4)) | 0;
23114    mid = (mid + Math.imul(ah8, bl4)) | 0;
23115    hi = (hi + Math.imul(ah8, bh4)) | 0;
23116    lo = (lo + Math.imul(al7, bl5)) | 0;
23117    mid = (mid + Math.imul(al7, bh5)) | 0;
23118    mid = (mid + Math.imul(ah7, bl5)) | 0;
23119    hi = (hi + Math.imul(ah7, bh5)) | 0;
23120    lo = (lo + Math.imul(al6, bl6)) | 0;
23121    mid = (mid + Math.imul(al6, bh6)) | 0;
23122    mid = (mid + Math.imul(ah6, bl6)) | 0;
23123    hi = (hi + Math.imul(ah6, bh6)) | 0;
23124    lo = (lo + Math.imul(al5, bl7)) | 0;
23125    mid = (mid + Math.imul(al5, bh7)) | 0;
23126    mid = (mid + Math.imul(ah5, bl7)) | 0;
23127    hi = (hi + Math.imul(ah5, bh7)) | 0;
23128    lo = (lo + Math.imul(al4, bl8)) | 0;
23129    mid = (mid + Math.imul(al4, bh8)) | 0;
23130    mid = (mid + Math.imul(ah4, bl8)) | 0;
23131    hi = (hi + Math.imul(ah4, bh8)) | 0;
23132    lo = (lo + Math.imul(al3, bl9)) | 0;
23133    mid = (mid + Math.imul(al3, bh9)) | 0;
23134    mid = (mid + Math.imul(ah3, bl9)) | 0;
23135    hi = (hi + Math.imul(ah3, bh9)) | 0;
23136    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23137    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
23138    w12 &= 0x3ffffff;
23139    /* k = 13 */
23140    lo = Math.imul(al9, bl4);
23141    mid = Math.imul(al9, bh4);
23142    mid = (mid + Math.imul(ah9, bl4)) | 0;
23143    hi = Math.imul(ah9, bh4);
23144    lo = (lo + Math.imul(al8, bl5)) | 0;
23145    mid = (mid + Math.imul(al8, bh5)) | 0;
23146    mid = (mid + Math.imul(ah8, bl5)) | 0;
23147    hi = (hi + Math.imul(ah8, bh5)) | 0;
23148    lo = (lo + Math.imul(al7, bl6)) | 0;
23149    mid = (mid + Math.imul(al7, bh6)) | 0;
23150    mid = (mid + Math.imul(ah7, bl6)) | 0;
23151    hi = (hi + Math.imul(ah7, bh6)) | 0;
23152    lo = (lo + Math.imul(al6, bl7)) | 0;
23153    mid = (mid + Math.imul(al6, bh7)) | 0;
23154    mid = (mid + Math.imul(ah6, bl7)) | 0;
23155    hi = (hi + Math.imul(ah6, bh7)) | 0;
23156    lo = (lo + Math.imul(al5, bl8)) | 0;
23157    mid = (mid + Math.imul(al5, bh8)) | 0;
23158    mid = (mid + Math.imul(ah5, bl8)) | 0;
23159    hi = (hi + Math.imul(ah5, bh8)) | 0;
23160    lo = (lo + Math.imul(al4, bl9)) | 0;
23161    mid = (mid + Math.imul(al4, bh9)) | 0;
23162    mid = (mid + Math.imul(ah4, bl9)) | 0;
23163    hi = (hi + Math.imul(ah4, bh9)) | 0;
23164    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23165    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
23166    w13 &= 0x3ffffff;
23167    /* k = 14 */
23168    lo = Math.imul(al9, bl5);
23169    mid = Math.imul(al9, bh5);
23170    mid = (mid + Math.imul(ah9, bl5)) | 0;
23171    hi = Math.imul(ah9, bh5);
23172    lo = (lo + Math.imul(al8, bl6)) | 0;
23173    mid = (mid + Math.imul(al8, bh6)) | 0;
23174    mid = (mid + Math.imul(ah8, bl6)) | 0;
23175    hi = (hi + Math.imul(ah8, bh6)) | 0;
23176    lo = (lo + Math.imul(al7, bl7)) | 0;
23177    mid = (mid + Math.imul(al7, bh7)) | 0;
23178    mid = (mid + Math.imul(ah7, bl7)) | 0;
23179    hi = (hi + Math.imul(ah7, bh7)) | 0;
23180    lo = (lo + Math.imul(al6, bl8)) | 0;
23181    mid = (mid + Math.imul(al6, bh8)) | 0;
23182    mid = (mid + Math.imul(ah6, bl8)) | 0;
23183    hi = (hi + Math.imul(ah6, bh8)) | 0;
23184    lo = (lo + Math.imul(al5, bl9)) | 0;
23185    mid = (mid + Math.imul(al5, bh9)) | 0;
23186    mid = (mid + Math.imul(ah5, bl9)) | 0;
23187    hi = (hi + Math.imul(ah5, bh9)) | 0;
23188    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23189    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
23190    w14 &= 0x3ffffff;
23191    /* k = 15 */
23192    lo = Math.imul(al9, bl6);
23193    mid = Math.imul(al9, bh6);
23194    mid = (mid + Math.imul(ah9, bl6)) | 0;
23195    hi = Math.imul(ah9, bh6);
23196    lo = (lo + Math.imul(al8, bl7)) | 0;
23197    mid = (mid + Math.imul(al8, bh7)) | 0;
23198    mid = (mid + Math.imul(ah8, bl7)) | 0;
23199    hi = (hi + Math.imul(ah8, bh7)) | 0;
23200    lo = (lo + Math.imul(al7, bl8)) | 0;
23201    mid = (mid + Math.imul(al7, bh8)) | 0;
23202    mid = (mid + Math.imul(ah7, bl8)) | 0;
23203    hi = (hi + Math.imul(ah7, bh8)) | 0;
23204    lo = (lo + Math.imul(al6, bl9)) | 0;
23205    mid = (mid + Math.imul(al6, bh9)) | 0;
23206    mid = (mid + Math.imul(ah6, bl9)) | 0;
23207    hi = (hi + Math.imul(ah6, bh9)) | 0;
23208    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23209    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
23210    w15 &= 0x3ffffff;
23211    /* k = 16 */
23212    lo = Math.imul(al9, bl7);
23213    mid = Math.imul(al9, bh7);
23214    mid = (mid + Math.imul(ah9, bl7)) | 0;
23215    hi = Math.imul(ah9, bh7);
23216    lo = (lo + Math.imul(al8, bl8)) | 0;
23217    mid = (mid + Math.imul(al8, bh8)) | 0;
23218    mid = (mid + Math.imul(ah8, bl8)) | 0;
23219    hi = (hi + Math.imul(ah8, bh8)) | 0;
23220    lo = (lo + Math.imul(al7, bl9)) | 0;
23221    mid = (mid + Math.imul(al7, bh9)) | 0;
23222    mid = (mid + Math.imul(ah7, bl9)) | 0;
23223    hi = (hi + Math.imul(ah7, bh9)) | 0;
23224    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23225    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
23226    w16 &= 0x3ffffff;
23227    /* k = 17 */
23228    lo = Math.imul(al9, bl8);
23229    mid = Math.imul(al9, bh8);
23230    mid = (mid + Math.imul(ah9, bl8)) | 0;
23231    hi = Math.imul(ah9, bh8);
23232    lo = (lo + Math.imul(al8, bl9)) | 0;
23233    mid = (mid + Math.imul(al8, bh9)) | 0;
23234    mid = (mid + Math.imul(ah8, bl9)) | 0;
23235    hi = (hi + Math.imul(ah8, bh9)) | 0;
23236    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23237    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
23238    w17 &= 0x3ffffff;
23239    /* k = 18 */
23240    lo = Math.imul(al9, bl9);
23241    mid = Math.imul(al9, bh9);
23242    mid = (mid + Math.imul(ah9, bl9)) | 0;
23243    hi = Math.imul(ah9, bh9);
23244    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
23245    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
23246    w18 &= 0x3ffffff;
23247    o[0] = w0;
23248    o[1] = w1;
23249    o[2] = w2;
23250    o[3] = w3;
23251    o[4] = w4;
23252    o[5] = w5;
23253    o[6] = w6;
23254    o[7] = w7;
23255    o[8] = w8;
23256    o[9] = w9;
23257    o[10] = w10;
23258    o[11] = w11;
23259    o[12] = w12;
23260    o[13] = w13;
23261    o[14] = w14;
23262    o[15] = w15;
23263    o[16] = w16;
23264    o[17] = w17;
23265    o[18] = w18;
23266    if (c !== 0) {
23267      o[19] = c;
23268      out.length++;
23269    }
23270    return out;
23271  };
23272
23273  // Polyfill comb
23274  if (!Math.imul) {
23275    comb10MulTo = smallMulTo;
23276  }
23277
23278  function bigMulTo (self, num, out) {
23279    out.negative = num.negative ^ self.negative;
23280    out.length = self.length + num.length;
23281
23282    var carry = 0;
23283    var hncarry = 0;
23284    for (var k = 0; k < out.length - 1; k++) {
23285      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
23286      // note that ncarry could be >= 0x3ffffff
23287      var ncarry = hncarry;
23288      hncarry = 0;
23289      var rword = carry & 0x3ffffff;
23290      var maxJ = Math.min(k, num.length - 1);
23291      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
23292        var i = k - j;
23293        var a = self.words[i] | 0;
23294        var b = num.words[j] | 0;
23295        var r = a * b;
23296
23297        var lo = r & 0x3ffffff;
23298        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
23299        lo = (lo + rword) | 0;
23300        rword = lo & 0x3ffffff;
23301        ncarry = (ncarry + (lo >>> 26)) | 0;
23302
23303        hncarry += ncarry >>> 26;
23304        ncarry &= 0x3ffffff;
23305      }
23306      out.words[k] = rword;
23307      carry = ncarry;
23308      ncarry = hncarry;
23309    }
23310    if (carry !== 0) {
23311      out.words[k] = carry;
23312    } else {
23313      out.length--;
23314    }
23315
23316    return out.strip();
23317  }
23318
23319  function jumboMulTo (self, num, out) {
23320    var fftm = new FFTM();
23321    return fftm.mulp(self, num, out);
23322  }
23323
23324  BN.prototype.mulTo = function mulTo (num, out) {
23325    var res;
23326    var len = this.length + num.length;
23327    if (this.length === 10 && num.length === 10) {
23328      res = comb10MulTo(this, num, out);
23329    } else if (len < 63) {
23330      res = smallMulTo(this, num, out);
23331    } else if (len < 1024) {
23332      res = bigMulTo(this, num, out);
23333    } else {
23334      res = jumboMulTo(this, num, out);
23335    }
23336
23337    return res;
23338  };
23339
23340  // Cooley-Tukey algorithm for FFT
23341  // slightly revisited to rely on looping instead of recursion
23342
23343  function FFTM (x, y) {
23344    this.x = x;
23345    this.y = y;
23346  }
23347
23348  FFTM.prototype.makeRBT = function makeRBT (N) {
23349    var t = new Array(N);
23350    var l = BN.prototype._countBits(N) - 1;
23351    for (var i = 0; i < N; i++) {
23352      t[i] = this.revBin(i, l, N);
23353    }
23354
23355    return t;
23356  };
23357
23358  // Returns binary-reversed representation of `x`
23359  FFTM.prototype.revBin = function revBin (x, l, N) {
23360    if (x === 0 || x === N - 1) return x;
23361
23362    var rb = 0;
23363    for (var i = 0; i < l; i++) {
23364      rb |= (x & 1) << (l - i - 1);
23365      x >>= 1;
23366    }
23367
23368    return rb;
23369  };
23370
23371  // Performs "tweedling" phase, therefore 'emulating'
23372  // behaviour of the recursive algorithm
23373  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
23374    for (var i = 0; i < N; i++) {
23375      rtws[i] = rws[rbt[i]];
23376      itws[i] = iws[rbt[i]];
23377    }
23378  };
23379
23380  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
23381    this.permute(rbt, rws, iws, rtws, itws, N);
23382
23383    for (var s = 1; s < N; s <<= 1) {
23384      var l = s << 1;
23385
23386      var rtwdf = Math.cos(2 * Math.PI / l);
23387      var itwdf = Math.sin(2 * Math.PI / l);
23388
23389      for (var p = 0; p < N; p += l) {
23390        var rtwdf_ = rtwdf;
23391        var itwdf_ = itwdf;
23392
23393        for (var j = 0; j < s; j++) {
23394          var re = rtws[p + j];
23395          var ie = itws[p + j];
23396
23397          var ro = rtws[p + j + s];
23398          var io = itws[p + j + s];
23399
23400          var rx = rtwdf_ * ro - itwdf_ * io;
23401
23402          io = rtwdf_ * io + itwdf_ * ro;
23403          ro = rx;
23404
23405          rtws[p + j] = re + ro;
23406          itws[p + j] = ie + io;
23407
23408          rtws[p + j + s] = re - ro;
23409          itws[p + j + s] = ie - io;
23410
23411          /* jshint maxdepth : false */
23412          if (j !== l) {
23413            rx = rtwdf * rtwdf_ - itwdf * itwdf_;
23414
23415            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
23416            rtwdf_ = rx;
23417          }
23418        }
23419      }
23420    }
23421  };
23422
23423  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
23424    var N = Math.max(m, n) | 1;
23425    var odd = N & 1;
23426    var i = 0;
23427    for (N = N / 2 | 0; N; N = N >>> 1) {
23428      i++;
23429    }
23430
23431    return 1 << i + 1 + odd;
23432  };
23433
23434  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
23435    if (N <= 1) return;
23436
23437    for (var i = 0; i < N / 2; i++) {
23438      var t = rws[i];
23439
23440      rws[i] = rws[N - i - 1];
23441      rws[N - i - 1] = t;
23442
23443      t = iws[i];
23444
23445      iws[i] = -iws[N - i - 1];
23446      iws[N - i - 1] = -t;
23447    }
23448  };
23449
23450  FFTM.prototype.normalize13b = function normalize13b (ws, N) {
23451    var carry = 0;
23452    for (var i = 0; i < N / 2; i++) {
23453      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
23454        Math.round(ws[2 * i] / N) +
23455        carry;
23456
23457      ws[i] = w & 0x3ffffff;
23458
23459      if (w < 0x4000000) {
23460        carry = 0;
23461      } else {
23462        carry = w / 0x4000000 | 0;
23463      }
23464    }
23465
23466    return ws;
23467  };
23468
23469  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
23470    var carry = 0;
23471    for (var i = 0; i < len; i++) {
23472      carry = carry + (ws[i] | 0);
23473
23474      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
23475      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
23476    }
23477
23478    // Pad with zeroes
23479    for (i = 2 * len; i < N; ++i) {
23480      rws[i] = 0;
23481    }
23482
23483    assert(carry === 0);
23484    assert((carry & ~0x1fff) === 0);
23485  };
23486
23487  FFTM.prototype.stub = function stub (N) {
23488    var ph = new Array(N);
23489    for (var i = 0; i < N; i++) {
23490      ph[i] = 0;
23491    }
23492
23493    return ph;
23494  };
23495
23496  FFTM.prototype.mulp = function mulp (x, y, out) {
23497    var N = 2 * this.guessLen13b(x.length, y.length);
23498
23499    var rbt = this.makeRBT(N);
23500
23501    var _ = this.stub(N);
23502
23503    var rws = new Array(N);
23504    var rwst = new Array(N);
23505    var iwst = new Array(N);
23506
23507    var nrws = new Array(N);
23508    var nrwst = new Array(N);
23509    var niwst = new Array(N);
23510
23511    var rmws = out.words;
23512    rmws.length = N;
23513
23514    this.convert13b(x.words, x.length, rws, N);
23515    this.convert13b(y.words, y.length, nrws, N);
23516
23517    this.transform(rws, _, rwst, iwst, N, rbt);
23518    this.transform(nrws, _, nrwst, niwst, N, rbt);
23519
23520    for (var i = 0; i < N; i++) {
23521      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
23522      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
23523      rwst[i] = rx;
23524    }
23525
23526    this.conjugate(rwst, iwst, N);
23527    this.transform(rwst, iwst, rmws, _, N, rbt);
23528    this.conjugate(rmws, _, N);
23529    this.normalize13b(rmws, N);
23530
23531    out.negative = x.negative ^ y.negative;
23532    out.length = x.length + y.length;
23533    return out.strip();
23534  };
23535
23536  // Multiply `this` by `num`
23537  BN.prototype.mul = function mul (num) {
23538    var out = new BN(null);
23539    out.words = new Array(this.length + num.length);
23540    return this.mulTo(num, out);
23541  };
23542
23543  // Multiply employing FFT
23544  BN.prototype.mulf = function mulf (num) {
23545    var out = new BN(null);
23546    out.words = new Array(this.length + num.length);
23547    return jumboMulTo(this, num, out);
23548  };
23549
23550  // In-place Multiplication
23551  BN.prototype.imul = function imul (num) {
23552    return this.clone().mulTo(num, this);
23553  };
23554
23555  BN.prototype.imuln = function imuln (num) {
23556    assert(typeof num === 'number');
23557    assert(num < 0x4000000);
23558
23559    // Carry
23560    var carry = 0;
23561    for (var i = 0; i < this.length; i++) {
23562      var w = (this.words[i] | 0) * num;
23563      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
23564      carry >>= 26;
23565      carry += (w / 0x4000000) | 0;
23566      // NOTE: lo is 27bit maximum
23567      carry += lo >>> 26;
23568      this.words[i] = lo & 0x3ffffff;
23569    }
23570
23571    if (carry !== 0) {
23572      this.words[i] = carry;
23573      this.length++;
23574    }
23575
23576    return this;
23577  };
23578
23579  BN.prototype.muln = function muln (num) {
23580    return this.clone().imuln(num);
23581  };
23582
23583  // `this` * `this`
23584  BN.prototype.sqr = function sqr () {
23585    return this.mul(this);
23586  };
23587
23588  // `this` * `this` in-place
23589  BN.prototype.isqr = function isqr () {
23590    return this.imul(this.clone());
23591  };
23592
23593  // Math.pow(`this`, `num`)
23594  BN.prototype.pow = function pow (num) {
23595    var w = toBitArray(num);
23596    if (w.length === 0) return new BN(1);
23597
23598    // Skip leading zeroes
23599    var res = this;
23600    for (var i = 0; i < w.length; i++, res = res.sqr()) {
23601      if (w[i] !== 0) break;
23602    }
23603
23604    if (++i < w.length) {
23605      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
23606        if (w[i] === 0) continue;
23607
23608        res = res.mul(q);
23609      }
23610    }
23611
23612    return res;
23613  };
23614
23615  // Shift-left in-place
23616  BN.prototype.iushln = function iushln (bits) {
23617    assert(typeof bits === 'number' && bits >= 0);
23618    var r = bits % 26;
23619    var s = (bits - r) / 26;
23620    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
23621    var i;
23622
23623    if (r !== 0) {
23624      var carry = 0;
23625
23626      for (i = 0; i < this.length; i++) {
23627        var newCarry = this.words[i] & carryMask;
23628        var c = ((this.words[i] | 0) - newCarry) << r;
23629        this.words[i] = c | carry;
23630        carry = newCarry >>> (26 - r);
23631      }
23632
23633      if (carry) {
23634        this.words[i] = carry;
23635        this.length++;
23636      }
23637    }
23638
23639    if (s !== 0) {
23640      for (i = this.length - 1; i >= 0; i--) {
23641        this.words[i + s] = this.words[i];
23642      }
23643
23644      for (i = 0; i < s; i++) {
23645        this.words[i] = 0;
23646      }
23647
23648      this.length += s;
23649    }
23650
23651    return this.strip();
23652  };
23653
23654  BN.prototype.ishln = function ishln (bits) {
23655    // TODO(indutny): implement me
23656    assert(this.negative === 0);
23657    return this.iushln(bits);
23658  };
23659
23660  // Shift-right in-place
23661  // NOTE: `hint` is a lowest bit before trailing zeroes
23662  // NOTE: if `extended` is present - it will be filled with destroyed bits
23663  BN.prototype.iushrn = function iushrn (bits, hint, extended) {
23664    assert(typeof bits === 'number' && bits >= 0);
23665    var h;
23666    if (hint) {
23667      h = (hint - (hint % 26)) / 26;
23668    } else {
23669      h = 0;
23670    }
23671
23672    var r = bits % 26;
23673    var s = Math.min((bits - r) / 26, this.length);
23674    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
23675    var maskedWords = extended;
23676
23677    h -= s;
23678    h = Math.max(0, h);
23679
23680    // Extended mode, copy masked part
23681    if (maskedWords) {
23682      for (var i = 0; i < s; i++) {
23683        maskedWords.words[i] = this.words[i];
23684      }
23685      maskedWords.length = s;
23686    }
23687
23688    if (s === 0) {
23689      // No-op, we should not move anything at all
23690    } else if (this.length > s) {
23691      this.length -= s;
23692      for (i = 0; i < this.length; i++) {
23693        this.words[i] = this.words[i + s];
23694      }
23695    } else {
23696      this.words[0] = 0;
23697      this.length = 1;
23698    }
23699
23700    var carry = 0;
23701    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
23702      var word = this.words[i] | 0;
23703      this.words[i] = (carry << (26 - r)) | (word >>> r);
23704      carry = word & mask;
23705    }
23706
23707    // Push carried bits as a mask
23708    if (maskedWords && carry !== 0) {
23709      maskedWords.words[maskedWords.length++] = carry;
23710    }
23711
23712    if (this.length === 0) {
23713      this.words[0] = 0;
23714      this.length = 1;
23715    }
23716
23717    return this.strip();
23718  };
23719
23720  BN.prototype.ishrn = function ishrn (bits, hint, extended) {
23721    // TODO(indutny): implement me
23722    assert(this.negative === 0);
23723    return this.iushrn(bits, hint, extended);
23724  };
23725
23726  // Shift-left
23727  BN.prototype.shln = function shln (bits) {
23728    return this.clone().ishln(bits);
23729  };
23730
23731  BN.prototype.ushln = function ushln (bits) {
23732    return this.clone().iushln(bits);
23733  };
23734
23735  // Shift-right
23736  BN.prototype.shrn = function shrn (bits) {
23737    return this.clone().ishrn(bits);
23738  };
23739
23740  BN.prototype.ushrn = function ushrn (bits) {
23741    return this.clone().iushrn(bits);
23742  };
23743
23744  // Test if n bit is set
23745  BN.prototype.testn = function testn (bit) {
23746    assert(typeof bit === 'number' && bit >= 0);
23747    var r = bit % 26;
23748    var s = (bit - r) / 26;
23749    var q = 1 << r;
23750
23751    // Fast case: bit is much higher than all existing words
23752    if (this.length <= s) return false;
23753
23754    // Check bit and return
23755    var w = this.words[s];
23756
23757    return !!(w & q);
23758  };
23759
23760  // Return only lowers bits of number (in-place)
23761  BN.prototype.imaskn = function imaskn (bits) {
23762    assert(typeof bits === 'number' && bits >= 0);
23763    var r = bits % 26;
23764    var s = (bits - r) / 26;
23765
23766    assert(this.negative === 0, 'imaskn works only with positive numbers');
23767
23768    if (this.length <= s) {
23769      return this;
23770    }
23771
23772    if (r !== 0) {
23773      s++;
23774    }
23775    this.length = Math.min(s, this.length);
23776
23777    if (r !== 0) {
23778      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
23779      this.words[this.length - 1] &= mask;
23780    }
23781
23782    return this.strip();
23783  };
23784
23785  // Return only lowers bits of number
23786  BN.prototype.maskn = function maskn (bits) {
23787    return this.clone().imaskn(bits);
23788  };
23789
23790  // Add plain number `num` to `this`
23791  BN.prototype.iaddn = function iaddn (num) {
23792    assert(typeof num === 'number');
23793    assert(num < 0x4000000);
23794    if (num < 0) return this.isubn(-num);
23795
23796    // Possible sign change
23797    if (this.negative !== 0) {
23798      if (this.length === 1 && (this.words[0] | 0) < num) {
23799        this.words[0] = num - (this.words[0] | 0);
23800        this.negative = 0;
23801        return this;
23802      }
23803
23804      this.negative = 0;
23805      this.isubn(num);
23806      this.negative = 1;
23807      return this;
23808    }
23809
23810    // Add without checks
23811    return this._iaddn(num);
23812  };
23813
23814  BN.prototype._iaddn = function _iaddn (num) {
23815    this.words[0] += num;
23816
23817    // Carry
23818    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
23819      this.words[i] -= 0x4000000;
23820      if (i === this.length - 1) {
23821        this.words[i + 1] = 1;
23822      } else {
23823        this.words[i + 1]++;
23824      }
23825    }
23826    this.length = Math.max(this.length, i + 1);
23827
23828    return this;
23829  };
23830
23831  // Subtract plain number `num` from `this`
23832  BN.prototype.isubn = function isubn (num) {
23833    assert(typeof num === 'number');
23834    assert(num < 0x4000000);
23835    if (num < 0) return this.iaddn(-num);
23836
23837    if (this.negative !== 0) {
23838      this.negative = 0;
23839      this.iaddn(num);
23840      this.negative = 1;
23841      return this;
23842    }
23843
23844    this.words[0] -= num;
23845
23846    if (this.length === 1 && this.words[0] < 0) {
23847      this.words[0] = -this.words[0];
23848      this.negative = 1;
23849    } else {
23850      // Carry
23851      for (var i = 0; i < this.length && this.words[i] < 0; i++) {
23852        this.words[i] += 0x4000000;
23853        this.words[i + 1] -= 1;
23854      }
23855    }
23856
23857    return this.strip();
23858  };
23859
23860  BN.prototype.addn = function addn (num) {
23861    return this.clone().iaddn(num);
23862  };
23863
23864  BN.prototype.subn = function subn (num) {
23865    return this.clone().isubn(num);
23866  };
23867
23868  BN.prototype.iabs = function iabs () {
23869    this.negative = 0;
23870
23871    return this;
23872  };
23873
23874  BN.prototype.abs = function abs () {
23875    return this.clone().iabs();
23876  };
23877
23878  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
23879    var len = num.length + shift;
23880    var i;
23881
23882    this._expand(len);
23883
23884    var w;
23885    var carry = 0;
23886    for (i = 0; i < num.length; i++) {
23887      w = (this.words[i + shift] | 0) + carry;
23888      var right = (num.words[i] | 0) * mul;
23889      w -= right & 0x3ffffff;
23890      carry = (w >> 26) - ((right / 0x4000000) | 0);
23891      this.words[i + shift] = w & 0x3ffffff;
23892    }
23893    for (; i < this.length - shift; i++) {
23894      w = (this.words[i + shift] | 0) + carry;
23895      carry = w >> 26;
23896      this.words[i + shift] = w & 0x3ffffff;
23897    }
23898
23899    if (carry === 0) return this.strip();
23900
23901    // Subtraction overflow
23902    assert(carry === -1);
23903    carry = 0;
23904    for (i = 0; i < this.length; i++) {
23905      w = -(this.words[i] | 0) + carry;
23906      carry = w >> 26;
23907      this.words[i] = w & 0x3ffffff;
23908    }
23909    this.negative = 1;
23910
23911    return this.strip();
23912  };
23913
23914  BN.prototype._wordDiv = function _wordDiv (num, mode) {
23915    var shift = this.length - num.length;
23916
23917    var a = this.clone();
23918    var b = num;
23919
23920    // Normalize
23921    var bhi = b.words[b.length - 1] | 0;
23922    var bhiBits = this._countBits(bhi);
23923    shift = 26 - bhiBits;
23924    if (shift !== 0) {
23925      b = b.ushln(shift);
23926      a.iushln(shift);
23927      bhi = b.words[b.length - 1] | 0;
23928    }
23929
23930    // Initialize quotient
23931    var m = a.length - b.length;
23932    var q;
23933
23934    if (mode !== 'mod') {
23935      q = new BN(null);
23936      q.length = m + 1;
23937      q.words = new Array(q.length);
23938      for (var i = 0; i < q.length; i++) {
23939        q.words[i] = 0;
23940      }
23941    }
23942
23943    var diff = a.clone()._ishlnsubmul(b, 1, m);
23944    if (diff.negative === 0) {
23945      a = diff;
23946      if (q) {
23947        q.words[m] = 1;
23948      }
23949    }
23950
23951    for (var j = m - 1; j >= 0; j--) {
23952      var qj = (a.words[b.length + j] | 0) * 0x4000000 +
23953        (a.words[b.length + j - 1] | 0);
23954
23955      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
23956      // (0x7ffffff)
23957      qj = Math.min((qj / bhi) | 0, 0x3ffffff);
23958
23959      a._ishlnsubmul(b, qj, j);
23960      while (a.negative !== 0) {
23961        qj--;
23962        a.negative = 0;
23963        a._ishlnsubmul(b, 1, j);
23964        if (!a.isZero()) {
23965          a.negative ^= 1;
23966        }
23967      }
23968      if (q) {
23969        q.words[j] = qj;
23970      }
23971    }
23972    if (q) {
23973      q.strip();
23974    }
23975    a.strip();
23976
23977    // Denormalize
23978    if (mode !== 'div' && shift !== 0) {
23979      a.iushrn(shift);
23980    }
23981
23982    return {
23983      div: q || null,
23984      mod: a
23985    };
23986  };
23987
23988  // NOTE: 1) `mode` can be set to `mod` to request mod only,
23989  //       to `div` to request div only, or be absent to
23990  //       request both div & mod
23991  //       2) `positive` is true if unsigned mod is requested
23992  BN.prototype.divmod = function divmod (num, mode, positive) {
23993    assert(!num.isZero());
23994
23995    if (this.isZero()) {
23996      return {
23997        div: new BN(0),
23998        mod: new BN(0)
23999      };
24000    }
24001
24002    var div, mod, res;
24003    if (this.negative !== 0 && num.negative === 0) {
24004      res = this.neg().divmod(num, mode);
24005
24006      if (mode !== 'mod') {
24007        div = res.div.neg();
24008      }
24009
24010      if (mode !== 'div') {
24011        mod = res.mod.neg();
24012        if (positive && mod.negative !== 0) {
24013          mod.iadd(num);
24014        }
24015      }
24016
24017      return {
24018        div: div,
24019        mod: mod
24020      };
24021    }
24022
24023    if (this.negative === 0 && num.negative !== 0) {
24024      res = this.divmod(num.neg(), mode);
24025
24026      if (mode !== 'mod') {
24027        div = res.div.neg();
24028      }
24029
24030      return {
24031        div: div,
24032        mod: res.mod
24033      };
24034    }
24035
24036    if ((this.negative & num.negative) !== 0) {
24037      res = this.neg().divmod(num.neg(), mode);
24038
24039      if (mode !== 'div') {
24040        mod = res.mod.neg();
24041        if (positive && mod.negative !== 0) {
24042          mod.isub(num);
24043        }
24044      }
24045
24046      return {
24047        div: res.div,
24048        mod: mod
24049      };
24050    }
24051
24052    // Both numbers are positive at this point
24053
24054    // Strip both numbers to approximate shift value
24055    if (num.length > this.length || this.cmp(num) < 0) {
24056      return {
24057        div: new BN(0),
24058        mod: this
24059      };
24060    }
24061
24062    // Very short reduction
24063    if (num.length === 1) {
24064      if (mode === 'div') {
24065        return {
24066          div: this.divn(num.words[0]),
24067          mod: null
24068        };
24069      }
24070
24071      if (mode === 'mod') {
24072        return {
24073          div: null,
24074          mod: new BN(this.modn(num.words[0]))
24075        };
24076      }
24077
24078      return {
24079        div: this.divn(num.words[0]),
24080        mod: new BN(this.modn(num.words[0]))
24081      };
24082    }
24083
24084    return this._wordDiv(num, mode);
24085  };
24086
24087  // Find `this` / `num`
24088  BN.prototype.div = function div (num) {
24089    return this.divmod(num, 'div', false).div;
24090  };
24091
24092  // Find `this` % `num`
24093  BN.prototype.mod = function mod (num) {
24094    return this.divmod(num, 'mod', false).mod;
24095  };
24096
24097  BN.prototype.umod = function umod (num) {
24098    return this.divmod(num, 'mod', true).mod;
24099  };
24100
24101  // Find Round(`this` / `num`)
24102  BN.prototype.divRound = function divRound (num) {
24103    var dm = this.divmod(num);
24104
24105    // Fast case - exact division
24106    if (dm.mod.isZero()) return dm.div;
24107
24108    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
24109
24110    var half = num.ushrn(1);
24111    var r2 = num.andln(1);
24112    var cmp = mod.cmp(half);
24113
24114    // Round down
24115    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
24116
24117    // Round up
24118    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
24119  };
24120
24121  BN.prototype.modn = function modn (num) {
24122    assert(num <= 0x3ffffff);
24123    var p = (1 << 26) % num;
24124
24125    var acc = 0;
24126    for (var i = this.length - 1; i >= 0; i--) {
24127      acc = (p * acc + (this.words[i] | 0)) % num;
24128    }
24129
24130    return acc;
24131  };
24132
24133  // In-place division by number
24134  BN.prototype.idivn = function idivn (num) {
24135    assert(num <= 0x3ffffff);
24136
24137    var carry = 0;
24138    for (var i = this.length - 1; i >= 0; i--) {
24139      var w = (this.words[i] | 0) + carry * 0x4000000;
24140      this.words[i] = (w / num) | 0;
24141      carry = w % num;
24142    }
24143
24144    return this.strip();
24145  };
24146
24147  BN.prototype.divn = function divn (num) {
24148    return this.clone().idivn(num);
24149  };
24150
24151  BN.prototype.egcd = function egcd (p) {
24152    assert(p.negative === 0);
24153    assert(!p.isZero());
24154
24155    var x = this;
24156    var y = p.clone();
24157
24158    if (x.negative !== 0) {
24159      x = x.umod(p);
24160    } else {
24161      x = x.clone();
24162    }
24163
24164    // A * x + B * y = x
24165    var A = new BN(1);
24166    var B = new BN(0);
24167
24168    // C * x + D * y = y
24169    var C = new BN(0);
24170    var D = new BN(1);
24171
24172    var g = 0;
24173
24174    while (x.isEven() && y.isEven()) {
24175      x.iushrn(1);
24176      y.iushrn(1);
24177      ++g;
24178    }
24179
24180    var yp = y.clone();
24181    var xp = x.clone();
24182
24183    while (!x.isZero()) {
24184      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
24185      if (i > 0) {
24186        x.iushrn(i);
24187        while (i-- > 0) {
24188          if (A.isOdd() || B.isOdd()) {
24189            A.iadd(yp);
24190            B.isub(xp);
24191          }
24192
24193          A.iushrn(1);
24194          B.iushrn(1);
24195        }
24196      }
24197
24198      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
24199      if (j > 0) {
24200        y.iushrn(j);
24201        while (j-- > 0) {
24202          if (C.isOdd() || D.isOdd()) {
24203            C.iadd(yp);
24204            D.isub(xp);
24205          }
24206
24207          C.iushrn(1);
24208          D.iushrn(1);
24209        }
24210      }
24211
24212      if (x.cmp(y) >= 0) {
24213        x.isub(y);
24214        A.isub(C);
24215        B.isub(D);
24216      } else {
24217        y.isub(x);
24218        C.isub(A);
24219        D.isub(B);
24220      }
24221    }
24222
24223    return {
24224      a: C,
24225      b: D,
24226      gcd: y.iushln(g)
24227    };
24228  };
24229
24230  // This is reduced incarnation of the binary EEA
24231  // above, designated to invert members of the
24232  // _prime_ fields F(p) at a maximal speed
24233  BN.prototype._invmp = function _invmp (p) {
24234    assert(p.negative === 0);
24235    assert(!p.isZero());
24236
24237    var a = this;
24238    var b = p.clone();
24239
24240    if (a.negative !== 0) {
24241      a = a.umod(p);
24242    } else {
24243      a = a.clone();
24244    }
24245
24246    var x1 = new BN(1);
24247    var x2 = new BN(0);
24248
24249    var delta = b.clone();
24250
24251    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
24252      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
24253      if (i > 0) {
24254        a.iushrn(i);
24255        while (i-- > 0) {
24256          if (x1.isOdd()) {
24257            x1.iadd(delta);
24258          }
24259
24260          x1.iushrn(1);
24261        }
24262      }
24263
24264      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
24265      if (j > 0) {
24266        b.iushrn(j);
24267        while (j-- > 0) {
24268          if (x2.isOdd()) {
24269            x2.iadd(delta);
24270          }
24271
24272          x2.iushrn(1);
24273        }
24274      }
24275
24276      if (a.cmp(b) >= 0) {
24277        a.isub(b);
24278        x1.isub(x2);
24279      } else {
24280        b.isub(a);
24281        x2.isub(x1);
24282      }
24283    }
24284
24285    var res;
24286    if (a.cmpn(1) === 0) {
24287      res = x1;
24288    } else {
24289      res = x2;
24290    }
24291
24292    if (res.cmpn(0) < 0) {
24293      res.iadd(p);
24294    }
24295
24296    return res;
24297  };
24298
24299  BN.prototype.gcd = function gcd (num) {
24300    if (this.isZero()) return num.abs();
24301    if (num.isZero()) return this.abs();
24302
24303    var a = this.clone();
24304    var b = num.clone();
24305    a.negative = 0;
24306    b.negative = 0;
24307
24308    // Remove common factor of two
24309    for (var shift = 0; a.isEven() && b.isEven(); shift++) {
24310      a.iushrn(1);
24311      b.iushrn(1);
24312    }
24313
24314    do {
24315      while (a.isEven()) {
24316        a.iushrn(1);
24317      }
24318      while (b.isEven()) {
24319        b.iushrn(1);
24320      }
24321
24322      var r = a.cmp(b);
24323      if (r < 0) {
24324        // Swap `a` and `b` to make `a` always bigger than `b`
24325        var t = a;
24326        a = b;
24327        b = t;
24328      } else if (r === 0 || b.cmpn(1) === 0) {
24329        break;
24330      }
24331
24332      a.isub(b);
24333    } while (true);
24334
24335    return b.iushln(shift);
24336  };
24337
24338  // Invert number in the field F(num)
24339  BN.prototype.invm = function invm (num) {
24340    return this.egcd(num).a.umod(num);
24341  };
24342
24343  BN.prototype.isEven = function isEven () {
24344    return (this.words[0] & 1) === 0;
24345  };
24346
24347  BN.prototype.isOdd = function isOdd () {
24348    return (this.words[0] & 1) === 1;
24349  };
24350
24351  // And first word and num
24352  BN.prototype.andln = function andln (num) {
24353    return this.words[0] & num;
24354  };
24355
24356  // Increment at the bit position in-line
24357  BN.prototype.bincn = function bincn (bit) {
24358    assert(typeof bit === 'number');
24359    var r = bit % 26;
24360    var s = (bit - r) / 26;
24361    var q = 1 << r;
24362
24363    // Fast case: bit is much higher than all existing words
24364    if (this.length <= s) {
24365      this._expand(s + 1);
24366      this.words[s] |= q;
24367      return this;
24368    }
24369
24370    // Add bit and propagate, if needed
24371    var carry = q;
24372    for (var i = s; carry !== 0 && i < this.length; i++) {
24373      var w = this.words[i] | 0;
24374      w += carry;
24375      carry = w >>> 26;
24376      w &= 0x3ffffff;
24377      this.words[i] = w;
24378    }
24379    if (carry !== 0) {
24380      this.words[i] = carry;
24381      this.length++;
24382    }
24383    return this;
24384  };
24385
24386  BN.prototype.isZero = function isZero () {
24387    return this.length === 1 && this.words[0] === 0;
24388  };
24389
24390  BN.prototype.cmpn = function cmpn (num) {
24391    var negative = num < 0;
24392
24393    if (this.negative !== 0 && !negative) return -1;
24394    if (this.negative === 0 && negative) return 1;
24395
24396    this.strip();
24397
24398    var res;
24399    if (this.length > 1) {
24400      res = 1;
24401    } else {
24402      if (negative) {
24403        num = -num;
24404      }
24405
24406      assert(num <= 0x3ffffff, 'Number is too big');
24407
24408      var w = this.words[0] | 0;
24409      res = w === num ? 0 : w < num ? -1 : 1;
24410    }
24411    if (this.negative !== 0) return -res | 0;
24412    return res;
24413  };
24414
24415  // Compare two numbers and return:
24416  // 1 - if `this` > `num`
24417  // 0 - if `this` == `num`
24418  // -1 - if `this` < `num`
24419  BN.prototype.cmp = function cmp (num) {
24420    if (this.negative !== 0 && num.negative === 0) return -1;
24421    if (this.negative === 0 && num.negative !== 0) return 1;
24422
24423    var res = this.ucmp(num);
24424    if (this.negative !== 0) return -res | 0;
24425    return res;
24426  };
24427
24428  // Unsigned comparison
24429  BN.prototype.ucmp = function ucmp (num) {
24430    // At this point both numbers have the same sign
24431    if (this.length > num.length) return 1;
24432    if (this.length < num.length) return -1;
24433
24434    var res = 0;
24435    for (var i = this.length - 1; i >= 0; i--) {
24436      var a = this.words[i] | 0;
24437      var b = num.words[i] | 0;
24438
24439      if (a === b) continue;
24440      if (a < b) {
24441        res = -1;
24442      } else if (a > b) {
24443        res = 1;
24444      }
24445      break;
24446    }
24447    return res;
24448  };
24449
24450  BN.prototype.gtn = function gtn (num) {
24451    return this.cmpn(num) === 1;
24452  };
24453
24454  BN.prototype.gt = function gt (num) {
24455    return this.cmp(num) === 1;
24456  };
24457
24458  BN.prototype.gten = function gten (num) {
24459    return this.cmpn(num) >= 0;
24460  };
24461
24462  BN.prototype.gte = function gte (num) {
24463    return this.cmp(num) >= 0;
24464  };
24465
24466  BN.prototype.ltn = function ltn (num) {
24467    return this.cmpn(num) === -1;
24468  };
24469
24470  BN.prototype.lt = function lt (num) {
24471    return this.cmp(num) === -1;
24472  };
24473
24474  BN.prototype.lten = function lten (num) {
24475    return this.cmpn(num) <= 0;
24476  };
24477
24478  BN.prototype.lte = function lte (num) {
24479    return this.cmp(num) <= 0;
24480  };
24481
24482  BN.prototype.eqn = function eqn (num) {
24483    return this.cmpn(num) === 0;
24484  };
24485
24486  BN.prototype.eq = function eq (num) {
24487    return this.cmp(num) === 0;
24488  };
24489
24490  //
24491  // A reduce context, could be using montgomery or something better, depending
24492  // on the `m` itself.
24493  //
24494  BN.red = function red (num) {
24495    return new Red(num);
24496  };
24497
24498  BN.prototype.toRed = function toRed (ctx) {
24499    assert(!this.red, 'Already a number in reduction context');
24500    assert(this.negative === 0, 'red works only with positives');
24501    return ctx.convertTo(this)._forceRed(ctx);
24502  };
24503
24504  BN.prototype.fromRed = function fromRed () {
24505    assert(this.red, 'fromRed works only with numbers in reduction context');
24506    return this.red.convertFrom(this);
24507  };
24508
24509  BN.prototype._forceRed = function _forceRed (ctx) {
24510    this.red = ctx;
24511    return this;
24512  };
24513
24514  BN.prototype.forceRed = function forceRed (ctx) {
24515    assert(!this.red, 'Already a number in reduction context');
24516    return this._forceRed(ctx);
24517  };
24518
24519  BN.prototype.redAdd = function redAdd (num) {
24520    assert(this.red, 'redAdd works only with red numbers');
24521    return this.red.add(this, num);
24522  };
24523
24524  BN.prototype.redIAdd = function redIAdd (num) {
24525    assert(this.red, 'redIAdd works only with red numbers');
24526    return this.red.iadd(this, num);
24527  };
24528
24529  BN.prototype.redSub = function redSub (num) {
24530    assert(this.red, 'redSub works only with red numbers');
24531    return this.red.sub(this, num);
24532  };
24533
24534  BN.prototype.redISub = function redISub (num) {
24535    assert(this.red, 'redISub works only with red numbers');
24536    return this.red.isub(this, num);
24537  };
24538
24539  BN.prototype.redShl = function redShl (num) {
24540    assert(this.red, 'redShl works only with red numbers');
24541    return this.red.shl(this, num);
24542  };
24543
24544  BN.prototype.redMul = function redMul (num) {
24545    assert(this.red, 'redMul works only with red numbers');
24546    this.red._verify2(this, num);
24547    return this.red.mul(this, num);
24548  };
24549
24550  BN.prototype.redIMul = function redIMul (num) {
24551    assert(this.red, 'redMul works only with red numbers');
24552    this.red._verify2(this, num);
24553    return this.red.imul(this, num);
24554  };
24555
24556  BN.prototype.redSqr = function redSqr () {
24557    assert(this.red, 'redSqr works only with red numbers');
24558    this.red._verify1(this);
24559    return this.red.sqr(this);
24560  };
24561
24562  BN.prototype.redISqr = function redISqr () {
24563    assert(this.red, 'redISqr works only with red numbers');
24564    this.red._verify1(this);
24565    return this.red.isqr(this);
24566  };
24567
24568  // Square root over p
24569  BN.prototype.redSqrt = function redSqrt () {
24570    assert(this.red, 'redSqrt works only with red numbers');
24571    this.red._verify1(this);
24572    return this.red.sqrt(this);
24573  };
24574
vendor: 8,763 bytes, lines 24575-24954
24575  BN.prototype.redInvm = function redInvm () {
24576    assert(this.red, 'redInvm works only with red numbers');
24577    this.red._verify1(this);
24578    return this.red.invm(this);
24579  };
24580
24581  // Return negative clone of `this` % `red modulo`
24582  BN.prototype.redNeg = function redNeg () {
24583    assert(this.red, 'redNeg works only with red numbers');
24584    this.red._verify1(this);
24585    return this.red.neg(this);
24586  };
24587
24588  BN.prototype.redPow = function redPow (num) {
24589    assert(this.red && !num.red, 'redPow(normalNum)');
24590    this.red._verify1(this);
24591    return this.red.pow(this, num);
24592  };
24593
24594  // Prime numbers with efficient reduction
24595  var primes = {
24596    k256: null,
24597    p224: null,
24598    p192: null,
24599    p25519: null
24600  };
24601
24602  // Pseudo-Mersenne prime
24603  function MPrime (name, p) {
24604    // P = 2 ^ N - K
24605    this.name = name;
24606    this.p = new BN(p, 16);
24607    this.n = this.p.bitLength();
24608    this.k = new BN(1).iushln(this.n).isub(this.p);
24609
24610    this.tmp = this._tmp();
24611  }
24612
24613  MPrime.prototype._tmp = function _tmp () {
24614    var tmp = new BN(null);
24615    tmp.words = new Array(Math.ceil(this.n / 13));
24616    return tmp;
24617  };
24618
24619  MPrime.prototype.ireduce = function ireduce (num) {
24620    // Assumes that `num` is less than `P^2`
24621    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
24622    var r = num;
24623    var rlen;
24624
24625    do {
24626      this.split(r, this.tmp);
24627      r = this.imulK(r);
24628      r = r.iadd(this.tmp);
24629      rlen = r.bitLength();
24630    } while (rlen > this.n);
24631
24632    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
24633    if (cmp === 0) {
24634      r.words[0] = 0;
24635      r.length = 1;
24636    } else if (cmp > 0) {
24637      r.isub(this.p);
24638    } else {
24639      r.strip();
24640    }
24641
24642    return r;
24643  };
24644
24645  MPrime.prototype.split = function split (input, out) {
24646    input.iushrn(this.n, 0, out);
24647  };
24648
24649  MPrime.prototype.imulK = function imulK (num) {
24650    return num.imul(this.k);
24651  };
24652
24653  function K256 () {
24654    MPrime.call(
24655      this,
24656      'k256',
24657      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
24658  }
24659  inherits(K256, MPrime);
24660
24661  K256.prototype.split = function split (input, output) {
24662    // 256 = 9 * 26 + 22
24663    var mask = 0x3fffff;
24664
24665    var outLen = Math.min(input.length, 9);
24666    for (var i = 0; i < outLen; i++) {
24667      output.words[i] = input.words[i];
24668    }
24669    output.length = outLen;
24670
24671    if (input.length <= 9) {
24672      input.words[0] = 0;
24673      input.length = 1;
24674      return;
24675    }
24676
24677    // Shift by 9 limbs
24678    var prev = input.words[9];
24679    output.words[output.length++] = prev & mask;
24680
24681    for (i = 10; i < input.length; i++) {
24682      var next = input.words[i] | 0;
24683      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
24684      prev = next;
24685    }
24686    prev >>>= 22;
24687    input.words[i - 10] = prev;
24688    if (prev === 0 && input.length > 10) {
24689      input.length -= 10;
24690    } else {
24691      input.length -= 9;
24692    }
24693  };
24694
24695  K256.prototype.imulK = function imulK (num) {
24696    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
24697    num.words[num.length] = 0;
24698    num.words[num.length + 1] = 0;
24699    num.length += 2;
24700
24701    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
24702    var lo = 0;
24703    for (var i = 0; i < num.length; i++) {
24704      var w = num.words[i] | 0;
24705      lo += w * 0x3d1;
24706      num.words[i] = lo & 0x3ffffff;
24707      lo = w * 0x40 + ((lo / 0x4000000) | 0);
24708    }
24709
24710    // Fast length reduction
24711    if (num.words[num.length - 1] === 0) {
24712      num.length--;
24713      if (num.words[num.length - 1] === 0) {
24714        num.length--;
24715      }
24716    }
24717    return num;
24718  };
24719
24720  function P224 () {
24721    MPrime.call(
24722      this,
24723      'p224',
24724      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
24725  }
24726  inherits(P224, MPrime);
24727
24728  function P192 () {
24729    MPrime.call(
24730      this,
24731      'p192',
24732      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
24733  }
24734  inherits(P192, MPrime);
24735
24736  function P25519 () {
24737    // 2 ^ 255 - 19
24738    MPrime.call(
24739      this,
24740      '25519',
24741      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
24742  }
24743  inherits(P25519, MPrime);
24744
24745  P25519.prototype.imulK = function imulK (num) {
24746    // K = 0x13
24747    var carry = 0;
24748    for (var i = 0; i < num.length; i++) {
24749      var hi = (num.words[i] | 0) * 0x13 + carry;
24750      var lo = hi & 0x3ffffff;
24751      hi >>>= 26;
24752
24753      num.words[i] = lo;
24754      carry = hi;
24755    }
24756    if (carry !== 0) {
24757      num.words[num.length++] = carry;
24758    }
24759    return num;
24760  };
24761
24762  // Exported mostly for testing purposes, use plain name instead
24763  BN._prime = function prime (name) {
24764    // Cached version of prime
24765    if (primes[name]) return primes[name];
24766
24767    var prime;
24768    if (name === 'k256') {
24769      prime = new K256();
24770    } else if (name === 'p224') {
24771      prime = new P224();
24772    } else if (name === 'p192') {
24773      prime = new P192();
24774    } else if (name === 'p25519') {
24775      prime = new P25519();
24776    } else {
24777      throw new Error('Unknown prime ' + name);
24778    }
24779    primes[name] = prime;
24780
24781    return prime;
24782  };
24783
24784  //
24785  // Base reduction engine
24786  //
24787  function Red (m) {
24788    if (typeof m === 'string') {
24789      var prime = BN._prime(m);
24790      this.m = prime.p;
24791      this.prime = prime;
24792    } else {
24793      assert(m.gtn(1), 'modulus must be greater than 1');
24794      this.m = m;
24795      this.prime = null;
24796    }
24797  }
24798
24799  Red.prototype._verify1 = function _verify1 (a) {
24800    assert(a.negative === 0, 'red works only with positives');
24801    assert(a.red, 'red works only with red numbers');
24802  };
24803
24804  Red.prototype._verify2 = function _verify2 (a, b) {
24805    assert((a.negative | b.negative) === 0, 'red works only with positives');
24806    assert(a.red && a.red === b.red,
24807      'red works only with red numbers');
24808  };
24809
24810  Red.prototype.imod = function imod (a) {
24811    if (this.prime) return this.prime.ireduce(a)._forceRed(this);
24812    return a.umod(this.m)._forceRed(this);
24813  };
24814
24815  Red.prototype.neg = function neg (a) {
24816    if (a.isZero()) {
24817      return a.clone();
24818    }
24819
24820    return this.m.sub(a)._forceRed(this);
24821  };
24822
24823  Red.prototype.add = function add (a, b) {
24824    this._verify2(a, b);
24825
24826    var res = a.add(b);
24827    if (res.cmp(this.m) >= 0) {
24828      res.isub(this.m);
24829    }
24830    return res._forceRed(this);
24831  };
24832
24833  Red.prototype.iadd = function iadd (a, b) {
24834    this._verify2(a, b);
24835
24836    var res = a.iadd(b);
24837    if (res.cmp(this.m) >= 0) {
24838      res.isub(this.m);
24839    }
24840    return res;
24841  };
24842
24843  Red.prototype.sub = function sub (a, b) {
24844    this._verify2(a, b);
24845
24846    var res = a.sub(b);
24847    if (res.cmpn(0) < 0) {
24848      res.iadd(this.m);
24849    }
24850    return res._forceRed(this);
24851  };
24852
24853  Red.prototype.isub = function isub (a, b) {
24854    this._verify2(a, b);
24855
24856    var res = a.isub(b);
24857    if (res.cmpn(0) < 0) {
24858      res.iadd(this.m);
24859    }
24860    return res;
24861  };
24862
24863  Red.prototype.shl = function shl (a, num) {
24864    this._verify1(a);
24865    return this.imod(a.ushln(num));
24866  };
24867
24868  Red.prototype.imul = function imul (a, b) {
24869    this._verify2(a, b);
24870    return this.imod(a.imul(b));
24871  };
24872
24873  Red.prototype.mul = function mul (a, b) {
24874    this._verify2(a, b);
24875    return this.imod(a.mul(b));
24876  };
24877
24878  Red.prototype.isqr = function isqr (a) {
24879    return this.imul(a, a.clone());
24880  };
24881
24882  Red.prototype.sqr = function sqr (a) {
24883    return this.mul(a, a);
24884  };
24885
24886  Red.prototype.sqrt = function sqrt (a) {
24887    if (a.isZero()) return a.clone();
24888
24889    var mod3 = this.m.andln(3);
24890    assert(mod3 % 2 === 1);
24891
24892    // Fast case
24893    if (mod3 === 3) {
24894      var pow = this.m.add(new BN(1)).iushrn(2);
24895      return this.pow(a, pow);
24896    }
24897
24898    // Tonelli-Shanks algorithm (Totally unoptimized and slow)
24899    //
24900    // Find Q and S, that Q * 2 ^ S = (P - 1)
24901    var q = this.m.subn(1);
24902    var s = 0;
24903    while (!q.isZero() && q.andln(1) === 0) {
24904      s++;
24905      q.iushrn(1);
24906    }
24907    assert(!q.isZero());
24908
24909    var one = new BN(1).toRed(this);
24910    var nOne = one.redNeg();
24911
24912    // Find quadratic non-residue
24913    // NOTE: Max is such because of generalized Riemann hypothesis.
24914    var lpow = this.m.subn(1).iushrn(1);
24915    var z = this.m.bitLength();
24916    z = new BN(2 * z * z).toRed(this);
24917
24918    while (this.pow(z, lpow).cmp(nOne) !== 0) {
24919      z.redIAdd(nOne);
24920    }
24921
24922    var c = this.pow(z, q);
24923    var r = this.pow(a, q.addn(1).iushrn(1));
24924    var t = this.pow(a, q);
24925    var m = s;
24926    while (t.cmp(one) !== 0) {
24927      var tmp = t;
24928      for (var i = 0; tmp.cmp(one) !== 0; i++) {
24929        tmp = tmp.redSqr();
24930      }
24931      assert(i < m);
24932      var b = this.pow(c, new BN(1).iushln(m - i - 1));
24933
24934      r = r.redMul(b);
24935      c = b.redSqr();
24936      t = t.redMul(c);
24937      m = i;
24938    }
24939
24940    return r;
24941  };
24942
24943  Red.prototype.invm = function invm (a) {
24944    var inv = a._invmp(this.m);
24945    if (inv.negative !== 0) {
24946      inv.negative = 0;
24947      return this.imod(inv).redNeg();
24948    } else {
24949      return this.imod(inv);
24950    }
24951  };
24952
24953  Red.prototype.pow = function pow (a, num) {
24954    if (num.isZero()) return new BN(1)
vendor: 4,291 bytes, lines 24954-25133
24954;
24955    if (num.cmpn(1) === 0) return a.clone();
24956
24957    var windowSize = 4;
24958    var wnd = new Array(1 << windowSize);
24959    wnd[0] = new BN(1).toRed(this);
24960    wnd[1] = a;
24961    for (var i = 2; i < wnd.length; i++) {
24962      wnd[i] = this.mul(wnd[i - 1], a);
24963    }
24964
24965    var res = wnd[0];
24966    var current = 0;
24967    var currentLen = 0;
24968    var start = num.bitLength() % 26;
24969    if (start === 0) {
24970      start = 26;
24971    }
24972
24973    for (i = num.length - 1; i >= 0; i--) {
24974      var word = num.words[i];
24975      for (var j = start - 1; j >= 0; j--) {
24976        var bit = (word >> j) & 1;
24977        if (res !== wnd[0]) {
24978          res = this.sqr(res);
24979        }
24980
24981        if (bit === 0 && current === 0) {
24982          currentLen = 0;
24983          continue;
24984        }
24985
24986        current <<= 1;
24987        current |= bit;
24988        currentLen++;
24989        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
24990
24991        res = this.mul(res, wnd[current]);
24992        currentLen = 0;
24993        current = 0;
24994      }
24995      start = 26;
24996    }
24997
24998    return res;
24999  };
25000
25001  Red.prototype.convertTo = function convertTo (num) {
25002    var r = num.umod(this.m);
25003
25004    return r === num ? r.clone() : r;
25005  };
25006
25007  Red.prototype.convertFrom = function convertFrom (num) {
25008    var res = num.clone();
25009    res.red = null;
25010    return res;
25011  };
25012
25013  //
25014  // Montgomery method engine
25015  //
25016
25017  BN.mont = function mont (num) {
25018    return new Mont(num);
25019  };
25020
25021  function Mont (m) {
25022    Red.call(this, m);
25023
25024    this.shift = this.m.bitLength();
25025    if (this.shift % 26 !== 0) {
25026      this.shift += 26 - (this.shift % 26);
25027    }
25028
25029    this.r = new BN(1).iushln(this.shift);
25030    this.r2 = this.imod(this.r.sqr());
25031    this.rinv = this.r._invmp(this.m);
25032
25033    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
25034    this.minv = this.minv.umod(this.r);
25035    this.minv = this.r.sub(this.minv);
25036  }
25037  inherits(Mont, Red);
25038
25039  Mont.prototype.convertTo = function convertTo (num) {
25040    return this.imod(num.ushln(this.shift));
25041  };
25042
25043  Mont.prototype.convertFrom = function convertFrom (num) {
25044    var r = this.imod(num.mul(this.rinv));
25045    r.red = null;
25046    return r;
25047  };
25048
25049  Mont.prototype.imul = function imul (a, b) {
25050    if (a.isZero() || b.isZero()) {
25051      a.words[0] = 0;
25052      a.length = 1;
25053      return a;
25054    }
25055
25056    var t = a.imul(b);
25057    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
25058    var u = t.isub(c).iushrn(this.shift);
25059    var res = u;
25060
25061    if (u.cmp(this.m) >= 0) {
25062      res = u.isub(this.m);
25063    } else if (u.cmpn(0) < 0) {
25064      res = u.iadd(this.m);
25065    }
25066
25067    return res._forceRed(this);
25068  };
25069
25070  Mont.prototype.mul = function mul (a, b) {
25071    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
25072
25073    var t = a.mul(b);
25074    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
25075    var u = t.isub(c).iushrn(this.shift);
25076    var res = u;
25077    if (u.cmp(this.m) >= 0) {
25078      res = u.isub(this.m);
25079    } else if (u.cmpn(0) < 0) {
25080      res = u.iadd(this.m);
25081    }
25082
25083    return res._forceRed(this);
25084  };
25085
25086  Mont.prototype.invm = function invm (a) {
25087    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
25088    var res = this.imod(a._invmp(this.m).mul(this.r2));
25089    return res._forceRed(this);
25090  };
25091})(typeof module === 'undefined' || module, this);
25092
25093/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(42)(module)))
25094
25095/***/ },
25096/* 2 */
25097/***/ function(module, exports, __webpack_require__) {
25098
25099var hash = exports;
25100
25101hash.utils = __webpack_require__(32);
25102hash.common = __webpack_require__(28);
25103hash.sha = __webpack_require__(31);
25104hash.ripemd = __webpack_require__(30);
25105hash.hmac = __webpack_require__(29);
25106
25107// Proxy hash functions to the main object
25108hash.sha1 = hash.sha.sha1;
25109hash.sha256 = hash.sha.sha256;
25110hash.sha224 = hash.sha.sha224;
25111hash.sha384 = hash.sha.sha384;
25112hash.sha512 = hash.sha.sha512;
25113hash.ripemd160 = hash.ripemd.ripemd160;
25114
25115
25116/***/ },
25117/* 3 */
25118/***/ function(module, exports, __webpack_require__) {
25119
25120"use strict";
25121/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
25122 * The buffer module from node.js, for the browser.
25123 *
25124 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
25125 * @license  MIT
25126 */
25127/* eslint-disable no-proto */
25128
25129'use strict'
25130
25131var base64 = __webpack_require__(12)
25132var ieee754 = __webpack_require__(33)
25133var isArray = __webpack_require__(34
vendor: 48,349 bytes, lines 25133-26911
25133)
25134
25135exports.Buffer = Buffer
25136exports.SlowBuffer = SlowBuffer
25137exports.INSPECT_MAX_BYTES = 50
25138
25139/**
25140 * If `Buffer.TYPED_ARRAY_SUPPORT`:
25141 *   === true    Use Uint8Array implementation (fastest)
25142 *   === false   Use Object implementation (most compatible, even IE6)
25143 *
25144 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
25145 * Opera 11.6+, iOS 4.2+.
25146 *
25147 * Due to various browser bugs, sometimes the Object implementation will be used even
25148 * when the browser supports typed arrays.
25149 *
25150 * Note:
25151 *
25152 *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
25153 *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
25154 *
25155 *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
25156 *
25157 *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
25158 *     incorrect length in some situations.
25159
25160 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
25161 * get the Object implementation, which is slower but behaves correctly.
25162 */
25163Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
25164  ? global.TYPED_ARRAY_SUPPORT
25165  : typedArraySupport()
25166
25167/*
25168 * Export kMaxLength after typed array support is determined.
25169 */
25170exports.kMaxLength = kMaxLength()
25171
25172function typedArraySupport () {
25173  try {
25174    var arr = new Uint8Array(1)
25175    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
25176    return arr.foo() === 42 && // typed array instances can be augmented
25177        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
25178        arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
25179  } catch (e) {
25180    return false
25181  }
25182}
25183
25184function kMaxLength () {
25185  return Buffer.TYPED_ARRAY_SUPPORT
25186    ? 0x7fffffff
25187    : 0x3fffffff
25188}
25189
25190function createBuffer (that, length) {
25191  if (kMaxLength() < length) {
25192    throw new RangeError('Invalid typed array length')
25193  }
25194  if (Buffer.TYPED_ARRAY_SUPPORT) {
25195    // Return an augmented `Uint8Array` instance, for best performance
25196    that = new Uint8Array(length)
25197    that.__proto__ = Buffer.prototype
25198  } else {
25199    // Fallback: Return an object instance of the Buffer class
25200    if (that === null) {
25201      that = new Buffer(length)
25202    }
25203    that.length = length
25204  }
25205
25206  return that
25207}
25208
25209/**
25210 * The Buffer constructor returns instances of `Uint8Array` that have their
25211 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
25212 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
25213 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
25214 * returns a single octet.
25215 *
25216 * The `Uint8Array` prototype remains unmodified.
25217 */
25218
25219function Buffer (arg, encodingOrOffset, length) {
25220  if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
25221    return new Buffer(arg, encodingOrOffset, length)
25222  }
25223
25224  // Common case.
25225  if (typeof arg === 'number') {
25226    if (typeof encodingOrOffset === 'string') {
25227      throw new Error(
25228        'If encoding is specified then the first argument must be a string'
25229      )
25230    }
25231    return allocUnsafe(this, arg)
25232  }
25233  return from(this, arg, encodingOrOffset, length)
25234}
25235
25236Buffer.poolSize = 8192 // not used by this implementation
25237
25238// TODO: Legacy, not needed anymore. Remove in next major version.
25239Buffer._augment = function (arr) {
25240  arr.__proto__ = Buffer.prototype
25241  return arr
25242}
25243
25244function from (that, value, encodingOrOffset, length) {
25245  if (typeof value === 'number') {
25246    throw new TypeError('"value" argument must not be a number')
25247  }
25248
25249  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
25250    return fromArrayBuffer(that, value, encodingOrOffset, length)
25251  }
25252
25253  if (typeof value === 'string') {
25254    return fromString(that, value, encodingOrOffset)
25255  }
25256
25257  return fromObject(that, value)
25258}
25259
25260/**
25261 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
25262 * if value is a number.
25263 * Buffer.from(str[, encoding])
25264 * Buffer.from(array)
25265 * Buffer.from(buffer)
25266 * Buffer.from(arrayBuffer[, byteOffset[, length]])
25267 **/
25268Buffer.from = function (value, encodingOrOffset, length) {
25269  return from(null, value, encodingOrOffset, length)
25270}
25271
25272if (Buffer.TYPED_ARRAY_SUPPORT) {
25273  Buffer.prototype.__proto__ = Uint8Array.prototype
25274  Buffer.__proto__ = Uint8Array
25275  if (typeof Symbol !== 'undefined' && Symbol.species &&
25276      Buffer[Symbol.species] === Buffer) {
25277    // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
25278    Object.defineProperty(Buffer, Symbol.species, {
25279      value: null,
25280      configurable: true
25281    })
25282  }
25283}
25284
25285function assertSize (size) {
25286  if (typeof size !== 'number') {
25287    throw new TypeError('"size" argument must be a number')
25288  } else if (size < 0) {
25289    throw new RangeError('"size" argument must not be negative')
25290  }
25291}
25292
25293function alloc (that, size, fill, encoding) {
25294  assertSize(size)
25295  if (size <= 0) {
25296    return createBuffer(that, size)
25297  }
25298  if (fill !== undefined) {
25299    // Only pay attention to encoding if it's a string. This
25300    // prevents accidentally sending in a number that would
25301    // be interpretted as a start offset.
25302    return typeof encoding === 'string'
25303      ? createBuffer(that, size).fill(fill, encoding)
25304      : createBuffer(that, size).fill(fill)
25305  }
25306  return createBuffer(that, size)
25307}
25308
25309/**
25310 * Creates a new filled Buffer instance.
25311 * alloc(size[, fill[, encoding]])
25312 **/
25313Buffer.alloc = function (size, fill, encoding) {
25314  return alloc(null, size, fill, encoding)
25315}
25316
25317function allocUnsafe (that, size) {
25318  assertSize(size)
25319  that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
25320  if (!Buffer.TYPED_ARRAY_SUPPORT) {
25321    for (var i = 0; i < size; ++i) {
25322      that[i] = 0
25323    }
25324  }
25325  return that
25326}
25327
25328/**
25329 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
25330 * */
25331Buffer.allocUnsafe = function (size) {
25332  return allocUnsafe(null, size)
25333}
25334/**
25335 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
25336 */
25337Buffer.allocUnsafeSlow = function (size) {
25338  return allocUnsafe(null, size)
25339}
25340
25341function fromString (that, string, encoding) {
25342  if (typeof encoding !== 'string' || encoding === '') {
25343    encoding = 'utf8'
25344  }
25345
25346  if (!Buffer.isEncoding(encoding)) {
25347    throw new TypeError('"encoding" must be a valid string encoding')
25348  }
25349
25350  var length = byteLength(string, encoding) | 0
25351  that = createBuffer(that, length)
25352
25353  var actual = that.write(string, encoding)
25354
25355  if (actual !== length) {
25356    // Writing a hex string, for example, that contains invalid characters will
25357    // cause everything after the first invalid character to be ignored. (e.g.
25358    // 'abxxcd' will be treated as 'ab')
25359    that = that.slice(0, actual)
25360  }
25361
25362  return that
25363}
25364
25365function fromArrayLike (that, array) {
25366  var length = array.length < 0 ? 0 : checked(array.length) | 0
25367  that = createBuffer(that, length)
25368  for (var i = 0; i < length; i += 1) {
25369    that[i] = array[i] & 255
25370  }
25371  return that
25372}
25373
25374function fromArrayBuffer (that, array, byteOffset, length) {
25375  array.byteLength // this throws if `array` is not a valid ArrayBuffer
25376
25377  if (byteOffset < 0 || array.byteLength < byteOffset) {
25378    throw new RangeError('\'offset\' is out of bounds')
25379  }
25380
25381  if (array.byteLength < byteOffset + (length || 0)) {
25382    throw new RangeError('\'length\' is out of bounds')
25383  }
25384
25385  if (byteOffset === undefined && length === undefined) {
25386    array = new Uint8Array(array)
25387  } else if (length === undefined) {
25388    array = new Uint8Array(array, byteOffset)
25389  } else {
25390    array = new Uint8Array(array, byteOffset, length)
25391  }
25392
25393  if (Buffer.TYPED_ARRAY_SUPPORT) {
25394    // Return an augmented `Uint8Array` instance, for best performance
25395    that = array
25396    that.__proto__ = Buffer.prototype
25397  } else {
25398    // Fallback: Return an object instance of the Buffer class
25399    that = fromArrayLike(that, array)
25400  }
25401  return that
25402}
25403
25404function fromObject (that, obj) {
25405  if (Buffer.isBuffer(obj)) {
25406    var len = checked(obj.length) | 0
25407    that = createBuffer(that, len)
25408
25409    if (that.length === 0) {
25410      return that
25411    }
25412
25413    obj.copy(that, 0, 0, len)
25414    return that
25415  }
25416
25417  if (obj) {
25418    if ((typeof ArrayBuffer !== 'undefined' &&
25419        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
25420      if (typeof obj.length !== 'number' || isnan(obj.length)) {
25421        return createBuffer(that, 0)
25422      }
25423      return fromArrayLike(that, obj)
25424    }
25425
25426    if (obj.type === 'Buffer' && isArray(obj.data)) {
25427      return fromArrayLike(that, obj.data)
25428    }
25429  }
25430
25431  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
25432}
25433
25434function checked (length) {
25435  // Note: cannot use `length < kMaxLength()` here because that fails when
25436  // length is NaN (which is otherwise coerced to zero.)
25437  if (length >= kMaxLength()) {
25438    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
25439                         'size: 0x' + kMaxLength().toString(16) + ' bytes')
25440  }
25441  return length | 0
25442}
25443
25444function SlowBuffer (length) {
25445  if (+length != length) { // eslint-disable-line eqeqeq
25446    length = 0
25447  }
25448  return Buffer.alloc(+length)
25449}
25450
25451Buffer.isBuffer = function isBuffer (b) {
25452  return !!(b != null && b._isBuffer)
25453}
25454
25455Buffer.compare = function compare (a, b) {
25456  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
25457    throw new TypeError('Arguments must be Buffers')
25458  }
25459
25460  if (a === b) return 0
25461
25462  var x = a.length
25463  var y = b.length
25464
25465  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
25466    if (a[i] !== b[i]) {
25467      x = a[i]
25468      y = b[i]
25469      break
25470    }
25471  }
25472
25473  if (x < y) return -1
25474  if (y < x) return 1
25475  return 0
25476}
25477
25478Buffer.isEncoding = function isEncoding (encoding) {
25479  switch (String(encoding).toLowerCase()) {
25480    case 'hex':
25481    case 'utf8':
25482    case 'utf-8':
25483    case 'ascii':
25484    case 'latin1':
25485    case 'binary':
25486    case 'base64':
25487    case 'ucs2':
25488    case 'ucs-2':
25489    case 'utf16le':
25490    case 'utf-16le':
25491      return true
25492    default:
25493      return false
25494  }
25495}
25496
25497Buffer.concat = function concat (list, length) {
25498  if (!isArray(list)) {
25499    throw new TypeError('"list" argument must be an Array of Buffers')
25500  }
25501
25502  if (list.length === 0) {
25503    return Buffer.alloc(0)
25504  }
25505
25506  var i
25507  if (length === undefined) {
25508    length = 0
25509    for (i = 0; i < list.length; ++i) {
25510      length += list[i].length
25511    }
25512  }
25513
25514  var buffer = Buffer.allocUnsafe(length)
25515  var pos = 0
25516  for (i = 0; i < list.length; ++i) {
25517    var buf = list[i]
25518    if (!Buffer.isBuffer(buf)) {
25519      throw new TypeError('"list" argument must be an Array of Buffers')
25520    }
25521    buf.copy(buffer, pos)
25522    pos += buf.length
25523  }
25524  return buffer
25525}
25526
25527function byteLength (string, encoding) {
25528  if (Buffer.isBuffer(string)) {
25529    return string.length
25530  }
25531  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
25532      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
25533    return string.byteLength
25534  }
25535  if (typeof string !== 'string') {
25536    string = '' + string
25537  }
25538
25539  var len = string.length
25540  if (len === 0) return 0
25541
25542  // Use a for loop to avoid recursion
25543  var loweredCase = false
25544  for (;;) {
25545    switch (encoding) {
25546      case 'ascii':
25547      case 'latin1':
25548      case 'binary':
25549        return len
25550      case 'utf8':
25551      case 'utf-8':
25552      case undefined:
25553        return utf8ToBytes(string).length
25554      case 'ucs2':
25555      case 'ucs-2':
25556      case 'utf16le':
25557      case 'utf-16le':
25558        return len * 2
25559      case 'hex':
25560        return len >>> 1
25561      case 'base64':
25562        return base64ToBytes(string).length
25563      default:
25564        if (loweredCase) return utf8ToBytes(string).length // assume utf8
25565        encoding = ('' + encoding).toLowerCase()
25566        loweredCase = true
25567    }
25568  }
25569}
25570Buffer.byteLength = byteLength
25571
25572function slowToString (encoding, start, end) {
25573  var loweredCase = false
25574
25575  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
25576  // property of a typed array.
25577
25578  // This behaves neither like String nor Uint8Array in that we set start/end
25579  // to their upper/lower bounds if the value passed is out of range.
25580  // undefined is handled specially as per ECMA-262 6th Edition,
25581  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
25582  if (start === undefined || start < 0) {
25583    start = 0
25584  }
25585  // Return early if start > this.length. Done here to prevent potential uint32
25586  // coercion fail below.
25587  if (start > this.length) {
25588    return ''
25589  }
25590
25591  if (end === undefined || end > this.length) {
25592    end = this.length
25593  }
25594
25595  if (end <= 0) {
25596    return ''
25597  }
25598
25599  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
25600  end >>>= 0
25601  start >>>= 0
25602
25603  if (end <= start) {
25604    return ''
25605  }
25606
25607  if (!encoding) encoding = 'utf8'
25608
25609  while (true) {
25610    switch (encoding) {
25611      case 'hex':
25612        return hexSlice(this, start, end)
25613
25614      case 'utf8':
25615      case 'utf-8':
25616        return utf8Slice(this, start, end)
25617
25618      case 'ascii':
25619        return asciiSlice(this, start, end)
25620
25621      case 'latin1':
25622      case 'binary':
25623        return latin1Slice(this, start, end)
25624
25625      case 'base64':
25626        return base64Slice(this, start, end)
25627
25628      case 'ucs2':
25629      case 'ucs-2':
25630      case 'utf16le':
25631      case 'utf-16le':
25632        return utf16leSlice(this, start, end)
25633
25634      default:
25635        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
25636        encoding = (encoding + '').toLowerCase()
25637        loweredCase = true
25638    }
25639  }
25640}
25641
25642// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
25643// Buffer instances.
25644Buffer.prototype._isBuffer = true
25645
25646function swap (b, n, m) {
25647  var i = b[n]
25648  b[n] = b[m]
25649  b[m] = i
25650}
25651
25652Buffer.prototype.swap16 = function swap16 () {
25653  var len = this.length
25654  if (len % 2 !== 0) {
25655    throw new RangeError('Buffer size must be a multiple of 16-bits')
25656  }
25657  for (var i = 0; i < len; i += 2) {
25658    swap(this, i, i + 1)
25659  }
25660  return this
25661}
25662
25663Buffer.prototype.swap32 = function swap32 () {
25664  var len = this.length
25665  if (len % 4 !== 0) {
25666    throw new RangeError('Buffer size must be a multiple of 32-bits')
25667  }
25668  for (var i = 0; i < len; i += 4) {
25669    swap(this, i, i + 3)
25670    swap(this, i + 1, i + 2)
25671  }
25672  return this
25673}
25674
25675Buffer.prototype.swap64 = function swap64 () {
25676  var len = this.length
25677  if (len % 8 !== 0) {
25678    throw new RangeError('Buffer size must be a multiple of 64-bits')
25679  }
25680  for (var i = 0; i < len; i += 8) {
25681    swap(this, i, i + 7)
25682    swap(this, i + 1, i + 6)
25683    swap(this, i + 2, i + 5)
25684    swap(this, i + 3, i + 4)
25685  }
25686  return this
25687}
25688
25689Buffer.prototype.toString = function toString () {
25690  var length = this.length | 0
25691  if (length === 0) return ''
25692  if (arguments.length === 0) return utf8Slice(this, 0, length)
25693  return slowToString.apply(this, arguments)
25694}
25695
25696Buffer.prototype.equals = function equals (b) {
25697  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
25698  if (this === b) return true
25699  return Buffer.compare(this, b) === 0
25700}
25701
25702Buffer.prototype.inspect = function inspect () {
25703  var str = ''
25704  var max = exports.INSPECT_MAX_BYTES
25705  if (this.length > 0) {
25706    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
25707    if (this.length > max) str += ' ... '
25708  }
25709  return '<Buffer ' + str + '>'
25710}
25711
25712Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
25713  if (!Buffer.isBuffer(target)) {
25714    throw new TypeError('Argument must be a Buffer')
25715  }
25716
25717  if (start === undefined) {
25718    start = 0
25719  }
25720  if (end === undefined) {
25721    end = target ? target.length : 0
25722  }
25723  if (thisStart === undefined) {
25724    thisStart = 0
25725  }
25726  if (thisEnd === undefined) {
25727    thisEnd = this.length
25728  }
25729
25730  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
25731    throw new RangeError('out of range index')
25732  }
25733
25734  if (thisStart >= thisEnd && start >= end) {
25735    return 0
25736  }
25737  if (thisStart >= thisEnd) {
25738    return -1
25739  }
25740  if (start >= end) {
25741    return 1
25742  }
25743
25744  start >>>= 0
25745  end >>>= 0
25746  thisStart >>>= 0
25747  thisEnd >>>= 0
25748
25749  if (this === target) return 0
25750
25751  var x = thisEnd - thisStart
25752  var y = end - start
25753  var len = Math.min(x, y)
25754
25755  var thisCopy = this.slice(thisStart, thisEnd)
25756  var targetCopy = target.slice(start, end)
25757
25758  for (var i = 0; i < len; ++i) {
25759    if (thisCopy[i] !== targetCopy[i]) {
25760      x = thisCopy[i]
25761      y = targetCopy[i]
25762      break
25763    }
25764  }
25765
25766  if (x < y) return -1
25767  if (y < x) return 1
25768  return 0
25769}
25770
25771// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
25772// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
25773//
25774// Arguments:
25775// - buffer - a Buffer to search
25776// - val - a string, Buffer, or number
25777// - byteOffset - an index into `buffer`; will be clamped to an int32
25778// - encoding - an optional encoding, relevant is val is a string
25779// - dir - true for indexOf, false for lastIndexOf
25780function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
25781  // Empty buffer means no match
25782  if (buffer.length === 0) return -1
25783
25784  // Normalize byteOffset
25785  if (typeof byteOffset === 'string') {
25786    encoding = byteOffset
25787    byteOffset = 0
25788  } else if (byteOffset > 0x7fffffff) {
25789    byteOffset = 0x7fffffff
25790  } else if (byteOffset < -0x80000000) {
25791    byteOffset = -0x80000000
25792  }
25793  byteOffset = +byteOffset  // Coerce to Number.
25794  if (isNaN(byteOffset)) {
25795    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
25796    byteOffset = dir ? 0 : (buffer.length - 1)
25797  }
25798
25799  // Normalize byteOffset: negative offsets start from the end of the buffer
25800  if (byteOffset < 0) byteOffset = buffer.length + byteOffset
25801  if (byteOffset >= buffer.length) {
25802    if (dir) return -1
25803    else byteOffset = buffer.length - 1
25804  } else if (byteOffset < 0) {
25805    if (dir) byteOffset = 0
25806    else return -1
25807  }
25808
25809  // Normalize val
25810  if (typeof val === 'string') {
25811    val = Buffer.from(val, encoding)
25812  }
25813
25814  // Finally, search either indexOf (if dir is true) or lastIndexOf
25815  if (Buffer.isBuffer(val)) {
25816    // Special case: looking for empty string/buffer always fails
25817    if (val.length === 0) {
25818      return -1
25819    }
25820    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
25821  } else if (typeof val === 'number') {
25822    val = val & 0xFF // Search for a byte value [0-255]
25823    if (Buffer.TYPED_ARRAY_SUPPORT &&
25824        typeof Uint8Array.prototype.indexOf === 'function') {
25825      if (dir) {
25826        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
25827      } else {
25828        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
25829      }
25830    }
25831    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
25832  }
25833
25834  throw new TypeError('val must be string, number or Buffer')
25835}
25836
25837function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
25838  var indexSize = 1
25839  var arrLength = arr.length
25840  var valLength = val.length
25841
25842  if (encoding !== undefined) {
25843    encoding = String(encoding).toLowerCase()
25844    if (encoding === 'ucs2' || encoding === 'ucs-2' ||
25845        encoding === 'utf16le' || encoding === 'utf-16le') {
25846      if (arr.length < 2 || val.length < 2) {
25847        return -1
25848      }
25849      indexSize = 2
25850      arrLength /= 2
25851      valLength /= 2
25852      byteOffset /= 2
25853    }
25854  }
25855
25856  function read (buf, i) {
25857    if (indexSize === 1) {
25858      return buf[i]
25859    } else {
25860      return buf.readUInt16BE(i * indexSize)
25861    }
25862  }
25863
25864  var i
25865  if (dir) {
25866    var foundIndex = -1
25867    for (i = byteOffset; i < arrLength; i++) {
25868      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
25869        if (foundIndex === -1) foundIndex = i
25870        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
25871      } else {
25872        if (foundIndex !== -1) i -= i - foundIndex
25873        foundIndex = -1
25874      }
25875    }
25876  } else {
25877    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
25878    for (i = byteOffset; i >= 0; i--) {
25879      var found = true
25880      for (var j = 0; j < valLength; j++) {
25881        if (read(arr, i + j) !== read(val, j)) {
25882          found = false
25883          break
25884        }
25885      }
25886      if (found) return i
25887    }
25888  }
25889
25890  return -1
25891}
25892
25893Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
25894  return this.indexOf(val, byteOffset, encoding) !== -1
25895}
25896
25897Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
25898  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
25899}
25900
25901Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
25902  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
25903}
25904
25905function hexWrite (buf, string, offset, length) {
25906  offset = Number(offset) || 0
25907  var remaining = buf.length - offset
25908  if (!length) {
25909    length = remaining
25910  } else {
25911    length = Number(length)
25912    if (length > remaining) {
25913      length = remaining
25914    }
25915  }
25916
25917  // must be an even number of digits
25918  var strLen = string.length
25919  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
25920
25921  if (length > strLen / 2) {
25922    length = strLen / 2
25923  }
25924  for (var i = 0; i < length; ++i) {
25925    var parsed = parseInt(string.substr(i * 2, 2), 16)
25926    if (isNaN(parsed)) return i
25927    buf[offset + i] = parsed
25928  }
25929  return i
25930}
25931
25932function utf8Write (buf, string, offset, length) {
25933  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
25934}
25935
25936function asciiWrite (buf, string, offset, length) {
25937  return blitBuffer(asciiToBytes(string), buf, offset, length)
25938}
25939
25940function latin1Write (buf, string, offset, length) {
25941  return asciiWrite(buf, string, offset, length)
25942}
25943
25944function base64Write (buf, string, offset, length) {
25945  return blitBuffer(base64ToBytes(string), buf, offset, length)
25946}
25947
25948function ucs2Write (buf, string, offset, length) {
25949  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
25950}
25951
25952Buffer.prototype.write = function write (string, offset, length, encoding) {
25953  // Buffer#write(string)
25954  if (offset === undefined) {
25955    encoding = 'utf8'
25956    length = this.length
25957    offset = 0
25958  // Buffer#write(string, encoding)
25959  } else if (length === undefined && typeof offset === 'string') {
25960    encoding = offset
25961    length = this.length
25962    offset = 0
25963  // Buffer#write(string, offset[, length][, encoding])
25964  } else if (isFinite(offset)) {
25965    offset = offset | 0
25966    if (isFinite(length)) {
25967      length = length | 0
25968      if (encoding === undefined) encoding = 'utf8'
25969    } else {
25970      encoding = length
25971      length = undefined
25972    }
25973  // legacy write(string, encoding, offset, length) - remove in v0.13
25974  } else {
25975    throw new Error(
25976      'Buffer.write(string, encoding, offset[, length]) is no longer supported'
25977    )
25978  }
25979
25980  var remaining = this.length - offset
25981  if (length === undefined || length > remaining) length = remaining
25982
25983  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
25984    throw new RangeError('Attempt to write outside buffer bounds')
25985  }
25986
25987  if (!encoding) encoding = 'utf8'
25988
25989  var loweredCase = false
25990  for (;;) {
25991    switch (encoding) {
25992      case 'hex':
25993        return hexWrite(this, string, offset, length)
25994
25995      case 'utf8':
25996      case 'utf-8':
25997        return utf8Write(this, string, offset, length)
25998
25999      case 'ascii':
26000        return asciiWrite(this, string, offset, length)
26001
26002      case 'latin1':
26003      case 'binary':
26004        return latin1Write(this, string, offset, length)
26005
26006      case 'base64':
26007        // Warning: maxLength not taken into account in base64Write
26008        return base64Write(this, string, offset, length)
26009
26010      case 'ucs2':
26011      case 'ucs-2':
26012      case 'utf16le':
26013      case 'utf-16le':
26014        return ucs2Write(this, string, offset, length)
26015
26016      default:
26017        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
26018        encoding = ('' + encoding).toLowerCase()
26019        loweredCase = true
26020    }
26021  }
26022}
26023
26024Buffer.prototype.toJSON = function toJSON () {
26025  return {
26026    type: 'Buffer',
26027    data: Array.prototype.slice.call(this._arr || this, 0)
26028  }
26029}
26030
26031function base64Slice (buf, start, end) {
26032  if (start === 0 && end === buf.length) {
26033    return base64.fromByteArray(buf)
26034  } else {
26035    return base64.fromByteArray(buf.slice(start, end))
26036  }
26037}
26038
26039function utf8Slice (buf, start, end) {
26040  end = Math.min(buf.length, end)
26041  var res = []
26042
26043  var i = start
26044  while (i < end) {
26045    var firstByte = buf[i]
26046    var codePoint = null
26047    var bytesPerSequence = (firstByte > 0xEF) ? 4
26048      : (firstByte > 0xDF) ? 3
26049      : (firstByte > 0xBF) ? 2
26050      : 1
26051
26052    if (i + bytesPerSequence <= end) {
26053      var secondByte, thirdByte, fourthByte, tempCodePoint
26054
26055      switch (bytesPerSequence) {
26056        case 1:
26057          if (firstByte < 0x80) {
26058            codePoint = firstByte
26059          }
26060          break
26061        case 2:
26062          secondByte = buf[i + 1]
26063          if ((secondByte & 0xC0) === 0x80) {
26064            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
26065            if (tempCodePoint > 0x7F) {
26066              codePoint = tempCodePoint
26067            }
26068          }
26069          break
26070        case 3:
26071          secondByte = buf[i + 1]
26072          thirdByte = buf[i + 2]
26073          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
26074            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
26075            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
26076              codePoint = tempCodePoint
26077            }
26078          }
26079          break
26080        case 4:
26081          secondByte = buf[i + 1]
26082          thirdByte = buf[i + 2]
26083          fourthByte = buf[i + 3]
26084          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
26085            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
26086            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
26087              codePoint = tempCodePoint
26088            }
26089          }
26090      }
26091    }
26092
26093    if (codePoint === null) {
26094      // we did not generate a valid codePoint so insert a
26095      // replacement char (U+FFFD) and advance only 1 byte
26096      codePoint = 0xFFFD
26097      bytesPerSequence = 1
26098    } else if (codePoint > 0xFFFF) {
26099      // encode to utf16 (surrogate pair dance)
26100      codePoint -= 0x10000
26101      res.push(codePoint >>> 10 & 0x3FF | 0xD800)
26102      codePoint = 0xDC00 | codePoint & 0x3FF
26103    }
26104
26105    res.push(codePoint)
26106    i += bytesPerSequence
26107  }
26108
26109  return decodeCodePointsArray(res)
26110}
26111
26112// Based on http://stackoverflow.com/a/22747272/680742, the browser with
26113// the lowest limit is Chrome, with 0x10000 args.
26114// We go 1 magnitude less, for safety
26115var MAX_ARGUMENTS_LENGTH = 0x1000
26116
26117function decodeCodePointsArray (codePoints) {
26118  var len = codePoints.length
26119  if (len <= MAX_ARGUMENTS_LENGTH) {
26120    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
26121  }
26122
26123  // Decode in chunks to avoid "call stack size exceeded".
26124  var res = ''
26125  var i = 0
26126  while (i < len) {
26127    res += String.fromCharCode.apply(
26128      String,
26129      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
26130    )
26131  }
26132  return res
26133}
26134
26135function asciiSlice (buf, start, end) {
26136  var ret = ''
26137  end = Math.min(buf.length, end)
26138
26139  for (var i = start; i < end; ++i) {
26140    ret += String.fromCharCode(buf[i] & 0x7F)
26141  }
26142  return ret
26143}
26144
26145function latin1Slice (buf, start, end) {
26146  var ret = ''
26147  end = Math.min(buf.length, end)
26148
26149  for (var i = start; i < end; ++i) {
26150    ret += String.fromCharCode(buf[i])
26151  }
26152  return ret
26153}
26154
26155function hexSlice (buf, start, end) {
26156  var len = buf.length
26157
26158  if (!start || start < 0) start = 0
26159  if (!end || end < 0 || end > len) end = len
26160
26161  var out = ''
26162  for (var i = start; i < end; ++i) {
26163    out += toHex(buf[i])
26164  }
26165  return out
26166}
26167
26168function utf16leSlice (buf, start, end) {
26169  var bytes = buf.slice(start, end)
26170  var res = ''
26171  for (var i = 0; i < bytes.length; i += 2) {
26172    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
26173  }
26174  return res
26175}
26176
26177Buffer.prototype.slice = function slice (start, end) {
26178  var len = this.length
26179  start = ~~start
26180  end = end === undefined ? len : ~~end
26181
26182  if (start < 0) {
26183    start += len
26184    if (start < 0) start = 0
26185  } else if (start > len) {
26186    start = len
26187  }
26188
26189  if (end < 0) {
26190    end += len
26191    if (end < 0) end = 0
26192  } else if (end > len) {
26193    end = len
26194  }
26195
26196  if (end < start) end = start
26197
26198  var newBuf
26199  if (Buffer.TYPED_ARRAY_SUPPORT) {
26200    newBuf = this.subarray(start, end)
26201    newBuf.__proto__ = Buffer.prototype
26202  } else {
26203    var sliceLen = end - start
26204    newBuf = new Buffer(sliceLen, undefined)
26205    for (var i = 0; i < sliceLen; ++i) {
26206      newBuf[i] = this[i + start]
26207    }
26208  }
26209
26210  return newBuf
26211}
26212
26213/*
26214 * Need to make sure that buffer isn't trying to write out of bounds.
26215 */
26216function checkOffset (offset, ext, length) {
26217  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
26218  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
26219}
26220
26221Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
26222  offset = offset | 0
26223  byteLength = byteLength | 0
26224  if (!noAssert) checkOffset(offset, byteLength, this.length)
26225
26226  var val = this[offset]
26227  var mul = 1
26228  var i = 0
26229  while (++i < byteLength && (mul *= 0x100)) {
26230    val += this[offset + i] * mul
26231  }
26232
26233  return val
26234}
26235
26236Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
26237  offset = offset | 0
26238  byteLength = byteLength | 0
26239  if (!noAssert) {
26240    checkOffset(offset, byteLength, this.length)
26241  }
26242
26243  var val = this[offset + --byteLength]
26244  var mul = 1
26245  while (byteLength > 0 && (mul *= 0x100)) {
26246    val += this[offset + --byteLength] * mul
26247  }
26248
26249  return val
26250}
26251
26252Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
26253  if (!noAssert) checkOffset(offset, 1, this.length)
26254  return this[offset]
26255}
26256
26257Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
26258  if (!noAssert) checkOffset(offset, 2, this.length)
26259  return this[offset] | (this[offset + 1] << 8)
26260}
26261
26262Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
26263  if (!noAssert) checkOffset(offset, 2, this.length)
26264  return (this[offset] << 8) | this[offset + 1]
26265}
26266
26267Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
26268  if (!noAssert) checkOffset(offset, 4, this.length)
26269
26270  return ((this[offset]) |
26271      (this[offset + 1] << 8) |
26272      (this[offset + 2] << 16)) +
26273      (this[offset + 3] * 0x1000000)
26274}
26275
26276Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
26277  if (!noAssert) checkOffset(offset, 4, this.length)
26278
26279  return (this[offset] * 0x1000000) +
26280    ((this[offset + 1] << 16) |
26281    (this[offset + 2] << 8) |
26282    this[offset + 3])
26283}
26284
26285Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
26286  offset = offset | 0
26287  byteLength = byteLength | 0
26288  if (!noAssert) checkOffset(offset, byteLength, this.length)
26289
26290  var val = this[offset]
26291  var mul = 1
26292  var i = 0
26293  while (++i < byteLength && (mul *= 0x100)) {
26294    val += this[offset + i] * mul
26295  }
26296  mul *= 0x80
26297
26298  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
26299
26300  return val
26301}
26302
26303Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
26304  offset = offset | 0
26305  byteLength = byteLength | 0
26306  if (!noAssert) checkOffset(offset, byteLength, this.length)
26307
26308  var i = byteLength
26309  var mul = 1
26310  var val = this[offset + --i]
26311  while (i > 0 && (mul *= 0x100)) {
26312    val += this[offset + --i] * mul
26313  }
26314  mul *= 0x80
26315
26316  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
26317
26318  return val
26319}
26320
26321Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
26322  if (!noAssert) checkOffset(offset, 1, this.length)
26323  if (!(this[offset] & 0x80)) return (this[offset])
26324  return ((0xff - this[offset] + 1) * -1)
26325}
26326
26327Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
26328  if (!noAssert) checkOffset(offset, 2, this.length)
26329  var val = this[offset] | (this[offset + 1] << 8)
26330  return (val & 0x8000) ? val | 0xFFFF0000 : val
26331}
26332
26333Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
26334  if (!noAssert) checkOffset(offset, 2, this.length)
26335  var val = this[offset + 1] | (this[offset] << 8)
26336  return (val & 0x8000) ? val | 0xFFFF0000 : val
26337}
26338
26339Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
26340  if (!noAssert) checkOffset(offset, 4, this.length)
26341
26342  return (this[offset]) |
26343    (this[offset + 1] << 8) |
26344    (this[offset + 2] << 16) |
26345    (this[offset + 3] << 24)
26346}
26347
26348Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
26349  if (!noAssert) checkOffset(offset, 4, this.length)
26350
26351  return (this[offset] << 24) |
26352    (this[offset + 1] << 16) |
26353    (this[offset + 2] << 8) |
26354    (this[offset + 3])
26355}
26356
26357Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
26358  if (!noAssert) checkOffset(offset, 4, this.length)
26359  return ieee754.read(this, offset, true, 23, 4)
26360}
26361
26362Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
26363  if (!noAssert) checkOffset(offset, 4, this.length)
26364  return ieee754.read(this, offset, false, 23, 4)
26365}
26366
26367Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
26368  if (!noAssert) checkOffset(offset, 8, this.length)
26369  return ieee754.read(this, offset, true, 52, 8)
26370}
26371
26372Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
26373  if (!noAssert) checkOffset(offset, 8, this.length)
26374  return ieee754.read(this, offset, false, 52, 8)
26375}
26376
26377function checkInt (buf, value, offset, ext, max, min) {
26378  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
26379  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
26380  if (offset + ext > buf.length) throw new RangeError('Index out of range')
26381}
26382
26383Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
26384  value = +value
26385  offset = offset | 0
26386  byteLength = byteLength | 0
26387  if (!noAssert) {
26388    var maxBytes = Math.pow(2, 8 * byteLength) - 1
26389    checkInt(this, value, offset, byteLength, maxBytes, 0)
26390  }
26391
26392  var mul = 1
26393  var i = 0
26394  this[offset] = value & 0xFF
26395  while (++i < byteLength && (mul *= 0x100)) {
26396    this[offset + i] = (value / mul) & 0xFF
26397  }
26398
26399  return offset + byteLength
26400}
26401
26402Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
26403  value = +value
26404  offset = offset | 0
26405  byteLength = byteLength | 0
26406  if (!noAssert) {
26407    var maxBytes = Math.pow(2, 8 * byteLength) - 1
26408    checkInt(this, value, offset, byteLength, maxBytes, 0)
26409  }
26410
26411  var i = byteLength - 1
26412  var mul = 1
26413  this[offset + i] = value & 0xFF
26414  while (--i >= 0 && (mul *= 0x100)) {
26415    this[offset + i] = (value / mul) & 0xFF
26416  }
26417
26418  return offset + byteLength
26419}
26420
26421Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
26422  value = +value
26423  offset = offset | 0
26424  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
26425  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
26426  this[offset] = (value & 0xff)
26427  return offset + 1
26428}
26429
26430function objectWriteUInt16 (buf, value, offset, littleEndian) {
26431  if (value < 0) value = 0xffff + value + 1
26432  for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
26433    buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
26434      (littleEndian ? i : 1 - i) * 8
26435  }
26436}
26437
26438Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
26439  value = +value
26440  offset = offset | 0
26441  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
26442  if (Buffer.TYPED_ARRAY_SUPPORT) {
26443    this[offset] = (value & 0xff)
26444    this[offset + 1] = (value >>> 8)
26445  } else {
26446    objectWriteUInt16(this, value, offset, true)
26447  }
26448  return offset + 2
26449}
26450
26451Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
26452  value = +value
26453  offset = offset | 0
26454  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
26455  if (Buffer.TYPED_ARRAY_SUPPORT) {
26456    this[offset] = (value >>> 8)
26457    this[offset + 1] = (value & 0xff)
26458  } else {
26459    objectWriteUInt16(this, value, offset, false)
26460  }
26461  return offset + 2
26462}
26463
26464function objectWriteUInt32 (buf, value, offset, littleEndian) {
26465  if (value < 0) value = 0xffffffff + value + 1
26466  for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
26467    buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
26468  }
26469}
26470
26471Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
26472  value = +value
26473  offset = offset | 0
26474  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
26475  if (Buffer.TYPED_ARRAY_SUPPORT) {
26476    this[offset + 3] = (value >>> 24)
26477    this[offset + 2] = (value >>> 16)
26478    this[offset + 1] = (value >>> 8)
26479    this[offset] = (value & 0xff)
26480  } else {
26481    objectWriteUInt32(this, value, offset, true)
26482  }
26483  return offset + 4
26484}
26485
26486Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
26487  value = +value
26488  offset = offset | 0
26489  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
26490  if (Buffer.TYPED_ARRAY_SUPPORT) {
26491    this[offset] = (value >>> 24)
26492    this[offset + 1] = (value >>> 16)
26493    this[offset + 2] = (value >>> 8)
26494    this[offset + 3] = (value & 0xff)
26495  } else {
26496    objectWriteUInt32(this, value, offset, false)
26497  }
26498  return offset + 4
26499}
26500
26501Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
26502  value = +value
26503  offset = offset | 0
26504  if (!noAssert) {
26505    var limit = Math.pow(2, 8 * byteLength - 1)
26506
26507    checkInt(this, value, offset, byteLength, limit - 1, -limit)
26508  }
26509
26510  var i = 0
26511  var mul = 1
26512  var sub = 0
26513  this[offset] = value & 0xFF
26514  while (++i < byteLength && (mul *= 0x100)) {
26515    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
26516      sub = 1
26517    }
26518    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
26519  }
26520
26521  return offset + byteLength
26522}
26523
26524Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
26525  value = +value
26526  offset = offset | 0
26527  if (!noAssert) {
26528    var limit = Math.pow(2, 8 * byteLength - 1)
26529
26530    checkInt(this, value, offset, byteLength, limit - 1, -limit)
26531  }
26532
26533  var i = byteLength - 1
26534  var mul = 1
26535  var sub = 0
26536  this[offset + i] = value & 0xFF
26537  while (--i >= 0 && (mul *= 0x100)) {
26538    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
26539      sub = 1
26540    }
26541    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
26542  }
26543
26544  return offset + byteLength
26545}
26546
26547Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
26548  value = +value
26549  offset = offset | 0
26550  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
26551  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
26552  if (value < 0) value = 0xff + value + 1
26553  this[offset] = (value & 0xff)
26554  return offset + 1
26555}
26556
26557Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
26558  value = +value
26559  offset = offset | 0
26560  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
26561  if (Buffer.TYPED_ARRAY_SUPPORT) {
26562    this[offset] = (value & 0xff)
26563    this[offset + 1] = (value >>> 8)
26564  } else {
26565    objectWriteUInt16(this, value, offset, true)
26566  }
26567  return offset + 2
26568}
26569
26570Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
26571  value = +value
26572  offset = offset | 0
26573  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
26574  if (Buffer.TYPED_ARRAY_SUPPORT) {
26575    this[offset] = (value >>> 8)
26576    this[offset + 1] = (value & 0xff)
26577  } else {
26578    objectWriteUInt16(this, value, offset, false)
26579  }
26580  return offset + 2
26581}
26582
26583Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
26584  value = +value
26585  offset = offset | 0
26586  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
26587  if (Buffer.TYPED_ARRAY_SUPPORT) {
26588    this[offset] = (value & 0xff)
26589    this[offset + 1] = (value >>> 8)
26590    this[offset + 2] = (value >>> 16)
26591    this[offset + 3] = (value >>> 24)
26592  } else {
26593    objectWriteUInt32(this, value, offset, true)
26594  }
26595  return offset + 4
26596}
26597
26598Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
26599  value = +value
26600  offset = offset | 0
26601  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
26602  if (value < 0) value = 0xffffffff + value + 1
26603  if (Buffer.TYPED_ARRAY_SUPPORT) {
26604    this[offset] = (value >>> 24)
26605    this[offset + 1] = (value >>> 16)
26606    this[offset + 2] = (value >>> 8)
26607    this[offset + 3] = (value & 0xff)
26608  } else {
26609    objectWriteUInt32(this, value, offset, false)
26610  }
26611  return offset + 4
26612}
26613
26614function checkIEEE754 (buf, value, offset, ext, max, min) {
26615  if (offset + ext > buf.length) throw new RangeError('Index out of range')
26616  if (offset < 0) throw new RangeError('Index out of range')
26617}
26618
26619function writeFloat (buf, value, offset, littleEndian, noAssert) {
26620  if (!noAssert) {
26621    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
26622  }
26623  ieee754.write(buf, value, offset, littleEndian, 23, 4)
26624  return offset + 4
26625}
26626
26627Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
26628  return writeFloat(this, value, offset, true, noAssert)
26629}
26630
26631Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
26632  return writeFloat(this, value, offset, false, noAssert)
26633}
26634
26635function writeDouble (buf, value, offset, littleEndian, noAssert) {
26636  if (!noAssert) {
26637    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
26638  }
26639  ieee754.write(buf, value, offset, littleEndian, 52, 8)
26640  return offset + 8
26641}
26642
26643Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
26644  return writeDouble(this, value, offset, true, noAssert)
26645}
26646
26647Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
26648  return writeDouble(this, value, offset, false, noAssert)
26649}
26650
26651// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
26652Buffer.prototype.copy = function copy (target, targetStart, start, end) {
26653  if (!start) start = 0
26654  if (!end && end !== 0) end = this.length
26655  if (targetStart >= target.length) targetStart = target.length
26656  if (!targetStart) targetStart = 0
26657  if (end > 0 && end < start) end = start
26658
26659  // Copy 0 bytes; we're done
26660  if (end === start) return 0
26661  if (target.length === 0 || this.length === 0) return 0
26662
26663  // Fatal error conditions
26664  if (targetStart < 0) {
26665    throw new RangeError('targetStart out of bounds')
26666  }
26667  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
26668  if (end < 0) throw new RangeError('sourceEnd out of bounds')
26669
26670  // Are we oob?
26671  if (end > this.length) end = this.length
26672  if (target.length - targetStart < end - start) {
26673    end = target.length - targetStart + start
26674  }
26675
26676  var len = end - start
26677  var i
26678
26679  if (this === target && start < targetStart && targetStart < end) {
26680    // descending copy from end
26681    for (i = len - 1; i >= 0; --i) {
26682      target[i + targetStart] = this[i + start]
26683    }
26684  } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
26685    // ascending copy from start
26686    for (i = 0; i < len; ++i) {
26687      target[i + targetStart] = this[i + start]
26688    }
26689  } else {
26690    Uint8Array.prototype.set.call(
26691      target,
26692      this.subarray(start, start + len),
26693      targetStart
26694    )
26695  }
26696
26697  return len
26698}
26699
26700// Usage:
26701//    buffer.fill(number[, offset[, end]])
26702//    buffer.fill(buffer[, offset[, end]])
26703//    buffer.fill(string[, offset[, end]][, encoding])
26704Buffer.prototype.fill = function fill (val, start, end, encoding) {
26705  // Handle string cases:
26706  if (typeof val === 'string') {
26707    if (typeof start === 'string') {
26708      encoding = start
26709      start = 0
26710      end = this.length
26711    } else if (typeof end === 'string') {
26712      encoding = end
26713      end = this.length
26714    }
26715    if (val.length === 1) {
26716      var code = val.charCodeAt(0)
26717      if (code < 256) {
26718        val = code
26719      }
26720    }
26721    if (encoding !== undefined && typeof encoding !== 'string') {
26722      throw new TypeError('encoding must be a string')
26723    }
26724    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
26725      throw new TypeError('Unknown encoding: ' + encoding)
26726    }
26727  } else if (typeof val === 'number') {
26728    val = val & 255
26729  }
26730
26731  // Invalid ranges are not set to a default, so can range check early.
26732  if (start < 0 || this.length < start || this.length < end) {
26733    throw new RangeError('Out of range index')
26734  }
26735
26736  if (end <= start) {
26737    return this
26738  }
26739
26740  start = start >>> 0
26741  end = end === undefined ? this.length : end >>> 0
26742
26743  if (!val) val = 0
26744
26745  var i
26746  if (typeof val === 'number') {
26747    for (i = start; i < end; ++i) {
26748      this[i] = val
26749    }
26750  } else {
26751    var bytes = Buffer.isBuffer(val)
26752      ? val
26753      : utf8ToBytes(new Buffer(val, encoding).toString())
26754    var len = bytes.length
26755    for (i = 0; i < end - start; ++i) {
26756      this[i + start] = bytes[i % len]
26757    }
26758  }
26759
26760  return this
26761}
26762
26763// HELPER FUNCTIONS
26764// ================
26765
26766var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
26767
26768function base64clean (str) {
26769  // Node strips out invalid characters like \n and \t from the string, base64-js does not
26770  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
26771  // Node converts strings with length < 2 to ''
26772  if (str.length < 2) return ''
26773  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
26774  while (str.length % 4 !== 0) {
26775    str = str + '='
26776  }
26777  return str
26778}
26779
26780function stringtrim (str) {
26781  if (str.trim) return str.trim()
26782  return str.replace(/^\s+|\s+$/g, '')
26783}
26784
26785function toHex (n) {
26786  if (n < 16) return '0' + n.toString(16)
26787  return n.toString(16)
26788}
26789
26790function utf8ToBytes (string, units) {
26791  units = units || Infinity
26792  var codePoint
26793  var length = string.length
26794  var leadSurrogate = null
26795  var bytes = []
26796
26797  for (var i = 0; i < length; ++i) {
26798    codePoint = string.charCodeAt(i)
26799
26800    // is surrogate component
26801    if (codePoint > 0xD7FF && codePoint < 0xE000) {
26802      // last char was a lead
26803      if (!leadSurrogate) {
26804        // no lead yet
26805        if (codePoint > 0xDBFF) {
26806          // unexpected trail
26807          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
26808          continue
26809        } else if (i + 1 === length) {
26810          // unpaired lead
26811          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
26812          continue
26813        }
26814
26815        // valid lead
26816        leadSurrogate = codePoint
26817
26818        continue
26819      }
26820
26821      // 2 leads in a row
26822      if (codePoint < 0xDC00) {
26823        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
26824        leadSurrogate = codePoint
26825        continue
26826      }
26827
26828      // valid surrogate pair
26829      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
26830    } else if (leadSurrogate) {
26831      // valid bmp char, but last char was a lead
26832      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
26833    }
26834
26835    leadSurrogate = null
26836
26837    // encode utf8
26838    if (codePoint < 0x80) {
26839      if ((units -= 1) < 0) break
26840      bytes.push(codePoint)
26841    } else if (codePoint < 0x800) {
26842      if ((units -= 2) < 0) break
26843      bytes.push(
26844        codePoint >> 0x6 | 0xC0,
26845        codePoint & 0x3F | 0x80
26846      )
26847    } else if (codePoint < 0x10000) {
26848      if ((units -= 3) < 0) break
26849      bytes.push(
26850        codePoint >> 0xC | 0xE0,
26851        codePoint >> 0x6 & 0x3F | 0x80,
26852        codePoint & 0x3F | 0x80
26853      )
26854    } else if (codePoint < 0x110000) {
26855      if ((units -= 4) < 0) break
26856      bytes.push(
26857        codePoint >> 0x12 | 0xF0,
26858        codePoint >> 0xC & 0x3F | 0x80,
26859        codePoint >> 0x6 & 0x3F | 0x80,
26860        codePoint & 0x3F | 0x80
26861      )
26862    } else {
26863      throw new Error('Invalid code point')
26864    }
26865  }
26866
26867  return bytes
26868}
26869
26870function asciiToBytes (str) {
26871  var byteArray = []
26872  for (var i = 0; i < str.length; ++i) {
26873    // Node's code seems to be doing this and not & 0x7F..
26874    byteArray.push(str.charCodeAt(i) & 0xFF)
26875  }
26876  return byteArray
26877}
26878
26879function utf16leToBytes (str, units) {
26880  var c, hi, lo
26881  var byteArray = []
26882  for (var i = 0; i < str.length; ++i) {
26883    if ((units -= 2) < 0) break
26884
26885    c = str.charCodeAt(i)
26886    hi = c >> 8
26887    lo = c % 256
26888    byteArray.push(lo)
26889    byteArray.push(hi)
26890  }
26891
26892  return byteArray
26893}
26894
26895function base64ToBytes (str) {
26896  return base64.toByteArray(base64clean(str))
26897}
26898
26899function blitBuffer (src, dst, offset, length) {
26900  for (var i = 0; i < length; ++i) {
26901    if ((i + offset >= dst.length) || (i >= src.length)) break
26902    dst[i + offset] = src[i]
26903  }
26904  return i
26905}
26906
26907function isnan (val) {
26908  return val !== val // eslint-disable-line no-self-compare
26909}
26910
26911/* WEBPACK VAR INJECTION */}.call(
vendor: 5,512 bytes, lines 26911-27095
26911exports, __webpack_require__(3).Buffer, __webpack_require__(6)))
26912
26913/***/ },
26914/* 4 */
26915/***/ function(module, exports, __webpack_require__) {
26916
26917"use strict";
26918'use strict';
26919
26920var curve = exports;
26921
26922curve.base = __webpack_require__(14);
26923curve.short = __webpack_require__(17);
26924curve.mont = __webpack_require__(16);
26925curve.edwards = __webpack_require__(15);
26926
26927
26928/***/ },
26929/* 5 */
26930/***/ function(module, exports) {
26931
26932if (typeof Object.create === 'function') {
26933  // implementation from standard node.js 'util' module
26934  module.exports = function inherits(ctor, superCtor) {
26935    ctor.super_ = superCtor
26936    ctor.prototype = Object.create(superCtor.prototype, {
26937      constructor: {
26938        value: ctor,
26939        enumerable: false,
26940        writable: true,
26941        configurable: true
26942      }
26943    });
26944  };
26945} else {
26946  // old school shim for old browsers
26947  module.exports = function inherits(ctor, superCtor) {
26948    ctor.super_ = superCtor
26949    var TempCtor = function () {}
26950    TempCtor.prototype = superCtor.prototype
26951    ctor.prototype = new TempCtor()
26952    ctor.prototype.constructor = ctor
26953  }
26954}
26955
26956
26957/***/ },
26958/* 6 */
26959/***/ function(module, exports) {
26960
26961var g;
26962
26963// This works in non-strict mode
26964g = (function() { return this; })();
26965
26966try {
26967	// This works if eval is allowed (see CSP)
26968	g = g || Function("return this")() || (1,eval)("this");
26969} catch(e) {
26970	// This works if the window reference is available
26971	if(typeof window === "object")
26972		g = window;
26973}
26974
26975// g can still be undefined, but nothing to do about it...
26976// We return undefined, instead of nothing here, so it's
26977// easier to handle this case. if(!global) { ...}
26978
26979module.exports = g;
26980
26981
26982/***/ },
26983/* 7 */
26984/***/ function(module, exports) {
26985
26986/**
26987 * Returns a `Boolean` on whether or not the a `String` starts with '0x'
26988 * @param {String} str the string input value
26989 * @return {Boolean} a boolean if it is or is not hex prefixed
26990 * @throws if the str input is not a string
26991 */
26992module.exports = function isHexPrefixed(str) {
26993  if (typeof str !== 'string') {
26994    throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed.");
26995  }
26996
26997  return str.slice(0, 2) === '0x';
26998}
26999
27000
27001/***/ },
27002/* 8 */
27003/***/ function(module, exports) {
27004
27005// shim for using process in browser
27006var process = module.exports = {};
27007
27008// cached from whatever global is present so that test runners that stub it
27009// don't break things.  But we need to wrap it in a try catch in case it is
27010// wrapped in strict mode code which doesn't define any globals.  It's inside a
27011// function because try/catches deoptimize in certain engines.
27012
27013var cachedSetTimeout;
27014var cachedClearTimeout;
27015
27016function defaultSetTimout() {
27017    throw new Error('setTimeout has not been defined');
27018}
27019function defaultClearTimeout () {
27020    throw new Error('clearTimeout has not been defined');
27021}
27022(function () {
27023    try {
27024        if (typeof setTimeout === 'function') {
27025            cachedSetTimeout = setTimeout;
27026        } else {
27027            cachedSetTimeout = defaultSetTimout;
27028        }
27029    } catch (e) {
27030        cachedSetTimeout = defaultSetTimout;
27031    }
27032    try {
27033        if (typeof clearTimeout === 'function') {
27034            cachedClearTimeout = clearTimeout;
27035        } else {
27036            cachedClearTimeout = defaultClearTimeout;
27037        }
27038    } catch (e) {
27039        cachedClearTimeout = defaultClearTimeout;
27040    }
27041} ())
27042function runTimeout(fun) {
27043    if (cachedSetTimeout === setTimeout) {
27044        //normal enviroments in sane situations
27045        return setTimeout(fun, 0);
27046    }
27047    // if setTimeout wasn't available but was latter defined
27048    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
27049        cachedSetTimeout = setTimeout;
27050        return setTimeout(fun, 0);
27051    }
27052    try {
27053        // when when somebody has screwed with setTimeout but no I.E. maddness
27054        return cachedSetTimeout(fun, 0);
27055    } catch(e){
27056        try {
27057            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
27058            return cachedSetTimeout.call(null, fun, 0);
27059        } catch(e){
27060            // 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
27061            return cachedSetTimeout.call(this, fun, 0);
27062        }
27063    }
27064
27065
27066}
27067function runClearTimeout(marker) {
27068    if (cachedClearTimeout === clearTimeout) {
27069        //normal enviroments in sane situations
27070        return clearTimeout(marker);
27071    }
27072    // if clearTimeout wasn't available but was latter defined
27073    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
27074        cachedClearTimeout = clearTimeout;
27075        return clearTimeout(marker);
27076    }
27077    try {
27078        // when when somebody has screwed with setTimeout but no I.E. maddness
27079        return cachedClearTimeout(marker);
27080    } catch (e){
27081        try {
27082            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
27083            return cachedClearTimeout.call(null, marker);
27084        } catch (e){
27085            // 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.
27086            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
27087            return cachedClearTimeout.call(this, marker);
27088        }
27089    }
27090
27091
27092
27093}
27094var queue = [];
27095var draining = false;
27096var currentQueue;
27097var queueIndex = -1;
27098
27099function cleanUpNextTick() {
27100    if (!draining || !currentQueue) {
27101        return;
27102    }
27103    draining = false;
27104    if (currentQueue.length) {
27105        queue = currentQueue.concat(queue);
27106    } else {
27107        queueIndex = -1;
27108    }
27109    if (queue.length) {
27110        drainQueue();
27111    }
27112}
27113
27114function drainQueue() {
27115    if (draining) {
27116        return;
27117    }
27118    var timeout = runTimeout(cleanUpNextTick);
27119    draining = true;
27120
27121    var len = queue.length;
27122    while(len) {
27123        currentQueue = queue;
27124        queue = [];
27125        while (++queueIndex < len) {
27126            if (currentQueue) {
27127                currentQueue[queueIndex].run();
27128            }
27129        }
27130        queueIndex = -1;
27131        len = queue.length;
27132    }
27133    currentQueue = null;
27134    draining = false;
27135    runClearTimeout(timeout);
27136}
27137
27138process.nextTick = function (fun) {
27139    var args = new Array(arguments.length - 1);
27140    if (arguments.length > 1) {
27141        for (var i = 1; i < arguments.length; i++) {
27142            args[i - 1] = arguments[i];
27143        }
27144    }
27145    queue.push(new Item(fun, args));
27146    if (queue.length === 1 && !draining) {
27147        runTimeout(drainQueue);
27148    }
27149};
27150
27151// v8 likes predictible objects
27152function Item(fun, array) {
27153    this.fun = fun;
27154    this.array = array;
27155}
27156Item.prototype.run = function () {
27157    this.fun.apply(null, this.array);
27158};
27159process.title = 'browser';
27160process.browser = true;
27161process.env = {};
27162process.argv = [];
27163process.version = ''; // empty string to avoid regexp issues
27164process.versions = {};
27165
27166function noop() {}
27167
27168process.on = noop;
27169process.addListener = noop;
27170process.once = noop;
27171process.off = noop;
27172process.removeListener = noop;
27173process.removeAllListeners = noop;
27174process.emit = noop;
27175
27176process.binding = function (name) {
27177    throw new Error('process.binding is not supported');
27178};
27179
27180process.cwd = function () { return '/' };
27181process.chdir = function (dir) {
27182    throw new Error('process.chdir is not supported');
27183};
27184process.umask = function() { return 0; };
27185
27186
27187/***/ },
27188/* 9 */
27189/***/ function(module, exports, __webpack_require__) {
27190
27191var isHexPrefixed = __webpack_require__(7);
27192
27193/**
27194 * Removes '0x' from a given `String` is present
27195 * @param {String} str the string value
27196 * @return {String|Optional} a string by pass if necessary
27197 */
27198module.exports = function stripHexPrefix(str) {
27199  if (typeof str !== 'string') {
27200    return str;
27201  }
27202
27203  return isHexPrefixed(str) ? str.slice(2) : str;
27204}
27205
27206
27207/***/ },
27208/* 10 */
27209/***/ function(module, exports, __webpack_require__) {
27210
27211"use strict";
27212/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
27213
27214var rlp = __webpack_require__(38);
27215var elliptic = __webpack_require__(0);
27216var keccak256 = __webpack_require__(35).keccak_256;
27217var secp256k1 = new elliptic.ec('secp256k1'); // eslint-disable-line
27218var stripHexPrefix = __webpack_require__(9);
27219var numberToBN = __webpack_require__(37);
27220
27221function stripZeros(buffer) {
27222  var i = 0; // eslint-disable-line
27223  for (i = 0; i < buffer.length; i++) {
27224    if (buffer[i] !== 0) {
27225      break;
27226    }
27227  }
27228  return i > 0 ? buffer.slice(i) : buffer;
27229}
27230
27231function padToEven(str) {
27232  return str.length % 2 ? '0' + str : str;
27233}
27234
27235function bnToBuffer(bn) {
27236  return stripZeros(new Buffer(padToEven(bn.toString(16)), 'hex'));
27237}
27238
27239var transactionFields = [{ name: 'nonce', maxLength: 32, number: true }, { name: 'gasPrice', maxLength: 32, number: true }, { name: 'gasLimit', maxLength: 32, number: true }, { name: 'to', length: 20 }, { name: 'value', maxLength: 32, number: true }, { name: 'data' }];
27240
27241/**
27242 * ECDSA public key recovery from a rawTransaction
27243 *
27244 * @method recover
27245 * @param {String|Buffer} rawTransaction either a hex string or buffer instance
27246 * @param {Number} v
27247 * @param {Buffer} r
27248 * @param {Buffer} s
27249 * @return {Buffer} publicKey
27250 */
27251
27252function recover(rawTx, v, r, s) {
27253  var rawTransaction = typeof rawTx === 'string' ? new Buffer(stripHexPrefix(rawTx), 'hex') : rawTx;
27254  var signedTransaction = rlp.decode(rawTransaction);
27255  var raw = [];
27256
27257  transactionFields.forEach(function (fieldInfo, fieldIndex) {
27258    raw[fieldIndex] = signedTransaction[fieldIndex];
27259  });
27260
27261  var publicKey = secp256k1.recoverPubKey(new Buffer(keccak256(rlp.encode(raw)), 'hex'), { r: r, s: s }, v - 27);
27262  return new Buffer(publicKey.encode('hex', false), 'hex').slice(1);
27263}
27264
27265/**
27266 * Will sign a raw transaction and return it either as a serlized hex string or raw tx object.
27267 *
27268 * @method sign
27269 * @param {Object} transaction a valid transaction object
27270 * @param {String} privateKey a valid 32 byte prefixed hex string private key
27271 * @param {Boolean} toObject **Optional**
27272 * @returns {String|Object} output either a serilized hex string or signed tx object
27273 */
27274
27275function sign(transaction, privateKey, toObject) {
27276  if (typeof transaction !== 'object' || transaction === null) {
27277    throw new Error('[ethjs-signer] transaction input must be a type \'object\', got \'' + typeof transaction + '\'');
27278  }
27279  if (typeof privateKey !== 'string') {
27280    throw new Error('[ethjs-signer] private key input must be a string');
27281  }
27282  if (!privateKey.match(/^(0x)[0-9a-fA-F]{64}$/)) {
27283    throw new Error('[ethjs-signer] invalid private key value, private key must be a prefixed hexified 32 byte string (i.e. "0x..." 64 chars long).');
27284  }
27285
27286  var raw = [];
27287
27288  transactionFields.forEach(function (fieldInfo) {
27289    var value = new Buffer(0); // eslint-disable-line
27290
27291    // shim for field name gas
27292    var txKey = fieldInfo.name === 'gasLimit' && transaction.gas ? 'gas' : fieldInfo.name;
27293
27294    if (typeof transaction[txKey] !== 'undefined') {
27295      if (fieldInfo.number === true) {
27296        value = bnToBuffer(numberToBN(transaction[txKey]));
27297      } else {
27298        value = new Buffer(padToEven(stripHexPrefix(transaction[txKey])), 'hex');
27299      }
27300    }
27301
27302    // Fixed-width field
27303    if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) {
27304      throw new Error('[ethjs-signer] while signing raw transaction, invalid \'' + fieldInfo.name + '\', invalid length should be \'' + fieldInfo.length + '\' got \'' + value.length + '\'');
27305    }
27306
27307    // Variable-width (with a maximum)
27308    if (fieldInfo.maxLength) {
27309      value = stripZeros(value);
27310      if (value.length > fieldInfo.maxLength) {
27311        throw new Error('[ethjs-signer] while signing raw transaction, invalid \'' + fieldInfo.name + '\' length, the max length is \'' + fieldInfo.maxLength + '\', got \'' + value.length + '\'');
27312      }
27313    }
27314
27315    raw.push(value);
27316  });
27317
27318  // private key is not stored in memory
27319  var signature = secp256k1.keyFromPrivate(new Buffer(privateKey.slice(2), 'hex')).sign(new Buffer(keccak256(rlp.encode(raw)), 'hex'), { canonical: true });
27320
27321  raw.push(new Buffer([27 + signature.recoveryParam]));
27322  raw.push(bnToBuffer(signature.r));
27323  raw.push(bnToBuffer(signature.s));
27324
27325  return toObject ? raw : '0x' + rlp.encode(raw).toString('hex');
27326}
27327
27328module.exports = {
27329  sign: sign,
27330  recover: recover
27331};
27332/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
27333
27334/***/ },
27335/* 11 */
27336/***/ function(module, exports, __webpack_require__) {
27337
27338"use strict";
27339/* WEBPACK VAR INJECTION */(function(global) {'use strict';
27340
27341// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
27342// original notice:
27343
27344/*!
27345 * The buffer module from node.js, for the browser.
27346 *
27347 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
27348 * @license  MIT
27349 */
27350function compare(a, b) {
27351  if (a === b) {
27352    return 0;
27353  }
27354
27355  var x = a.length;
27356  var y = b.length;
27357
27358  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
27359    if (a[i] !== b[i]) {
27360      x = a[i];
27361      y = b[i];
27362      break;
27363    }
27364  }
27365
27366  if (x < y) {
27367    return -1;
27368  }
27369  if (y < x) {
27370    return 1;
27371  }
27372  return 0;
27373}
27374function isBuffer(b) {
27375  if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
27376    return global.Buffer.isBuffer(b);
27377  }
27378  return !!(b != null && b._isBuffer);
27379}
27380
27381// based on node assert, original notice:
27382
27383// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
27384//
27385// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
27386//
27387// Originally from narwhal.js (http://narwhaljs.org)
27388// Copyright (c) 2009 Thomas Robinson <280north.com>
27389//
27390// Permission is hereby granted, free of charge, to any person obtaining a copy
27391// of this software and associated documentation files (the 'Software'), to
27392// deal in the Software without restriction, including without limitation the
27393// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27394// sell copies of the Software, and to permit persons to whom the Software is
27395// furnished to do so, subject to the following conditions:
27396//
27397// The above copyright notice and this permission notice shall be included in
27398// all copies or substantial portions of the Software.
27399//
27400// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27401// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27402// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27403// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27404// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27405// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27406
27407var util = __webpack_require__(41
vendor: 13,137 bytes, lines 27407-27821
27407);
27408var hasOwn = Object.prototype.hasOwnProperty;
27409var pSlice = Array.prototype.slice;
27410var functionsHaveNames = (function () {
27411  return function foo() {}.name === 'foo';
27412}());
27413function pToString (obj) {
27414  return Object.prototype.toString.call(obj);
27415}
27416function isView(arrbuf) {
27417  if (isBuffer(arrbuf)) {
27418    return false;
27419  }
27420  if (typeof global.ArrayBuffer !== 'function') {
27421    return false;
27422  }
27423  if (typeof ArrayBuffer.isView === 'function') {
27424    return ArrayBuffer.isView(arrbuf);
27425  }
27426  if (!arrbuf) {
27427    return false;
27428  }
27429  if (arrbuf instanceof DataView) {
27430    return true;
27431  }
27432  if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
27433    return true;
27434  }
27435  return false;
27436}
27437// 1. The assert module provides functions that throw
27438// AssertionError's when particular conditions are not met. The
27439// assert module must conform to the following interface.
27440
27441var assert = module.exports = ok;
27442
27443// 2. The AssertionError is defined in assert.
27444// new assert.AssertionError({ message: message,
27445//                             actual: actual,
27446//                             expected: expected })
27447
27448var regex = /\s*function\s+([^\(\s]*)\s*/;
27449// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
27450function getName(func) {
27451  if (!util.isFunction(func)) {
27452    return;
27453  }
27454  if (functionsHaveNames) {
27455    return func.name;
27456  }
27457  var str = func.toString();
27458  var match = str.match(regex);
27459  return match && match[1];
27460}
27461assert.AssertionError = function AssertionError(options) {
27462  this.name = 'AssertionError';
27463  this.actual = options.actual;
27464  this.expected = options.expected;
27465  this.operator = options.operator;
27466  if (options.message) {
27467    this.message = options.message;
27468    this.generatedMessage = false;
27469  } else {
27470    this.message = getMessage(this);
27471    this.generatedMessage = true;
27472  }
27473  var stackStartFunction = options.stackStartFunction || fail;
27474  if (Error.captureStackTrace) {
27475    Error.captureStackTrace(this, stackStartFunction);
27476  } else {
27477    // non v8 browsers so we can have a stacktrace
27478    var err = new Error();
27479    if (err.stack) {
27480      var out = err.stack;
27481
27482      // try to strip useless frames
27483      var fn_name = getName(stackStartFunction);
27484      var idx = out.indexOf('\n' + fn_name);
27485      if (idx >= 0) {
27486        // once we have located the function frame
27487        // we need to strip out everything before it (and its line)
27488        var next_line = out.indexOf('\n', idx + 1);
27489        out = out.substring(next_line + 1);
27490      }
27491
27492      this.stack = out;
27493    }
27494  }
27495};
27496
27497// assert.AssertionError instanceof Error
27498util.inherits(assert.AssertionError, Error);
27499
27500function truncate(s, n) {
27501  if (typeof s === 'string') {
27502    return s.length < n ? s : s.slice(0, n);
27503  } else {
27504    return s;
27505  }
27506}
27507function inspect(something) {
27508  if (functionsHaveNames || !util.isFunction(something)) {
27509    return util.inspect(something);
27510  }
27511  var rawname = getName(something);
27512  var name = rawname ? ': ' + rawname : '';
27513  return '[Function' +  name + ']';
27514}
27515function getMessage(self) {
27516  return truncate(inspect(self.actual), 128) + ' ' +
27517         self.operator + ' ' +
27518         truncate(inspect(self.expected), 128);
27519}
27520
27521// At present only the three keys mentioned above are used and
27522// understood by the spec. Implementations or sub modules can pass
27523// other keys to the AssertionError's constructor - they will be
27524// ignored.
27525
27526// 3. All of the following functions must throw an AssertionError
27527// when a corresponding condition is not met, with a message that
27528// may be undefined if not provided.  All assertion methods provide
27529// both the actual and expected values to the assertion error for
27530// display purposes.
27531
27532function fail(actual, expected, message, operator, stackStartFunction) {
27533  throw new assert.AssertionError({
27534    message: message,
27535    actual: actual,
27536    expected: expected,
27537    operator: operator,
27538    stackStartFunction: stackStartFunction
27539  });
27540}
27541
27542// EXTENSION! allows for well behaved errors defined elsewhere.
27543assert.fail = fail;
27544
27545// 4. Pure assertion tests whether a value is truthy, as determined
27546// by !!guard.
27547// assert.ok(guard, message_opt);
27548// This statement is equivalent to assert.equal(true, !!guard,
27549// message_opt);. To test strictly for the value true, use
27550// assert.strictEqual(true, guard, message_opt);.
27551
27552function ok(value, message) {
27553  if (!value) fail(value, true, message, '==', assert.ok);
27554}
27555assert.ok = ok;
27556
27557// 5. The equality assertion tests shallow, coercive equality with
27558// ==.
27559// assert.equal(actual, expected, message_opt);
27560
27561assert.equal = function equal(actual, expected, message) {
27562  if (actual != expected) fail(actual, expected, message, '==', assert.equal);
27563};
27564
27565// 6. The non-equality assertion tests for whether two objects are not equal
27566// with != assert.notEqual(actual, expected, message_opt);
27567
27568assert.notEqual = function notEqual(actual, expected, message) {
27569  if (actual == expected) {
27570    fail(actual, expected, message, '!=', assert.notEqual);
27571  }
27572};
27573
27574// 7. The equivalence assertion tests a deep equality relation.
27575// assert.deepEqual(actual, expected, message_opt);
27576
27577assert.deepEqual = function deepEqual(actual, expected, message) {
27578  if (!_deepEqual(actual, expected, false)) {
27579    fail(actual, expected, message, 'deepEqual', assert.deepEqual);
27580  }
27581};
27582
27583assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
27584  if (!_deepEqual(actual, expected, true)) {
27585    fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
27586  }
27587};
27588
27589function _deepEqual(actual, expected, strict, memos) {
27590  // 7.1. All identical values are equivalent, as determined by ===.
27591  if (actual === expected) {
27592    return true;
27593  } else if (isBuffer(actual) && isBuffer(expected)) {
27594    return compare(actual, expected) === 0;
27595
27596  // 7.2. If the expected value is a Date object, the actual value is
27597  // equivalent if it is also a Date object that refers to the same time.
27598  } else if (util.isDate(actual) && util.isDate(expected)) {
27599    return actual.getTime() === expected.getTime();
27600
27601  // 7.3 If the expected value is a RegExp object, the actual value is
27602  // equivalent if it is also a RegExp object with the same source and
27603  // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
27604  } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
27605    return actual.source === expected.source &&
27606           actual.global === expected.global &&
27607           actual.multiline === expected.multiline &&
27608           actual.lastIndex === expected.lastIndex &&
27609           actual.ignoreCase === expected.ignoreCase;
27610
27611  // 7.4. Other pairs that do not both pass typeof value == 'object',
27612  // equivalence is determined by ==.
27613  } else if ((actual === null || typeof actual !== 'object') &&
27614             (expected === null || typeof expected !== 'object')) {
27615    return strict ? actual === expected : actual == expected;
27616
27617  // If both values are instances of typed arrays, wrap their underlying
27618  // ArrayBuffers in a Buffer each to increase performance
27619  // This optimization requires the arrays to have the same type as checked by
27620  // Object.prototype.toString (aka pToString). Never perform binary
27621  // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
27622  // bit patterns are not identical.
27623  } else if (isView(actual) && isView(expected) &&
27624             pToString(actual) === pToString(expected) &&
27625             !(actual instanceof Float32Array ||
27626               actual instanceof Float64Array)) {
27627    return compare(new Uint8Array(actual.buffer),
27628                   new Uint8Array(expected.buffer)) === 0;
27629
27630  // 7.5 For all other Object pairs, including Array objects, equivalence is
27631  // determined by having the same number of owned properties (as verified
27632  // with Object.prototype.hasOwnProperty.call), the same set of keys
27633  // (although not necessarily the same order), equivalent values for every
27634  // corresponding key, and an identical 'prototype' property. Note: this
27635  // accounts for both named and indexed properties on Arrays.
27636  } else if (isBuffer(actual) !== isBuffer(expected)) {
27637    return false;
27638  } else {
27639    memos = memos || {actual: [], expected: []};
27640
27641    var actualIndex = memos.actual.indexOf(actual);
27642    if (actualIndex !== -1) {
27643      if (actualIndex === memos.expected.indexOf(expected)) {
27644        return true;
27645      }
27646    }
27647
27648    memos.actual.push(actual);
27649    memos.expected.push(expected);
27650
27651    return objEquiv(actual, expected, strict, memos);
27652  }
27653}
27654
27655function isArguments(object) {
27656  return Object.prototype.toString.call(object) == '[object Arguments]';
27657}
27658
27659function objEquiv(a, b, strict, actualVisitedObjects) {
27660  if (a === null || a === undefined || b === null || b === undefined)
27661    return false;
27662  // if one is a primitive, the other must be same
27663  if (util.isPrimitive(a) || util.isPrimitive(b))
27664    return a === b;
27665  if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
27666    return false;
27667  var aIsArgs = isArguments(a);
27668  var bIsArgs = isArguments(b);
27669  if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
27670    return false;
27671  if (aIsArgs) {
27672    a = pSlice.call(a);
27673    b = pSlice.call(b);
27674    return _deepEqual(a, b, strict);
27675  }
27676  var ka = objectKeys(a);
27677  var kb = objectKeys(b);
27678  var key, i;
27679  // having the same number of owned properties (keys incorporates
27680  // hasOwnProperty)
27681  if (ka.length !== kb.length)
27682    return false;
27683  //the same set of keys (although not necessarily the same order),
27684  ka.sort();
27685  kb.sort();
27686  //~~~cheap key test
27687  for (i = ka.length - 1; i >= 0; i--) {
27688    if (ka[i] !== kb[i])
27689      return false;
27690  }
27691  //equivalent values for every corresponding key, and
27692  //~~~possibly expensive deep test
27693  for (i = ka.length - 1; i >= 0; i--) {
27694    key = ka[i];
27695    if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
27696      return false;
27697  }
27698  return true;
27699}
27700
27701// 8. The non-equivalence assertion tests for any deep inequality.
27702// assert.notDeepEqual(actual, expected, message_opt);
27703
27704assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
27705  if (_deepEqual(actual, expected, false)) {
27706    fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
27707  }
27708};
27709
27710assert.notDeepStrictEqual = notDeepStrictEqual;
27711function notDeepStrictEqual(actual, expected, message) {
27712  if (_deepEqual(actual, expected, true)) {
27713    fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
27714  }
27715}
27716
27717
27718// 9. The strict equality assertion tests strict equality, as determined by ===.
27719// assert.strictEqual(actual, expected, message_opt);
27720
27721assert.strictEqual = function strictEqual(actual, expected, message) {
27722  if (actual !== expected) {
27723    fail(actual, expected, message, '===', assert.strictEqual);
27724  }
27725};
27726
27727// 10. The strict non-equality assertion tests for strict inequality, as
27728// determined by !==.  assert.notStrictEqual(actual, expected, message_opt);
27729
27730assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
27731  if (actual === expected) {
27732    fail(actual, expected, message, '!==', assert.notStrictEqual);
27733  }
27734};
27735
27736function expectedException(actual, expected) {
27737  if (!actual || !expected) {
27738    return false;
27739  }
27740
27741  if (Object.prototype.toString.call(expected) == '[object RegExp]') {
27742    return expected.test(actual);
27743  }
27744
27745  try {
27746    if (actual instanceof expected) {
27747      return true;
27748    }
27749  } catch (e) {
27750    // Ignore.  The instanceof check doesn't work for arrow functions.
27751  }
27752
27753  if (Error.isPrototypeOf(expected)) {
27754    return false;
27755  }
27756
27757  return expected.call({}, actual) === true;
27758}
27759
27760function _tryBlock(block) {
27761  var error;
27762  try {
27763    block();
27764  } catch (e) {
27765    error = e;
27766  }
27767  return error;
27768}
27769
27770function _throws(shouldThrow, block, expected, message) {
27771  var actual;
27772
27773  if (typeof block !== 'function') {
27774    throw new TypeError('"block" argument must be a function');
27775  }
27776
27777  if (typeof expected === 'string') {
27778    message = expected;
27779    expected = null;
27780  }
27781
27782  actual = _tryBlock(block);
27783
27784  message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
27785            (message ? ' ' + message : '.');
27786
27787  if (shouldThrow && !actual) {
27788    fail(actual, expected, 'Missing expected exception' + message);
27789  }
27790
27791  var userProvidedMessage = typeof message === 'string';
27792  var isUnwantedException = !shouldThrow && util.isError(actual);
27793  var isUnexpectedException = !shouldThrow && actual && !expected;
27794
27795  if ((isUnwantedException &&
27796      userProvidedMessage &&
27797      expectedException(actual, expected)) ||
27798      isUnexpectedException) {
27799    fail(actual, expected, 'Got unwanted exception' + message);
27800  }
27801
27802  if ((shouldThrow && actual && expected &&
27803      !expectedException(actual, expected)) || (!shouldThrow && actual)) {
27804    throw actual;
27805  }
27806}
27807
27808// 11. Expected to throw an error:
27809// assert.throws(block, Error_opt, message_opt);
27810
27811assert.throws = function(block, /*optional*/error, /*optional*/message) {
27812  _throws(true, block, error, message);
27813};
27814
27815// EXTENSION! This is annoying to write outside this module.
27816assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
27817  _throws(false, block, error, message);
27818};
27819
27820assert.ifError = function(err) { if (err) throw err; };
27821
27822var objectKeys = Object.keys || function (obj) {
27823  var keys = [];
27824  for (var key in obj) {
27825    if (hasOwn.call(obj, key)) keys.push(key);
27826  }
27827  return keys;
27828};
27829
27830/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
27831
27832/***/ },
27833/* 12 */
vendor: 5,086 bytes, lines 27834-28024
27834/***/ function(module, exports) {
27835
27836"use strict";
27837'use strict'
27838
27839exports.byteLength = byteLength
27840exports.toByteArray = toByteArray
27841exports.fromByteArray = fromByteArray
27842
27843var lookup = []
27844var revLookup = []
27845var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
27846
27847var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
27848for (var i = 0, len = code.length; i < len; ++i) {
27849  lookup[i] = code[i]
27850  revLookup[code.charCodeAt(i)] = i
27851}
27852
27853revLookup['-'.charCodeAt(0)] = 62
27854revLookup['_'.charCodeAt(0)] = 63
27855
27856function placeHoldersCount (b64) {
27857  var len = b64.length
27858  if (len % 4 > 0) {
27859    throw new Error('Invalid string. Length must be a multiple of 4')
27860  }
27861
27862  // the number of equal signs (place holders)
27863  // if there are two placeholders, than the two characters before it
27864  // represent one byte
27865  // if there is only one, then the three characters before it represent 2 bytes
27866  // this is just a cheap hack to not do indexOf twice
27867  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
27868}
27869
27870function byteLength (b64) {
27871  // base64 is 4/3 + up to two characters of the original data
27872  return b64.length * 3 / 4 - placeHoldersCount(b64)
27873}
27874
27875function toByteArray (b64) {
27876  var i, j, l, tmp, placeHolders, arr
27877  var len = b64.length
27878  placeHolders = placeHoldersCount(b64)
27879
27880  arr = new Arr(len * 3 / 4 - placeHolders)
27881
27882  // if there are placeholders, only get up to the last complete 4 chars
27883  l = placeHolders > 0 ? len - 4 : len
27884
27885  var L = 0
27886
27887  for (i = 0, j = 0; i < l; i += 4, j += 3) {
27888    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
27889    arr[L++] = (tmp >> 16) & 0xFF
27890    arr[L++] = (tmp >> 8) & 0xFF
27891    arr[L++] = tmp & 0xFF
27892  }
27893
27894  if (placeHolders === 2) {
27895    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
27896    arr[L++] = tmp & 0xFF
27897  } else if (placeHolders === 1) {
27898    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
27899    arr[L++] = (tmp >> 8) & 0xFF
27900    arr[L++] = tmp & 0xFF
27901  }
27902
27903  return arr
27904}
27905
27906function tripletToBase64 (num) {
27907  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
27908}
27909
27910function encodeChunk (uint8, start, end) {
27911  var tmp
27912  var output = []
27913  for (var i = start; i < end; i += 3) {
27914    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
27915    output.push(tripletToBase64(tmp))
27916  }
27917  return output.join('')
27918}
27919
27920function fromByteArray (uint8) {
27921  var tmp
27922  var len = uint8.length
27923  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
27924  var output = ''
27925  var parts = []
27926  var maxChunkLength = 16383 // must be multiple of 3
27927
27928  // go through the array every three bytes, we'll deal with trailing stuff later
27929  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
27930    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
27931  }
27932
27933  // pad the end with zeros, but make sure to not forget the extra bytes
27934  if (extraBytes === 1) {
27935    tmp = uint8[len - 1]
27936    output += lookup[tmp >> 2]
27937    output += lookup[(tmp << 4) & 0x3F]
27938    output += '=='
27939  } else if (extraBytes === 2) {
27940    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
27941    output += lookup[tmp >> 10]
27942    output += lookup[(tmp >> 4) & 0x3F]
27943    output += lookup[(tmp << 2) & 0x3F]
27944    output += '='
27945  }
27946
27947  parts.push(output)
27948
27949  return parts.join('')
27950}
27951
27952
27953/***/ },
27954/* 13 */
27955/***/ function(module, exports, __webpack_require__) {
27956
27957var r;
27958
27959module.exports = function rand(len) {
27960  if (!r)
27961    r = new Rand(null);
27962
27963  return r.generate(len);
27964};
27965
27966function Rand(rand) {
27967  this.rand = rand;
27968}
27969module.exports.Rand = Rand;
27970
27971Rand.prototype.generate = function generate(len) {
27972  return this._rand(len);
27973};
27974
27975if (typeof window === 'object') {
27976  if (window.crypto && window.crypto.getRandomValues) {
27977    // Modern browsers
27978    Rand.prototype._rand = function _rand(n) {
27979      var arr = new Uint8Array(n);
27980      window.crypto.getRandomValues(arr);
27981      return arr;
27982    };
27983  } else if (window.msCrypto && window.msCrypto.getRandomValues) {
27984    // IE
27985    Rand.prototype._rand = function _rand(n) {
27986      var arr = new Uint8Array(n);
27987      window.msCrypto.getRandomValues(arr);
27988      return arr;
27989    };
27990  } else {
27991    // Old junk
27992    Rand.prototype._rand = function() {
27993      throw new Error('Not implemented yet');
27994    };
27995  }
27996} else {
27997  // Node.js or Web worker
27998  try {
27999    var crypto = __webpack_require__(43);
28000
28001    Rand.prototype._rand = function _rand(n) {
28002      return crypto.randomBytes(n);
28003    };
28004  } catch (e) {
28005    // Emulate crypto API using randy
28006    Rand.prototype._rand = function _rand(n) {
28007      var res = new Uint8Array(n);
28008      for (var i = 0; i < res.length; i++)
28009        res[i] = this.rand.getByte();
28010      return res;
28011    };
28012  }
28013}
28014
28015
28016/***/ },
28017/* 14 */
28018/***/ function(module, exports, __webpack_require__) {
28019
28020"use strict";
28021'use strict';
28022
28023var BN = __webpack_require__(1);
28024var elliptic = __webpack_require__(0
vendor: 9,277 bytes, lines 28024-28398
28024);
28025var utils = elliptic.utils;
28026var getNAF = utils.getNAF;
28027var getJSF = utils.getJSF;
28028var assert = utils.assert;
28029
28030function BaseCurve(type, conf) {
28031  this.type = type;
28032  this.p = new BN(conf.p, 16);
28033
28034  // Use Montgomery, when there is no fast reduction for the prime
28035  this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
28036
28037  // Useful for many curves
28038  this.zero = new BN(0).toRed(this.red);
28039  this.one = new BN(1).toRed(this.red);
28040  this.two = new BN(2).toRed(this.red);
28041
28042  // Curve configuration, optional
28043  this.n = conf.n && new BN(conf.n, 16);
28044  this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
28045
28046  // Temporary arrays
28047  this._wnafT1 = new Array(4);
28048  this._wnafT2 = new Array(4);
28049  this._wnafT3 = new Array(4);
28050  this._wnafT4 = new Array(4);
28051
28052  // Generalized Greg Maxwell's trick
28053  var adjustCount = this.n && this.p.div(this.n);
28054  if (!adjustCount || adjustCount.cmpn(100) > 0) {
28055    this.redN = null;
28056  } else {
28057    this._maxwellTrick = true;
28058    this.redN = this.n.toRed(this.red);
28059  }
28060}
28061module.exports = BaseCurve;
28062
28063BaseCurve.prototype.point = function point() {
28064  throw new Error('Not implemented');
28065};
28066
28067BaseCurve.prototype.validate = function validate() {
28068  throw new Error('Not implemented');
28069};
28070
28071BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
28072  assert(p.precomputed);
28073  var doubles = p._getDoubles();
28074
28075  var naf = getNAF(k, 1);
28076  var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
28077  I /= 3;
28078
28079  // Translate into more windowed form
28080  var repr = [];
28081  for (var j = 0; j < naf.length; j += doubles.step) {
28082    var nafW = 0;
28083    for (var k = j + doubles.step - 1; k >= j; k--)
28084      nafW = (nafW << 1) + naf[k];
28085    repr.push(nafW);
28086  }
28087
28088  var a = this.jpoint(null, null, null);
28089  var b = this.jpoint(null, null, null);
28090  for (var i = I; i > 0; i--) {
28091    for (var j = 0; j < repr.length; j++) {
28092      var nafW = repr[j];
28093      if (nafW === i)
28094        b = b.mixedAdd(doubles.points[j]);
28095      else if (nafW === -i)
28096        b = b.mixedAdd(doubles.points[j].neg());
28097    }
28098    a = a.add(b);
28099  }
28100  return a.toP();
28101};
28102
28103BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
28104  var w = 4;
28105
28106  // Precompute window
28107  var nafPoints = p._getNAFPoints(w);
28108  w = nafPoints.wnd;
28109  var wnd = nafPoints.points;
28110
28111  // Get NAF form
28112  var naf = getNAF(k, w);
28113
28114  // Add `this`*(N+1) for every w-NAF index
28115  var acc = this.jpoint(null, null, null);
28116  for (var i = naf.length - 1; i >= 0; i--) {
28117    // Count zeroes
28118    for (var k = 0; i >= 0 && naf[i] === 0; i--)
28119      k++;
28120    if (i >= 0)
28121      k++;
28122    acc = acc.dblp(k);
28123
28124    if (i < 0)
28125      break;
28126    var z = naf[i];
28127    assert(z !== 0);
28128    if (p.type === 'affine') {
28129      // J +- P
28130      if (z > 0)
28131        acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
28132      else
28133        acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
28134    } else {
28135      // J +- J
28136      if (z > 0)
28137        acc = acc.add(wnd[(z - 1) >> 1]);
28138      else
28139        acc = acc.add(wnd[(-z - 1) >> 1].neg());
28140    }
28141  }
28142  return p.type === 'affine' ? acc.toP() : acc;
28143};
28144
28145BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
28146                                                       points,
28147                                                       coeffs,
28148                                                       len,
28149                                                       jacobianResult) {
28150  var wndWidth = this._wnafT1;
28151  var wnd = this._wnafT2;
28152  var naf = this._wnafT3;
28153
28154  // Fill all arrays
28155  var max = 0;
28156  for (var i = 0; i < len; i++) {
28157    var p = points[i];
28158    var nafPoints = p._getNAFPoints(defW);
28159    wndWidth[i] = nafPoints.wnd;
28160    wnd[i] = nafPoints.points;
28161  }
28162
28163  // Comb small window NAFs
28164  for (var i = len - 1; i >= 1; i -= 2) {
28165    var a = i - 1;
28166    var b = i;
28167    if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
28168      naf[a] = getNAF(coeffs[a], wndWidth[a]);
28169      naf[b] = getNAF(coeffs[b], wndWidth[b]);
28170      max = Math.max(naf[a].length, max);
28171      max = Math.max(naf[b].length, max);
28172      continue;
28173    }
28174
28175    var comb = [
28176      points[a], /* 1 */
28177      null, /* 3 */
28178      null, /* 5 */
28179      points[b] /* 7 */
28180    ];
28181
28182    // Try to avoid Projective points, if possible
28183    if (points[a].y.cmp(points[b].y) === 0) {
28184      comb[1] = points[a].add(points[b]);
28185      comb[2] = points[a].toJ().mixedAdd(points[b].neg());
28186    } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
28187      comb[1] = points[a].toJ().mixedAdd(points[b]);
28188      comb[2] = points[a].add(points[b].neg());
28189    } else {
28190      comb[1] = points[a].toJ().mixedAdd(points[b]);
28191      comb[2] = points[a].toJ().mixedAdd(points[b].neg());
28192    }
28193
28194    var index = [
28195      -3, /* -1 -1 */
28196      -1, /* -1 0 */
28197      -5, /* -1 1 */
28198      -7, /* 0 -1 */
28199      0, /* 0 0 */
28200      7, /* 0 1 */
28201      5, /* 1 -1 */
28202      1, /* 1 0 */
28203      3  /* 1 1 */
28204    ];
28205
28206    var jsf = getJSF(coeffs[a], coeffs[b]);
28207    max = Math.max(jsf[0].length, max);
28208    naf[a] = new Array(max);
28209    naf[b] = new Array(max);
28210    for (var j = 0; j < max; j++) {
28211      var ja = jsf[0][j] | 0;
28212      var jb = jsf[1][j] | 0;
28213
28214      naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
28215      naf[b][j] = 0;
28216      wnd[a] = comb;
28217    }
28218  }
28219
28220  var acc = this.jpoint(null, null, null);
28221  var tmp = this._wnafT4;
28222  for (var i = max; i >= 0; i--) {
28223    var k = 0;
28224
28225    while (i >= 0) {
28226      var zero = true;
28227      for (var j = 0; j < len; j++) {
28228        tmp[j] = naf[j][i] | 0;
28229        if (tmp[j] !== 0)
28230          zero = false;
28231      }
28232      if (!zero)
28233        break;
28234      k++;
28235      i--;
28236    }
28237    if (i >= 0)
28238      k++;
28239    acc = acc.dblp(k);
28240    if (i < 0)
28241      break;
28242
28243    for (var j = 0; j < len; j++) {
28244      var z = tmp[j];
28245      var p;
28246      if (z === 0)
28247        continue;
28248      else if (z > 0)
28249        p = wnd[j][(z - 1) >> 1];
28250      else if (z < 0)
28251        p = wnd[j][(-z - 1) >> 1].neg();
28252
28253      if (p.type === 'affine')
28254        acc = acc.mixedAdd(p);
28255      else
28256        acc = acc.add(p);
28257    }
28258  }
28259  // Zeroify references
28260  for (var i = 0; i < len; i++)
28261    wnd[i] = null;
28262
28263  if (jacobianResult)
28264    return acc;
28265  else
28266    return acc.toP();
28267};
28268
28269function BasePoint(curve, type) {
28270  this.curve = curve;
28271  this.type = type;
28272  this.precomputed = null;
28273}
28274BaseCurve.BasePoint = BasePoint;
28275
28276BasePoint.prototype.eq = function eq(/*other*/) {
28277  throw new Error('Not implemented');
28278};
28279
28280BasePoint.prototype.validate = function validate() {
28281  return this.curve.validate(this);
28282};
28283
28284BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
28285  bytes = utils.toArray(bytes, enc);
28286
28287  var len = this.p.byteLength();
28288
28289  // uncompressed, hybrid-odd, hybrid-even
28290  if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
28291      bytes.length - 1 === 2 * len) {
28292    if (bytes[0] === 0x06)
28293      assert(bytes[bytes.length - 1] % 2 === 0);
28294    else if (bytes[0] === 0x07)
28295      assert(bytes[bytes.length - 1] % 2 === 1);
28296
28297    var res =  this.point(bytes.slice(1, 1 + len),
28298                          bytes.slice(1 + len, 1 + 2 * len));
28299
28300    return res;
28301  } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
28302              bytes.length - 1 === len) {
28303    return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
28304  }
28305  throw new Error('Unknown point format');
28306};
28307
28308BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
28309  return this.encode(enc, true);
28310};
28311
28312BasePoint.prototype._encode = function _encode(compact) {
28313  var len = this.curve.p.byteLength();
28314  var x = this.getX().toArray('be', len);
28315
28316  if (compact)
28317    return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
28318
28319  return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
28320};
28321
28322BasePoint.prototype.encode = function encode(enc, compact) {
28323  return utils.encode(this._encode(compact), enc);
28324};
28325
28326BasePoint.prototype.precompute = function precompute(power) {
28327  if (this.precomputed)
28328    return this;
28329
28330  var precomputed = {
28331    doubles: null,
28332    naf: null,
28333    beta: null
28334  };
28335  precomputed.naf = this._getNAFPoints(8);
28336  precomputed.doubles = this._getDoubles(4, power);
28337  precomputed.beta = this._getBeta();
28338  this.precomputed = precomputed;
28339
28340  return this;
28341};
28342
28343BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
28344  if (!this.precomputed)
28345    return false;
28346
28347  var doubles = this.precomputed.doubles;
28348  if (!doubles)
28349    return false;
28350
28351  return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
28352};
28353
28354BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
28355  if (this.precomputed && this.precomputed.doubles)
28356    return this.precomputed.doubles;
28357
28358  var doubles = [ this ];
28359  var acc = this;
28360  for (var i = 0; i < power; i += step) {
28361    for (var j = 0; j < step; j++)
28362      acc = acc.dbl();
28363    doubles.push(acc);
28364  }
28365  return {
28366    step: step,
28367    points: doubles
28368  };
28369};
28370
28371BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
28372  if (this.precomputed && this.precomputed.naf)
28373    return this.precomputed.naf;
28374
28375  var res = [ this ];
28376  var max = (1 << wnd) - 1;
28377  var dbl = max === 1 ? null : this.dbl();
28378  for (var i = 1; i < max; i++)
28379    res[i] = res[i - 1].add(dbl);
28380  return {
28381    wnd: wnd,
28382    points: res
28383  };
28384};
28385
28386BasePoint.prototype._getBeta = function _getBeta() {
28387  return null;
28388};
28389
28390BasePoint.prototype.dblp = function dblp(k) {
28391  var r = this;
28392  for (var i = 0; i < k; i++)
28393    r = r.dbl();
28394  return r;
28395};
28396
28397
28398/***/ }
vendor: 16,049 bytes, lines 28398-29035
28398,
28399/* 15 */
28400/***/ function(module, exports, __webpack_require__) {
28401
28402"use strict";
28403'use strict';
28404
28405var curve = __webpack_require__(4);
28406var elliptic = __webpack_require__(0);
28407var BN = __webpack_require__(1);
28408var inherits = __webpack_require__(5);
28409var Base = curve.base;
28410
28411var assert = elliptic.utils.assert;
28412
28413function EdwardsCurve(conf) {
28414  // NOTE: Important as we are creating point in Base.call()
28415  this.twisted = (conf.a | 0) !== 1;
28416  this.mOneA = this.twisted && (conf.a | 0) === -1;
28417  this.extended = this.mOneA;
28418
28419  Base.call(this, 'edwards', conf);
28420
28421  this.a = new BN(conf.a, 16).umod(this.red.m);
28422  this.a = this.a.toRed(this.red);
28423  this.c = new BN(conf.c, 16).toRed(this.red);
28424  this.c2 = this.c.redSqr();
28425  this.d = new BN(conf.d, 16).toRed(this.red);
28426  this.dd = this.d.redAdd(this.d);
28427
28428  assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
28429  this.oneC = (conf.c | 0) === 1;
28430}
28431inherits(EdwardsCurve, Base);
28432module.exports = EdwardsCurve;
28433
28434EdwardsCurve.prototype._mulA = function _mulA(num) {
28435  if (this.mOneA)
28436    return num.redNeg();
28437  else
28438    return this.a.redMul(num);
28439};
28440
28441EdwardsCurve.prototype._mulC = function _mulC(num) {
28442  if (this.oneC)
28443    return num;
28444  else
28445    return this.c.redMul(num);
28446};
28447
28448// Just for compatibility with Short curve
28449EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
28450  return this.point(x, y, z, t);
28451};
28452
28453EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
28454  x = new BN(x, 16);
28455  if (!x.red)
28456    x = x.toRed(this.red);
28457
28458  var x2 = x.redSqr();
28459  var rhs = this.c2.redSub(this.a.redMul(x2));
28460  var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
28461
28462  var y2 = rhs.redMul(lhs.redInvm());
28463  var y = y2.redSqrt();
28464  if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
28465    throw new Error('invalid point');
28466
28467  var isOdd = y.fromRed().isOdd();
28468  if (odd && !isOdd || !odd && isOdd)
28469    y = y.redNeg();
28470
28471  return this.point(x, y);
28472};
28473
28474EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
28475  y = new BN(y, 16);
28476  if (!y.red)
28477    y = y.toRed(this.red);
28478
28479  // x^2 = (y^2 - 1) / (d y^2 + 1)
28480  var y2 = y.redSqr();
28481  var lhs = y2.redSub(this.one);
28482  var rhs = y2.redMul(this.d).redAdd(this.one);
28483  var x2 = lhs.redMul(rhs.redInvm());
28484
28485  if (x2.cmp(this.zero) === 0) {
28486    if (odd)
28487      throw new Error('invalid point');
28488    else
28489      return this.point(this.zero, y);
28490  }
28491
28492  var x = x2.redSqrt();
28493  if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
28494    throw new Error('invalid point');
28495
28496  if (x.isOdd() !== odd)
28497    x = x.redNeg();
28498
28499  return this.point(x, y);
28500};
28501
28502EdwardsCurve.prototype.validate = function validate(point) {
28503  if (point.isInfinity())
28504    return true;
28505
28506  // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
28507  point.normalize();
28508
28509  var x2 = point.x.redSqr();
28510  var y2 = point.y.redSqr();
28511  var lhs = x2.redMul(this.a).redAdd(y2);
28512  var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
28513
28514  return lhs.cmp(rhs) === 0;
28515};
28516
28517function Point(curve, x, y, z, t) {
28518  Base.BasePoint.call(this, curve, 'projective');
28519  if (x === null && y === null && z === null) {
28520    this.x = this.curve.zero;
28521    this.y = this.curve.one;
28522    this.z = this.curve.one;
28523    this.t = this.curve.zero;
28524    this.zOne = true;
28525  } else {
28526    this.x = new BN(x, 16);
28527    this.y = new BN(y, 16);
28528    this.z = z ? new BN(z, 16) : this.curve.one;
28529    this.t = t && new BN(t, 16);
28530    if (!this.x.red)
28531      this.x = this.x.toRed(this.curve.red);
28532    if (!this.y.red)
28533      this.y = this.y.toRed(this.curve.red);
28534    if (!this.z.red)
28535      this.z = this.z.toRed(this.curve.red);
28536    if (this.t && !this.t.red)
28537      this.t = this.t.toRed(this.curve.red);
28538    this.zOne = this.z === this.curve.one;
28539
28540    // Use extended coordinates
28541    if (this.curve.extended && !this.t) {
28542      this.t = this.x.redMul(this.y);
28543      if (!this.zOne)
28544        this.t = this.t.redMul(this.z.redInvm());
28545    }
28546  }
28547}
28548inherits(Point, Base.BasePoint);
28549
28550EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
28551  return Point.fromJSON(this, obj);
28552};
28553
28554EdwardsCurve.prototype.point = function point(x, y, z, t) {
28555  return new Point(this, x, y, z, t);
28556};
28557
28558Point.fromJSON = function fromJSON(curve, obj) {
28559  return new Point(curve, obj[0], obj[1], obj[2]);
28560};
28561
28562Point.prototype.inspect = function inspect() {
28563  if (this.isInfinity())
28564    return '<EC Point Infinity>';
28565  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
28566      ' y: ' + this.y.fromRed().toString(16, 2) +
28567      ' z: ' + this.z.fromRed().toString(16, 2) + '>';
28568};
28569
28570Point.prototype.isInfinity = function isInfinity() {
28571  // XXX This code assumes that zero is always zero in red
28572  return this.x.cmpn(0) === 0 &&
28573         this.y.cmp(this.z) === 0;
28574};
28575
28576Point.prototype._extDbl = function _extDbl() {
28577  // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
28578  //     #doubling-dbl-2008-hwcd
28579  // 4M + 4S
28580
28581  // A = X1^2
28582  var a = this.x.redSqr();
28583  // B = Y1^2
28584  var b = this.y.redSqr();
28585  // C = 2 * Z1^2
28586  var c = this.z.redSqr();
28587  c = c.redIAdd(c);
28588  // D = a * A
28589  var d = this.curve._mulA(a);
28590  // E = (X1 + Y1)^2 - A - B
28591  var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
28592  // G = D + B
28593  var g = d.redAdd(b);
28594  // F = G - C
28595  var f = g.redSub(c);
28596  // H = D - B
28597  var h = d.redSub(b);
28598  // X3 = E * F
28599  var nx = e.redMul(f);
28600  // Y3 = G * H
28601  var ny = g.redMul(h);
28602  // T3 = E * H
28603  var nt = e.redMul(h);
28604  // Z3 = F * G
28605  var nz = f.redMul(g);
28606  return this.curve.point(nx, ny, nz, nt);
28607};
28608
28609Point.prototype._projDbl = function _projDbl() {
28610  // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
28611  //     #doubling-dbl-2008-bbjlp
28612  //     #doubling-dbl-2007-bl
28613  // and others
28614  // Generally 3M + 4S or 2M + 4S
28615
28616  // B = (X1 + Y1)^2
28617  var b = this.x.redAdd(this.y).redSqr();
28618  // C = X1^2
28619  var c = this.x.redSqr();
28620  // D = Y1^2
28621  var d = this.y.redSqr();
28622
28623  var nx;
28624  var ny;
28625  var nz;
28626  if (this.curve.twisted) {
28627    // E = a * C
28628    var e = this.curve._mulA(c);
28629    // F = E + D
28630    var f = e.redAdd(d);
28631    if (this.zOne) {
28632      // X3 = (B - C - D) * (F - 2)
28633      nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
28634      // Y3 = F * (E - D)
28635      ny = f.redMul(e.redSub(d));
28636      // Z3 = F^2 - 2 * F
28637      nz = f.redSqr().redSub(f).redSub(f);
28638    } else {
28639      // H = Z1^2
28640      var h = this.z.redSqr();
28641      // J = F - 2 * H
28642      var j = f.redSub(h).redISub(h);
28643      // X3 = (B-C-D)*J
28644      nx = b.redSub(c).redISub(d).redMul(j);
28645      // Y3 = F * (E - D)
28646      ny = f.redMul(e.redSub(d));
28647      // Z3 = F * J
28648      nz = f.redMul(j);
28649    }
28650  } else {
28651    // E = C + D
28652    var e = c.redAdd(d);
28653    // H = (c * Z1)^2
28654    var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
28655    // J = E - 2 * H
28656    var j = e.redSub(h).redSub(h);
28657    // X3 = c * (B - E) * J
28658    nx = this.curve._mulC(b.redISub(e)).redMul(j);
28659    // Y3 = c * E * (C - D)
28660    ny = this.curve._mulC(e).redMul(c.redISub(d));
28661    // Z3 = E * J
28662    nz = e.redMul(j);
28663  }
28664  return this.curve.point(nx, ny, nz);
28665};
28666
28667Point.prototype.dbl = function dbl() {
28668  if (this.isInfinity())
28669    return this;
28670
28671  // Double in extended coordinates
28672  if (this.curve.extended)
28673    return this._extDbl();
28674  else
28675    return this._projDbl();
28676};
28677
28678Point.prototype._extAdd = function _extAdd(p) {
28679  // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
28680  //     #addition-add-2008-hwcd-3
28681  // 8M
28682
28683  // A = (Y1 - X1) * (Y2 - X2)
28684  var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
28685  // B = (Y1 + X1) * (Y2 + X2)
28686  var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
28687  // C = T1 * k * T2
28688  var c = this.t.redMul(this.curve.dd).redMul(p.t);
28689  // D = Z1 * 2 * Z2
28690  var d = this.z.redMul(p.z.redAdd(p.z));
28691  // E = B - A
28692  var e = b.redSub(a);
28693  // F = D - C
28694  var f = d.redSub(c);
28695  // G = D + C
28696  var g = d.redAdd(c);
28697  // H = B + A
28698  var h = b.redAdd(a);
28699  // X3 = E * F
28700  var nx = e.redMul(f);
28701  // Y3 = G * H
28702  var ny = g.redMul(h);
28703  // T3 = E * H
28704  var nt = e.redMul(h);
28705  // Z3 = F * G
28706  var nz = f.redMul(g);
28707  return this.curve.point(nx, ny, nz, nt);
28708};
28709
28710Point.prototype._projAdd = function _projAdd(p) {
28711  // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
28712  //     #addition-add-2008-bbjlp
28713  //     #addition-add-2007-bl
28714  // 10M + 1S
28715
28716  // A = Z1 * Z2
28717  var a = this.z.redMul(p.z);
28718  // B = A^2
28719  var b = a.redSqr();
28720  // C = X1 * X2
28721  var c = this.x.redMul(p.x);
28722  // D = Y1 * Y2
28723  var d = this.y.redMul(p.y);
28724  // E = d * C * D
28725  var e = this.curve.d.redMul(c).redMul(d);
28726  // F = B - E
28727  var f = b.redSub(e);
28728  // G = B + E
28729  var g = b.redAdd(e);
28730  // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
28731  var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
28732  var nx = a.redMul(f).redMul(tmp);
28733  var ny;
28734  var nz;
28735  if (this.curve.twisted) {
28736    // Y3 = A * G * (D - a * C)
28737    ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
28738    // Z3 = F * G
28739    nz = f.redMul(g);
28740  } else {
28741    // Y3 = A * G * (D - C)
28742    ny = a.redMul(g).redMul(d.redSub(c));
28743    // Z3 = c * F * G
28744    nz = this.curve._mulC(f).redMul(g);
28745  }
28746  return this.curve.point(nx, ny, nz);
28747};
28748
28749Point.prototype.add = function add(p) {
28750  if (this.isInfinity())
28751    return p;
28752  if (p.isInfinity())
28753    return this;
28754
28755  if (this.curve.extended)
28756    return this._extAdd(p);
28757  else
28758    return this._projAdd(p);
28759};
28760
28761Point.prototype.mul = function mul(k) {
28762  if (this._hasDoubles(k))
28763    return this.curve._fixedNafMul(this, k);
28764  else
28765    return this.curve._wnafMul(this, k);
28766};
28767
28768Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
28769  return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
28770};
28771
28772Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
28773  return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
28774};
28775
28776Point.prototype.normalize = function normalize() {
28777  if (this.zOne)
28778    return this;
28779
28780  // Normalize coordinates
28781  var zi = this.z.redInvm();
28782  this.x = this.x.redMul(zi);
28783  this.y = this.y.redMul(zi);
28784  if (this.t)
28785    this.t = this.t.redMul(zi);
28786  this.z = this.curve.one;
28787  this.zOne = true;
28788  return this;
28789};
28790
28791Point.prototype.neg = function neg() {
28792  return this.curve.point(this.x.redNeg(),
28793                          this.y,
28794                          this.z,
28795                          this.t && this.t.redNeg());
28796};
28797
28798Point.prototype.getX = function getX() {
28799  this.normalize();
28800  return this.x.fromRed();
28801};
28802
28803Point.prototype.getY = function getY() {
28804  this.normalize();
28805  return this.y.fromRed();
28806};
28807
28808Point.prototype.eq = function eq(other) {
28809  return this === other ||
28810         this.getX().cmp(other.getX()) === 0 &&
28811         this.getY().cmp(other.getY()) === 0;
28812};
28813
28814Point.prototype.eqXToP = function eqXToP(x) {
28815  var rx = x.toRed(this.curve.red).redMul(this.z);
28816  if (this.x.cmp(rx) === 0)
28817    return true;
28818
28819  var xc = x.clone();
28820  var t = this.curve.redN.redMul(this.z);
28821  for (;;) {
28822    xc.iadd(this.curve.n);
28823    if (xc.cmp(this.curve.p) >= 0)
28824      return false;
28825
28826    rx.redIAdd(t);
28827    if (this.x.cmp(rx) === 0)
28828      return true;
28829  }
28830  return false;
28831};
28832
28833// Compatibility with BaseCurve
28834Point.prototype.toP = Point.prototype.normalize;
28835Point.prototype.mixedAdd = Point.prototype.add;
28836
28837
28838/***/ },
28839/* 16 */
28840/***/ function(module, exports, __webpack_require__) {
28841
28842"use strict";
28843'use strict';
28844
28845var curve = __webpack_require__(4);
28846var BN = __webpack_require__(1);
28847var inherits = __webpack_require__(5);
28848var Base = curve.base;
28849
28850var elliptic = __webpack_require__(0);
28851var utils = elliptic.utils;
28852
28853function MontCurve(conf) {
28854  Base.call(this, 'mont', conf);
28855
28856  this.a = new BN(conf.a, 16).toRed(this.red);
28857  this.b = new BN(conf.b, 16).toRed(this.red);
28858  this.i4 = new BN(4).toRed(this.red).redInvm();
28859  this.two = new BN(2).toRed(this.red);
28860  this.a24 = this.i4.redMul(this.a.redAdd(this.two));
28861}
28862inherits(MontCurve, Base);
28863module.exports = MontCurve;
28864
28865MontCurve.prototype.validate = function validate(point) {
28866  var x = point.normalize().x;
28867  var x2 = x.redSqr();
28868  var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
28869  var y = rhs.redSqrt();
28870
28871  return y.redSqr().cmp(rhs) === 0;
28872};
28873
28874function Point(curve, x, z) {
28875  Base.BasePoint.call(this, curve, 'projective');
28876  if (x === null && z === null) {
28877    this.x = this.curve.one;
28878    this.z = this.curve.zero;
28879  } else {
28880    this.x = new BN(x, 16);
28881    this.z = new BN(z, 16);
28882    if (!this.x.red)
28883      this.x = this.x.toRed(this.curve.red);
28884    if (!this.z.red)
28885      this.z = this.z.toRed(this.curve.red);
28886  }
28887}
28888inherits(Point, Base.BasePoint);
28889
28890MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
28891  return this.point(utils.toArray(bytes, enc), 1);
28892};
28893
28894MontCurve.prototype.point = function point(x, z) {
28895  return new Point(this, x, z);
28896};
28897
28898MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
28899  return Point.fromJSON(this, obj);
28900};
28901
28902Point.prototype.precompute = function precompute() {
28903  // No-op
28904};
28905
28906Point.prototype._encode = function _encode() {
28907  return this.getX().toArray('be', this.curve.p.byteLength());
28908};
28909
28910Point.fromJSON = function fromJSON(curve, obj) {
28911  return new Point(curve, obj[0], obj[1] || curve.one);
28912};
28913
28914Point.prototype.inspect = function inspect() {
28915  if (this.isInfinity())
28916    return '<EC Point Infinity>';
28917  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
28918      ' z: ' + this.z.fromRed().toString(16, 2) + '>';
28919};
28920
28921Point.prototype.isInfinity = function isInfinity() {
28922  // XXX This code assumes that zero is always zero in red
28923  return this.z.cmpn(0) === 0;
28924};
28925
28926Point.prototype.dbl = function dbl() {
28927  // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
28928  // 2M + 2S + 4A
28929
28930  // A = X1 + Z1
28931  var a = this.x.redAdd(this.z);
28932  // AA = A^2
28933  var aa = a.redSqr();
28934  // B = X1 - Z1
28935  var b = this.x.redSub(this.z);
28936  // BB = B^2
28937  var bb = b.redSqr();
28938  // C = AA - BB
28939  var c = aa.redSub(bb);
28940  // X3 = AA * BB
28941  var nx = aa.redMul(bb);
28942  // Z3 = C * (BB + A24 * C)
28943  var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
28944  return this.curve.point(nx, nz);
28945};
28946
28947Point.prototype.add = function add() {
28948  throw new Error('Not supported on Montgomery curve');
28949};
28950
28951Point.prototype.diffAdd = function diffAdd(p, diff) {
28952  // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
28953  // 4M + 2S + 6A
28954
28955  // A = X2 + Z2
28956  var a = this.x.redAdd(this.z);
28957  // B = X2 - Z2
28958  var b = this.x.redSub(this.z);
28959  // C = X3 + Z3
28960  var c = p.x.redAdd(p.z);
28961  // D = X3 - Z3
28962  var d = p.x.redSub(p.z);
28963  // DA = D * A
28964  var da = d.redMul(a);
28965  // CB = C * B
28966  var cb = c.redMul(b);
28967  // X5 = Z1 * (DA + CB)^2
28968  var nx = diff.z.redMul(da.redAdd(cb).redSqr());
28969  // Z5 = X1 * (DA - CB)^2
28970  var nz = diff.x.redMul(da.redISub(cb).redSqr());
28971  return this.curve.point(nx, nz);
28972};
28973
28974Point.prototype.mul = function mul(k) {
28975  var t = k.clone();
28976  var a = this; // (N / 2) * Q + Q
28977  var b = this.curve.point(null, null); // (N / 2) * Q
28978  var c = this; // Q
28979
28980  for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
28981    bits.push(t.andln(1));
28982
28983  for (var i = bits.length - 1; i >= 0; i--) {
28984    if (bits[i] === 0) {
28985      // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
28986      a = a.diffAdd(b, c);
28987      // N * Q = 2 * ((N / 2) * Q + Q))
28988      b = b.dbl();
28989    } else {
28990      // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
28991      b = a.diffAdd(b, c);
28992      // N * Q + Q = 2 * ((N / 2) * Q + Q)
28993      a = a.dbl();
28994    }
28995  }
28996  return b;
28997};
28998
28999Point.prototype.mulAdd = function mulAdd() {
29000  throw new Error('Not supported on Montgomery curve');
29001};
29002
29003Point.prototype.jumlAdd = function jumlAdd() {
29004  throw new Error('Not supported on Montgomery curve');
29005};
29006
29007Point.prototype.eq = function eq(other) {
29008  return this.getX().cmp(other.getX()) === 0;
29009};
29010
29011Point.prototype.normalize = function normalize() {
29012  this.x = this.x.redMul(this.z.redInvm());
29013  this.z = this.curve.one;
29014  return this;
29015};
29016
29017Point.prototype.getX = function getX() {
29018  // Normalize coordinates
29019  this.normalize();
29020
29021  return this.x.fromRed();
29022};
29023
29024
29025/***/ },
29026/* 17 */
29027/***/ function(module, exports, __webpack_require__) {
29028
29029"use strict";
29030'use strict';
29031
29032var curve = __webpack_require__(4);
29033var elliptic = __webpack_require__(0);
29034var BN = __webpack_require__(1);
29035var inherits = __webpack_require__(5
vendor: 22,718 bytes, lines 29035-29970
29035);
29036var Base = curve.base;
29037
29038var assert = elliptic.utils.assert;
29039
29040function ShortCurve(conf) {
29041  Base.call(this, 'short', conf);
29042
29043  this.a = new BN(conf.a, 16).toRed(this.red);
29044  this.b = new BN(conf.b, 16).toRed(this.red);
29045  this.tinv = this.two.redInvm();
29046
29047  this.zeroA = this.a.fromRed().cmpn(0) === 0;
29048  this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
29049
29050  // If the curve is endomorphic, precalculate beta and lambda
29051  this.endo = this._getEndomorphism(conf);
29052  this._endoWnafT1 = new Array(4);
29053  this._endoWnafT2 = new Array(4);
29054}
29055inherits(ShortCurve, Base);
29056module.exports = ShortCurve;
29057
29058ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
29059  // No efficient endomorphism
29060  if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
29061    return;
29062
29063  // Compute beta and lambda, that lambda * P = (beta * Px; Py)
29064  var beta;
29065  var lambda;
29066  if (conf.beta) {
29067    beta = new BN(conf.beta, 16).toRed(this.red);
29068  } else {
29069    var betas = this._getEndoRoots(this.p);
29070    // Choose the smallest beta
29071    beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
29072    beta = beta.toRed(this.red);
29073  }
29074  if (conf.lambda) {
29075    lambda = new BN(conf.lambda, 16);
29076  } else {
29077    // Choose the lambda that is matching selected beta
29078    var lambdas = this._getEndoRoots(this.n);
29079    if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
29080      lambda = lambdas[0];
29081    } else {
29082      lambda = lambdas[1];
29083      assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
29084    }
29085  }
29086
29087  // Get basis vectors, used for balanced length-two representation
29088  var basis;
29089  if (conf.basis) {
29090    basis = conf.basis.map(function(vec) {
29091      return {
29092        a: new BN(vec.a, 16),
29093        b: new BN(vec.b, 16)
29094      };
29095    });
29096  } else {
29097    basis = this._getEndoBasis(lambda);
29098  }
29099
29100  return {
29101    beta: beta,
29102    lambda: lambda,
29103    basis: basis
29104  };
29105};
29106
29107ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
29108  // Find roots of for x^2 + x + 1 in F
29109  // Root = (-1 +- Sqrt(-3)) / 2
29110  //
29111  var red = num === this.p ? this.red : BN.mont(num);
29112  var tinv = new BN(2).toRed(red).redInvm();
29113  var ntinv = tinv.redNeg();
29114
29115  var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
29116
29117  var l1 = ntinv.redAdd(s).fromRed();
29118  var l2 = ntinv.redSub(s).fromRed();
29119  return [ l1, l2 ];
29120};
29121
29122ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
29123  // aprxSqrt >= sqrt(this.n)
29124  var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
29125
29126  // 3.74
29127  // Run EGCD, until r(L + 1) < aprxSqrt
29128  var u = lambda;
29129  var v = this.n.clone();
29130  var x1 = new BN(1);
29131  var y1 = new BN(0);
29132  var x2 = new BN(0);
29133  var y2 = new BN(1);
29134
29135  // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
29136  var a0;
29137  var b0;
29138  // First vector
29139  var a1;
29140  var b1;
29141  // Second vector
29142  var a2;
29143  var b2;
29144
29145  var prevR;
29146  var i = 0;
29147  var r;
29148  var x;
29149  while (u.cmpn(0) !== 0) {
29150    var q = v.div(u);
29151    r = v.sub(q.mul(u));
29152    x = x2.sub(q.mul(x1));
29153    var y = y2.sub(q.mul(y1));
29154
29155    if (!a1 && r.cmp(aprxSqrt) < 0) {
29156      a0 = prevR.neg();
29157      b0 = x1;
29158      a1 = r.neg();
29159      b1 = x;
29160    } else if (a1 && ++i === 2) {
29161      break;
29162    }
29163    prevR = r;
29164
29165    v = u;
29166    u = r;
29167    x2 = x1;
29168    x1 = x;
29169    y2 = y1;
29170    y1 = y;
29171  }
29172  a2 = r.neg();
29173  b2 = x;
29174
29175  var len1 = a1.sqr().add(b1.sqr());
29176  var len2 = a2.sqr().add(b2.sqr());
29177  if (len2.cmp(len1) >= 0) {
29178    a2 = a0;
29179    b2 = b0;
29180  }
29181
29182  // Normalize signs
29183  if (a1.negative) {
29184    a1 = a1.neg();
29185    b1 = b1.neg();
29186  }
29187  if (a2.negative) {
29188    a2 = a2.neg();
29189    b2 = b2.neg();
29190  }
29191
29192  return [
29193    { a: a1, b: b1 },
29194    { a: a2, b: b2 }
29195  ];
29196};
29197
29198ShortCurve.prototype._endoSplit = function _endoSplit(k) {
29199  var basis = this.endo.basis;
29200  var v1 = basis[0];
29201  var v2 = basis[1];
29202
29203  var c1 = v2.b.mul(k).divRound(this.n);
29204  var c2 = v1.b.neg().mul(k).divRound(this.n);
29205
29206  var p1 = c1.mul(v1.a);
29207  var p2 = c2.mul(v2.a);
29208  var q1 = c1.mul(v1.b);
29209  var q2 = c2.mul(v2.b);
29210
29211  // Calculate answer
29212  var k1 = k.sub(p1).sub(p2);
29213  var k2 = q1.add(q2).neg();
29214  return { k1: k1, k2: k2 };
29215};
29216
29217ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
29218  x = new BN(x, 16);
29219  if (!x.red)
29220    x = x.toRed(this.red);
29221
29222  var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
29223  var y = y2.redSqrt();
29224  if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
29225    throw new Error('invalid point');
29226
29227  // XXX Is there any way to tell if the number is odd without converting it
29228  // to non-red form?
29229  var isOdd = y.fromRed().isOdd();
29230  if (odd && !isOdd || !odd && isOdd)
29231    y = y.redNeg();
29232
29233  return this.point(x, y);
29234};
29235
29236ShortCurve.prototype.validate = function validate(point) {
29237  if (point.inf)
29238    return true;
29239
29240  var x = point.x;
29241  var y = point.y;
29242
29243  var ax = this.a.redMul(x);
29244  var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
29245  return y.redSqr().redISub(rhs).cmpn(0) === 0;
29246};
29247
29248ShortCurve.prototype._endoWnafMulAdd =
29249    function _endoWnafMulAdd(points, coeffs, jacobianResult) {
29250  var npoints = this._endoWnafT1;
29251  var ncoeffs = this._endoWnafT2;
29252  for (var i = 0; i < points.length; i++) {
29253    var split = this._endoSplit(coeffs[i]);
29254    var p = points[i];
29255    var beta = p._getBeta();
29256
29257    if (split.k1.negative) {
29258      split.k1.ineg();
29259      p = p.neg(true);
29260    }
29261    if (split.k2.negative) {
29262      split.k2.ineg();
29263      beta = beta.neg(true);
29264    }
29265
29266    npoints[i * 2] = p;
29267    npoints[i * 2 + 1] = beta;
29268    ncoeffs[i * 2] = split.k1;
29269    ncoeffs[i * 2 + 1] = split.k2;
29270  }
29271  var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
29272
29273  // Clean-up references to points and coefficients
29274  for (var j = 0; j < i * 2; j++) {
29275    npoints[j] = null;
29276    ncoeffs[j] = null;
29277  }
29278  return res;
29279};
29280
29281function Point(curve, x, y, isRed) {
29282  Base.BasePoint.call(this, curve, 'affine');
29283  if (x === null && y === null) {
29284    this.x = null;
29285    this.y = null;
29286    this.inf = true;
29287  } else {
29288    this.x = new BN(x, 16);
29289    this.y = new BN(y, 16);
29290    // Force redgomery representation when loading from JSON
29291    if (isRed) {
29292      this.x.forceRed(this.curve.red);
29293      this.y.forceRed(this.curve.red);
29294    }
29295    if (!this.x.red)
29296      this.x = this.x.toRed(this.curve.red);
29297    if (!this.y.red)
29298      this.y = this.y.toRed(this.curve.red);
29299    this.inf = false;
29300  }
29301}
29302inherits(Point, Base.BasePoint);
29303
29304ShortCurve.prototype.point = function point(x, y, isRed) {
29305  return new Point(this, x, y, isRed);
29306};
29307
29308ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
29309  return Point.fromJSON(this, obj, red);
29310};
29311
29312Point.prototype._getBeta = function _getBeta() {
29313  if (!this.curve.endo)
29314    return;
29315
29316  var pre = this.precomputed;
29317  if (pre && pre.beta)
29318    return pre.beta;
29319
29320  var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
29321  if (pre) {
29322    var curve = this.curve;
29323    var endoMul = function(p) {
29324      return curve.point(p.x.redMul(curve.endo.beta), p.y);
29325    };
29326    pre.beta = beta;
29327    beta.precomputed = {
29328      beta: null,
29329      naf: pre.naf && {
29330        wnd: pre.naf.wnd,
29331        points: pre.naf.points.map(endoMul)
29332      },
29333      doubles: pre.doubles && {
29334        step: pre.doubles.step,
29335        points: pre.doubles.points.map(endoMul)
29336      }
29337    };
29338  }
29339  return beta;
29340};
29341
29342Point.prototype.toJSON = function toJSON() {
29343  if (!this.precomputed)
29344    return [ this.x, this.y ];
29345
29346  return [ this.x, this.y, this.precomputed && {
29347    doubles: this.precomputed.doubles && {
29348      step: this.precomputed.doubles.step,
29349      points: this.precomputed.doubles.points.slice(1)
29350    },
29351    naf: this.precomputed.naf && {
29352      wnd: this.precomputed.naf.wnd,
29353      points: this.precomputed.naf.points.slice(1)
29354    }
29355  } ];
29356};
29357
29358Point.fromJSON = function fromJSON(curve, obj, red) {
29359  if (typeof obj === 'string')
29360    obj = JSON.parse(obj);
29361  var res = curve.point(obj[0], obj[1], red);
29362  if (!obj[2])
29363    return res;
29364
29365  function obj2point(obj) {
29366    return curve.point(obj[0], obj[1], red);
29367  }
29368
29369  var pre = obj[2];
29370  res.precomputed = {
29371    beta: null,
29372    doubles: pre.doubles && {
29373      step: pre.doubles.step,
29374      points: [ res ].concat(pre.doubles.points.map(obj2point))
29375    },
29376    naf: pre.naf && {
29377      wnd: pre.naf.wnd,
29378      points: [ res ].concat(pre.naf.points.map(obj2point))
29379    }
29380  };
29381  return res;
29382};
29383
29384Point.prototype.inspect = function inspect() {
29385  if (this.isInfinity())
29386    return '<EC Point Infinity>';
29387  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
29388      ' y: ' + this.y.fromRed().toString(16, 2) + '>';
29389};
29390
29391Point.prototype.isInfinity = function isInfinity() {
29392  return this.inf;
29393};
29394
29395Point.prototype.add = function add(p) {
29396  // O + P = P
29397  if (this.inf)
29398    return p;
29399
29400  // P + O = P
29401  if (p.inf)
29402    return this;
29403
29404  // P + P = 2P
29405  if (this.eq(p))
29406    return this.dbl();
29407
29408  // P + (-P) = O
29409  if (this.neg().eq(p))
29410    return this.curve.point(null, null);
29411
29412  // P + Q = O
29413  if (this.x.cmp(p.x) === 0)
29414    return this.curve.point(null, null);
29415
29416  var c = this.y.redSub(p.y);
29417  if (c.cmpn(0) !== 0)
29418    c = c.redMul(this.x.redSub(p.x).redInvm());
29419  var nx = c.redSqr().redISub(this.x).redISub(p.x);
29420  var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
29421  return this.curve.point(nx, ny);
29422};
29423
29424Point.prototype.dbl = function dbl() {
29425  if (this.inf)
29426    return this;
29427
29428  // 2P = O
29429  var ys1 = this.y.redAdd(this.y);
29430  if (ys1.cmpn(0) === 0)
29431    return this.curve.point(null, null);
29432
29433  var a = this.curve.a;
29434
29435  var x2 = this.x.redSqr();
29436  var dyinv = ys1.redInvm();
29437  var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
29438
29439  var nx = c.redSqr().redISub(this.x.redAdd(this.x));
29440  var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
29441  return this.curve.point(nx, ny);
29442};
29443
29444Point.prototype.getX = function getX() {
29445  return this.x.fromRed();
29446};
29447
29448Point.prototype.getY = function getY() {
29449  return this.y.fromRed();
29450};
29451
29452Point.prototype.mul = function mul(k) {
29453  k = new BN(k, 16);
29454
29455  if (this._hasDoubles(k))
29456    return this.curve._fixedNafMul(this, k);
29457  else if (this.curve.endo)
29458    return this.curve._endoWnafMulAdd([ this ], [ k ]);
29459  else
29460    return this.curve._wnafMul(this, k);
29461};
29462
29463Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
29464  var points = [ this, p2 ];
29465  var coeffs = [ k1, k2 ];
29466  if (this.curve.endo)
29467    return this.curve._endoWnafMulAdd(points, coeffs);
29468  else
29469    return this.curve._wnafMulAdd(1, points, coeffs, 2);
29470};
29471
29472Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
29473  var points = [ this, p2 ];
29474  var coeffs = [ k1, k2 ];
29475  if (this.curve.endo)
29476    return this.curve._endoWnafMulAdd(points, coeffs, true);
29477  else
29478    return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
29479};
29480
29481Point.prototype.eq = function eq(p) {
29482  return this === p ||
29483         this.inf === p.inf &&
29484             (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
29485};
29486
29487Point.prototype.neg = function neg(_precompute) {
29488  if (this.inf)
29489    return this;
29490
29491  var res = this.curve.point(this.x, this.y.redNeg());
29492  if (_precompute && this.precomputed) {
29493    var pre = this.precomputed;
29494    var negate = function(p) {
29495      return p.neg();
29496    };
29497    res.precomputed = {
29498      naf: pre.naf && {
29499        wnd: pre.naf.wnd,
29500        points: pre.naf.points.map(negate)
29501      },
29502      doubles: pre.doubles && {
29503        step: pre.doubles.step,
29504        points: pre.doubles.points.map(negate)
29505      }
29506    };
29507  }
29508  return res;
29509};
29510
29511Point.prototype.toJ = function toJ() {
29512  if (this.inf)
29513    return this.curve.jpoint(null, null, null);
29514
29515  var res = this.curve.jpoint(this.x, this.y, this.curve.one);
29516  return res;
29517};
29518
29519function JPoint(curve, x, y, z) {
29520  Base.BasePoint.call(this, curve, 'jacobian');
29521  if (x === null && y === null && z === null) {
29522    this.x = this.curve.one;
29523    this.y = this.curve.one;
29524    this.z = new BN(0);
29525  } else {
29526    this.x = new BN(x, 16);
29527    this.y = new BN(y, 16);
29528    this.z = new BN(z, 16);
29529  }
29530  if (!this.x.red)
29531    this.x = this.x.toRed(this.curve.red);
29532  if (!this.y.red)
29533    this.y = this.y.toRed(this.curve.red);
29534  if (!this.z.red)
29535    this.z = this.z.toRed(this.curve.red);
29536
29537  this.zOne = this.z === this.curve.one;
29538}
29539inherits(JPoint, Base.BasePoint);
29540
29541ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
29542  return new JPoint(this, x, y, z);
29543};
29544
29545JPoint.prototype.toP = function toP() {
29546  if (this.isInfinity())
29547    return this.curve.point(null, null);
29548
29549  var zinv = this.z.redInvm();
29550  var zinv2 = zinv.redSqr();
29551  var ax = this.x.redMul(zinv2);
29552  var ay = this.y.redMul(zinv2).redMul(zinv);
29553
29554  return this.curve.point(ax, ay);
29555};
29556
29557JPoint.prototype.neg = function neg() {
29558  return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
29559};
29560
29561JPoint.prototype.add = function add(p) {
29562  // O + P = P
29563  if (this.isInfinity())
29564    return p;
29565
29566  // P + O = P
29567  if (p.isInfinity())
29568    return this;
29569
29570  // 12M + 4S + 7A
29571  var pz2 = p.z.redSqr();
29572  var z2 = this.z.redSqr();
29573  var u1 = this.x.redMul(pz2);
29574  var u2 = p.x.redMul(z2);
29575  var s1 = this.y.redMul(pz2.redMul(p.z));
29576  var s2 = p.y.redMul(z2.redMul(this.z));
29577
29578  var h = u1.redSub(u2);
29579  var r = s1.redSub(s2);
29580  if (h.cmpn(0) === 0) {
29581    if (r.cmpn(0) !== 0)
29582      return this.curve.jpoint(null, null, null);
29583    else
29584      return this.dbl();
29585  }
29586
29587  var h2 = h.redSqr();
29588  var h3 = h2.redMul(h);
29589  var v = u1.redMul(h2);
29590
29591  var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
29592  var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
29593  var nz = this.z.redMul(p.z).redMul(h);
29594
29595  return this.curve.jpoint(nx, ny, nz);
29596};
29597
29598JPoint.prototype.mixedAdd = function mixedAdd(p) {
29599  // O + P = P
29600  if (this.isInfinity())
29601    return p.toJ();
29602
29603  // P + O = P
29604  if (p.isInfinity())
29605    return this;
29606
29607  // 8M + 3S + 7A
29608  var z2 = this.z.redSqr();
29609  var u1 = this.x;
29610  var u2 = p.x.redMul(z2);
29611  var s1 = this.y;
29612  var s2 = p.y.redMul(z2).redMul(this.z);
29613
29614  var h = u1.redSub(u2);
29615  var r = s1.redSub(s2);
29616  if (h.cmpn(0) === 0) {
29617    if (r.cmpn(0) !== 0)
29618      return this.curve.jpoint(null, null, null);
29619    else
29620      return this.dbl();
29621  }
29622
29623  var h2 = h.redSqr();
29624  var h3 = h2.redMul(h);
29625  var v = u1.redMul(h2);
29626
29627  var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
29628  var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
29629  var nz = this.z.redMul(h);
29630
29631  return this.curve.jpoint(nx, ny, nz);
29632};
29633
29634JPoint.prototype.dblp = function dblp(pow) {
29635  if (pow === 0)
29636    return this;
29637  if (this.isInfinity())
29638    return this;
29639  if (!pow)
29640    return this.dbl();
29641
29642  if (this.curve.zeroA || this.curve.threeA) {
29643    var r = this;
29644    for (var i = 0; i < pow; i++)
29645      r = r.dbl();
29646    return r;
29647  }
29648
29649  // 1M + 2S + 1A + N * (4S + 5M + 8A)
29650  // N = 1 => 6M + 6S + 9A
29651  var a = this.curve.a;
29652  var tinv = this.curve.tinv;
29653
29654  var jx = this.x;
29655  var jy = this.y;
29656  var jz = this.z;
29657  var jz4 = jz.redSqr().redSqr();
29658
29659  // Reuse results
29660  var jyd = jy.redAdd(jy);
29661  for (var i = 0; i < pow; i++) {
29662    var jx2 = jx.redSqr();
29663    var jyd2 = jyd.redSqr();
29664    var jyd4 = jyd2.redSqr();
29665    var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
29666
29667    var t1 = jx.redMul(jyd2);
29668    var nx = c.redSqr().redISub(t1.redAdd(t1));
29669    var t2 = t1.redISub(nx);
29670    var dny = c.redMul(t2);
29671    dny = dny.redIAdd(dny).redISub(jyd4);
29672    var nz = jyd.redMul(jz);
29673    if (i + 1 < pow)
29674      jz4 = jz4.redMul(jyd4);
29675
29676    jx = nx;
29677    jz = nz;
29678    jyd = dny;
29679  }
29680
29681  return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
29682};
29683
29684JPoint.prototype.dbl = function dbl() {
29685  if (this.isInfinity())
29686    return this;
29687
29688  if (this.curve.zeroA)
29689    return this._zeroDbl();
29690  else if (this.curve.threeA)
29691    return this._threeDbl();
29692  else
29693    return this._dbl();
29694};
29695
29696JPoint.prototype._zeroDbl = function _zeroDbl() {
29697  var nx;
29698  var ny;
29699  var nz;
29700  // Z = 1
29701  if (this.zOne) {
29702    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
29703    //     #doubling-mdbl-2007-bl
29704    // 1M + 5S + 14A
29705
29706    // XX = X1^2
29707    var xx = this.x.redSqr();
29708    // YY = Y1^2
29709    var yy = this.y.redSqr();
29710    // YYYY = YY^2
29711    var yyyy = yy.redSqr();
29712    // S = 2 * ((X1 + YY)^2 - XX - YYYY)
29713    var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
29714    s = s.redIAdd(s);
29715    // M = 3 * XX + a; a = 0
29716    var m = xx.redAdd(xx).redIAdd(xx);
29717    // T = M ^ 2 - 2*S
29718    var t = m.redSqr().redISub(s).redISub(s);
29719
29720    // 8 * YYYY
29721    var yyyy8 = yyyy.redIAdd(yyyy);
29722    yyyy8 = yyyy8.redIAdd(yyyy8);
29723    yyyy8 = yyyy8.redIAdd(yyyy8);
29724
29725    // X3 = T
29726    nx = t;
29727    // Y3 = M * (S - T) - 8 * YYYY
29728    ny = m.redMul(s.redISub(t)).redISub(yyyy8);
29729    // Z3 = 2*Y1
29730    nz = this.y.redAdd(this.y);
29731  } else {
29732    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
29733    //     #doubling-dbl-2009-l
29734    // 2M + 5S + 13A
29735
29736    // A = X1^2
29737    var a = this.x.redSqr();
29738    // B = Y1^2
29739    var b = this.y.redSqr();
29740    // C = B^2
29741    var c = b.redSqr();
29742    // D = 2 * ((X1 + B)^2 - A - C)
29743    var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
29744    d = d.redIAdd(d);
29745    // E = 3 * A
29746    var e = a.redAdd(a).redIAdd(a);
29747    // F = E^2
29748    var f = e.redSqr();
29749
29750    // 8 * C
29751    var c8 = c.redIAdd(c);
29752    c8 = c8.redIAdd(c8);
29753    c8 = c8.redIAdd(c8);
29754
29755    // X3 = F - 2 * D
29756    nx = f.redISub(d).redISub(d);
29757    // Y3 = E * (D - X3) - 8 * C
29758    ny = e.redMul(d.redISub(nx)).redISub(c8);
29759    // Z3 = 2 * Y1 * Z1
29760    nz = this.y.redMul(this.z);
29761    nz = nz.redIAdd(nz);
29762  }
29763
29764  return this.curve.jpoint(nx, ny, nz);
29765};
29766
29767JPoint.prototype._threeDbl = function _threeDbl() {
29768  var nx;
29769  var ny;
29770  var nz;
29771  // Z = 1
29772  if (this.zOne) {
29773    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
29774    //     #doubling-mdbl-2007-bl
29775    // 1M + 5S + 15A
29776
29777    // XX = X1^2
29778    var xx = this.x.redSqr();
29779    // YY = Y1^2
29780    var yy = this.y.redSqr();
29781    // YYYY = YY^2
29782    var yyyy = yy.redSqr();
29783    // S = 2 * ((X1 + YY)^2 - XX - YYYY)
29784    var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
29785    s = s.redIAdd(s);
29786    // M = 3 * XX + a
29787    var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
29788    // T = M^2 - 2 * S
29789    var t = m.redSqr().redISub(s).redISub(s);
29790    // X3 = T
29791    nx = t;
29792    // Y3 = M * (S - T) - 8 * YYYY
29793    var yyyy8 = yyyy.redIAdd(yyyy);
29794    yyyy8 = yyyy8.redIAdd(yyyy8);
29795    yyyy8 = yyyy8.redIAdd(yyyy8);
29796    ny = m.redMul(s.redISub(t)).redISub(yyyy8);
29797    // Z3 = 2 * Y1
29798    nz = this.y.redAdd(this.y);
29799  } else {
29800    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
29801    // 3M + 5S
29802
29803    // delta = Z1^2
29804    var delta = this.z.redSqr();
29805    // gamma = Y1^2
29806    var gamma = this.y.redSqr();
29807    // beta = X1 * gamma
29808    var beta = this.x.redMul(gamma);
29809    // alpha = 3 * (X1 - delta) * (X1 + delta)
29810    var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
29811    alpha = alpha.redAdd(alpha).redIAdd(alpha);
29812    // X3 = alpha^2 - 8 * beta
29813    var beta4 = beta.redIAdd(beta);
29814    beta4 = beta4.redIAdd(beta4);
29815    var beta8 = beta4.redAdd(beta4);
29816    nx = alpha.redSqr().redISub(beta8);
29817    // Z3 = (Y1 + Z1)^2 - gamma - delta
29818    nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
29819    // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
29820    var ggamma8 = gamma.redSqr();
29821    ggamma8 = ggamma8.redIAdd(ggamma8);
29822    ggamma8 = ggamma8.redIAdd(ggamma8);
29823    ggamma8 = ggamma8.redIAdd(ggamma8);
29824    ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
29825  }
29826
29827  return this.curve.jpoint(nx, ny, nz);
29828};
29829
29830JPoint.prototype._dbl = function _dbl() {
29831  var a = this.curve.a;
29832
29833  // 4M + 6S + 10A
29834  var jx = this.x;
29835  var jy = this.y;
29836  var jz = this.z;
29837  var jz4 = jz.redSqr().redSqr();
29838
29839  var jx2 = jx.redSqr();
29840  var jy2 = jy.redSqr();
29841
29842  var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
29843
29844  var jxd4 = jx.redAdd(jx);
29845  jxd4 = jxd4.redIAdd(jxd4);
29846  var t1 = jxd4.redMul(jy2);
29847  var nx = c.redSqr().redISub(t1.redAdd(t1));
29848  var t2 = t1.redISub(nx);
29849
29850  var jyd8 = jy2.redSqr();
29851  jyd8 = jyd8.redIAdd(jyd8);
29852  jyd8 = jyd8.redIAdd(jyd8);
29853  jyd8 = jyd8.redIAdd(jyd8);
29854  var ny = c.redMul(t2).redISub(jyd8);
29855  var nz = jy.redAdd(jy).redMul(jz);
29856
29857  return this.curve.jpoint(nx, ny, nz);
29858};
29859
29860JPoint.prototype.trpl = function trpl() {
29861  if (!this.curve.zeroA)
29862    return this.dbl().add(this);
29863
29864  // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
29865  // 5M + 10S + ...
29866
29867  // XX = X1^2
29868  var xx = this.x.redSqr();
29869  // YY = Y1^2
29870  var yy = this.y.redSqr();
29871  // ZZ = Z1^2
29872  var zz = this.z.redSqr();
29873  // YYYY = YY^2
29874  var yyyy = yy.redSqr();
29875  // M = 3 * XX + a * ZZ2; a = 0
29876  var m = xx.redAdd(xx).redIAdd(xx);
29877  // MM = M^2
29878  var mm = m.redSqr();
29879  // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
29880  var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
29881  e = e.redIAdd(e);
29882  e = e.redAdd(e).redIAdd(e);
29883  e = e.redISub(mm);
29884  // EE = E^2
29885  var ee = e.redSqr();
29886  // T = 16*YYYY
29887  var t = yyyy.redIAdd(yyyy);
29888  t = t.redIAdd(t);
29889  t = t.redIAdd(t);
29890  t = t.redIAdd(t);
29891  // U = (M + E)^2 - MM - EE - T
29892  var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
29893  // X3 = 4 * (X1 * EE - 4 * YY * U)
29894  var yyu4 = yy.redMul(u);
29895  yyu4 = yyu4.redIAdd(yyu4);
29896  yyu4 = yyu4.redIAdd(yyu4);
29897  var nx = this.x.redMul(ee).redISub(yyu4);
29898  nx = nx.redIAdd(nx);
29899  nx = nx.redIAdd(nx);
29900  // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
29901  var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
29902  ny = ny.redIAdd(ny);
29903  ny = ny.redIAdd(ny);
29904  ny = ny.redIAdd(ny);
29905  // Z3 = (Z1 + E)^2 - ZZ - EE
29906  var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
29907
29908  return this.curve.jpoint(nx, ny, nz);
29909};
29910
29911JPoint.prototype.mul = function mul(k, kbase) {
29912  k = new BN(k, kbase);
29913
29914  return this.curve._wnafMul(this, k);
29915};
29916
29917JPoint.prototype.eq = function eq(p) {
29918  if (p.type === 'affine')
29919    return this.eq(p.toJ());
29920
29921  if (this === p)
29922    return true;
29923
29924  // x1 * z2^2 == x2 * z1^2
29925  var z2 = this.z.redSqr();
29926  var pz2 = p.z.redSqr();
29927  if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
29928    return false;
29929
29930  // y1 * z2^3 == y2 * z1^3
29931  var z3 = z2.redMul(this.z);
29932  var pz3 = pz2.redMul(p.z);
29933  return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
29934};
29935
29936JPoint.prototype.eqXToP = function eqXToP(x) {
29937  var zs = this.z.redSqr();
29938  var rx = x.toRed(this.curve.red).redMul(zs);
29939  if (this.x.cmp(rx) === 0)
29940    return true;
29941
29942  var xc = x.clone();
29943  var t = this.curve.redN.redMul(zs);
29944  for (;;) {
29945    xc.iadd(this.curve.n);
29946    if (xc.cmp(this.curve.p) >= 0)
29947      return false;
29948
29949    rx.redIAdd(t);
29950    if (this.x.cmp(rx) === 0)
29951      return true;
29952  }
29953  return false;
29954};
29955
29956JPoint.prototype.inspect = function inspect() {
29957  if (this.isInfinity())
29958    return '<EC JPoint Infinity>';
29959  return '<EC JPoint x: ' + this.x.toString(16, 2) +
29960      ' y: ' + this.y.toString(16, 2) +
29961      ' z: ' + this.z.toString(16, 2) + '>';
29962};
29963
29964JPoint.prototype.isInfinity = function isInfinity() {
29965  // XXX This code assumes that zero is always zero in red
29966  return this.z.cmpn(0) === 0;
29967};
29968
29969
29970/***/ }
vendor: 29,460 bytes, lines 29970-31106
29970,
29971/* 18 */
29972/***/ function(module, exports, __webpack_require__) {
29973
29974"use strict";
29975'use strict';
29976
29977var curves = exports;
29978
29979var hash = __webpack_require__(2);
29980var elliptic = __webpack_require__(0);
29981
29982var assert = elliptic.utils.assert;
29983
29984function PresetCurve(options) {
29985  if (options.type === 'short')
29986    this.curve = new elliptic.curve.short(options);
29987  else if (options.type === 'edwards')
29988    this.curve = new elliptic.curve.edwards(options);
29989  else
29990    this.curve = new elliptic.curve.mont(options);
29991  this.g = this.curve.g;
29992  this.n = this.curve.n;
29993  this.hash = options.hash;
29994
29995  assert(this.g.validate(), 'Invalid curve');
29996  assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
29997}
29998curves.PresetCurve = PresetCurve;
29999
30000function defineCurve(name, options) {
30001  Object.defineProperty(curves, name, {
30002    configurable: true,
30003    enumerable: true,
30004    get: function() {
30005      var curve = new PresetCurve(options);
30006      Object.defineProperty(curves, name, {
30007        configurable: true,
30008        enumerable: true,
30009        value: curve
30010      });
30011      return curve;
30012    }
30013  });
30014}
30015
30016defineCurve('p192', {
30017  type: 'short',
30018  prime: 'p192',
30019  p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
30020  a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
30021  b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
30022  n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
30023  hash: hash.sha256,
30024  gRed: false,
30025  g: [
30026    '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
30027    '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
30028  ]
30029});
30030
30031defineCurve('p224', {
30032  type: 'short',
30033  prime: 'p224',
30034  p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
30035  a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
30036  b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
30037  n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
30038  hash: hash.sha256,
30039  gRed: false,
30040  g: [
30041    'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
30042    'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
30043  ]
30044});
30045
30046defineCurve('p256', {
30047  type: 'short',
30048  prime: null,
30049  p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
30050  a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
30051  b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
30052  n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
30053  hash: hash.sha256,
30054  gRed: false,
30055  g: [
30056    '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
30057    '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
30058  ]
30059});
30060
30061defineCurve('p384', {
30062  type: 'short',
30063  prime: null,
30064  p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30065     'fffffffe ffffffff 00000000 00000000 ffffffff',
30066  a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30067     'fffffffe ffffffff 00000000 00000000 fffffffc',
30068  b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
30069     '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
30070  n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
30071     'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
30072  hash: hash.sha384,
30073  gRed: false,
30074  g: [
30075    'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
30076    '5502f25d bf55296c 3a545e38 72760ab7',
30077    '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
30078    '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
30079  ]
30080});
30081
30082defineCurve('p521', {
30083  type: 'short',
30084  prime: null,
30085  p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30086     'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30087     'ffffffff ffffffff ffffffff ffffffff ffffffff',
30088  a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30089     'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30090     'ffffffff ffffffff ffffffff ffffffff fffffffc',
30091  b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
30092     '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
30093     '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
30094  n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
30095     'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
30096     'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
30097  hash: hash.sha512,
30098  gRed: false,
30099  g: [
30100    '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
30101    '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
30102    'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
30103    '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
30104    '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
30105    '3fad0761 353c7086 a272c240 88be9476 9fd16650'
30106  ]
30107});
30108
30109defineCurve('curve25519', {
30110  type: 'mont',
30111  prime: 'p25519',
30112  p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
30113  a: '76d06',
30114  b: '0',
30115  n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
30116  hash: hash.sha256,
30117  gRed: false,
30118  g: [
30119    '9'
30120  ]
30121});
30122
30123defineCurve('ed25519', {
30124  type: 'edwards',
30125  prime: 'p25519',
30126  p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
30127  a: '-1',
30128  c: '1',
30129  // -121665 * (121666^(-1)) (mod P)
30130  d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
30131  n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
30132  hash: hash.sha256,
30133  gRed: false,
30134  g: [
30135    '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
30136
30137    // 4/5
30138    '6666666666666666666666666666666666666666666666666666666666666658'
30139  ]
30140});
30141
30142var pre;
30143try {
30144  pre = __webpack_require__(26);
30145} catch (e) {
30146  pre = undefined;
30147}
30148
30149defineCurve('secp256k1', {
30150  type: 'short',
30151  prime: 'k256',
30152  p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
30153  a: '0',
30154  b: '7',
30155  n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
30156  h: '1',
30157  hash: hash.sha256,
30158
30159  // Precomputed endomorphism
30160  beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
30161  lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
30162  basis: [
30163    {
30164      a: '3086d221a7d46bcde86c90e49284eb15',
30165      b: '-e4437ed6010e88286f547fa90abfe4c3'
30166    },
30167    {
30168      a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
30169      b: '3086d221a7d46bcde86c90e49284eb15'
30170    }
30171  ],
30172
30173  gRed: false,
30174  g: [
30175    '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
30176    '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
30177    pre
30178  ]
30179});
30180
30181
30182/***/ },
30183/* 19 */
30184/***/ function(module, exports, __webpack_require__) {
30185
30186"use strict";
30187'use strict';
30188
30189var BN = __webpack_require__(1);
30190var elliptic = __webpack_require__(0);
30191var utils = elliptic.utils;
30192var assert = utils.assert;
30193
30194var KeyPair = __webpack_require__(20);
30195var Signature = __webpack_require__(21);
30196
30197function EC(options) {
30198  if (!(this instanceof EC))
30199    return new EC(options);
30200
30201  // Shortcut `elliptic.ec(curve-name)`
30202  if (typeof options === 'string') {
30203    assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
30204
30205    options = elliptic.curves[options];
30206  }
30207
30208  // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
30209  if (options instanceof elliptic.curves.PresetCurve)
30210    options = { curve: options };
30211
30212  this.curve = options.curve.curve;
30213  this.n = this.curve.n;
30214  this.nh = this.n.ushrn(1);
30215  this.g = this.curve.g;
30216
30217  // Point on curve
30218  this.g = options.curve.g;
30219  this.g.precompute(options.curve.n.bitLength() + 1);
30220
30221  // Hash for function for DRBG
30222  this.hash = options.hash || options.curve.hash;
30223}
30224module.exports = EC;
30225
30226EC.prototype.keyPair = function keyPair(options) {
30227  return new KeyPair(this, options);
30228};
30229
30230EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
30231  return KeyPair.fromPrivate(this, priv, enc);
30232};
30233
30234EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
30235  return KeyPair.fromPublic(this, pub, enc);
30236};
30237
30238EC.prototype.genKeyPair = function genKeyPair(options) {
30239  if (!options)
30240    options = {};
30241
30242  // Instantiate Hmac_DRBG
30243  var drbg = new elliptic.hmacDRBG({
30244    hash: this.hash,
30245    pers: options.pers,
30246    entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
30247    nonce: this.n.toArray()
30248  });
30249
30250  var bytes = this.n.byteLength();
30251  var ns2 = this.n.sub(new BN(2));
30252  do {
30253    var priv = new BN(drbg.generate(bytes));
30254    if (priv.cmp(ns2) > 0)
30255      continue;
30256
30257    priv.iaddn(1);
30258    return this.keyFromPrivate(priv);
30259  } while (true);
30260};
30261
30262EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
30263  var delta = msg.byteLength() * 8 - this.n.bitLength();
30264  if (delta > 0)
30265    msg = msg.ushrn(delta);
30266  if (!truncOnly && msg.cmp(this.n) >= 0)
30267    return msg.sub(this.n);
30268  else
30269    return msg;
30270};
30271
30272EC.prototype.sign = function sign(msg, key, enc, options) {
30273  if (typeof enc === 'object') {
30274    options = enc;
30275    enc = null;
30276  }
30277  if (!options)
30278    options = {};
30279
30280  key = this.keyFromPrivate(key, enc);
30281  msg = this._truncateToN(new BN(msg, 16));
30282
30283  // Zero-extend key to provide enough entropy
30284  var bytes = this.n.byteLength();
30285  var bkey = key.getPrivate().toArray('be', bytes);
30286
30287  // Zero-extend nonce to have the same byte size as N
30288  var nonce = msg.toArray('be', bytes);
30289
30290  // Instantiate Hmac_DRBG
30291  var drbg = new elliptic.hmacDRBG({
30292    hash: this.hash,
30293    entropy: bkey,
30294    nonce: nonce,
30295    pers: options.pers,
30296    persEnc: options.persEnc
30297  });
30298
30299  // Number of bytes to generate
30300  var ns1 = this.n.sub(new BN(1));
30301
30302  for (var iter = 0; true; iter++) {
30303    var k = options.k ?
30304        options.k(iter) :
30305        new BN(drbg.generate(this.n.byteLength()));
30306    k = this._truncateToN(k, true);
30307    if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
30308      continue;
30309
30310    var kp = this.g.mul(k);
30311    if (kp.isInfinity())
30312      continue;
30313
30314    var kpX = kp.getX();
30315    var r = kpX.umod(this.n);
30316    if (r.cmpn(0) === 0)
30317      continue;
30318
30319    var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
30320    s = s.umod(this.n);
30321    if (s.cmpn(0) === 0)
30322      continue;
30323
30324    var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
30325                        (kpX.cmp(r) !== 0 ? 2 : 0);
30326
30327    // Use complement of `s`, if it is > `n / 2`
30328    if (options.canonical && s.cmp(this.nh) > 0) {
30329      s = this.n.sub(s);
30330      recoveryParam ^= 1;
30331    }
30332
30333    return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
30334  }
30335};
30336
30337EC.prototype.verify = function verify(msg, signature, key, enc) {
30338  msg = this._truncateToN(new BN(msg, 16));
30339  key = this.keyFromPublic(key, enc);
30340  signature = new Signature(signature, 'hex');
30341
30342  // Perform primitive values validation
30343  var r = signature.r;
30344  var s = signature.s;
30345  if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
30346    return false;
30347  if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
30348    return false;
30349
30350  // Validate signature
30351  var sinv = s.invm(this.n);
30352  var u1 = sinv.mul(msg).umod(this.n);
30353  var u2 = sinv.mul(r).umod(this.n);
30354
30355  if (!this.curve._maxwellTrick) {
30356    var p = this.g.mulAdd(u1, key.getPublic(), u2);
30357    if (p.isInfinity())
30358      return false;
30359
30360    return p.getX().umod(this.n).cmp(r) === 0;
30361  }
30362
30363  // NOTE: Greg Maxwell's trick, inspired by:
30364  // https://git.io/vad3K
30365
30366  var p = this.g.jmulAdd(u1, key.getPublic(), u2);
30367  if (p.isInfinity())
30368    return false;
30369
30370  // Compare `p.x` of Jacobian point with `r`,
30371  // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
30372  // inverse of `p.z^2`
30373  return p.eqXToP(r);
30374};
30375
30376EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
30377  assert((3 & j) === j, 'The recovery param is more than two bits');
30378  signature = new Signature(signature, enc);
30379
30380  var n = this.n;
30381  var e = new BN(msg);
30382  var r = signature.r;
30383  var s = signature.s;
30384
30385  // A set LSB signifies that the y-coordinate is odd
30386  var isYOdd = j & 1;
30387  var isSecondKey = j >> 1;
30388  if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
30389    throw new Error('Unable to find sencond key candinate');
30390
30391  // 1.1. Let x = r + jn.
30392  if (isSecondKey)
30393    r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
30394  else
30395    r = this.curve.pointFromX(r, isYOdd);
30396
30397  var rInv = signature.r.invm(n);
30398  var s1 = n.sub(e).mul(rInv).umod(n);
30399  var s2 = s.mul(rInv).umod(n);
30400
30401  // 1.6.1 Compute Q = r^-1 (sR -  eG)
30402  //               Q = r^-1 (sR + -eG)
30403  return this.g.mulAdd(s1, r, s2);
30404};
30405
30406EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
30407  signature = new Signature(signature, enc);
30408  if (signature.recoveryParam !== null)
30409    return signature.recoveryParam;
30410
30411  for (var i = 0; i < 4; i++) {
30412    var Qprime;
30413    try {
30414      Qprime = this.recoverPubKey(e, signature, i);
30415    } catch (e) {
30416      continue;
30417    }
30418
30419    if (Qprime.eq(Q))
30420      return i;
30421  }
30422  throw new Error('Unable to find valid recovery factor');
30423};
30424
30425
30426/***/ },
30427/* 20 */
30428/***/ function(module, exports, __webpack_require__) {
30429
30430"use strict";
30431'use strict';
30432
30433var BN = __webpack_require__(1);
30434
30435function KeyPair(ec, options) {
30436  this.ec = ec;
30437  this.priv = null;
30438  this.pub = null;
30439
30440  // KeyPair(ec, { priv: ..., pub: ... })
30441  if (options.priv)
30442    this._importPrivate(options.priv, options.privEnc);
30443  if (options.pub)
30444    this._importPublic(options.pub, options.pubEnc);
30445}
30446module.exports = KeyPair;
30447
30448KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
30449  if (pub instanceof KeyPair)
30450    return pub;
30451
30452  return new KeyPair(ec, {
30453    pub: pub,
30454    pubEnc: enc
30455  });
30456};
30457
30458KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
30459  if (priv instanceof KeyPair)
30460    return priv;
30461
30462  return new KeyPair(ec, {
30463    priv: priv,
30464    privEnc: enc
30465  });
30466};
30467
30468KeyPair.prototype.validate = function validate() {
30469  var pub = this.getPublic();
30470
30471  if (pub.isInfinity())
30472    return { result: false, reason: 'Invalid public key' };
30473  if (!pub.validate())
30474    return { result: false, reason: 'Public key is not a point' };
30475  if (!pub.mul(this.ec.curve.n).isInfinity())
30476    return { result: false, reason: 'Public key * N != O' };
30477
30478  return { result: true, reason: null };
30479};
30480
30481KeyPair.prototype.getPublic = function getPublic(compact, enc) {
30482  // compact is optional argument
30483  if (typeof compact === 'string') {
30484    enc = compact;
30485    compact = null;
30486  }
30487
30488  if (!this.pub)
30489    this.pub = this.ec.g.mul(this.priv);
30490
30491  if (!enc)
30492    return this.pub;
30493
30494  return this.pub.encode(enc, compact);
30495};
30496
30497KeyPair.prototype.getPrivate = function getPrivate(enc) {
30498  if (enc === 'hex')
30499    return this.priv.toString(16, 2);
30500  else
30501    return this.priv;
30502};
30503
30504KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
30505  this.priv = new BN(key, enc || 16);
30506
30507  // Ensure that the priv won't be bigger than n, otherwise we may fail
30508  // in fixed multiplication method
30509  this.priv = this.priv.umod(this.ec.curve.n);
30510};
30511
30512KeyPair.prototype._importPublic = function _importPublic(key, enc) {
30513  if (key.x || key.y) {
30514    this.pub = this.ec.curve.point(key.x, key.y);
30515    return;
30516  }
30517  this.pub = this.ec.curve.decodePoint(key, enc);
30518};
30519
30520// ECDH
30521KeyPair.prototype.derive = function derive(pub) {
30522  return pub.mul(this.priv).getX();
30523};
30524
30525// ECDSA
30526KeyPair.prototype.sign = function sign(msg, enc, options) {
30527  return this.ec.sign(msg, this, enc, options);
30528};
30529
30530KeyPair.prototype.verify = function verify(msg, signature) {
30531  return this.ec.verify(msg, signature, this);
30532};
30533
30534KeyPair.prototype.inspect = function inspect() {
30535  return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
30536         ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
30537};
30538
30539
30540/***/ },
30541/* 21 */
30542/***/ function(module, exports, __webpack_require__) {
30543
30544"use strict";
30545'use strict';
30546
30547var BN = __webpack_require__(1);
30548
30549var elliptic = __webpack_require__(0);
30550var utils = elliptic.utils;
30551var assert = utils.assert;
30552
30553function Signature(options, enc) {
30554  if (options instanceof Signature)
30555    return options;
30556
30557  if (this._importDER(options, enc))
30558    return;
30559
30560  assert(options.r && options.s, 'Signature without r or s');
30561  this.r = new BN(options.r, 16);
30562  this.s = new BN(options.s, 16);
30563  if (options.recoveryParam === undefined)
30564    this.recoveryParam = null;
30565  else
30566    this.recoveryParam = options.recoveryParam;
30567}
30568module.exports = Signature;
30569
30570function Position() {
30571  this.place = 0;
30572}
30573
30574function getLength(buf, p) {
30575  var initial = buf[p.place++];
30576  if (!(initial & 0x80)) {
30577    return initial;
30578  }
30579  var octetLen = initial & 0xf;
30580  var val = 0;
30581  for (var i = 0, off = p.place; i < octetLen; i++, off++) {
30582    val <<= 8;
30583    val |= buf[off];
30584  }
30585  p.place = off;
30586  return val;
30587}
30588
30589function rmPadding(buf) {
30590  var i = 0;
30591  var len = buf.length - 1;
30592  while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
30593    i++;
30594  }
30595  if (i === 0) {
30596    return buf;
30597  }
30598  return buf.slice(i);
30599}
30600
30601Signature.prototype._importDER = function _importDER(data, enc) {
30602  data = utils.toArray(data, enc);
30603  var p = new Position();
30604  if (data[p.place++] !== 0x30) {
30605    return false;
30606  }
30607  var len = getLength(data, p);
30608  if ((len + p.place) !== data.length) {
30609    return false;
30610  }
30611  if (data[p.place++] !== 0x02) {
30612    return false;
30613  }
30614  var rlen = getLength(data, p);
30615  var r = data.slice(p.place, rlen + p.place);
30616  p.place += rlen;
30617  if (data[p.place++] !== 0x02) {
30618    return false;
30619  }
30620  var slen = getLength(data, p);
30621  if (data.length !== slen + p.place) {
30622    return false;
30623  }
30624  var s = data.slice(p.place, slen + p.place);
30625  if (r[0] === 0 && (r[1] & 0x80)) {
30626    r = r.slice(1);
30627  }
30628  if (s[0] === 0 && (s[1] & 0x80)) {
30629    s = s.slice(1);
30630  }
30631
30632  this.r = new BN(r);
30633  this.s = new BN(s);
30634  this.recoveryParam = null;
30635
30636  return true;
30637};
30638
30639function constructLength(arr, len) {
30640  if (len < 0x80) {
30641    arr.push(len);
30642    return;
30643  }
30644  var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
30645  arr.push(octets | 0x80);
30646  while (--octets) {
30647    arr.push((len >>> (octets << 3)) & 0xff);
30648  }
30649  arr.push(len);
30650}
30651
30652Signature.prototype.toDER = function toDER(enc) {
30653  var r = this.r.toArray();
30654  var s = this.s.toArray();
30655
30656  // Pad values
30657  if (r[0] & 0x80)
30658    r = [ 0 ].concat(r);
30659  // Pad values
30660  if (s[0] & 0x80)
30661    s = [ 0 ].concat(s);
30662
30663  r = rmPadding(r);
30664  s = rmPadding(s);
30665
30666  while (!s[0] && !(s[1] & 0x80)) {
30667    s = s.slice(1);
30668  }
30669  var arr = [ 0x02 ];
30670  constructLength(arr, r.length);
30671  arr = arr.concat(r);
30672  arr.push(0x02);
30673  constructLength(arr, s.length);
30674  var backHalf = arr.concat(s);
30675  var res = [ 0x30 ];
30676  constructLength(res, backHalf.length);
30677  res = res.concat(backHalf);
30678  return utils.encode(res, enc);
30679};
30680
30681
30682/***/ },
30683/* 22 */
30684/***/ function(module, exports, __webpack_require__) {
30685
30686"use strict";
30687'use strict';
30688
30689var hash = __webpack_require__(2);
30690var elliptic = __webpack_require__(0);
30691var utils = elliptic.utils;
30692var assert = utils.assert;
30693var parseBytes = utils.parseBytes;
30694var KeyPair = __webpack_require__(23);
30695var Signature = __webpack_require__(24);
30696
30697function EDDSA(curve) {
30698  assert(curve === 'ed25519', 'only tested with ed25519 so far');
30699
30700  if (!(this instanceof EDDSA))
30701    return new EDDSA(curve);
30702
30703  var curve = elliptic.curves[curve].curve;
30704  this.curve = curve;
30705  this.g = curve.g;
30706  this.g.precompute(curve.n.bitLength() + 1);
30707
30708  this.pointClass = curve.point().constructor;
30709  this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
30710  this.hash = hash.sha512;
30711}
30712
30713module.exports = EDDSA;
30714
30715/**
30716* @param {Array|String} message - message bytes
30717* @param {Array|String|KeyPair} secret - secret bytes or a keypair
30718* @returns {Signature} - signature
30719*/
30720EDDSA.prototype.sign = function sign(message, secret) {
30721  message = parseBytes(message);
30722  var key = this.keyFromSecret(secret);
30723  var r = this.hashInt(key.messagePrefix(), message);
30724  var R = this.g.mul(r);
30725  var Rencoded = this.encodePoint(R);
30726  var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
30727               .mul(key.priv());
30728  var S = r.add(s_).umod(this.curve.n);
30729  return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
30730};
30731
30732/**
30733* @param {Array} message - message bytes
30734* @param {Array|String|Signature} sig - sig bytes
30735* @param {Array|String|Point|KeyPair} pub - public key
30736* @returns {Boolean} - true if public key matches sig of message
30737*/
30738EDDSA.prototype.verify = function verify(message, sig, pub) {
30739  message = parseBytes(message);
30740  sig = this.makeSignature(sig);
30741  var key = this.keyFromPublic(pub);
30742  var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
30743  var SG = this.g.mul(sig.S());
30744  var RplusAh = sig.R().add(key.pub().mul(h));
30745  return RplusAh.eq(SG);
30746};
30747
30748EDDSA.prototype.hashInt = function hashInt() {
30749  var hash = this.hash();
30750  for (var i = 0; i < arguments.length; i++)
30751    hash.update(arguments[i]);
30752  return utils.intFromLE(hash.digest()).umod(this.curve.n);
30753};
30754
30755EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
30756  return KeyPair.fromPublic(this, pub);
30757};
30758
30759EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
30760  return KeyPair.fromSecret(this, secret);
30761};
30762
30763EDDSA.prototype.makeSignature = function makeSignature(sig) {
30764  if (sig instanceof Signature)
30765    return sig;
30766  return new Signature(this, sig);
30767};
30768
30769/**
30770* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
30771*
30772* EDDSA defines methods for encoding and decoding points and integers. These are
30773* helper convenience methods, that pass along to utility functions implied
30774* parameters.
30775*
30776*/
30777EDDSA.prototype.encodePoint = function encodePoint(point) {
30778  var enc = point.getY().toArray('le', this.encodingLength);
30779  enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
30780  return enc;
30781};
30782
30783EDDSA.prototype.decodePoint = function decodePoint(bytes) {
30784  bytes = utils.parseBytes(bytes);
30785
30786  var lastIx = bytes.length - 1;
30787  var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
30788  var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
30789
30790  var y = utils.intFromLE(normed);
30791  return this.curve.pointFromY(y, xIsOdd);
30792};
30793
30794EDDSA.prototype.encodeInt = function encodeInt(num) {
30795  return num.toArray('le', this.encodingLength);
30796};
30797
30798EDDSA.prototype.decodeInt = function decodeInt(bytes) {
30799  return utils.intFromLE(bytes);
30800};
30801
30802EDDSA.prototype.isPoint = function isPoint(val) {
30803  return val instanceof this.pointClass;
30804};
30805
30806
30807/***/ },
30808/* 23 */
30809/***/ function(module, exports, __webpack_require__) {
30810
30811"use strict";
30812'use strict';
30813
30814var elliptic = __webpack_require__(0);
30815var utils = elliptic.utils;
30816var assert = utils.assert;
30817var parseBytes = utils.parseBytes;
30818var cachedProperty = utils.cachedProperty;
30819
30820/**
30821* @param {EDDSA} eddsa - instance
30822* @param {Object} params - public/private key parameters
30823*
30824* @param {Array<Byte>} [params.secret] - secret seed bytes
30825* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
30826* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
30827*
30828*/
30829function KeyPair(eddsa, params) {
30830  this.eddsa = eddsa;
30831  this._secret = parseBytes(params.secret);
30832  if (eddsa.isPoint(params.pub))
30833    this._pub = params.pub;
30834  else
30835    this._pubBytes = parseBytes(params.pub);
30836}
30837
30838KeyPair.fromPublic = function fromPublic(eddsa, pub) {
30839  if (pub instanceof KeyPair)
30840    return pub;
30841  return new KeyPair(eddsa, { pub: pub });
30842};
30843
30844KeyPair.fromSecret = function fromSecret(eddsa, secret) {
30845  if (secret instanceof KeyPair)
30846    return secret;
30847  return new KeyPair(eddsa, { secret: secret });
30848};
30849
30850KeyPair.prototype.secret = function secret() {
30851  return this._secret;
30852};
30853
30854cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
30855  return this.eddsa.encodePoint(this.pub());
30856});
30857
30858cachedProperty(KeyPair, 'pub', function pub() {
30859  if (this._pubBytes)
30860    return this.eddsa.decodePoint(this._pubBytes);
30861  return this.eddsa.g.mul(this.priv());
30862});
30863
30864cachedProperty(KeyPair, 'privBytes', function privBytes() {
30865  var eddsa = this.eddsa;
30866  var hash = this.hash();
30867  var lastIx = eddsa.encodingLength - 1;
30868
30869  var a = hash.slice(0, eddsa.encodingLength);
30870  a[0] &= 248;
30871  a[lastIx] &= 127;
30872  a[lastIx] |= 64;
30873
30874  return a;
30875});
30876
30877cachedProperty(KeyPair, 'priv', function priv() {
30878  return this.eddsa.decodeInt(this.privBytes());
30879});
30880
30881cachedProperty(KeyPair, 'hash', function hash() {
30882  return this.eddsa.hash().update(this.secret()).digest();
30883});
30884
30885cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
30886  return this.hash().slice(this.eddsa.encodingLength);
30887});
30888
30889KeyPair.prototype.sign = function sign(message) {
30890  assert(this._secret, 'KeyPair can only verify');
30891  return this.eddsa.sign(message, this);
30892};
30893
30894KeyPair.prototype.verify = function verify(message, sig) {
30895  return this.eddsa.verify(message, sig, this);
30896};
30897
30898KeyPair.prototype.getSecret = function getSecret(enc) {
30899  assert(this._secret, 'KeyPair is public only');
30900  return utils.encode(this.secret(), enc);
30901};
30902
30903KeyPair.prototype.getPublic = function getPublic(enc) {
30904  return utils.encode(this.pubBytes(), enc);
30905};
30906
30907module.exports = KeyPair;
30908
30909
30910/***/ },
30911/* 24 */
30912/***/ function(module, exports, __webpack_require__) {
30913
30914"use strict";
30915'use strict';
30916
30917var BN = __webpack_require__(1);
30918var elliptic = __webpack_require__(0);
30919var utils = elliptic.utils;
30920var assert = utils.assert;
30921var cachedProperty = utils.cachedProperty;
30922var parseBytes = utils.parseBytes;
30923
30924/**
30925* @param {EDDSA} eddsa - eddsa instance
30926* @param {Array<Bytes>|Object} sig -
30927* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
30928* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
30929* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
30930* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
30931*/
30932function Signature(eddsa, sig) {
30933  this.eddsa = eddsa;
30934
30935  if (typeof sig !== 'object')
30936    sig = parseBytes(sig);
30937
30938  if (Array.isArray(sig)) {
30939    sig = {
30940      R: sig.slice(0, eddsa.encodingLength),
30941      S: sig.slice(eddsa.encodingLength)
30942    };
30943  }
30944
30945  assert(sig.R && sig.S, 'Signature without R or S');
30946
30947  if (eddsa.isPoint(sig.R))
30948    this._R = sig.R;
30949  if (sig.S instanceof BN)
30950    this._S = sig.S;
30951
30952  this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
30953  this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
30954}
30955
30956cachedProperty(Signature, 'S', function S() {
30957  return this.eddsa.decodeInt(this.Sencoded());
30958});
30959
30960cachedProperty(Signature, 'R', function R() {
30961  return this.eddsa.decodePoint(this.Rencoded());
30962});
30963
30964cachedProperty(Signature, 'Rencoded', function Rencoded() {
30965  return this.eddsa.encodePoint(this.R());
30966});
30967
30968cachedProperty(Signature, 'Sencoded', function Sencoded() {
30969  return this.eddsa.encodeInt(this.S());
30970});
30971
30972Signature.prototype.toBytes = function toBytes() {
30973  return this.Rencoded().concat(this.Sencoded());
30974};
30975
30976Signature.prototype.toHex = function toHex() {
30977  return utils.encode(this.toBytes(), 'hex').toUpperCase();
30978};
30979
30980module.exports = Signature;
30981
30982
30983/***/ },
30984/* 25 */
30985/***/ function(module, exports, __webpack_require__) {
30986
30987"use strict";
30988'use strict';
30989
30990var hash = __webpack_require__(2);
30991var elliptic = __webpack_require__(0);
30992var utils = elliptic.utils;
30993var assert = utils.assert;
30994
30995function HmacDRBG(options) {
30996  if (!(this instanceof HmacDRBG))
30997    return new HmacDRBG(options);
30998  this.hash = options.hash;
30999  this.predResist = !!options.predResist;
31000
31001  this.outLen = this.hash.outSize;
31002  this.minEntropy = options.minEntropy || this.hash.hmacStrength;
31003
31004  this.reseed = null;
31005  this.reseedInterval = null;
31006  this.K = null;
31007  this.V = null;
31008
31009  var entropy = utils.toArray(options.entropy, options.entropyEnc);
31010  var nonce = utils.toArray(options.nonce, options.nonceEnc);
31011  var pers = utils.toArray(options.pers, options.persEnc);
31012  assert(entropy.length >= (this.minEntropy / 8),
31013         'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
31014  this._init(entropy, nonce, pers);
31015}
31016module.exports = HmacDRBG;
31017
31018HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
31019  var seed = entropy.concat(nonce).concat(pers);
31020
31021  this.K = new Array(this.outLen / 8);
31022  this.V = new Array(this.outLen / 8);
31023  for (var i = 0; i < this.V.length; i++) {
31024    this.K[i] = 0x00;
31025    this.V[i] = 0x01;
31026  }
31027
31028  this._update(seed);
31029  this.reseed = 1;
31030  this.reseedInterval = 0x1000000000000;  // 2^48
31031};
31032
31033HmacDRBG.prototype._hmac = function hmac() {
31034  return new hash.hmac(this.hash, this.K);
31035};
31036
31037HmacDRBG.prototype._update = function update(seed) {
31038  var kmac = this._hmac()
31039                 .update(this.V)
31040                 .update([ 0x00 ]);
31041  if (seed)
31042    kmac = kmac.update(seed);
31043  this.K = kmac.digest();
31044  this.V = this._hmac().update(this.V).digest();
31045  if (!seed)
31046    return;
31047
31048  this.K = this._hmac()
31049               .update(this.V)
31050               .update([ 0x01 ])
31051               .update(seed)
31052               .digest();
31053  this.V = this._hmac().update(this.V).digest();
31054};
31055
31056HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
31057  // Optional entropy enc
31058  if (typeof entropyEnc !== 'string') {
31059    addEnc = add;
31060    add = entropyEnc;
31061    entropyEnc = null;
31062  }
31063
31064  entropy = utils.toBuffer(entropy, entropyEnc);
31065  add = utils.toBuffer(add, addEnc);
31066
31067  assert(entropy.length >= (this.minEntropy / 8),
31068         'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
31069
31070  this._update(entropy.concat(add || []));
31071  this.reseed = 1;
31072};
31073
31074HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
31075  if (this.reseed > this.reseedInterval)
31076    throw new Error('Reseed is required');
31077
31078  // Optional encoding
31079  if (typeof enc !== 'string') {
31080    addEnc = add;
31081    add = enc;
31082    enc = null;
31083  }
31084
31085  // Optional additional data
31086  if (add) {
31087    add = utils.toArray(add, addEnc);
31088    this._update(add);
31089  }
31090
31091  var temp = [];
31092  while (temp.length < len) {
31093    this.V = this._hmac().update(this.V).digest();
31094    temp = temp.concat(this.V);
31095  }
31096
31097  var res = temp.slice(0, len);
31098  this._update(add);
31099  this.reseed++;
31100  return utils.encode(res, enc);
31101};
31102
31103
31104/***/ },
31105/* 26 */
31106/***/ 
vendor: 32,376 bytes, lines 31106-31890
31106function(module, exports) {
31107
31108module.exports = {
31109  doubles: {
31110    step: 4,
31111    points: [
31112      [
31113        'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
31114        'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
31115      ],
31116      [
31117        '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
31118        '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
31119      ],
31120      [
31121        '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
31122        'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
31123      ],
31124      [
31125        '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
31126        '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
31127      ],
31128      [
31129        '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
31130        '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
31131      ],
31132      [
31133        '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
31134        '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
31135      ],
31136      [
31137        'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
31138        '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
31139      ],
31140      [
31141        '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
31142        'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
31143      ],
31144      [
31145        'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
31146        '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
31147      ],
31148      [
31149        'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
31150        'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
31151      ],
31152      [
31153        'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
31154        '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
31155      ],
31156      [
31157        '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
31158        '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
31159      ],
31160      [
31161        '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
31162        '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
31163      ],
31164      [
31165        '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
31166        '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
31167      ],
31168      [
31169        '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
31170        '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
31171      ],
31172      [
31173        '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
31174        '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
31175      ],
31176      [
31177        '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
31178        '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
31179      ],
31180      [
31181        '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
31182        '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
31183      ],
31184      [
31185        '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
31186        'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
31187      ],
31188      [
31189        'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
31190        '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
31191      ],
31192      [
31193        'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
31194        '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
31195      ],
31196      [
31197        '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
31198        '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
31199      ],
31200      [
31201        '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
31202        '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
31203      ],
31204      [
31205        'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
31206        '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
31207      ],
31208      [
31209        '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
31210        'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
31211      ],
31212      [
31213        'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
31214        '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
31215      ],
31216      [
31217        'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
31218        'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
31219      ],
31220      [
31221        'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
31222        '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
31223      ],
31224      [
31225        'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
31226        'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
31227      ],
31228      [
31229        'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
31230        '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
31231      ],
31232      [
31233        '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
31234        'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
31235      ],
31236      [
31237        '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
31238        '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
31239      ],
31240      [
31241        'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
31242        '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
31243      ],
31244      [
31245        '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
31246        'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
31247      ],
31248      [
31249        'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
31250        '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
31251      ],
31252      [
31253        'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
31254        '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
31255      ],
31256      [
31257        'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
31258        'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
31259      ],
31260      [
31261        '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
31262        '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
31263      ],
31264      [
31265        '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
31266        '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
31267      ],
31268      [
31269        '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
31270        'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
31271      ],
31272      [
31273        '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
31274        '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
31275      ],
31276      [
31277        'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
31278        '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
31279      ],
31280      [
31281        '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
31282        '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
31283      ],
31284      [
31285        '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
31286        'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
31287      ],
31288      [
31289        '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
31290        '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
31291      ],
31292      [
31293        'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
31294        '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
31295      ],
31296      [
31297        '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
31298        'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
31299      ],
31300      [
31301        'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
31302        'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
31303      ],
31304      [
31305        'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
31306        '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
31307      ],
31308      [
31309        '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
31310        'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
31311      ],
31312      [
31313        '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
31314        'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
31315      ],
31316      [
31317        'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
31318        '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
31319      ],
31320      [
31321        'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
31322        '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
31323      ],
31324      [
31325        'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
31326        '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
31327      ],
31328      [
31329        '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
31330        'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
31331      ],
31332      [
31333        '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
31334        '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
31335      ],
31336      [
31337        'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
31338        'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
31339      ],
31340      [
31341        '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
31342        'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
31343      ],
31344      [
31345        '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
31346        '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
31347      ],
31348      [
31349        '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
31350        '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
31351      ],
31352      [
31353        'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
31354        'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
31355      ],
31356      [
31357        '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
31358        '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
31359      ],
31360      [
31361        '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
31362        '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
31363      ],
31364      [
31365        'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
31366        '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
31367      ],
31368      [
31369        'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
31370        'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
31371      ]
31372    ]
31373  },
31374  naf: {
31375    wnd: 7,
31376    points: [
31377      [
31378        'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
31379        '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
31380      ],
31381      [
31382        '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
31383        'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
31384      ],
31385      [
31386        '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
31387        '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
31388      ],
31389      [
31390        'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
31391        'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
31392      ],
31393      [
31394        '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
31395        'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
31396      ],
31397      [
31398        'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
31399        'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
31400      ],
31401      [
31402        'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
31403        '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
31404      ],
31405      [
31406        'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
31407        '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
31408      ],
31409      [
31410        '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
31411        '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
31412      ],
31413      [
31414        '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
31415        '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
31416      ],
31417      [
31418        '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
31419        '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
31420      ],
31421      [
31422        '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
31423        '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
31424      ],
31425      [
31426        'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
31427        'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
31428      ],
31429      [
31430        'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
31431        '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
31432      ],
31433      [
31434        '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
31435        'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
31436      ],
31437      [
31438        '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
31439        'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
31440      ],
31441      [
31442        '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
31443        '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
31444      ],
31445      [
31446        '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
31447        '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
31448      ],
31449      [
31450        '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
31451        '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
31452      ],
31453      [
31454        '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
31455        'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
31456      ],
31457      [
31458        'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
31459        'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
31460      ],
31461      [
31462        '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
31463        '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
31464      ],
31465      [
31466        '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
31467        '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
31468      ],
31469      [
31470        'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
31471        'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
31472      ],
31473      [
31474        '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
31475        '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
31476      ],
31477      [
31478        'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
31479        'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
31480      ],
31481      [
31482        'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
31483        'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
31484      ],
31485      [
31486        '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
31487        '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
31488      ],
31489      [
31490        '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
31491        '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
31492      ],
31493      [
31494        '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
31495        '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
31496      ],
31497      [
31498        'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
31499        '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
31500      ],
31501      [
31502        '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
31503        '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
31504      ],
31505      [
31506        'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
31507        '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
31508      ],
31509      [
31510        '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
31511        'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
31512      ],
31513      [
31514        '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
31515        'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
31516      ],
31517      [
31518        'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
31519        'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
31520      ],
31521      [
31522        '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
31523        '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
31524      ],
31525      [
31526        '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
31527        'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
31528      ],
31529      [
31530        'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
31531        'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
31532      ],
31533      [
31534        '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
31535        '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
31536      ],
31537      [
31538        '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
31539        'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
31540      ],
31541      [
31542        '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
31543        '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
31544      ],
31545      [
31546        '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
31547        'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
31548      ],
31549      [
31550        'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
31551        '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
31552      ],
31553      [
31554        '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
31555        '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
31556      ],
31557      [
31558        '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
31559        'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
31560      ],
31561      [
31562        '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
31563        'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
31564      ],
31565      [
31566        'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
31567        'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
31568      ],
31569      [
31570        'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
31571        'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
31572      ],
31573      [
31574        '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
31575        '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
31576      ],
31577      [
31578        '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
31579        '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
31580      ],
31581      [
31582        'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
31583        '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
31584      ],
31585      [
31586        'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
31587        'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
31588      ],
31589      [
31590        '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
31591        '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
31592      ],
31593      [
31594        '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
31595        '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
31596      ],
31597      [
31598        'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
31599        '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
31600      ],
31601      [
31602        '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
31603        '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
31604      ],
31605      [
31606        'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
31607        'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
31608      ],
31609      [
31610        '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
31611        'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
31612      ],
31613      [
31614        '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
31615        '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
31616      ],
31617      [
31618        'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
31619        '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
31620      ],
31621      [
31622        'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
31623        '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
31624      ],
31625      [
31626        '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
31627        '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
31628      ],
31629      [
31630        '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
31631        '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
31632      ],
31633      [
31634        '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
31635        'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
31636      ],
31637      [
31638        '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
31639        'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
31640      ],
31641      [
31642        '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
31643        '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
31644      ],
31645      [
31646        '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
31647        '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
31648      ],
31649      [
31650        '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
31651        '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
31652      ],
31653      [
31654        '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
31655        'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
31656      ],
31657      [
31658        'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
31659        'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
31660      ],
31661      [
31662        '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
31663        'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
31664      ],
31665      [
31666        'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
31667        '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
31668      ],
31669      [
31670        'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
31671        '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
31672      ],
31673      [
31674        'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
31675        '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
31676      ],
31677      [
31678        'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
31679        '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
31680      ],
31681      [
31682        '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
31683        'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
31684      ],
31685      [
31686        '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
31687        '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
31688      ],
31689      [
31690        '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
31691        'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
31692      ],
31693      [
31694        'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
31695        'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
31696      ],
31697      [
31698        'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
31699        '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
31700      ],
31701      [
31702        'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
31703        'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
31704      ],
31705      [
31706        'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
31707        '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
31708      ],
31709      [
31710        '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
31711        '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
31712      ],
31713      [
31714        'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
31715        '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
31716      ],
31717      [
31718        'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
31719        '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
31720      ],
31721      [
31722        '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
31723        '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
31724      ],
31725      [
31726        '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
31727        'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
31728      ],
31729      [
31730        'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
31731        '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
31732      ],
31733      [
31734        'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
31735        '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
31736      ],
31737      [
31738        'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
31739        '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
31740      ],
31741      [
31742        '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
31743        '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
31744      ],
31745      [
31746        'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
31747        'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
31748      ],
31749      [
31750        '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
31751        'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
31752      ],
31753      [
31754        'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
31755        'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
31756      ],
31757      [
31758        'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
31759        '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
31760      ],
31761      [
31762        '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
31763        'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
31764      ],
31765      [
31766        'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
31767        '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
31768      ],
31769      [
31770        'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
31771        '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
31772      ],
31773      [
31774        'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
31775        '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
31776      ],
31777      [
31778        '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
31779        'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
31780      ],
31781      [
31782        '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
31783        'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
31784      ],
31785      [
31786        'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
31787        '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
31788      ],
31789      [
31790        '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
31791        'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
31792      ],
31793      [
31794        '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
31795        '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
31796      ],
31797      [
31798        '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
31799        'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
31800      ],
31801      [
31802        'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
31803        'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
31804      ],
31805      [
31806        '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
31807        'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
31808      ],
31809      [
31810        '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
31811        '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
31812      ],
31813      [
31814        '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
31815        'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
31816      ],
31817      [
31818        '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
31819        '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
31820      ],
31821      [
31822        'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
31823        'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
31824      ],
31825      [
31826        '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
31827        '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
31828      ],
31829      [
31830        'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
31831        '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
31832      ],
31833      [
31834        '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
31835        '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
31836      ],
31837      [
31838        'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
31839        'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
31840      ],
31841      [
31842        'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
31843        '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
31844      ],
31845      [
31846        'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
31847        'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
31848      ],
31849      [
31850        '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
31851        'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
31852      ],
31853      [
31854        '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
31855        '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
31856      ],
31857      [
31858        '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
31859        'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
31860      ],
31861      [
31862        '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
31863        '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
31864      ],
31865      [
31866        '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
31867        '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
31868      ],
31869      [
31870        '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
31871        'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
31872      ],
31873      [
31874        '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
31875        '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
31876      ],
31877      [
31878        '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
31879        '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
31880      ],
31881      [
31882        '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
31883        '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
31884      ]
31885    ]
31886  }
31887};
31888
31889
31890/***/ }
31890,
31891/* 27 */
31892/***/ function(module, exports, __webpack_require__) {
31893
31894"use strict";
31895'use strict';
31896
31897var utils = exports;
31898var BN = __webpack_require__(1);
31899
31900utils.assert = function assert(val, msg) {
31901  if (!val)
31902    throw new Error(msg || 'Assertion failed');
31903};
31904
31905function toArray(msg, enc) {
31906  if (Array.isArray(msg))
31907    return msg.slice();
31908  if (!msg)
31909    return [];
31910  var res = [];
31911  if (typeof msg !== 'string') {
31912    for (var i = 0; i < msg.length; i++)
31913      res[i] = msg[i] | 0;
31914    return res;
31915  }
31916  if (!enc) {
31917    for (var i = 0; i < msg.length; i++) {
31918      var c = msg.charCodeAt(i);
31919      var hi = c >> 8;
31920      var lo = c & 0xff;
vendor: 11,310 bytes, lines 31921-32405
31921      if (hi)
31922        res.push(hi, lo);
31923      else
31924        res.push(lo);
31925    }
31926  } else if (enc === 'hex') {
31927    msg = msg.replace(/[^a-z0-9]+/ig, '');
31928    if (msg.length % 2 !== 0)
31929      msg = '0' + msg;
31930    for (var i = 0; i < msg.length; i += 2)
31931      res.push(parseInt(msg[i] + msg[i + 1], 16));
31932  }
31933  return res;
31934}
31935utils.toArray = toArray;
31936
31937function zero2(word) {
31938  if (word.length === 1)
31939    return '0' + word;
31940  else
31941    return word;
31942}
31943utils.zero2 = zero2;
31944
31945function toHex(msg) {
31946  var res = '';
31947  for (var i = 0; i < msg.length; i++)
31948    res += zero2(msg[i].toString(16));
31949  return res;
31950}
31951utils.toHex = toHex;
31952
31953utils.encode = function encode(arr, enc) {
31954  if (enc === 'hex')
31955    return toHex(arr);
31956  else
31957    return arr;
31958};
31959
31960// Represent num in a w-NAF form
31961function getNAF(num, w) {
31962  var naf = [];
31963  var ws = 1 << (w + 1);
31964  var k = num.clone();
31965  while (k.cmpn(1) >= 0) {
31966    var z;
31967    if (k.isOdd()) {
31968      var mod = k.andln(ws - 1);
31969      if (mod > (ws >> 1) - 1)
31970        z = (ws >> 1) - mod;
31971      else
31972        z = mod;
31973      k.isubn(z);
31974    } else {
31975      z = 0;
31976    }
31977    naf.push(z);
31978
31979    // Optimization, shift by word if possible
31980    var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
31981    for (var i = 1; i < shift; i++)
31982      naf.push(0);
31983    k.iushrn(shift);
31984  }
31985
31986  return naf;
31987}
31988utils.getNAF = getNAF;
31989
31990// Represent k1, k2 in a Joint Sparse Form
31991function getJSF(k1, k2) {
31992  var jsf = [
31993    [],
31994    []
31995  ];
31996
31997  k1 = k1.clone();
31998  k2 = k2.clone();
31999  var d1 = 0;
32000  var d2 = 0;
32001  while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
32002
32003    // First phase
32004    var m14 = (k1.andln(3) + d1) & 3;
32005    var m24 = (k2.andln(3) + d2) & 3;
32006    if (m14 === 3)
32007      m14 = -1;
32008    if (m24 === 3)
32009      m24 = -1;
32010    var u1;
32011    if ((m14 & 1) === 0) {
32012      u1 = 0;
32013    } else {
32014      var m8 = (k1.andln(7) + d1) & 7;
32015      if ((m8 === 3 || m8 === 5) && m24 === 2)
32016        u1 = -m14;
32017      else
32018        u1 = m14;
32019    }
32020    jsf[0].push(u1);
32021
32022    var u2;
32023    if ((m24 & 1) === 0) {
32024      u2 = 0;
32025    } else {
32026      var m8 = (k2.andln(7) + d2) & 7;
32027      if ((m8 === 3 || m8 === 5) && m14 === 2)
32028        u2 = -m24;
32029      else
32030        u2 = m24;
32031    }
32032    jsf[1].push(u2);
32033
32034    // Second phase
32035    if (2 * d1 === u1 + 1)
32036      d1 = 1 - d1;
32037    if (2 * d2 === u2 + 1)
32038      d2 = 1 - d2;
32039    k1.iushrn(1);
32040    k2.iushrn(1);
32041  }
32042
32043  return jsf;
32044}
32045utils.getJSF = getJSF;
32046
32047function cachedProperty(obj, name, computer) {
32048  var key = '_' + name;
32049  obj.prototype[name] = function cachedProperty() {
32050    return this[key] !== undefined ? this[key] :
32051           this[key] = computer.call(this);
32052  };
32053}
32054utils.cachedProperty = cachedProperty;
32055
32056function parseBytes(bytes) {
32057  return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
32058                                     bytes;
32059}
32060utils.parseBytes = parseBytes;
32061
32062function intFromLE(bytes) {
32063  return new BN(bytes, 'hex', 'le');
32064}
32065utils.intFromLE = intFromLE;
32066
32067
32068
32069/***/ },
32070/* 28 */
32071/***/ function(module, exports, __webpack_require__) {
32072
32073var hash = __webpack_require__(2);
32074var utils = hash.utils;
32075var assert = utils.assert;
32076
32077function BlockHash() {
32078  this.pending = null;
32079  this.pendingTotal = 0;
32080  this.blockSize = this.constructor.blockSize;
32081  this.outSize = this.constructor.outSize;
32082  this.hmacStrength = this.constructor.hmacStrength;
32083  this.padLength = this.constructor.padLength / 8;
32084  this.endian = 'big';
32085
32086  this._delta8 = this.blockSize / 8;
32087  this._delta32 = this.blockSize / 32;
32088}
32089exports.BlockHash = BlockHash;
32090
32091BlockHash.prototype.update = function update(msg, enc) {
32092  // Convert message to array, pad it, and join into 32bit blocks
32093  msg = utils.toArray(msg, enc);
32094  if (!this.pending)
32095    this.pending = msg;
32096  else
32097    this.pending = this.pending.concat(msg);
32098  this.pendingTotal += msg.length;
32099
32100  // Enough data, try updating
32101  if (this.pending.length >= this._delta8) {
32102    msg = this.pending;
32103
32104    // Process pending data in blocks
32105    var r = msg.length % this._delta8;
32106    this.pending = msg.slice(msg.length - r, msg.length);
32107    if (this.pending.length === 0)
32108      this.pending = null;
32109
32110    msg = utils.join32(msg, 0, msg.length - r, this.endian);
32111    for (var i = 0; i < msg.length; i += this._delta32)
32112      this._update(msg, i, i + this._delta32);
32113  }
32114
32115  return this;
32116};
32117
32118BlockHash.prototype.digest = function digest(enc) {
32119  this.update(this._pad());
32120  assert(this.pending === null);
32121
32122  return this._digest(enc);
32123};
32124
32125BlockHash.prototype._pad = function pad() {
32126  var len = this.pendingTotal;
32127  var bytes = this._delta8;
32128  var k = bytes - ((len + this.padLength) % bytes);
32129  var res = new Array(k + this.padLength);
32130  res[0] = 0x80;
32131  for (var i = 1; i < k; i++)
32132    res[i] = 0;
32133
32134  // Append length
32135  len <<= 3;
32136  if (this.endian === 'big') {
32137    for (var t = 8; t < this.padLength; t++)
32138      res[i++] = 0;
32139
32140    res[i++] = 0;
32141    res[i++] = 0;
32142    res[i++] = 0;
32143    res[i++] = 0;
32144    res[i++] = (len >>> 24) & 0xff;
32145    res[i++] = (len >>> 16) & 0xff;
32146    res[i++] = (len >>> 8) & 0xff;
32147    res[i++] = len & 0xff;
32148  } else {
32149    res[i++] = len & 0xff;
32150    res[i++] = (len >>> 8) & 0xff;
32151    res[i++] = (len >>> 16) & 0xff;
32152    res[i++] = (len >>> 24) & 0xff;
32153    res[i++] = 0;
32154    res[i++] = 0;
32155    res[i++] = 0;
32156    res[i++] = 0;
32157
32158    for (var t = 8; t < this.padLength; t++)
32159      res[i++] = 0;
32160  }
32161
32162  return res;
32163};
32164
32165
32166/***/ },
32167/* 29 */
32168/***/ function(module, exports, __webpack_require__) {
32169
32170var hmac = exports;
32171
32172var hash = __webpack_require__(2);
32173var utils = hash.utils;
32174var assert = utils.assert;
32175
32176function Hmac(hash, key, enc) {
32177  if (!(this instanceof Hmac))
32178    return new Hmac(hash, key, enc);
32179  this.Hash = hash;
32180  this.blockSize = hash.blockSize / 8;
32181  this.outSize = hash.outSize / 8;
32182  this.inner = null;
32183  this.outer = null;
32184
32185  this._init(utils.toArray(key, enc));
32186}
32187module.exports = Hmac;
32188
32189Hmac.prototype._init = function init(key) {
32190  // Shorten key, if needed
32191  if (key.length > this.blockSize)
32192    key = new this.Hash().update(key).digest();
32193  assert(key.length <= this.blockSize);
32194
32195  // Add padding to key
32196  for (var i = key.length; i < this.blockSize; i++)
32197    key.push(0);
32198
32199  for (var i = 0; i < key.length; i++)
32200    key[i] ^= 0x36;
32201  this.inner = new this.Hash().update(key);
32202
32203  // 0x36 ^ 0x5c = 0x6a
32204  for (var i = 0; i < key.length; i++)
32205    key[i] ^= 0x6a;
32206  this.outer = new this.Hash().update(key);
32207};
32208
32209Hmac.prototype.update = function update(msg, enc) {
32210  this.inner.update(msg, enc);
32211  return this;
32212};
32213
32214Hmac.prototype.digest = function digest(enc) {
32215  this.outer.update(this.inner.digest());
32216  return this.outer.digest(enc);
32217};
32218
32219
32220/***/ },
32221/* 30 */
32222/***/ function(module, exports, __webpack_require__) {
32223
32224var hash = __webpack_require__(2);
32225var utils = hash.utils;
32226
32227var rotl32 = utils.rotl32;
32228var sum32 = utils.sum32;
32229var sum32_3 = utils.sum32_3;
32230var sum32_4 = utils.sum32_4;
32231var BlockHash = hash.common.BlockHash;
32232
32233function RIPEMD160() {
32234  if (!(this instanceof RIPEMD160))
32235    return new RIPEMD160();
32236
32237  BlockHash.call(this);
32238
32239  this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
32240  this.endian = 'little';
32241}
32242utils.inherits(RIPEMD160, BlockHash);
32243exports.ripemd160 = RIPEMD160;
32244
32245RIPEMD160.blockSize = 512;
32246RIPEMD160.outSize = 160;
32247RIPEMD160.hmacStrength = 192;
32248RIPEMD160.padLength = 64;
32249
32250RIPEMD160.prototype._update = function update(msg, start) {
32251  var A = this.h[0];
32252  var B = this.h[1];
32253  var C = this.h[2];
32254  var D = this.h[3];
32255  var E = this.h[4];
32256  var Ah = A;
32257  var Bh = B;
32258  var Ch = C;
32259  var Dh = D;
32260  var Eh = E;
32261  for (var j = 0; j < 80; j++) {
32262    var T = sum32(
32263      rotl32(
32264        sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
32265        s[j]),
32266      E);
32267    A = E;
32268    E = D;
32269    D = rotl32(C, 10);
32270    C = B;
32271    B = T;
32272    T = sum32(
32273      rotl32(
32274        sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
32275        sh[j]),
32276      Eh);
32277    Ah = Eh;
32278    Eh = Dh;
32279    Dh = rotl32(Ch, 10);
32280    Ch = Bh;
32281    Bh = T;
32282  }
32283  T = sum32_3(this.h[1], C, Dh);
32284  this.h[1] = sum32_3(this.h[2], D, Eh);
32285  this.h[2] = sum32_3(this.h[3], E, Ah);
32286  this.h[3] = sum32_3(this.h[4], A, Bh);
32287  this.h[4] = sum32_3(this.h[0], B, Ch);
32288  this.h[0] = T;
32289};
32290
32291RIPEMD160.prototype._digest = function digest(enc) {
32292  if (enc === 'hex')
32293    return utils.toHex32(this.h, 'little');
32294  else
32295    return utils.split32(this.h, 'little');
32296};
32297
32298function f(j, x, y, z) {
32299  if (j <= 15)
32300    return x ^ y ^ z;
32301  else if (j <= 31)
32302    return (x & y) | ((~x) & z);
32303  else if (j <= 47)
32304    return (x | (~y)) ^ z;
32305  else if (j <= 63)
32306    return (x & z) | (y & (~z));
32307  else
32308    return x ^ (y | (~z));
32309}
32310
32311function K(j) {
32312  if (j <= 15)
32313    return 0x00000000;
32314  else if (j <= 31)
32315    return 0x5a827999;
32316  else if (j <= 47)
32317    return 0x6ed9eba1;
32318  else if (j <= 63)
32319    return 0x8f1bbcdc;
32320  else
32321    return 0xa953fd4e;
32322}
32323
32324function Kh(j) {
32325  if (j <= 15)
32326    return 0x50a28be6;
32327  else if (j <= 31)
32328    return 0x5c4dd124;
32329  else if (j <= 47)
32330    return 0x6d703ef3;
32331  else if (j <= 63)
32332    return 0x7a6d76e9;
32333  else
32334    return 0x00000000;
32335}
32336
32337var r = [
32338  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
32339  7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
32340  3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
32341  1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
32342  4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
32343];
32344
32345var rh = [
32346  5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
32347  6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
32348  15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
32349  8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
32350  12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
32351];
32352
32353var s = [
32354  11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
32355  7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
32356  11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
32357  11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
32358  9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
32359];
32360
32361var sh = [
32362  8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
32363  9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
32364  9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
32365  15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
32366  8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
32367];
32368
32369
32370/***/ },
32371/* 31 */
32372/***/ function(module, exports, __webpack_require__) {
32373
32374var hash = __webpack_require__(2);
32375var utils = hash.utils;
32376var assert = utils.assert;
32377
32378var rotr32 = utils.rotr32;
32379var rotl32 = utils.rotl32;
32380var sum32 = utils.sum32;
32381var sum32_4 = utils.sum32_4;
32382var sum32_5 = utils.sum32_5;
32383var rotr64_hi = utils.rotr64_hi;
32384var rotr64_lo = utils.rotr64_lo;
32385var shr64_hi = utils.shr64_hi;
32386var shr64_lo = utils.shr64_lo;
32387var sum64 = utils.sum64;
32388var sum64_hi = utils.sum64_hi;
32389var sum64_lo = utils.sum64_lo;
32390var sum64_4_hi = utils.sum64_4_hi;
32391var sum64_4_lo = utils.sum64_4_lo;
32392var sum64_5_hi = utils.sum64_5_hi;
32393var sum64_5_lo = utils.sum64_5_lo;
32394var BlockHash = hash.common.BlockHash;
32395
32396var sha256_K = [
32397  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
32398  0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
32399  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
32400  0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
32401  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
32402  0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
32403  0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
32404  0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
32405  0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
vendor: 8,807 bytes, lines 32406-32713
32406  0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
32407  0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
32408  0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
32409  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
32410  0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
32411  0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
32412  0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
32413];
32414
32415var sha512_K = [
32416  0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
32417  0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
32418  0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
32419  0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
32420  0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
32421  0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
32422  0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
32423  0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
32424  0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
32425  0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
32426  0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
32427  0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
32428  0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
32429  0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
32430  0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
32431  0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
32432  0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
32433  0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
32434  0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
32435  0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
32436  0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
32437  0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
32438  0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
32439  0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
32440  0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
32441  0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
32442  0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
32443  0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
32444  0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
32445  0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
32446  0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
32447  0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
32448  0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
32449  0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
32450  0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
32451  0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
32452  0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
32453  0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
32454  0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
32455  0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
32456];
32457
32458var sha1_K = [
32459  0x5A827999, 0x6ED9EBA1,
32460  0x8F1BBCDC, 0xCA62C1D6
32461];
32462
32463function SHA256() {
32464  if (!(this instanceof SHA256))
32465    return new SHA256();
32466
32467  BlockHash.call(this);
32468  this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
32469             0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
32470  this.k = sha256_K;
32471  this.W = new Array(64);
32472}
32473utils.inherits(SHA256, BlockHash);
32474exports.sha256 = SHA256;
32475
32476SHA256.blockSize = 512;
32477SHA256.outSize = 256;
32478SHA256.hmacStrength = 192;
32479SHA256.padLength = 64;
32480
32481SHA256.prototype._update = function _update(msg, start) {
32482  var W = this.W;
32483
32484  for (var i = 0; i < 16; i++)
32485    W[i] = msg[start + i];
32486  for (; i < W.length; i++)
32487    W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
32488
32489  var a = this.h[0];
32490  var b = this.h[1];
32491  var c = this.h[2];
32492  var d = this.h[3];
32493  var e = this.h[4];
32494  var f = this.h[5];
32495  var g = this.h[6];
32496  var h = this.h[7];
32497
32498  assert(this.k.length === W.length);
32499  for (var i = 0; i < W.length; i++) {
32500    var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
32501    var T2 = sum32(s0_256(a), maj32(a, b, c));
32502    h = g;
32503    g = f;
32504    f = e;
32505    e = sum32(d, T1);
32506    d = c;
32507    c = b;
32508    b = a;
32509    a = sum32(T1, T2);
32510  }
32511
32512  this.h[0] = sum32(this.h[0], a);
32513  this.h[1] = sum32(this.h[1], b);
32514  this.h[2] = sum32(this.h[2], c);
32515  this.h[3] = sum32(this.h[3], d);
32516  this.h[4] = sum32(this.h[4], e);
32517  this.h[5] = sum32(this.h[5], f);
32518  this.h[6] = sum32(this.h[6], g);
32519  this.h[7] = sum32(this.h[7], h);
32520};
32521
32522SHA256.prototype._digest = function digest(enc) {
32523  if (enc === 'hex')
32524    return utils.toHex32(this.h, 'big');
32525  else
32526    return utils.split32(this.h, 'big');
32527};
32528
32529function SHA224() {
32530  if (!(this instanceof SHA224))
32531    return new SHA224();
32532
32533  SHA256.call(this);
32534  this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
32535             0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
32536}
32537utils.inherits(SHA224, SHA256);
32538exports.sha224 = SHA224;
32539
32540SHA224.blockSize = 512;
32541SHA224.outSize = 224;
32542SHA224.hmacStrength = 192;
32543SHA224.padLength = 64;
32544
32545SHA224.prototype._digest = function digest(enc) {
32546  // Just truncate output
32547  if (enc === 'hex')
32548    return utils.toHex32(this.h.slice(0, 7), 'big');
32549  else
32550    return utils.split32(this.h.slice(0, 7), 'big');
32551};
32552
32553function SHA512() {
32554  if (!(this instanceof SHA512))
32555    return new SHA512();
32556
32557  BlockHash.call(this);
32558  this.h = [ 0x6a09e667, 0xf3bcc908,
32559             0xbb67ae85, 0x84caa73b,
32560             0x3c6ef372, 0xfe94f82b,
32561             0xa54ff53a, 0x5f1d36f1,
32562             0x510e527f, 0xade682d1,
32563             0x9b05688c, 0x2b3e6c1f,
32564             0x1f83d9ab, 0xfb41bd6b,
32565             0x5be0cd19, 0x137e2179 ];
32566  this.k = sha512_K;
32567  this.W = new Array(160);
32568}
32569utils.inherits(SHA512, BlockHash);
32570exports.sha512 = SHA512;
32571
32572SHA512.blockSize = 1024;
32573SHA512.outSize = 512;
32574SHA512.hmacStrength = 192;
32575SHA512.padLength = 128;
32576
32577SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
32578  var W = this.W;
32579
32580  // 32 x 32bit words
32581  for (var i = 0; i < 32; i++)
32582    W[i] = msg[start + i];
32583  for (; i < W.length; i += 2) {
32584    var c0_hi = g1_512_hi(W[i - 4], W[i - 3]);  // i - 2
32585    var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
32586    var c1_hi = W[i - 14];  // i - 7
32587    var c1_lo = W[i - 13];
32588    var c2_hi = g0_512_hi(W[i - 30], W[i - 29]);  // i - 15
32589    var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
32590    var c3_hi = W[i - 32];  // i - 16
32591    var c3_lo = W[i - 31];
32592
32593    W[i] = sum64_4_hi(c0_hi, c0_lo,
32594                      c1_hi, c1_lo,
32595                      c2_hi, c2_lo,
32596                      c3_hi, c3_lo);
32597    W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
32598                          c1_hi, c1_lo,
32599                          c2_hi, c2_lo,
32600                          c3_hi, c3_lo);
32601  }
32602};
32603
32604SHA512.prototype._update = function _update(msg, start) {
32605  this._prepareBlock(msg, start);
32606
32607  var W = this.W;
32608
32609  var ah = this.h[0];
32610  var al = this.h[1];
32611  var bh = this.h[2];
32612  var bl = this.h[3];
32613  var ch = this.h[4];
32614  var cl = this.h[5];
32615  var dh = this.h[6];
32616  var dl = this.h[7];
32617  var eh = this.h[8];
32618  var el = this.h[9];
32619  var fh = this.h[10];
32620  var fl = this.h[11];
32621  var gh = this.h[12];
32622  var gl = this.h[13];
32623  var hh = this.h[14];
32624  var hl = this.h[15];
32625
32626  assert(this.k.length === W.length);
32627  for (var i = 0; i < W.length; i += 2) {
32628    var c0_hi = hh;
32629    var c0_lo = hl;
32630    var c1_hi = s1_512_hi(eh, el);
32631    var c1_lo = s1_512_lo(eh, el);
32632    var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
32633    var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
32634    var c3_hi = this.k[i];
32635    var c3_lo = this.k[i + 1];
32636    var c4_hi = W[i];
32637    var c4_lo = W[i + 1];
32638
32639    var T1_hi = sum64_5_hi(c0_hi, c0_lo,
32640                           c1_hi, c1_lo,
32641                           c2_hi, c2_lo,
32642                           c3_hi, c3_lo,
32643                           c4_hi, c4_lo);
32644    var T1_lo = sum64_5_lo(c0_hi, c0_lo,
32645                           c1_hi, c1_lo,
32646                           c2_hi, c2_lo,
32647                           c3_hi, c3_lo,
32648                           c4_hi, c4_lo);
32649
32650    var c0_hi = s0_512_hi(ah, al);
32651    var c0_lo = s0_512_lo(ah, al);
32652    var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
32653    var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
32654
32655    var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
32656    var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
32657
32658    hh = gh;
32659    hl = gl;
32660
32661    gh = fh;
32662    gl = fl;
32663
32664    fh = eh;
32665    fl = el;
32666
32667    eh = sum64_hi(dh, dl, T1_hi, T1_lo);
32668    el = sum64_lo(dl, dl, T1_hi, T1_lo);
32669
32670    dh = ch;
32671    dl = cl;
32672
32673    ch = bh;
32674    cl = bl;
32675
32676    bh = ah;
32677    bl = al;
32678
32679    ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
32680    al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
32681  }
32682
32683  sum64(this.h, 0, ah, al);
32684  sum64(this.h, 2, bh, bl);
32685  sum64(this.h, 4, ch, cl);
32686  sum64(this.h, 6, dh, dl);
32687  sum64(this.h, 8, eh, el);
32688  sum64(this.h, 10, fh, fl);
32689  sum64(this.h, 12, gh, gl);
32690  sum64(this.h, 14, hh, hl);
32691};
32692
32693SHA512.prototype._digest = function digest(enc) {
32694  if (enc === 'hex')
32695    return utils.toHex32(this.h, 'big');
32696  else
32697    return utils.split32(this.h, 'big');
32698};
32699
32700function SHA384() {
32701  if (!(this instanceof SHA384))
32702    return new SHA384();
32703
32704  SHA512.call(this);
32705  this.h = [ 0xcbbb9d5d, 0xc1059ed8,
32706             0x629a292a, 0x367cd507,
32707             0x9159015a, 0x3070dd17,
32708             0x152fecd8, 0xf70e5939,
32709             0x67332667, 0xffc00b31,
32710             0x8eb44a87, 0x68581511,
32711             0xdb0c2e0d, 0x64f98fa7,
32712             0x47b5481d, 0xbefa4fa4 ];
32713}
vendor: 12,276 bytes, lines 32714-33287
32714utils.inherits(SHA384, SHA512);
32715exports.sha384 = SHA384;
32716
32717SHA384.blockSize = 1024;
32718SHA384.outSize = 384;
32719SHA384.hmacStrength = 192;
32720SHA384.padLength = 128;
32721
32722SHA384.prototype._digest = function digest(enc) {
32723  if (enc === 'hex')
32724    return utils.toHex32(this.h.slice(0, 12), 'big');
32725  else
32726    return utils.split32(this.h.slice(0, 12), 'big');
32727};
32728
32729function SHA1() {
32730  if (!(this instanceof SHA1))
32731    return new SHA1();
32732
32733  BlockHash.call(this);
32734  this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
32735             0x10325476, 0xc3d2e1f0 ];
32736  this.W = new Array(80);
32737}
32738
32739utils.inherits(SHA1, BlockHash);
32740exports.sha1 = SHA1;
32741
32742SHA1.blockSize = 512;
32743SHA1.outSize = 160;
32744SHA1.hmacStrength = 80;
32745SHA1.padLength = 64;
32746
32747SHA1.prototype._update = function _update(msg, start) {
32748  var W = this.W;
32749
32750  for (var i = 0; i < 16; i++)
32751    W[i] = msg[start + i];
32752
32753  for(; i < W.length; i++)
32754    W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
32755
32756  var a = this.h[0];
32757  var b = this.h[1];
32758  var c = this.h[2];
32759  var d = this.h[3];
32760  var e = this.h[4];
32761
32762  for (var i = 0; i < W.length; i++) {
32763    var s = ~~(i / 20);
32764    var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
32765    e = d;
32766    d = c;
32767    c = rotl32(b, 30);
32768    b = a;
32769    a = t;
32770  }
32771
32772  this.h[0] = sum32(this.h[0], a);
32773  this.h[1] = sum32(this.h[1], b);
32774  this.h[2] = sum32(this.h[2], c);
32775  this.h[3] = sum32(this.h[3], d);
32776  this.h[4] = sum32(this.h[4], e);
32777};
32778
32779SHA1.prototype._digest = function digest(enc) {
32780  if (enc === 'hex')
32781    return utils.toHex32(this.h, 'big');
32782  else
32783    return utils.split32(this.h, 'big');
32784};
32785
32786function ch32(x, y, z) {
32787  return (x & y) ^ ((~x) & z);
32788}
32789
32790function maj32(x, y, z) {
32791  return (x & y) ^ (x & z) ^ (y & z);
32792}
32793
32794function p32(x, y, z) {
32795  return x ^ y ^ z;
32796}
32797
32798function s0_256(x) {
32799  return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
32800}
32801
32802function s1_256(x) {
32803  return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
32804}
32805
32806function g0_256(x) {
32807  return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
32808}
32809
32810function g1_256(x) {
32811  return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
32812}
32813
32814function ft_1(s, x, y, z) {
32815  if (s === 0)
32816    return ch32(x, y, z);
32817  if (s === 1 || s === 3)
32818    return p32(x, y, z);
32819  if (s === 2)
32820    return maj32(x, y, z);
32821}
32822
32823function ch64_hi(xh, xl, yh, yl, zh, zl) {
32824  var r = (xh & yh) ^ ((~xh) & zh);
32825  if (r < 0)
32826    r += 0x100000000;
32827  return r;
32828}
32829
32830function ch64_lo(xh, xl, yh, yl, zh, zl) {
32831  var r = (xl & yl) ^ ((~xl) & zl);
32832  if (r < 0)
32833    r += 0x100000000;
32834  return r;
32835}
32836
32837function maj64_hi(xh, xl, yh, yl, zh, zl) {
32838  var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
32839  if (r < 0)
32840    r += 0x100000000;
32841  return r;
32842}
32843
32844function maj64_lo(xh, xl, yh, yl, zh, zl) {
32845  var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
32846  if (r < 0)
32847    r += 0x100000000;
32848  return r;
32849}
32850
32851function s0_512_hi(xh, xl) {
32852  var c0_hi = rotr64_hi(xh, xl, 28);
32853  var c1_hi = rotr64_hi(xl, xh, 2);  // 34
32854  var c2_hi = rotr64_hi(xl, xh, 7);  // 39
32855
32856  var r = c0_hi ^ c1_hi ^ c2_hi;
32857  if (r < 0)
32858    r += 0x100000000;
32859  return r;
32860}
32861
32862function s0_512_lo(xh, xl) {
32863  var c0_lo = rotr64_lo(xh, xl, 28);
32864  var c1_lo = rotr64_lo(xl, xh, 2);  // 34
32865  var c2_lo = rotr64_lo(xl, xh, 7);  // 39
32866
32867  var r = c0_lo ^ c1_lo ^ c2_lo;
32868  if (r < 0)
32869    r += 0x100000000;
32870  return r;
32871}
32872
32873function s1_512_hi(xh, xl) {
32874  var c0_hi = rotr64_hi(xh, xl, 14);
32875  var c1_hi = rotr64_hi(xh, xl, 18);
32876  var c2_hi = rotr64_hi(xl, xh, 9);  // 41
32877
32878  var r = c0_hi ^ c1_hi ^ c2_hi;
32879  if (r < 0)
32880    r += 0x100000000;
32881  return r;
32882}
32883
32884function s1_512_lo(xh, xl) {
32885  var c0_lo = rotr64_lo(xh, xl, 14);
32886  var c1_lo = rotr64_lo(xh, xl, 18);
32887  var c2_lo = rotr64_lo(xl, xh, 9);  // 41
32888
32889  var r = c0_lo ^ c1_lo ^ c2_lo;
32890  if (r < 0)
32891    r += 0x100000000;
32892  return r;
32893}
32894
32895function g0_512_hi(xh, xl) {
32896  var c0_hi = rotr64_hi(xh, xl, 1);
32897  var c1_hi = rotr64_hi(xh, xl, 8);
32898  var c2_hi = shr64_hi(xh, xl, 7);
32899
32900  var r = c0_hi ^ c1_hi ^ c2_hi;
32901  if (r < 0)
32902    r += 0x100000000;
32903  return r;
32904}
32905
32906function g0_512_lo(xh, xl) {
32907  var c0_lo = rotr64_lo(xh, xl, 1);
32908  var c1_lo = rotr64_lo(xh, xl, 8);
32909  var c2_lo = shr64_lo(xh, xl, 7);
32910
32911  var r = c0_lo ^ c1_lo ^ c2_lo;
32912  if (r < 0)
32913    r += 0x100000000;
32914  return r;
32915}
32916
32917function g1_512_hi(xh, xl) {
32918  var c0_hi = rotr64_hi(xh, xl, 19);
32919  var c1_hi = rotr64_hi(xl, xh, 29);  // 61
32920  var c2_hi = shr64_hi(xh, xl, 6);
32921
32922  var r = c0_hi ^ c1_hi ^ c2_hi;
32923  if (r < 0)
32924    r += 0x100000000;
32925  return r;
32926}
32927
32928function g1_512_lo(xh, xl) {
32929  var c0_lo = rotr64_lo(xh, xl, 19);
32930  var c1_lo = rotr64_lo(xl, xh, 29);  // 61
32931  var c2_lo = shr64_lo(xh, xl, 6);
32932
32933  var r = c0_lo ^ c1_lo ^ c2_lo;
32934  if (r < 0)
32935    r += 0x100000000;
32936  return r;
32937}
32938
32939
32940/***/ },
32941/* 32 */
32942/***/ function(module, exports, __webpack_require__) {
32943
32944var utils = exports;
32945var inherits = __webpack_require__(5);
32946
32947function toArray(msg, enc) {
32948  if (Array.isArray(msg))
32949    return msg.slice();
32950  if (!msg)
32951    return [];
32952  var res = [];
32953  if (typeof msg === 'string') {
32954    if (!enc) {
32955      for (var i = 0; i < msg.length; i++) {
32956        var c = msg.charCodeAt(i);
32957        var hi = c >> 8;
32958        var lo = c & 0xff;
32959        if (hi)
32960          res.push(hi, lo);
32961        else
32962          res.push(lo);
32963      }
32964    } else if (enc === 'hex') {
32965      msg = msg.replace(/[^a-z0-9]+/ig, '');
32966      if (msg.length % 2 !== 0)
32967        msg = '0' + msg;
32968      for (var i = 0; i < msg.length; i += 2)
32969        res.push(parseInt(msg[i] + msg[i + 1], 16));
32970    }
32971  } else {
32972    for (var i = 0; i < msg.length; i++)
32973      res[i] = msg[i] | 0;
32974  }
32975  return res;
32976}
32977utils.toArray = toArray;
32978
32979function toHex(msg) {
32980  var res = '';
32981  for (var i = 0; i < msg.length; i++)
32982    res += zero2(msg[i].toString(16));
32983  return res;
32984}
32985utils.toHex = toHex;
32986
32987function htonl(w) {
32988  var res = (w >>> 24) |
32989            ((w >>> 8) & 0xff00) |
32990            ((w << 8) & 0xff0000) |
32991            ((w & 0xff) << 24);
32992  return res >>> 0;
32993}
32994utils.htonl = htonl;
32995
32996function toHex32(msg, endian) {
32997  var res = '';
32998  for (var i = 0; i < msg.length; i++) {
32999    var w = msg[i];
33000    if (endian === 'little')
33001      w = htonl(w);
33002    res += zero8(w.toString(16));
33003  }
33004  return res;
33005}
33006utils.toHex32 = toHex32;
33007
33008function zero2(word) {
33009  if (word.length === 1)
33010    return '0' + word;
33011  else
33012    return word;
33013}
33014utils.zero2 = zero2;
33015
33016function zero8(word) {
33017  if (word.length === 7)
33018    return '0' + word;
33019  else if (word.length === 6)
33020    return '00' + word;
33021  else if (word.length === 5)
33022    return '000' + word;
33023  else if (word.length === 4)
33024    return '0000' + word;
33025  else if (word.length === 3)
33026    return '00000' + word;
33027  else if (word.length === 2)
33028    return '000000' + word;
33029  else if (word.length === 1)
33030    return '0000000' + word;
33031  else
33032    return word;
33033}
33034utils.zero8 = zero8;
33035
33036function join32(msg, start, end, endian) {
33037  var len = end - start;
33038  assert(len % 4 === 0);
33039  var res = new Array(len / 4);
33040  for (var i = 0, k = start; i < res.length; i++, k += 4) {
33041    var w;
33042    if (endian === 'big')
33043      w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
33044    else
33045      w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
33046    res[i] = w >>> 0;
33047  }
33048  return res;
33049}
33050utils.join32 = join32;
33051
33052function split32(msg, endian) {
33053  var res = new Array(msg.length * 4);
33054  for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
33055    var m = msg[i];
33056    if (endian === 'big') {
33057      res[k] = m >>> 24;
33058      res[k + 1] = (m >>> 16) & 0xff;
33059      res[k + 2] = (m >>> 8) & 0xff;
33060      res[k + 3] = m & 0xff;
33061    } else {
33062      res[k + 3] = m >>> 24;
33063      res[k + 2] = (m >>> 16) & 0xff;
33064      res[k + 1] = (m >>> 8) & 0xff;
33065      res[k] = m & 0xff;
33066    }
33067  }
33068  return res;
33069}
33070utils.split32 = split32;
33071
33072function rotr32(w, b) {
33073  return (w >>> b) | (w << (32 - b));
33074}
33075utils.rotr32 = rotr32;
33076
33077function rotl32(w, b) {
33078  return (w << b) | (w >>> (32 - b));
33079}
33080utils.rotl32 = rotl32;
33081
33082function sum32(a, b) {
33083  return (a + b) >>> 0;
33084}
33085utils.sum32 = sum32;
33086
33087function sum32_3(a, b, c) {
33088  return (a + b + c) >>> 0;
33089}
33090utils.sum32_3 = sum32_3;
33091
33092function sum32_4(a, b, c, d) {
33093  return (a + b + c + d) >>> 0;
33094}
33095utils.sum32_4 = sum32_4;
33096
33097function sum32_5(a, b, c, d, e) {
33098  return (a + b + c + d + e) >>> 0;
33099}
33100utils.sum32_5 = sum32_5;
33101
33102function assert(cond, msg) {
33103  if (!cond)
33104    throw new Error(msg || 'Assertion failed');
33105}
33106utils.assert = assert;
33107
33108utils.inherits = inherits;
33109
33110function sum64(buf, pos, ah, al) {
33111  var bh = buf[pos];
33112  var bl = buf[pos + 1];
33113
33114  var lo = (al + bl) >>> 0;
33115  var hi = (lo < al ? 1 : 0) + ah + bh;
33116  buf[pos] = hi >>> 0;
33117  buf[pos + 1] = lo;
33118}
33119exports.sum64 = sum64;
33120
33121function sum64_hi(ah, al, bh, bl) {
33122  var lo = (al + bl) >>> 0;
33123  var hi = (lo < al ? 1 : 0) + ah + bh;
33124  return hi >>> 0;
33125};
33126exports.sum64_hi = sum64_hi;
33127
33128function sum64_lo(ah, al, bh, bl) {
33129  var lo = al + bl;
33130  return lo >>> 0;
33131};
33132exports.sum64_lo = sum64_lo;
33133
33134function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
33135  var carry = 0;
33136  var lo = al;
33137  lo = (lo + bl) >>> 0;
33138  carry += lo < al ? 1 : 0;
33139  lo = (lo + cl) >>> 0;
33140  carry += lo < cl ? 1 : 0;
33141  lo = (lo + dl) >>> 0;
33142  carry += lo < dl ? 1 : 0;
33143
33144  var hi = ah + bh + ch + dh + carry;
33145  return hi >>> 0;
33146};
33147exports.sum64_4_hi = sum64_4_hi;
33148
33149function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
33150  var lo = al + bl + cl + dl;
33151  return lo >>> 0;
33152};
33153exports.sum64_4_lo = sum64_4_lo;
33154
33155function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
33156  var carry = 0;
33157  var lo = al;
33158  lo = (lo + bl) >>> 0;
33159  carry += lo < al ? 1 : 0;
33160  lo = (lo + cl) >>> 0;
33161  carry += lo < cl ? 1 : 0;
33162  lo = (lo + dl) >>> 0;
33163  carry += lo < dl ? 1 : 0;
33164  lo = (lo + el) >>> 0;
33165  carry += lo < el ? 1 : 0;
33166
33167  var hi = ah + bh + ch + dh + eh + carry;
33168  return hi >>> 0;
33169};
33170exports.sum64_5_hi = sum64_5_hi;
33171
33172function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
33173  var lo = al + bl + cl + dl + el;
33174
33175  return lo >>> 0;
33176};
33177exports.sum64_5_lo = sum64_5_lo;
33178
33179function rotr64_hi(ah, al, num) {
33180  var r = (al << (32 - num)) | (ah >>> num);
33181  return r >>> 0;
33182};
33183exports.rotr64_hi = rotr64_hi;
33184
33185function rotr64_lo(ah, al, num) {
33186  var r = (ah << (32 - num)) | (al >>> num);
33187  return r >>> 0;
33188};
33189exports.rotr64_lo = rotr64_lo;
33190
33191function shr64_hi(ah, al, num) {
33192  return ah >>> num;
33193};
33194exports.shr64_hi = shr64_hi;
33195
33196function shr64_lo(ah, al, num) {
33197  var r = (ah << (32 - num)) | (al >>> num);
33198  return r >>> 0;
33199};
33200exports.shr64_lo = shr64_lo;
33201
33202
33203/***/ },
33204/* 33 */
33205/***/ function(module, exports) {
33206
33207exports.read = function (buffer, offset, isLE, mLen, nBytes) {
33208  var e, m
33209  var eLen = nBytes * 8 - mLen - 1
33210  var eMax = (1 << eLen) - 1
33211  var eBias = eMax >> 1
33212  var nBits = -7
33213  var i = isLE ? (nBytes - 1) : 0
33214  var d = isLE ? -1 : 1
33215  var s = buffer[offset + i]
33216
33217  i += d
33218
33219  e = s & ((1 << (-nBits)) - 1)
33220  s >>= (-nBits)
33221  nBits += eLen
33222  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
33223
33224  m = e & ((1 << (-nBits)) - 1)
33225  e >>= (-nBits)
33226  nBits += mLen
33227  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
33228
33229  if (e === 0) {
33230    e = 1 - eBias
33231  } else if (e === eMax) {
33232    return m ? NaN : ((s ? -1 : 1) * Infinity)
33233  } else {
33234    m = m + Math.pow(2, mLen)
33235    e = e - eBias
33236  }
33237  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
33238}
33239
33240exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
33241  var e, m, c
33242  var eLen = nBytes * 8 - mLen - 1
33243  var eMax = (1 << eLen) - 1
33244  var eBias = eMax >> 1
33245  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
33246  var i = isLE ? 0 : (nBytes - 1)
33247  var d = isLE ? 1 : -1
33248  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
33249
33250  value = Math.abs(value)
33251
33252  if (isNaN(value) || value === Infinity) {
33253    m = isNaN(value) ? 1 : 0
33254    e = eMax
33255  } else {
33256    e = Math.floor(Math.log(value) / Math.LN2)
33257    if (value * (c = Math.pow(2, -e)) < 1) {
33258      e--
33259      c *= 2
33260    }
33261    if (e + eBias >= 1) {
33262      value += rt / c
33263    } else {
33264      value += rt * Math.pow(2, 1 - eBias)
33265    }
33266    if (value * c >= 2) {
33267      e++
33268      c /= 2
33269    }
33270
33271    if (e + eBias >= eMax) {
33272      m = 0
33273      e = eMax
33274    } else if (e + eBias >= 1) {
33275      m = (value * c - 1) * Math.pow(2, mLen)
33276      e = e + eBias
33277    } else {
33278      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
33279      e = 0
33280    }
33281  }
33282
33283  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
33284
33285  e = (e << mLen) | m
33286  eLen += mLen
33287  for (; eLen > 0;
33287 buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
33288
33289  buffer[offset + i - d] |= s * 128
33290}
33291
33292
33293/***/ },
33294/* 34 */
33295/***/ function(module, exports) {
33296
33297var toString = {}.toString;
33298
33299module.exports = Array.isArray || function (arr) {
33300  return toString.call(arr) == '[object Array]';
33301};
33302
33303
33304/***/ },
33305/* 35 */
33306/***/ function(module, exports, __webpack_require__) {
33307
33308/* WEBPACK VAR INJECTION */(function(process, global) {/**
33309 * [js-sha3]{@link https://github.com/emn178/js-sha3}
33310 *
33311 * @version 0.5.5
33312 * @author Chen, Yi-Cyuan [[email protected]]
33313 * @copyright Chen, Yi-Cyuan 2015-2016
33314 * @license MIT
33315 */
33316(function (root) {
33317  'use strict';
33318
33319  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
33320  if (NODE_JS) {
33321    root = global;
33322  }
33323  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;
33324  var HEX_CHARS = '0123456789abcdef'.split('');
33325  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
33326  var KECCAK_PADDING = [1, 256, 65536, 16777216];
33327  var PADDING = [6, 1536, 393216, 100663296];
33328  var SHIFT = [0, 8, 16, 24];
33329  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
33330            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 
33331            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 
33332            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
33333            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
33334  var BITS = [224, 256, 384, 512];
33335  var SHAKE_BITS = [128, 256];
33336  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];
33337
33338  var createOutputMethod = function (bits, padding, outputType) {
33339    return function (message) {
33340      return new Keccak(bits, padding, bits).update(message)[outputType]();
33341    }
33342  };
33343
33344  var createShakeOutputMethod = function (bits, padding, outputType) {
33345    return function (message, outputBits) {
33346      return new Keccak(bits, padding, outputBits).update(message)[outputType]();
33347    }
33348  };
33349
33350  var createMethod = function (bits, padding) {
33351    var method = createOutputMethod(bits, padding, 'hex');
33352    method.create = function () {
33353      return new Keccak(bits, padding, bits);
33354    };
33355    method.update = function (message) {
33356      return method.create().update(message);
33357    };
33358    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
33359      var type = OUTPUT_TYPES[i];
33360      method[type] = createOutputMethod(bits, padding, type);
33361    }
33362    return method;
33363  };
33364
33365  var createShakeMethod = function (bits, padding) {
33366    var method = createShakeOutputMethod(bits, padding, 'hex');
33367    method.create = function (outputBits) {
33368      return new Keccak(bits, padding, outputBits);
33369    };
33370    method.update = function (message, outputBits) {
33371      return method.create(outputBits).update(message);
33372    };
33373    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
33374      var type = OUTPUT_TYPES[i];
33375      method[type] = createShakeOutputMethod(bits, padding, type);
33376    }
33377    return method;
33378  };
33379
33380  var algorithms = [
33381    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},
33382    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},
33383    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}
33384  ];
33385
33386  var methods = {};
33387
33388  for (var i = 0;i < algorithms.length;++i) {
33389    var algorithm = algorithms[i];
33390    var bits  = algorithm.bits;
33391    for (var j = 0;j < bits.length;++j) {
33392      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);
33393    }
33394  }
33395
33396  function Keccak(bits, padding, outputBits) {
33397    this.blocks = [];
33398    this.s = [];
33399    this.padding = padding;
33400    this.outputBits = outputBits;
33401    this.reset = true;
33402    this.block = 0;
33403    this.start = 0;
33404    this.blockCount = (1600 - (bits << 1)) >> 5;
33405    this.byteCount = this.blockCount << 2;
33406    this.outputBlocks = outputBits >> 5;
33407    this.extraBytes = (outputBits & 31) >> 3;
33408
33409    for (var i = 0;i < 50;++i) {
33410      this.s[i] = 0;
33411    }
33412  };
33413
33414  Keccak.prototype.update = function (message) {
33415    var notString = typeof message != 'string';
33416    if (notString && message.constructor == root.ArrayBuffer) {
33417      message = new Uint8Array(message);
33418    }
vendor: 10,274 bytes, lines 33419-33731
33419    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, 
33420        blockCount = this.blockCount, index = 0, s = this.s, i, code;
33421    
33422    while (index < length) {
33423      if (this.reset) {
33424        this.reset = false;
33425        blocks[0] = this.block;
33426        for (i = 1;i < blockCount + 1;++i) {
33427          blocks[i] = 0;
33428        }
33429      }
33430      if (notString) {
33431        for (i = this.start;index < length && i < byteCount;++index) {
33432          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
33433        }
33434      } else {
33435        for (i = this.start;index < length && i < byteCount;++index) {
33436          code = message.charCodeAt(index);
33437          if (code < 0x80) {
33438            blocks[i >> 2] |= code << SHIFT[i++ & 3];
33439          } else if (code < 0x800) {
33440            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
33441            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
33442          } else if (code < 0xd800 || code >= 0xe000) {
33443            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
33444            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
33445            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
33446          } else {
33447            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
33448            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
33449            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
33450            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
33451            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
33452          }
33453        }
33454      }
33455      this.lastByteIndex = i;
33456      if (i >= byteCount) {
33457        this.start = i - byteCount;
33458        this.block = blocks[blockCount];
33459        for (i = 0;i < blockCount;++i) {
33460          s[i] ^= blocks[i];
33461        }
33462        f(s);
33463        this.reset = true;
33464      } else {
33465        this.start = i;
33466      }
33467    }
33468    return this;
33469  };
33470
33471  Keccak.prototype.finalize = function () {
33472    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
33473    blocks[i >> 2] |= this.padding[i & 3];
33474    if (this.lastByteIndex == this.byteCount) {
33475      blocks[0] = blocks[blockCount];
33476      for (i = 1;i < blockCount + 1;++i) {
33477        blocks[i] = 0;
33478      }
33479    }
33480    blocks[blockCount - 1] |= 0x80000000;
33481    for (i = 0;i < blockCount;++i) {
33482      s[i] ^= blocks[i];
33483    }
33484    f(s);
33485  };
33486
33487  Keccak.prototype.toString = Keccak.prototype.hex = function () {
33488    this.finalize();
33489
33490    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
33491        extraBytes = this.extraBytes, i = 0, j = 0;
33492    var hex = '', block;
33493    while (j < outputBlocks) {
33494      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
33495        block = s[i];
33496        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
33497               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
33498               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
33499               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
33500      }
33501      if (j % blockCount == 0) {
33502        f(s);
33503        i = 0;
33504      }
33505    }
33506    if (extraBytes) {
33507      block = s[i];
33508      if (extraBytes > 0) {
33509        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
33510      }
33511      if (extraBytes > 1) {
33512        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
33513      }
33514      if (extraBytes > 2) {
33515        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
33516      }
33517    }
33518    return hex;
33519  };
33520
33521  Keccak.prototype.arrayBuffer = function () {
33522    this.finalize();
33523
33524    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
33525        extraBytes = this.extraBytes, i = 0, j = 0;
33526    var bytes = this.outputBits >> 3;
33527    var buffer;
33528    if (extraBytes) {
33529      buffer = new ArrayBuffer((outputBlocks + 1) << 2);
33530    } else {
33531      buffer = new ArrayBuffer(bytes);
33532    }
33533    var array = new Uint32Array(buffer);
33534    while (j < outputBlocks) {
33535      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
33536        array[j] = s[i];
33537      }
33538      if (j % blockCount == 0) {
33539        f(s);
33540      }
33541    }
33542    if (extraBytes) {
33543      array[i] = s[i];
33544      buffer = buffer.slice(0, bytes);
33545    }
33546    return buffer;
33547  };
33548
33549  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
33550
33551  Keccak.prototype.digest = Keccak.prototype.array = function () {
33552    this.finalize();
33553
33554    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
33555        extraBytes = this.extraBytes, i = 0, j = 0;
33556    var array = [], offset, block;
33557    while (j < outputBlocks) {
33558      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
33559        offset = j << 2;
33560        block = s[i];
33561        array[offset] = block & 0xFF;
33562        array[offset + 1] = (block >> 8) & 0xFF;
33563        array[offset + 2] = (block >> 16) & 0xFF;
33564        array[offset + 3] = (block >> 24) & 0xFF;
33565      }
33566      if (j % blockCount == 0) {
33567        f(s);
33568      }
33569    }
33570    if (extraBytes) {
33571      offset = j << 2;
33572      block = s[i];
33573      if (extraBytes > 0) {
33574        array[offset] = block & 0xFF;
33575      }
33576      if (extraBytes > 1) {
33577        array[offset + 1] = (block >> 8) & 0xFF;
33578      }
33579      if (extraBytes > 2) {
33580        array[offset + 2] = (block >> 16) & 0xFF;
33581      }
33582    }
33583    return array;
33584  };
33585
33586  var f = function (s) {
33587    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, 
33588        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, 
33589        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, 
33590        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
33591    for (n = 0;n < 48;n += 2) {
33592      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
33593      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
33594      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
33595      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
33596      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
33597      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
33598      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
33599      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
33600      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
33601      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
33602
33603      h = c8 ^ ((c2 << 1) | (c3 >>> 31));
33604      l = c9 ^ ((c3 << 1) | (c2 >>> 31));
33605      s[0] ^= h;
33606      s[1] ^= l;
33607      s[10] ^= h;
33608      s[11] ^= l;
33609      s[20] ^= h;
33610      s[21] ^= l;
33611      s[30] ^= h;
33612      s[31] ^= l;
33613      s[40] ^= h;
33614      s[41] ^= l;
33615      h = c0 ^ ((c4 << 1) | (c5 >>> 31));
33616      l = c1 ^ ((c5 << 1) | (c4 >>> 31));
33617      s[2] ^= h;
33618      s[3] ^= l;
33619      s[12] ^= h;
33620      s[13] ^= l;
33621      s[22] ^= h;
33622      s[23] ^= l;
33623      s[32] ^= h;
33624      s[33] ^= l;
33625      s[42] ^= h;
33626      s[43] ^= l;
33627      h = c2 ^ ((c6 << 1) | (c7 >>> 31));
33628      l = c3 ^ ((c7 << 1) | (c6 >>> 31));
33629      s[4] ^= h;
33630      s[5] ^= l;
33631      s[14] ^= h;
33632      s[15] ^= l;
33633      s[24] ^= h;
33634      s[25] ^= l;
33635      s[34] ^= h;
33636      s[35] ^= l;
33637      s[44] ^= h;
33638      s[45] ^= l;
33639      h = c4 ^ ((c8 << 1) | (c9 >>> 31));
33640      l = c5 ^ ((c9 << 1) | (c8 >>> 31));
33641      s[6] ^= h;
33642      s[7] ^= l;
33643      s[16] ^= h;
33644      s[17] ^= l;
33645      s[26] ^= h;
33646      s[27] ^= l;
33647      s[36] ^= h;
33648      s[37] ^= l;
33649      s[46] ^= h;
33650      s[47] ^= l;
33651      h = c6 ^ ((c0 << 1) | (c1 >>> 31));
33652      l = c7 ^ ((c1 << 1) | (c0 >>> 31));
33653      s[8] ^= h;
33654      s[9] ^= l;
33655      s[18] ^= h;
33656      s[19] ^= l;
33657      s[28] ^= h;
33658      s[29] ^= l;
33659      s[38] ^= h;
33660      s[39] ^= l;
33661      s[48] ^= h;
33662      s[49] ^= l;
33663
33664      b0 = s[0];
33665      b1 = s[1];
33666      b32 = (s[11] << 4) | (s[10] >>> 28);
33667      b33 = (s[10] << 4) | (s[11] >>> 28);
33668      b14 = (s[20] << 3) | (s[21] >>> 29);
33669      b15 = (s[21] << 3) | (s[20] >>> 29);
33670      b46 = (s[31] << 9) | (s[30] >>> 23);
33671      b47 = (s[30] << 9) | (s[31] >>> 23);
33672      b28 = (s[40] << 18) | (s[41] >>> 14);
33673      b29 = (s[41] << 18) | (s[40] >>> 14);
33674      b20 = (s[2] << 1) | (s[3] >>> 31);
33675      b21 = (s[3] << 1) | (s[2] >>> 31);
33676      b2 = (s[13] << 12) | (s[12] >>> 20);
33677      b3 = (s[12] << 12) | (s[13] >>> 20);
33678      b34 = (s[22] << 10) | (s[23] >>> 22);
33679      b35 = (s[23] << 10) | (s[22] >>> 22);
33680      b16 = (s[33] << 13) | (s[32] >>> 19);
33681      b17 = (s[32] << 13) | (s[33] >>> 19);
33682      b48 = (s[42] << 2) | (s[43] >>> 30);
33683      b49 = (s[43] << 2) | (s[42] >>> 30);
33684      b40 = (s[5] << 30) | (s[4] >>> 2);
33685      b41 = (s[4] << 30) | (s[5] >>> 2);
33686      b22 = (s[14] << 6) | (s[15] >>> 26);
33687      b23 = (s[15] << 6) | (s[14] >>> 26);
33688      b4 = (s[25] << 11) | (s[24] >>> 21);
33689      b5 = (s[24] << 11) | (s[25] >>> 21);
33690      b36 = (s[34] << 15) | (s[35] >>> 17);
33691      b37 = (s[35] << 15) | (s[34] >>> 17);
33692      b18 = (s[45] << 29) | (s[44] >>> 3);
33693      b19 = (s[44] << 29) | (s[45] >>> 3);
33694      b10 = (s[6] << 28) | (s[7] >>> 4);
33695      b11 = (s[7] << 28) | (s[6] >>> 4);
33696      b42 = (s[17] << 23) | (s[16] >>> 9);
33697      b43 = (s[16] << 23) | (s[17] >>> 9);
33698      b24 = (s[26] << 25) | (s[27] >>> 7);
33699      b25 = (s[27] << 25) | (s[26] >>> 7);
33700      b6 = (s[36] << 21) | (s[37] >>> 11);
33701      b7 = (s[37] << 21) | (s[36] >>> 11);
33702      b38 = (s[47] << 24) | (s[46] >>> 8);
33703      b39 = (s[46] << 24) | (s[47] >>> 8);
33704      b30 = (s[8] << 27) | (s[9] >>> 5);
33705      b31 = (s[9] << 27) | (s[8] >>> 5);
33706      b12 = (s[18] << 20) | (s[19] >>> 12);
33707      b13 = (s[19] << 20) | (s[18] >>> 12);
33708      b44 = (s[29] << 7) | (s[28] >>> 25);
33709      b45 = (s[28] << 7) | (s[29] >>> 25);
33710      b26 = (s[38] << 8) | (s[39] >>> 24);
33711      b27 = (s[39] << 8) | (s[38] >>> 24);
33712      b8 = (s[48] << 14) | (s[49] >>> 18);
33713      b9 = (s[49] << 14) | (s[48] >>> 18);
33714
33715      s[0] = b0 ^ (~b2 & b4);
33716      s[1] = b1 ^ (~b3 & b5);
33717      s[10] = b10 ^ (~b12 & b14);
33718      s[11] = b11 ^ (~b13 & b15);
33719      s[20] = b20 ^ (~b22 & b24);
33720      s[21] = b21 ^ (~b23 & b25);
33721      s[30] = b30 ^ (~b32 & b34);
33722      s[31] = b31 ^ (~b33 & b35);
33723      s[40] = b40 ^ (~b42 & b44);
33724      s[41] = b41 ^ (~b43 & b45);
33725      s[2] = b2 ^ (~b4 & b6);
33726      s[3] = b3 ^ (~b5 & b7);
33727      s[12] = b12 ^ (~b14 & b16);
33728      s[13] = b13 ^ (~b15 & b17);
33729      s[22] = b22 ^ (~b24 & b26);
33730      s[23] = b23 ^ (~b25 & b27);
33731      s[32] = b32 ^ (~b34 & b36);
33732      s[33] = b33 ^ (~b35 & b37);
33733      s[42] = b42 ^ (~b44 & b46);
33734      s[43] = b43 ^ (~b45 & b47);
33735      s[4] = b4 ^ (~b6 & b8);
33736      s[5] = b5 ^ (~b7 & b9);
33737      s[14] = b14 ^ (~b16 & b18);
33738      s[15] = b15 ^ (~b17 & b19);
33739      s[24] = b24 ^ (~b26 & b28);
33740      s[25] = b25 ^ (~b27 & b29);
33741      s[34] = b34 ^ (~b36 & b38);
33742      s[35] = b35 ^ (~b37 & b39);
33743      s[44] = b44 ^ (~b46 & b48);
33744      s[45] = b45 ^ (~b47 & b49);
33745      s[6] = b6 ^ (~b8 & b0);
33746      s[7] = b7 ^ (~b9 & b1);
33747      s[16] = b16 ^ (~b18 & b10);
33748      s[17] = b17 ^ (~b19 & b11);
33749      s[26] = b26 ^ (~b28 & b20);
33750      s[27] = b27 ^ (~b29 & b21);
33751      s[36] = b36 ^ (~b38 & b30);
33752      s[37] = b37 ^ (~b39 & b31);
33753      s[46] = b46 ^ (~b48 & b40);
33754      s[47] = b47 ^ (~b49 & b41);
33755      s[8] = b8 ^ (~b0 & b2);
33756      s[9] = b9 ^ (~b1 & b3);
33757      s[18] = b18 ^ (~b10 & b12);
33758      s[19] = b19 ^ (~b11 & b13);
33759      s[28] = b28 ^ (~b20 & b22);
33760      s[29] = b29 ^ (~b21 & b23);
33761      s[38] = b38 ^ (~b30 & b32);
33762      s[39] = b39 ^ (~b31 & b33);
33763      s[48] = b48 ^ (~b40 & b42);
33764      s[49] = b49 ^ (~b41 & b43);
33765
33766      s[0] ^= RC[n];
33767      s[1] ^= RC[n + 1];
33768    }
33769  }
33770
33771  if (COMMON_JS) {
33772    module.exports = methods;
33773  } else if (root) {
33774    for (var key in methods) {
33775      root[key] = methods[key];
33776    }
33777  }
33778}(this));
33779
33780/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(6)))
33781
33782/***/ },
33783/* 36 */
33784/***/ function(module, exports) {
33785
33786module.exports = {
33787	"_args": [
33788		[
33789			{
33790				"raw": "[email protected]",
33791				"scope": null,
33792				"escapedName": "elliptic",
33793				"name": "elliptic",
33794				"rawSpec": "6.3.2",
33795				"spec": "6.3.2",
33796				"type": "version"
33797			},
33798			"/home/nick/github/ethjs-signer"
33799		]
33800	],
33801	"_from": "[email protected]",
33802	"_id": "[email protected]",
33803	"_inCache": true,
33804	"_installable": true,
33805	"_location": "/elliptic",
33806	"_nodeVersion": "6.3.0",
33807	"_npmOperationalInternal": {
33808		"host": "packages-16-east.internal.npmjs.com",
33809		"tmp": "tmp/elliptic-6.3.2.tgz_1473938837205_0.3108903462998569"
33810	},
33811	"_npmUser": {
33812		"name": "indutny",
33813		"email": "[email protected]"
33814	},
33815	"_npmVersion": "3.10.3",
33816	"_phantomChildren": {},
33817	"_requested": {
33818		"raw": "[email protected]",
33819		"scope": null,
33820		"escapedName": "elliptic",
33821		"name": "elliptic",
33822		"rawSpec": "6.3.2",
33823		"spec": "6.3.2",
33824		"type": "version"
33825	},
33826	"_requiredBy": [
33827		"/",
33828		"/browserify-sign",
33829		"/create-ecdh",
33830		"/ethjs-account",
33831		"/secp256k1"
33832	],
33833	"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz",
33834	"_shasum": "e4c81e0829cf0a65ab70e998b8232723b5c1bc48",
33835	"_shrinkwrap": null,
33836	"_spec": "[email protected]",
33837	"_where": "/home/nick/github/ethjs-signer",
33838	"author": {
33839		"name": "Fedor Indutny",
33840		"email": "[email protected]"
33841	},
33842	"bugs": {
33843		"url": "https://github.com/indutny/elliptic/issues"
33844	},
33845	"dependencies": {
33846		"bn.js": "^4.4.0",
33847		"brorand": "^1.0.1",
33848		"hash.js": "^1.0.0",
33849		"inherits": "^2.0.1"
33850	},
33851	"description": "EC cryptography",
33852	"devDependencies": {
33853		"brfs": "^1.4.3",
33854		"coveralls": "^2.11.3",
33855		"grunt": "^0.4.5",
33856		"grunt-browserify": "^5.0.0",
33857		"grunt-contrib-connect": "^1.0.0",
33858		"grunt-contrib-copy": "^1.0.0",
33859		"grunt-contrib-uglify": "^1.0.1",
33860		"grunt-mocha-istanbul": "^3.0.1",
33861		"grunt-saucelabs": "^8.6.2",
33862		"istanbul": "^0.4.2",
33863		"jscs": "^2.9.0",
33864		"jshint": "^2.6.0",
33865		"mocha": "^2.1.0"
33866	},
33867	"directories": {},
33868	"dist": {
33869		"shasum": "e4c81e0829cf0a65ab70e998b8232723b5c1bc48",
33870		"tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz"
33871	},
33872	"files": [
33873		"lib"
33874	],
33875	"gitHead": "cbace4683a4a548dc0306ef36756151a20299cd5",
33876	"homepage": "https://github.com/indutny/elliptic",
33877	"keywords": [
33878		"EC",
33879		"Elliptic",
33880		"curve",
33881		"Cryptography"
33882	],
33883	"license": "MIT",
33884	"main": "lib/elliptic.js",
33885	"maintainers": [
33886		{
33887			"name": "indutny",
33888			"email": "[email protected]"
33889		}
33890	],
33891	"name": "elliptic",
33892	"optionalDependencies": {},
33893	"readme": "ERROR: No README data found!",
33894	"repository": {
33895		"type": "git",
33896		"url": "git+ssh://[email protected]/indutny/elliptic.git"
33897	},
33898	"scripts": {
33899		"jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
33900		"jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
33901		"lint": "npm run jscs && npm run jshint",
33902		"test": "npm run lint && npm run unit",
33903		"unit": "istanbul test _mocha --reporter=spec test/index.js",
33904		"version": "grunt dist && git add dist/"
33905	},
33906	"version": "6.3.2"
33907};
33908
33909/***/ },
33910/* 37 */
33911/***/ function(module, exports, __webpack_require__) {
33912
33913var BN = __webpack_require__(1);
33914var isHexPrefixed = __webpack_require__(7);
33915var stripHexPrefix = __webpack_require__(9);
33916
33917/**
33918 * Returns a BN object, converts a number value to a BN
33919 * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object
33920 * @return {Object} `output` BN object of the number
33921 * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number
33922 */
33923module.exports = function numberToBN(arg) {
33924  var errorMessage = new Error('[number-to-bn] while converting number to BN.js object, argument "' + String(arg) + '" type "' + String(typeof(arg)) + '" must be either a negative or positive (1) integer number, (2) string integer, (3) valid prefixed hex number string, (4) BN.js object instance or a (5) bignumber.js object.');
33925  if (typeof arg === 'string') {
33926    if (arg.match(/0[xX][0-9a-fA-F]+/) || arg.match(/^-?[0-9]+$/)) {
33927      if (isHexPrefixed(arg)) {
33928        return new BN(stripHexPrefix(arg), 16);
33929      } else if (arg.substr(0, 3) === '-0x') {
33930        return new BN('-' + String(arg.slice(3)), 16);
33931      } else { // eslint-disable-line
33932        return new BN(arg, 10);
33933      }
33934    } else {
33935      throw errorMessage;
33936    }
33937  } else if (typeof arg === 'number') {
33938    return new BN(String(arg));
33939  } else if (typeof arg === 'object'
33940    && arg.toString
33941    && (!arg.pop && !arg.push)) {
33942    if (arg.toString(10).match(/^-?[0-9]+$/)) {
33943      if (arg.toArray && arg.toTwos) {
33944        return arg;
33945      } else {
33946        return new BN(arg.toString(10));
33947      }
33948    } else {
33949      throw errorMessage;
33950    }
33951  } else {
33952    throw errorMessage;
33953  }
33954}
33955
33956
33957/***/ },
33958/* 38 */
33959/***/ function(module, exports, __webpack_require__) {
33960
33961/* WEBPACK VAR INJECTION */(function(Buffer) {const assert = __webpack_require__(11)
33962/**
33963 * RLP Encoding based on: https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP
33964 * This function takes in a data, convert it to buffer if not, and a length for recursion
33965 *
33966 * @param {Buffer,String,Integer,Array} data - will be converted to buffer
33967 * @returns {Buffer} - returns buffer of encoded data
33968 **/
33969exports.encode = function (input) {
33970  if (input instanceof Array) {
33971    var output = []
33972    for (var i = 0; i < input.length; i++) {
33973      output.push(exports.encode(input[i]))
33974    }
33975    var buf = Buffer.concat(output)
33976    return Buffer.concat([encodeLength(buf.length, 192), buf])
33977  } else {
33978    input = toBuffer(input)
33979    if (input.length === 1 && input[0] < 128) {
33980      return input
33981    } else {
33982      return Buffer.concat([encodeLength(input.length, 128), input])
33983    }
33984  }
33985}
33986
33987function safeParseInt (v, base) {
33988  if (v.slice(0, 2) === '00') {
33989    throw (new Error('invalid RLP: extra zeros'))
33990  }
33991
33992  return parseInt(v, base)
33993}
33994
33995function encodeLength (len, offset) {
33996  if (len < 56) {
33997    return new Buffer([len + offset])
33998  } else {
33999    var hexLength = intToHex(len)
34000    var lLength = hexLength.length / 2
34001    var firstByte = intToHex(offset + 55 + lLength)
34002    return new Buffer(firstByte + hexLength, 'hex')
34003  }
34004}
34005
34006/**
34007 * RLP Decoding based on: {@link https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP|RLP}
34008 * @param {Buffer,String,Integer,Array} data - will be converted to buffer
34009 * @returns {Array} - returns decode Array of Buffers containg the original message
34010 **/
34011exports.decode = function (input, stream) {
34012  if (!input || input.length === 0) {
34013    return new Buffer([])
34014  }
34015
34016  input = toBuffer(input)
34017  var decoded = _decode(input)
34018
34019  if (stream) {
34020    return decoded
34021  }
34022
34023  assert.equal(decoded.remainder.length, 0, 'invalid remainder')
34024  return decoded.data
34025}
34026
34027exports.getLength = function (input) {
34028  if (!input || input.length === 0) {
34029    return new Buffer([])
34030  }
34031
34032  input = toBuffer(input)
34033  var firstByte = input[0]
34034  if (firstByte <= 0x7f) {
34035    return input.length
34036  } else if (firstByte <= 0xb7) {
34037    return firstByte - 0x7f
34038  } else if (firstByte <= 0xbf) {
34039    return firstByte - 0xb6
34040  } else if (firstByte <= 0xf7) {
34041    // a list between  0-55 bytes long
34042    return firstByte - 0xbf
34043  } else {
34044    // a list  over 55 bytes long
34045    var llength = firstByte - 0xf6
34046    var length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
34047    return llength + length
34048  }
34049}
34050
34051function _decode (input) {
34052  var length, llength, data, innerRemainder, d
34053  var decoded = []
34054  var firstByte = input[0]
34055
34056  if (firstByte <= 0x7f) {
34057    // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding.
34058    return {
34059      data: input.slice(0, 1),
34060      remainder: input.slice(1)
34061    }
34062  } else if (firstByte <= 0xb7) {
34063    // string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string
34064    // The range of the first byte is [0x80, 0xb7]
34065    length = firstByte - 0x7f
34066
34067    // set 0x80 null to 0
34068    if (firstByte === 0x80) {
34069      data = new Buffer([])
34070    } else {
34071      data = input.slice(1, length)
34072    }
34073
34074    if (length === 2 && data[0] < 0x80) {
34075      throw new Error('invalid rlp encoding: byte must be less 0x80')
34076    }
34077
34078    return {
34079      data: data,
34080      remainder: input.slice(length)
34081    }
34082  } else if (firstByte <= 0xbf) {
34083    llength = firstByte - 0xb6
34084    length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
34085    data = input.slice(llength, length + llength)
34086    if (data.length < length) {
34087      throw (new Error('invalid RLP'))
34088    }
34089
34090    return {
34091      data: data,
34092      remainder: input.slice(length + llength)
34093    }
34094  } else if (firstByte <= 0xf7) {
34095    // a list between  0-55 bytes long
34096    length = firstByte - 0xbf
34097    innerRemainder = input.slice(1, length)
34098    while (innerRemainder.length) {
34099      d = _decode(innerRemainder)
34100      decoded.push(d.data)
34101      innerRemainder = d.remainder
34102    }
34103
34104    return {
34105      data: decoded,
34106      remainder: input.slice(length)
34107    }
34108  } else {
34109    // a list  over 55 bytes long
34110    llength = firstByte - 0xf6
34111    length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
34112    var totalLength = llength + length
34113    if (totalLength > input.length) {
34114      throw new Error('invalid rlp: total length is larger than the data')
34115    }
34116
34117    innerRemainder = input.slice(llength, totalLength)
34118    if (innerRemainder.length === 0) {
34119      throw new Error('invalid rlp, List has a invalid length')
34120    }
34121
34122    while (innerRemainder.length) {
34123      d = _decode(innerRemainder)
34124      decoded.push(d.data)
34125      innerRemainder = d.remainder
34126    }
34127    return {
34128      data: decoded,
34129      remainder: input.slice(totalLength)
34130    }
34131  }
34132}
34133
34134function isHexPrefixed (str) {
34135  return str.slice(0, 2) === '0x'
34136}
34137
34138// Removes 0x from a given String
34139function stripHexPrefix (str) {
34140  if (typeof str !== 'string') {
34141    return str
34142  }
34143  return isHexPrefixed(str) ? str.slice(2) : str
34144}
34145
34146function intToHex (i) {
34147  var hex = i.toString(16)
34148  if (hex.length % 2) {
34149    hex = '0' + hex
34150  }
34151
34152  return hex
34153}
34154
34155function padToEven (a) {
34156  if (a.length % 2) a = '0' + a
34157  return a
34158}
34159
34160function intToBuffer (i) {
34161  var hex = intToHex(i)
34162  return new Buffer(hex, 'hex')
34163}
34164
34165function toBuffer (v) {
34166  if (!Buffer.isBuffer(v)) {
34167    if (typeof v === 'string') {
34168      if (isHexPrefixed(v)) {
34169        v = new Buffer(padToEven(stripHexPrefix(v)), 'hex')
34170      } else {
34171        v = new Buffer(v)
34172      }
34173    } else if (typeof v === 'number') {
34174      if (!v) {
34175        v = new Buffer([])
34176      } else {
34177        v = intToBuffer(v)
34178      }
34179    } else if (v === null || v === undefined) {
34180      v = new Buffer([])
34181    } else if (v.toArray) {
34182      // converts a BN to a Buffer
34183      v = new Buffer(v.toArray())
34184    } else {
34185      throw new Error('invalid type')
34186    }
34187  }
34188  return v
34189}
34190
34191/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
34192
34193/***/ },
34194/* 39 */
34195/***/ function(module, exports) {
34196
34197if (typeof Object.create === 'function') {
34198  // implementation from standard node.js 'util' module
34199  module.exports = function inherits(ctor, superCtor) {
34200    ctor.super_ = superCtor
34201    ctor.prototype = Object.create(superCtor.prototype, {
34202      constructor: {
34203        value: ctor,
34204        enumerable: false,
34205        writable: true,
34206        configurable: true
34207      }
34208    });
34209  };
34210} else {
34211  // old school shim for old browsers
34212  module.exports = function inherits(ctor, superCtor) {
34213    ctor.super_ = superCtor
34214    var TempCtor = function () {}
34215    TempCtor.prototype = superCtor.prototype
34216    ctor.prototype = new TempCtor()
34217    ctor.prototype.constructor = ctor
34218  }
34219}
34220
34221
34222/***/ },
34223/* 40 */
34224/***/ function(module, exports) {
34225
34226module.exports = function isBuffer(arg) {
34227  return arg && typeof arg === 'object'
34228    && typeof arg.copy === 'function'
34229    && typeof arg.fill === 'function'
34230    && typeof arg.readUInt8 === 'function';
34231}
34232
34233/***/ },
34234/* 41 */
34235/***/ function(module, exports, __webpack_require__) {
34236
34237/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
34238//
34239// Permission is hereby granted, free of charge, to any person obtaining a
34240// copy of this software and associated documentation files (the
34241// "Software"), to deal in the Software without restriction, including
34242// without limitation the rights to use, copy, modify, merge, publish,
34243// distribute, sublicense, and/or sell copies of the Software, and to permit
34244// persons to whom the Software is furnished to do so, subject to the
34245// following conditions:
34246//
34247// The above copyright notice and this permission notice shall be included
34248// in all copies or substantial portions of the Software.
34249//
34250// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
34251// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34252// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
34253// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34254// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
34255// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
34256// USE OR OTHER DEALINGS IN THE SOFTWARE.
34257
34258var formatRegExp = /%[sdj%]/g;
34259exports.format = function(f) {
34260  if (!isString(f)) {
34261    var objects = [];
34262    for (var i = 0; i < arguments.length; i++) {
34263      objects.push(inspect(arguments[i]));
34264    }
34265    return objects.join(' ');
34266  }
34267
34268  var i = 1;
34269  var args = arguments;
34270  var len = args.length;
34271  var str = String(f).replace(formatRegExp, function(x) {
34272    if (x === '%%') return '%';
34273    if (i >= len) return x;
34274    switch (x) {
34275      case '%s': return String(args[i++]);
34276      case '%d': return Number(args[i++]);
34277      case '%j':
34278        try {
34279          return JSON.stringify(args[i++]);
34280        } catch (_) {
34281          return '[Circular]';
34282        }
34283      default:
34284        return x;
34285    }
34286  });
34287  for (var x = args[i]; i < len; x = args[++i]) {
34288    if (isNull(x) || !isObject(x)) {
34289      str += ' ' + x;
34290    } else {
34291      str += ' ' + inspect(x);
34292    }
34293  }
34294  return str;
34295};
34296
34297
34298// Mark that a method should not be used.
34299// Returns a modified function which warns once by default.
34300// If --no-deprecation is set, then it is a no-op.
34301exports.deprecate = function(fn, msg) {
34302  // Allow for deprecating things in the process of starting up.
34303  if (isUndefined(global.process)) {
34304    return function() {
34305      return exports.deprecate(fn, msg).apply(this, arguments);
34306    };
34307  }
34308
34309  if (process.noDeprecation === true) {
34310    return fn;
34311  }
34312
34313  var warned = false;
vendor: 12,905 bytes, lines 34314-34814
34314  function deprecated() {
34315    if (!warned) {
34316      if (process.throwDeprecation) {
34317        throw new Error(msg);
34318      } else if (process.traceDeprecation) {
34319        console.trace(msg);
34320      } else {
34321        console.error(msg);
34322      }
34323      warned = true;
34324    }
34325    return fn.apply(this, arguments);
34326  }
34327
34328  return deprecated;
34329};
34330
34331
34332var debugs = {};
34333var debugEnviron;
34334exports.debuglog = function(set) {
34335  if (isUndefined(debugEnviron))
34336    debugEnviron = process.env.NODE_DEBUG || '';
34337  set = set.toUpperCase();
34338  if (!debugs[set]) {
34339    if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
34340      var pid = process.pid;
34341      debugs[set] = function() {
34342        var msg = exports.format.apply(exports, arguments);
34343        console.error('%s %d: %s', set, pid, msg);
34344      };
34345    } else {
34346      debugs[set] = function() {};
34347    }
34348  }
34349  return debugs[set];
34350};
34351
34352
34353/**
34354 * Echos the value of a value. Trys to print the value out
34355 * in the best way possible given the different types.
34356 *
34357 * @param {Object} obj The object to print out.
34358 * @param {Object} opts Optional options object that alters the output.
34359 */
34360/* legacy: obj, showHidden, depth, colors*/
34361function inspect(obj, opts) {
34362  // default options
34363  var ctx = {
34364    seen: [],
34365    stylize: stylizeNoColor
34366  };
34367  // legacy...
34368  if (arguments.length >= 3) ctx.depth = arguments[2];
34369  if (arguments.length >= 4) ctx.colors = arguments[3];
34370  if (isBoolean(opts)) {
34371    // legacy...
34372    ctx.showHidden = opts;
34373  } else if (opts) {
34374    // got an "options" object
34375    exports._extend(ctx, opts);
34376  }
34377  // set default options
34378  if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
34379  if (isUndefined(ctx.depth)) ctx.depth = 2;
34380  if (isUndefined(ctx.colors)) ctx.colors = false;
34381  if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
34382  if (ctx.colors) ctx.stylize = stylizeWithColor;
34383  return formatValue(ctx, obj, ctx.depth);
34384}
34385exports.inspect = inspect;
34386
34387
34388// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
34389inspect.colors = {
34390  'bold' : [1, 22],
34391  'italic' : [3, 23],
34392  'underline' : [4, 24],
34393  'inverse' : [7, 27],
34394  'white' : [37, 39],
34395  'grey' : [90, 39],
34396  'black' : [30, 39],
34397  'blue' : [34, 39],
34398  'cyan' : [36, 39],
34399  'green' : [32, 39],
34400  'magenta' : [35, 39],
34401  'red' : [31, 39],
34402  'yellow' : [33, 39]
34403};
34404
34405// Don't use 'blue' not visible on cmd.exe
34406inspect.styles = {
34407  'special': 'cyan',
34408  'number': 'yellow',
34409  'boolean': 'yellow',
34410  'undefined': 'grey',
34411  'null': 'bold',
34412  'string': 'green',
34413  'date': 'magenta',
34414  // "name": intentionally not styling
34415  'regexp': 'red'
34416};
34417
34418
34419function stylizeWithColor(str, styleType) {
34420  var style = inspect.styles[styleType];
34421
34422  if (style) {
34423    return '\u001b[' + inspect.colors[style][0] + 'm' + str +
34424           '\u001b[' + inspect.colors[style][1] + 'm';
34425  } else {
34426    return str;
34427  }
34428}
34429
34430
34431function stylizeNoColor(str, styleType) {
34432  return str;
34433}
34434
34435
34436function arrayToHash(array) {
34437  var hash = {};
34438
34439  array.forEach(function(val, idx) {
34440    hash[val] = true;
34441  });
34442
34443  return hash;
34444}
34445
34446
34447function formatValue(ctx, value, recurseTimes) {
34448  // Provide a hook for user-specified inspect functions.
34449  // Check that value is an object with an inspect function on it
34450  if (ctx.customInspect &&
34451      value &&
34452      isFunction(value.inspect) &&
34453      // Filter out the util module, it's inspect function is special
34454      value.inspect !== exports.inspect &&
34455      // Also filter out any prototype objects using the circular check.
34456      !(value.constructor && value.constructor.prototype === value)) {
34457    var ret = value.inspect(recurseTimes, ctx);
34458    if (!isString(ret)) {
34459      ret = formatValue(ctx, ret, recurseTimes);
34460    }
34461    return ret;
34462  }
34463
34464  // Primitive types cannot have properties
34465  var primitive = formatPrimitive(ctx, value);
34466  if (primitive) {
34467    return primitive;
34468  }
34469
34470  // Look up the keys of the object.
34471  var keys = Object.keys(value);
34472  var visibleKeys = arrayToHash(keys);
34473
34474  if (ctx.showHidden) {
34475    keys = Object.getOwnPropertyNames(value);
34476  }
34477
34478  // IE doesn't make error fields non-enumerable
34479  // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
34480  if (isError(value)
34481      && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
34482    return formatError(value);
34483  }
34484
34485  // Some type of object without properties can be shortcutted.
34486  if (keys.length === 0) {
34487    if (isFunction(value)) {
34488      var name = value.name ? ': ' + value.name : '';
34489      return ctx.stylize('[Function' + name + ']', 'special');
34490    }
34491    if (isRegExp(value)) {
34492      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
34493    }
34494    if (isDate(value)) {
34495      return ctx.stylize(Date.prototype.toString.call(value), 'date');
34496    }
34497    if (isError(value)) {
34498      return formatError(value);
34499    }
34500  }
34501
34502  var base = '', array = false, braces = ['{', '}'];
34503
34504  // Make Array say that they are Array
34505  if (isArray(value)) {
34506    array = true;
34507    braces = ['[', ']'];
34508  }
34509
34510  // Make functions say that they are functions
34511  if (isFunction(value)) {
34512    var n = value.name ? ': ' + value.name : '';
34513    base = ' [Function' + n + ']';
34514  }
34515
34516  // Make RegExps say that they are RegExps
34517  if (isRegExp(value)) {
34518    base = ' ' + RegExp.prototype.toString.call(value);
34519  }
34520
34521  // Make dates with properties first say the date
34522  if (isDate(value)) {
34523    base = ' ' + Date.prototype.toUTCString.call(value);
34524  }
34525
34526  // Make error with message first say the error
34527  if (isError(value)) {
34528    base = ' ' + formatError(value);
34529  }
34530
34531  if (keys.length === 0 && (!array || value.length == 0)) {
34532    return braces[0] + base + braces[1];
34533  }
34534
34535  if (recurseTimes < 0) {
34536    if (isRegExp(value)) {
34537      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
34538    } else {
34539      return ctx.stylize('[Object]', 'special');
34540    }
34541  }
34542
34543  ctx.seen.push(value);
34544
34545  var output;
34546  if (array) {
34547    output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
34548  } else {
34549    output = keys.map(function(key) {
34550      return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
34551    });
34552  }
34553
34554  ctx.seen.pop();
34555
34556  return reduceToSingleString(output, base, braces);
34557}
34558
34559
34560function formatPrimitive(ctx, value) {
34561  if (isUndefined(value))
34562    return ctx.stylize('undefined', 'undefined');
34563  if (isString(value)) {
34564    var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
34565                                             .replace(/'/g, "\\'")
34566                                             .replace(/\\"/g, '"') + '\'';
34567    return ctx.stylize(simple, 'string');
34568  }
34569  if (isNumber(value))
34570    return ctx.stylize('' + value, 'number');
34571  if (isBoolean(value))
34572    return ctx.stylize('' + value, 'boolean');
34573  // For some reason typeof null is "object", so special case here.
34574  if (isNull(value))
34575    return ctx.stylize('null', 'null');
34576}
34577
34578
34579function formatError(value) {
34580  return '[' + Error.prototype.toString.call(value) + ']';
34581}
34582
34583
34584function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
34585  var output = [];
34586  for (var i = 0, l = value.length; i < l; ++i) {
34587    if (hasOwnProperty(value, String(i))) {
34588      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
34589          String(i), true));
34590    } else {
34591      output.push('');
34592    }
34593  }
34594  keys.forEach(function(key) {
34595    if (!key.match(/^\d+$/)) {
34596      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
34597          key, true));
34598    }
34599  });
34600  return output;
34601}
34602
34603
34604function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
34605  var name, str, desc;
34606  desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
34607  if (desc.get) {
34608    if (desc.set) {
34609      str = ctx.stylize('[Getter/Setter]', 'special');
34610    } else {
34611      str = ctx.stylize('[Getter]', 'special');
34612    }
34613  } else {
34614    if (desc.set) {
34615      str = ctx.stylize('[Setter]', 'special');
34616    }
34617  }
34618  if (!hasOwnProperty(visibleKeys, key)) {
34619    name = '[' + key + ']';
34620  }
34621  if (!str) {
34622    if (ctx.seen.indexOf(desc.value) < 0) {
34623      if (isNull(recurseTimes)) {
34624        str = formatValue(ctx, desc.value, null);
34625      } else {
34626        str = formatValue(ctx, desc.value, recurseTimes - 1);
34627      }
34628      if (str.indexOf('\n') > -1) {
34629        if (array) {
34630          str = str.split('\n').map(function(line) {
34631            return '  ' + line;
34632          }).join('\n').substr(2);
34633        } else {
34634          str = '\n' + str.split('\n').map(function(line) {
34635            return '   ' + line;
34636          }).join('\n');
34637        }
34638      }
34639    } else {
34640      str = ctx.stylize('[Circular]', 'special');
34641    }
34642  }
34643  if (isUndefined(name)) {
34644    if (array && key.match(/^\d+$/)) {
34645      return str;
34646    }
34647    name = JSON.stringify('' + key);
34648    if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
34649      name = name.substr(1, name.length - 2);
34650      name = ctx.stylize(name, 'name');
34651    } else {
34652      name = name.replace(/'/g, "\\'")
34653                 .replace(/\\"/g, '"')
34654                 .replace(/(^"|"$)/g, "'");
34655      name = ctx.stylize(name, 'string');
34656    }
34657  }
34658
34659  return name + ': ' + str;
34660}
34661
34662
34663function reduceToSingleString(output, base, braces) {
34664  var numLinesEst = 0;
34665  var length = output.reduce(function(prev, cur) {
34666    numLinesEst++;
34667    if (cur.indexOf('\n') >= 0) numLinesEst++;
34668    return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
34669  }, 0);
34670
34671  if (length > 60) {
34672    return braces[0] +
34673           (base === '' ? '' : base + '\n ') +
34674           ' ' +
34675           output.join(',\n  ') +
34676           ' ' +
34677           braces[1];
34678  }
34679
34680  return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
34681}
34682
34683
34684// NOTE: These type checking functions intentionally don't use `instanceof`
34685// because it is fragile and can be easily faked with `Object.create()`.
34686function isArray(ar) {
34687  return Array.isArray(ar);
34688}
34689exports.isArray = isArray;
34690
34691function isBoolean(arg) {
34692  return typeof arg === 'boolean';
34693}
34694exports.isBoolean = isBoolean;
34695
34696function isNull(arg) {
34697  return arg === null;
34698}
34699exports.isNull = isNull;
34700
34701function isNullOrUndefined(arg) {
34702  return arg == null;
34703}
34704exports.isNullOrUndefined = isNullOrUndefined;
34705
34706function isNumber(arg) {
34707  return typeof arg === 'number';
34708}
34709exports.isNumber = isNumber;
34710
34711function isString(arg) {
34712  return typeof arg === 'string';
34713}
34714exports.isString = isString;
34715
34716function isSymbol(arg) {
34717  return typeof arg === 'symbol';
34718}
34719exports.isSymbol = isSymbol;
34720
34721function isUndefined(arg) {
34722  return arg === void 0;
34723}
34724exports.isUndefined = isUndefined;
34725
34726function isRegExp(re) {
34727  return isObject(re) && objectToString(re) === '[object RegExp]';
34728}
34729exports.isRegExp = isRegExp;
34730
34731function isObject(arg) {
34732  return typeof arg === 'object' && arg !== null;
34733}
34734exports.isObject = isObject;
34735
34736function isDate(d) {
34737  return isObject(d) && objectToString(d) === '[object Date]';
34738}
34739exports.isDate = isDate;
34740
34741function isError(e) {
34742  return isObject(e) &&
34743      (objectToString(e) === '[object Error]' || e instanceof Error);
34744}
34745exports.isError = isError;
34746
34747function isFunction(arg) {
34748  return typeof arg === 'function';
34749}
34750exports.isFunction = isFunction;
34751
34752function isPrimitive(arg) {
34753  return arg === null ||
34754         typeof arg === 'boolean' ||
34755         typeof arg === 'number' ||
34756         typeof arg === 'string' ||
34757         typeof arg === 'symbol' ||  // ES6 symbol
34758         typeof arg === 'undefined';
34759}
34760exports.isPrimitive = isPrimitive;
34761
34762exports.isBuffer = __webpack_require__(40);
34763
34764function objectToString(o) {
34765  return Object.prototype.toString.call(o);
34766}
34767
34768
34769function pad(n) {
34770  return n < 10 ? '0' + n.toString(10) : n.toString(10);
34771}
34772
34773
34774var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
34775              'Oct', 'Nov', 'Dec'];
34776
34777// 26 Feb 16:19:34
34778function timestamp() {
34779  var d = new Date();
34780  var time = [pad(d.getHours()),
34781              pad(d.getMinutes()),
34782              pad(d.getSeconds())].join(':');
34783  return [d.getDate(), months[d.getMonth()], time].join(' ');
34784}
34785
34786
34787// log is just a thin wrapper to console.log that prepends a timestamp
34788exports.log = function() {
34789  console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
34790};
34791
34792
34793/**
34794 * Inherit the prototype methods from one constructor into another.
34795 *
34796 * The Function.prototype.inherits from lang.js rewritten as a standalone
34797 * function (not on Function.prototype). NOTE: If this file is to be loaded
34798 * during bootstrapping this function needs to be rewritten using some native
34799 * functions as prototype setup using normal JavaScript does not work as
34800 * expected during bootstrapping (see mirror.js in r114903).
34801 *
34802 * @param {function} ctor Constructor function which needs to inherit the
34803 *     prototype.
34804 * @param {function} superCtor Constructor function to inherit prototype from.
34805 */
34806exports.inherits = __webpack_require__(39);
34807
34808exports._extend = function(origin, add) {
34809  // Don't do anything if add isn't an object
34810  if (!add || !isObject(add)) return origin;
34811
34812  var keys = Object.keys(add);
34813  var i = keys.length;
34814  while (i--) {
34815    origin[keys[i]] = add[keys[i]];
34816  }
34817  return origin;
34818};
34819
34820function hasOwnProperty(obj, prop) {
34821  return Object.prototype.hasOwnProperty.call(obj, prop);
34822}
34823
34824/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6), __webpack_require__(8)))
34825
34826/***/ },
34827/* 42 */
34828/***/ function(module, exports) {
34829
34830module.exports = function(module) {
34831	if(!module.webpackPolyfill) {
34832		module.deprecate = function() {};
34833		module.paths = [];
34834		// module.parent = undefined by default
34835		if(!module.children) module.children = [];
34836		Object.defineProperty(module, "loaded", {
34837			enumerable: true,
34838			configurable: false,
34839			get: function() { return module.l; }
34840		});
34841		Object.defineProperty(module, "id", {
34842			enumerable: true,
34843			configurable: false,
34844			get: function() { return module.i; }
34845		});
34846		module.webpackPolyfill = 1;
34847	}
34848	return module;
34849}
34850
34851
34852/***/ },
34853/* 43 */
34854/***/ function(module, exports) {
34855
34856/* (ignored) */
34857
34858/***/ },
34859/* 44 */
34860/***/ function(module, exports, __webpack_require__) {
34861
34862module.exports = __webpack_require__(10);
34863
34864
34865/***/ }
34866/******/ ])
34867});
34868;
34869//# sourceMappingURL=ethjs-signer.js.map</script>
34869
34870
34871    
vendor: 2,798 bytes, lines 34871-34956
34871<script> /* eslint-disable */ 
34872(function webpackUniversalModuleDefinition(root, factory) {
34873	if(typeof exports === 'object' && typeof module === 'object')
34874		module.exports = factory();
34875	else if(typeof define === 'function' && define.amd)
34876		define("Eth", [], factory);
34877	else if(typeof exports === 'object')
34878		exports["Eth"] = factory();
34879	else
34880		root["Eth"] = factory();
34881})(this, function() {
34882return /******/ (function(modules) { // webpackBootstrap
34883/******/ 	// The module cache
34884/******/ 	var installedModules = {};
34885
34886/******/ 	// The require function
34887/******/ 	function __webpack_require__(moduleId) {
34888
34889/******/ 		// Check if module is in cache
34890/******/ 		if(installedModules[moduleId])
34891/******/ 			return installedModules[moduleId].exports;
34892
34893/******/ 		// Create a new module (and put it into the cache)
34894/******/ 		var module = installedModules[moduleId] = {
34895/******/ 			i: moduleId,
34896/******/ 			l: false,
34897/******/ 			exports: {}
34898/******/ 		};
34899
34900/******/ 		// Execute the module function
34901/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
34902
34903/******/ 		// Flag the module as loaded
34904/******/ 		module.l = true;
34905
34906/******/ 		// Return the exports of the module
34907/******/ 		return module.exports;
34908/******/ 	}
34909
34910
34911/******/ 	// expose the modules object (__webpack_modules__)
34912/******/ 	__webpack_require__.m = modules;
34913
34914/******/ 	// expose the module cache
34915/******/ 	__webpack_require__.c = installedModules;
34916
34917/******/ 	// identity function for calling harmory imports with the correct context
34918/******/ 	__webpack_require__.i = function(value) { return value; };
34919
34920/******/ 	// define getter function for harmory exports
34921/******/ 	__webpack_require__.d = function(exports, name, getter) {
34922/******/ 		Object.defineProperty(exports, name, {
34923/******/ 			configurable: false,
34924/******/ 			enumerable: true,
34925/******/ 			get: getter
34926/******/ 		});
34927/******/ 	};
34928
34929/******/ 	// Object.prototype.hasOwnProperty.call
34930/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
34931
34932/******/ 	// __webpack_public_path__
34933/******/ 	__webpack_require__.p = "";
34934
34935/******/ 	// Load entry module and return exports
34936/******/ 	return __webpack_require__(__webpack_require__.s = 27);
34937/******/ })
34938/************************************************************************/
34939/******/ ([
34940/* 0 */
34941/***/ function(module, exports, __webpack_require__) {
34942
34943"use strict";
34944/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
34945 * The buffer module from node.js, for the browser.
34946 *
34947 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
34948 * @license  MIT
34949 */
34950/* eslint-disable no-proto */
34951
34952'use strict'
34953
34954var base64 = __webpack_require__(10)
34955var ieee754 = __webpack_require__(21)
34956var isArray = __webpack_require__(22
vendor: 48,349 bytes, lines 34956-36734
34956)
34957
34958exports.Buffer = Buffer
34959exports.SlowBuffer = SlowBuffer
34960exports.INSPECT_MAX_BYTES = 50
34961
34962/**
34963 * If `Buffer.TYPED_ARRAY_SUPPORT`:
34964 *   === true    Use Uint8Array implementation (fastest)
34965 *   === false   Use Object implementation (most compatible, even IE6)
34966 *
34967 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
34968 * Opera 11.6+, iOS 4.2+.
34969 *
34970 * Due to various browser bugs, sometimes the Object implementation will be used even
34971 * when the browser supports typed arrays.
34972 *
34973 * Note:
34974 *
34975 *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
34976 *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
34977 *
34978 *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
34979 *
34980 *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
34981 *     incorrect length in some situations.
34982
34983 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
34984 * get the Object implementation, which is slower but behaves correctly.
34985 */
34986Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
34987  ? global.TYPED_ARRAY_SUPPORT
34988  : typedArraySupport()
34989
34990/*
34991 * Export kMaxLength after typed array support is determined.
34992 */
34993exports.kMaxLength = kMaxLength()
34994
34995function typedArraySupport () {
34996  try {
34997    var arr = new Uint8Array(1)
34998    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
34999    return arr.foo() === 42 && // typed array instances can be augmented
35000        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
35001        arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
35002  } catch (e) {
35003    return false
35004  }
35005}
35006
35007function kMaxLength () {
35008  return Buffer.TYPED_ARRAY_SUPPORT
35009    ? 0x7fffffff
35010    : 0x3fffffff
35011}
35012
35013function createBuffer (that, length) {
35014  if (kMaxLength() < length) {
35015    throw new RangeError('Invalid typed array length')
35016  }
35017  if (Buffer.TYPED_ARRAY_SUPPORT) {
35018    // Return an augmented `Uint8Array` instance, for best performance
35019    that = new Uint8Array(length)
35020    that.__proto__ = Buffer.prototype
35021  } else {
35022    // Fallback: Return an object instance of the Buffer class
35023    if (that === null) {
35024      that = new Buffer(length)
35025    }
35026    that.length = length
35027  }
35028
35029  return that
35030}
35031
35032/**
35033 * The Buffer constructor returns instances of `Uint8Array` that have their
35034 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
35035 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
35036 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
35037 * returns a single octet.
35038 *
35039 * The `Uint8Array` prototype remains unmodified.
35040 */
35041
35042function Buffer (arg, encodingOrOffset, length) {
35043  if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
35044    return new Buffer(arg, encodingOrOffset, length)
35045  }
35046
35047  // Common case.
35048  if (typeof arg === 'number') {
35049    if (typeof encodingOrOffset === 'string') {
35050      throw new Error(
35051        'If encoding is specified then the first argument must be a string'
35052      )
35053    }
35054    return allocUnsafe(this, arg)
35055  }
35056  return from(this, arg, encodingOrOffset, length)
35057}
35058
35059Buffer.poolSize = 8192 // not used by this implementation
35060
35061// TODO: Legacy, not needed anymore. Remove in next major version.
35062Buffer._augment = function (arr) {
35063  arr.__proto__ = Buffer.prototype
35064  return arr
35065}
35066
35067function from (that, value, encodingOrOffset, length) {
35068  if (typeof value === 'number') {
35069    throw new TypeError('"value" argument must not be a number')
35070  }
35071
35072  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
35073    return fromArrayBuffer(that, value, encodingOrOffset, length)
35074  }
35075
35076  if (typeof value === 'string') {
35077    return fromString(that, value, encodingOrOffset)
35078  }
35079
35080  return fromObject(that, value)
35081}
35082
35083/**
35084 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
35085 * if value is a number.
35086 * Buffer.from(str[, encoding])
35087 * Buffer.from(array)
35088 * Buffer.from(buffer)
35089 * Buffer.from(arrayBuffer[, byteOffset[, length]])
35090 **/
35091Buffer.from = function (value, encodingOrOffset, length) {
35092  return from(null, value, encodingOrOffset, length)
35093}
35094
35095if (Buffer.TYPED_ARRAY_SUPPORT) {
35096  Buffer.prototype.__proto__ = Uint8Array.prototype
35097  Buffer.__proto__ = Uint8Array
35098  if (typeof Symbol !== 'undefined' && Symbol.species &&
35099      Buffer[Symbol.species] === Buffer) {
35100    // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
35101    Object.defineProperty(Buffer, Symbol.species, {
35102      value: null,
35103      configurable: true
35104    })
35105  }
35106}
35107
35108function assertSize (size) {
35109  if (typeof size !== 'number') {
35110    throw new TypeError('"size" argument must be a number')
35111  } else if (size < 0) {
35112    throw new RangeError('"size" argument must not be negative')
35113  }
35114}
35115
35116function alloc (that, size, fill, encoding) {
35117  assertSize(size)
35118  if (size <= 0) {
35119    return createBuffer(that, size)
35120  }
35121  if (fill !== undefined) {
35122    // Only pay attention to encoding if it's a string. This
35123    // prevents accidentally sending in a number that would
35124    // be interpretted as a start offset.
35125    return typeof encoding === 'string'
35126      ? createBuffer(that, size).fill(fill, encoding)
35127      : createBuffer(that, size).fill(fill)
35128  }
35129  return createBuffer(that, size)
35130}
35131
35132/**
35133 * Creates a new filled Buffer instance.
35134 * alloc(size[, fill[, encoding]])
35135 **/
35136Buffer.alloc = function (size, fill, encoding) {
35137  return alloc(null, size, fill, encoding)
35138}
35139
35140function allocUnsafe (that, size) {
35141  assertSize(size)
35142  that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
35143  if (!Buffer.TYPED_ARRAY_SUPPORT) {
35144    for (var i = 0; i < size; ++i) {
35145      that[i] = 0
35146    }
35147  }
35148  return that
35149}
35150
35151/**
35152 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
35153 * */
35154Buffer.allocUnsafe = function (size) {
35155  return allocUnsafe(null, size)
35156}
35157/**
35158 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
35159 */
35160Buffer.allocUnsafeSlow = function (size) {
35161  return allocUnsafe(null, size)
35162}
35163
35164function fromString (that, string, encoding) {
35165  if (typeof encoding !== 'string' || encoding === '') {
35166    encoding = 'utf8'
35167  }
35168
35169  if (!Buffer.isEncoding(encoding)) {
35170    throw new TypeError('"encoding" must be a valid string encoding')
35171  }
35172
35173  var length = byteLength(string, encoding) | 0
35174  that = createBuffer(that, length)
35175
35176  var actual = that.write(string, encoding)
35177
35178  if (actual !== length) {
35179    // Writing a hex string, for example, that contains invalid characters will
35180    // cause everything after the first invalid character to be ignored. (e.g.
35181    // 'abxxcd' will be treated as 'ab')
35182    that = that.slice(0, actual)
35183  }
35184
35185  return that
35186}
35187
35188function fromArrayLike (that, array) {
35189  var length = array.length < 0 ? 0 : checked(array.length) | 0
35190  that = createBuffer(that, length)
35191  for (var i = 0; i < length; i += 1) {
35192    that[i] = array[i] & 255
35193  }
35194  return that
35195}
35196
35197function fromArrayBuffer (that, array, byteOffset, length) {
35198  array.byteLength // this throws if `array` is not a valid ArrayBuffer
35199
35200  if (byteOffset < 0 || array.byteLength < byteOffset) {
35201    throw new RangeError('\'offset\' is out of bounds')
35202  }
35203
35204  if (array.byteLength < byteOffset + (length || 0)) {
35205    throw new RangeError('\'length\' is out of bounds')
35206  }
35207
35208  if (byteOffset === undefined && length === undefined) {
35209    array = new Uint8Array(array)
35210  } else if (length === undefined) {
35211    array = new Uint8Array(array, byteOffset)
35212  } else {
35213    array = new Uint8Array(array, byteOffset, length)
35214  }
35215
35216  if (Buffer.TYPED_ARRAY_SUPPORT) {
35217    // Return an augmented `Uint8Array` instance, for best performance
35218    that = array
35219    that.__proto__ = Buffer.prototype
35220  } else {
35221    // Fallback: Return an object instance of the Buffer class
35222    that = fromArrayLike(that, array)
35223  }
35224  return that
35225}
35226
35227function fromObject (that, obj) {
35228  if (Buffer.isBuffer(obj)) {
35229    var len = checked(obj.length) | 0
35230    that = createBuffer(that, len)
35231
35232    if (that.length === 0) {
35233      return that
35234    }
35235
35236    obj.copy(that, 0, 0, len)
35237    return that
35238  }
35239
35240  if (obj) {
35241    if ((typeof ArrayBuffer !== 'undefined' &&
35242        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
35243      if (typeof obj.length !== 'number' || isnan(obj.length)) {
35244        return createBuffer(that, 0)
35245      }
35246      return fromArrayLike(that, obj)
35247    }
35248
35249    if (obj.type === 'Buffer' && isArray(obj.data)) {
35250      return fromArrayLike(that, obj.data)
35251    }
35252  }
35253
35254  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
35255}
35256
35257function checked (length) {
35258  // Note: cannot use `length < kMaxLength()` here because that fails when
35259  // length is NaN (which is otherwise coerced to zero.)
35260  if (length >= kMaxLength()) {
35261    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
35262                         'size: 0x' + kMaxLength().toString(16) + ' bytes')
35263  }
35264  return length | 0
35265}
35266
35267function SlowBuffer (length) {
35268  if (+length != length) { // eslint-disable-line eqeqeq
35269    length = 0
35270  }
35271  return Buffer.alloc(+length)
35272}
35273
35274Buffer.isBuffer = function isBuffer (b) {
35275  return !!(b != null && b._isBuffer)
35276}
35277
35278Buffer.compare = function compare (a, b) {
35279  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
35280    throw new TypeError('Arguments must be Buffers')
35281  }
35282
35283  if (a === b) return 0
35284
35285  var x = a.length
35286  var y = b.length
35287
35288  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
35289    if (a[i] !== b[i]) {
35290      x = a[i]
35291      y = b[i]
35292      break
35293    }
35294  }
35295
35296  if (x < y) return -1
35297  if (y < x) return 1
35298  return 0
35299}
35300
35301Buffer.isEncoding = function isEncoding (encoding) {
35302  switch (String(encoding).toLowerCase()) {
35303    case 'hex':
35304    case 'utf8':
35305    case 'utf-8':
35306    case 'ascii':
35307    case 'latin1':
35308    case 'binary':
35309    case 'base64':
35310    case 'ucs2':
35311    case 'ucs-2':
35312    case 'utf16le':
35313    case 'utf-16le':
35314      return true
35315    default:
35316      return false
35317  }
35318}
35319
35320Buffer.concat = function concat (list, length) {
35321  if (!isArray(list)) {
35322    throw new TypeError('"list" argument must be an Array of Buffers')
35323  }
35324
35325  if (list.length === 0) {
35326    return Buffer.alloc(0)
35327  }
35328
35329  var i
35330  if (length === undefined) {
35331    length = 0
35332    for (i = 0; i < list.length; ++i) {
35333      length += list[i].length
35334    }
35335  }
35336
35337  var buffer = Buffer.allocUnsafe(length)
35338  var pos = 0
35339  for (i = 0; i < list.length; ++i) {
35340    var buf = list[i]
35341    if (!Buffer.isBuffer(buf)) {
35342      throw new TypeError('"list" argument must be an Array of Buffers')
35343    }
35344    buf.copy(buffer, pos)
35345    pos += buf.length
35346  }
35347  return buffer
35348}
35349
35350function byteLength (string, encoding) {
35351  if (Buffer.isBuffer(string)) {
35352    return string.length
35353  }
35354  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
35355      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
35356    return string.byteLength
35357  }
35358  if (typeof string !== 'string') {
35359    string = '' + string
35360  }
35361
35362  var len = string.length
35363  if (len === 0) return 0
35364
35365  // Use a for loop to avoid recursion
35366  var loweredCase = false
35367  for (;;) {
35368    switch (encoding) {
35369      case 'ascii':
35370      case 'latin1':
35371      case 'binary':
35372        return len
35373      case 'utf8':
35374      case 'utf-8':
35375      case undefined:
35376        return utf8ToBytes(string).length
35377      case 'ucs2':
35378      case 'ucs-2':
35379      case 'utf16le':
35380      case 'utf-16le':
35381        return len * 2
35382      case 'hex':
35383        return len >>> 1
35384      case 'base64':
35385        return base64ToBytes(string).length
35386      default:
35387        if (loweredCase) return utf8ToBytes(string).length // assume utf8
35388        encoding = ('' + encoding).toLowerCase()
35389        loweredCase = true
35390    }
35391  }
35392}
35393Buffer.byteLength = byteLength
35394
35395function slowToString (encoding, start, end) {
35396  var loweredCase = false
35397
35398  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
35399  // property of a typed array.
35400
35401  // This behaves neither like String nor Uint8Array in that we set start/end
35402  // to their upper/lower bounds if the value passed is out of range.
35403  // undefined is handled specially as per ECMA-262 6th Edition,
35404  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
35405  if (start === undefined || start < 0) {
35406    start = 0
35407  }
35408  // Return early if start > this.length. Done here to prevent potential uint32
35409  // coercion fail below.
35410  if (start > this.length) {
35411    return ''
35412  }
35413
35414  if (end === undefined || end > this.length) {
35415    end = this.length
35416  }
35417
35418  if (end <= 0) {
35419    return ''
35420  }
35421
35422  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
35423  end >>>= 0
35424  start >>>= 0
35425
35426  if (end <= start) {
35427    return ''
35428  }
35429
35430  if (!encoding) encoding = 'utf8'
35431
35432  while (true) {
35433    switch (encoding) {
35434      case 'hex':
35435        return hexSlice(this, start, end)
35436
35437      case 'utf8':
35438      case 'utf-8':
35439        return utf8Slice(this, start, end)
35440
35441      case 'ascii':
35442        return asciiSlice(this, start, end)
35443
35444      case 'latin1':
35445      case 'binary':
35446        return latin1Slice(this, start, end)
35447
35448      case 'base64':
35449        return base64Slice(this, start, end)
35450
35451      case 'ucs2':
35452      case 'ucs-2':
35453      case 'utf16le':
35454      case 'utf-16le':
35455        return utf16leSlice(this, start, end)
35456
35457      default:
35458        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
35459        encoding = (encoding + '').toLowerCase()
35460        loweredCase = true
35461    }
35462  }
35463}
35464
35465// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
35466// Buffer instances.
35467Buffer.prototype._isBuffer = true
35468
35469function swap (b, n, m) {
35470  var i = b[n]
35471  b[n] = b[m]
35472  b[m] = i
35473}
35474
35475Buffer.prototype.swap16 = function swap16 () {
35476  var len = this.length
35477  if (len % 2 !== 0) {
35478    throw new RangeError('Buffer size must be a multiple of 16-bits')
35479  }
35480  for (var i = 0; i < len; i += 2) {
35481    swap(this, i, i + 1)
35482  }
35483  return this
35484}
35485
35486Buffer.prototype.swap32 = function swap32 () {
35487  var len = this.length
35488  if (len % 4 !== 0) {
35489    throw new RangeError('Buffer size must be a multiple of 32-bits')
35490  }
35491  for (var i = 0; i < len; i += 4) {
35492    swap(this, i, i + 3)
35493    swap(this, i + 1, i + 2)
35494  }
35495  return this
35496}
35497
35498Buffer.prototype.swap64 = function swap64 () {
35499  var len = this.length
35500  if (len % 8 !== 0) {
35501    throw new RangeError('Buffer size must be a multiple of 64-bits')
35502  }
35503  for (var i = 0; i < len; i += 8) {
35504    swap(this, i, i + 7)
35505    swap(this, i + 1, i + 6)
35506    swap(this, i + 2, i + 5)
35507    swap(this, i + 3, i + 4)
35508  }
35509  return this
35510}
35511
35512Buffer.prototype.toString = function toString () {
35513  var length = this.length | 0
35514  if (length === 0) return ''
35515  if (arguments.length === 0) return utf8Slice(this, 0, length)
35516  return slowToString.apply(this, arguments)
35517}
35518
35519Buffer.prototype.equals = function equals (b) {
35520  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
35521  if (this === b) return true
35522  return Buffer.compare(this, b) === 0
35523}
35524
35525Buffer.prototype.inspect = function inspect () {
35526  var str = ''
35527  var max = exports.INSPECT_MAX_BYTES
35528  if (this.length > 0) {
35529    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
35530    if (this.length > max) str += ' ... '
35531  }
35532  return '<Buffer ' + str + '>'
35533}
35534
35535Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
35536  if (!Buffer.isBuffer(target)) {
35537    throw new TypeError('Argument must be a Buffer')
35538  }
35539
35540  if (start === undefined) {
35541    start = 0
35542  }
35543  if (end === undefined) {
35544    end = target ? target.length : 0
35545  }
35546  if (thisStart === undefined) {
35547    thisStart = 0
35548  }
35549  if (thisEnd === undefined) {
35550    thisEnd = this.length
35551  }
35552
35553  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
35554    throw new RangeError('out of range index')
35555  }
35556
35557  if (thisStart >= thisEnd && start >= end) {
35558    return 0
35559  }
35560  if (thisStart >= thisEnd) {
35561    return -1
35562  }
35563  if (start >= end) {
35564    return 1
35565  }
35566
35567  start >>>= 0
35568  end >>>= 0
35569  thisStart >>>= 0
35570  thisEnd >>>= 0
35571
35572  if (this === target) return 0
35573
35574  var x = thisEnd - thisStart
35575  var y = end - start
35576  var len = Math.min(x, y)
35577
35578  var thisCopy = this.slice(thisStart, thisEnd)
35579  var targetCopy = target.slice(start, end)
35580
35581  for (var i = 0; i < len; ++i) {
35582    if (thisCopy[i] !== targetCopy[i]) {
35583      x = thisCopy[i]
35584      y = targetCopy[i]
35585      break
35586    }
35587  }
35588
35589  if (x < y) return -1
35590  if (y < x) return 1
35591  return 0
35592}
35593
35594// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
35595// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
35596//
35597// Arguments:
35598// - buffer - a Buffer to search
35599// - val - a string, Buffer, or number
35600// - byteOffset - an index into `buffer`; will be clamped to an int32
35601// - encoding - an optional encoding, relevant is val is a string
35602// - dir - true for indexOf, false for lastIndexOf
35603function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
35604  // Empty buffer means no match
35605  if (buffer.length === 0) return -1
35606
35607  // Normalize byteOffset
35608  if (typeof byteOffset === 'string') {
35609    encoding = byteOffset
35610    byteOffset = 0
35611  } else if (byteOffset > 0x7fffffff) {
35612    byteOffset = 0x7fffffff
35613  } else if (byteOffset < -0x80000000) {
35614    byteOffset = -0x80000000
35615  }
35616  byteOffset = +byteOffset  // Coerce to Number.
35617  if (isNaN(byteOffset)) {
35618    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
35619    byteOffset = dir ? 0 : (buffer.length - 1)
35620  }
35621
35622  // Normalize byteOffset: negative offsets start from the end of the buffer
35623  if (byteOffset < 0) byteOffset = buffer.length + byteOffset
35624  if (byteOffset >= buffer.length) {
35625    if (dir) return -1
35626    else byteOffset = buffer.length - 1
35627  } else if (byteOffset < 0) {
35628    if (dir) byteOffset = 0
35629    else return -1
35630  }
35631
35632  // Normalize val
35633  if (typeof val === 'string') {
35634    val = Buffer.from(val, encoding)
35635  }
35636
35637  // Finally, search either indexOf (if dir is true) or lastIndexOf
35638  if (Buffer.isBuffer(val)) {
35639    // Special case: looking for empty string/buffer always fails
35640    if (val.length === 0) {
35641      return -1
35642    }
35643    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
35644  } else if (typeof val === 'number') {
35645    val = val & 0xFF // Search for a byte value [0-255]
35646    if (Buffer.TYPED_ARRAY_SUPPORT &&
35647        typeof Uint8Array.prototype.indexOf === 'function') {
35648      if (dir) {
35649        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
35650      } else {
35651        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
35652      }
35653    }
35654    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
35655  }
35656
35657  throw new TypeError('val must be string, number or Buffer')
35658}
35659
35660function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
35661  var indexSize = 1
35662  var arrLength = arr.length
35663  var valLength = val.length
35664
35665  if (encoding !== undefined) {
35666    encoding = String(encoding).toLowerCase()
35667    if (encoding === 'ucs2' || encoding === 'ucs-2' ||
35668        encoding === 'utf16le' || encoding === 'utf-16le') {
35669      if (arr.length < 2 || val.length < 2) {
35670        return -1
35671      }
35672      indexSize = 2
35673      arrLength /= 2
35674      valLength /= 2
35675      byteOffset /= 2
35676    }
35677  }
35678
35679  function read (buf, i) {
35680    if (indexSize === 1) {
35681      return buf[i]
35682    } else {
35683      return buf.readUInt16BE(i * indexSize)
35684    }
35685  }
35686
35687  var i
35688  if (dir) {
35689    var foundIndex = -1
35690    for (i = byteOffset; i < arrLength; i++) {
35691      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
35692        if (foundIndex === -1) foundIndex = i
35693        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
35694      } else {
35695        if (foundIndex !== -1) i -= i - foundIndex
35696        foundIndex = -1
35697      }
35698    }
35699  } else {
35700    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
35701    for (i = byteOffset; i >= 0; i--) {
35702      var found = true
35703      for (var j = 0; j < valLength; j++) {
35704        if (read(arr, i + j) !== read(val, j)) {
35705          found = false
35706          break
35707        }
35708      }
35709      if (found) return i
35710    }
35711  }
35712
35713  return -1
35714}
35715
35716Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
35717  return this.indexOf(val, byteOffset, encoding) !== -1
35718}
35719
35720Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
35721  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
35722}
35723
35724Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
35725  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
35726}
35727
35728function hexWrite (buf, string, offset, length) {
35729  offset = Number(offset) || 0
35730  var remaining = buf.length - offset
35731  if (!length) {
35732    length = remaining
35733  } else {
35734    length = Number(length)
35735    if (length > remaining) {
35736      length = remaining
35737    }
35738  }
35739
35740  // must be an even number of digits
35741  var strLen = string.length
35742  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
35743
35744  if (length > strLen / 2) {
35745    length = strLen / 2
35746  }
35747  for (var i = 0; i < length; ++i) {
35748    var parsed = parseInt(string.substr(i * 2, 2), 16)
35749    if (isNaN(parsed)) return i
35750    buf[offset + i] = parsed
35751  }
35752  return i
35753}
35754
35755function utf8Write (buf, string, offset, length) {
35756  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
35757}
35758
35759function asciiWrite (buf, string, offset, length) {
35760  return blitBuffer(asciiToBytes(string), buf, offset, length)
35761}
35762
35763function latin1Write (buf, string, offset, length) {
35764  return asciiWrite(buf, string, offset, length)
35765}
35766
35767function base64Write (buf, string, offset, length) {
35768  return blitBuffer(base64ToBytes(string), buf, offset, length)
35769}
35770
35771function ucs2Write (buf, string, offset, length) {
35772  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
35773}
35774
35775Buffer.prototype.write = function write (string, offset, length, encoding) {
35776  // Buffer#write(string)
35777  if (offset === undefined) {
35778    encoding = 'utf8'
35779    length = this.length
35780    offset = 0
35781  // Buffer#write(string, encoding)
35782  } else if (length === undefined && typeof offset === 'string') {
35783    encoding = offset
35784    length = this.length
35785    offset = 0
35786  // Buffer#write(string, offset[, length][, encoding])
35787  } else if (isFinite(offset)) {
35788    offset = offset | 0
35789    if (isFinite(length)) {
35790      length = length | 0
35791      if (encoding === undefined) encoding = 'utf8'
35792    } else {
35793      encoding = length
35794      length = undefined
35795    }
35796  // legacy write(string, encoding, offset, length) - remove in v0.13
35797  } else {
35798    throw new Error(
35799      'Buffer.write(string, encoding, offset[, length]) is no longer supported'
35800    )
35801  }
35802
35803  var remaining = this.length - offset
35804  if (length === undefined || length > remaining) length = remaining
35805
35806  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
35807    throw new RangeError('Attempt to write outside buffer bounds')
35808  }
35809
35810  if (!encoding) encoding = 'utf8'
35811
35812  var loweredCase = false
35813  for (;;) {
35814    switch (encoding) {
35815      case 'hex':
35816        return hexWrite(this, string, offset, length)
35817
35818      case 'utf8':
35819      case 'utf-8':
35820        return utf8Write(this, string, offset, length)
35821
35822      case 'ascii':
35823        return asciiWrite(this, string, offset, length)
35824
35825      case 'latin1':
35826      case 'binary':
35827        return latin1Write(this, string, offset, length)
35828
35829      case 'base64':
35830        // Warning: maxLength not taken into account in base64Write
35831        return base64Write(this, string, offset, length)
35832
35833      case 'ucs2':
35834      case 'ucs-2':
35835      case 'utf16le':
35836      case 'utf-16le':
35837        return ucs2Write(this, string, offset, length)
35838
35839      default:
35840        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
35841        encoding = ('' + encoding).toLowerCase()
35842        loweredCase = true
35843    }
35844  }
35845}
35846
35847Buffer.prototype.toJSON = function toJSON () {
35848  return {
35849    type: 'Buffer',
35850    data: Array.prototype.slice.call(this._arr || this, 0)
35851  }
35852}
35853
35854function base64Slice (buf, start, end) {
35855  if (start === 0 && end === buf.length) {
35856    return base64.fromByteArray(buf)
35857  } else {
35858    return base64.fromByteArray(buf.slice(start, end))
35859  }
35860}
35861
35862function utf8Slice (buf, start, end) {
35863  end = Math.min(buf.length, end)
35864  var res = []
35865
35866  var i = start
35867  while (i < end) {
35868    var firstByte = buf[i]
35869    var codePoint = null
35870    var bytesPerSequence = (firstByte > 0xEF) ? 4
35871      : (firstByte > 0xDF) ? 3
35872      : (firstByte > 0xBF) ? 2
35873      : 1
35874
35875    if (i + bytesPerSequence <= end) {
35876      var secondByte, thirdByte, fourthByte, tempCodePoint
35877
35878      switch (bytesPerSequence) {
35879        case 1:
35880          if (firstByte < 0x80) {
35881            codePoint = firstByte
35882          }
35883          break
35884        case 2:
35885          secondByte = buf[i + 1]
35886          if ((secondByte & 0xC0) === 0x80) {
35887            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
35888            if (tempCodePoint > 0x7F) {
35889              codePoint = tempCodePoint
35890            }
35891          }
35892          break
35893        case 3:
35894          secondByte = buf[i + 1]
35895          thirdByte = buf[i + 2]
35896          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
35897            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
35898            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
35899              codePoint = tempCodePoint
35900            }
35901          }
35902          break
35903        case 4:
35904          secondByte = buf[i + 1]
35905          thirdByte = buf[i + 2]
35906          fourthByte = buf[i + 3]
35907          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
35908            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
35909            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
35910              codePoint = tempCodePoint
35911            }
35912          }
35913      }
35914    }
35915
35916    if (codePoint === null) {
35917      // we did not generate a valid codePoint so insert a
35918      // replacement char (U+FFFD) and advance only 1 byte
35919      codePoint = 0xFFFD
35920      bytesPerSequence = 1
35921    } else if (codePoint > 0xFFFF) {
35922      // encode to utf16 (surrogate pair dance)
35923      codePoint -= 0x10000
35924      res.push(codePoint >>> 10 & 0x3FF | 0xD800)
35925      codePoint = 0xDC00 | codePoint & 0x3FF
35926    }
35927
35928    res.push(codePoint)
35929    i += bytesPerSequence
35930  }
35931
35932  return decodeCodePointsArray(res)
35933}
35934
35935// Based on http://stackoverflow.com/a/22747272/680742, the browser with
35936// the lowest limit is Chrome, with 0x10000 args.
35937// We go 1 magnitude less, for safety
35938var MAX_ARGUMENTS_LENGTH = 0x1000
35939
35940function decodeCodePointsArray (codePoints) {
35941  var len = codePoints.length
35942  if (len <= MAX_ARGUMENTS_LENGTH) {
35943    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
35944  }
35945
35946  // Decode in chunks to avoid "call stack size exceeded".
35947  var res = ''
35948  var i = 0
35949  while (i < len) {
35950    res += String.fromCharCode.apply(
35951      String,
35952      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
35953    )
35954  }
35955  return res
35956}
35957
35958function asciiSlice (buf, start, end) {
35959  var ret = ''
35960  end = Math.min(buf.length, end)
35961
35962  for (var i = start; i < end; ++i) {
35963    ret += String.fromCharCode(buf[i] & 0x7F)
35964  }
35965  return ret
35966}
35967
35968function latin1Slice (buf, start, end) {
35969  var ret = ''
35970  end = Math.min(buf.length, end)
35971
35972  for (var i = start; i < end; ++i) {
35973    ret += String.fromCharCode(buf[i])
35974  }
35975  return ret
35976}
35977
35978function hexSlice (buf, start, end) {
35979  var len = buf.length
35980
35981  if (!start || start < 0) start = 0
35982  if (!end || end < 0 || end > len) end = len
35983
35984  var out = ''
35985  for (var i = start; i < end; ++i) {
35986    out += toHex(buf[i])
35987  }
35988  return out
35989}
35990
35991function utf16leSlice (buf, start, end) {
35992  var bytes = buf.slice(start, end)
35993  var res = ''
35994  for (var i = 0; i < bytes.length; i += 2) {
35995    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
35996  }
35997  return res
35998}
35999
36000Buffer.prototype.slice = function slice (start, end) {
36001  var len = this.length
36002  start = ~~start
36003  end = end === undefined ? len : ~~end
36004
36005  if (start < 0) {
36006    start += len
36007    if (start < 0) start = 0
36008  } else if (start > len) {
36009    start = len
36010  }
36011
36012  if (end < 0) {
36013    end += len
36014    if (end < 0) end = 0
36015  } else if (end > len) {
36016    end = len
36017  }
36018
36019  if (end < start) end = start
36020
36021  var newBuf
36022  if (Buffer.TYPED_ARRAY_SUPPORT) {
36023    newBuf = this.subarray(start, end)
36024    newBuf.__proto__ = Buffer.prototype
36025  } else {
36026    var sliceLen = end - start
36027    newBuf = new Buffer(sliceLen, undefined)
36028    for (var i = 0; i < sliceLen; ++i) {
36029      newBuf[i] = this[i + start]
36030    }
36031  }
36032
36033  return newBuf
36034}
36035
36036/*
36037 * Need to make sure that buffer isn't trying to write out of bounds.
36038 */
36039function checkOffset (offset, ext, length) {
36040  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
36041  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
36042}
36043
36044Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
36045  offset = offset | 0
36046  byteLength = byteLength | 0
36047  if (!noAssert) checkOffset(offset, byteLength, this.length)
36048
36049  var val = this[offset]
36050  var mul = 1
36051  var i = 0
36052  while (++i < byteLength && (mul *= 0x100)) {
36053    val += this[offset + i] * mul
36054  }
36055
36056  return val
36057}
36058
36059Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
36060  offset = offset | 0
36061  byteLength = byteLength | 0
36062  if (!noAssert) {
36063    checkOffset(offset, byteLength, this.length)
36064  }
36065
36066  var val = this[offset + --byteLength]
36067  var mul = 1
36068  while (byteLength > 0 && (mul *= 0x100)) {
36069    val += this[offset + --byteLength] * mul
36070  }
36071
36072  return val
36073}
36074
36075Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
36076  if (!noAssert) checkOffset(offset, 1, this.length)
36077  return this[offset]
36078}
36079
36080Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
36081  if (!noAssert) checkOffset(offset, 2, this.length)
36082  return this[offset] | (this[offset + 1] << 8)
36083}
36084
36085Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
36086  if (!noAssert) checkOffset(offset, 2, this.length)
36087  return (this[offset] << 8) | this[offset + 1]
36088}
36089
36090Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
36091  if (!noAssert) checkOffset(offset, 4, this.length)
36092
36093  return ((this[offset]) |
36094      (this[offset + 1] << 8) |
36095      (this[offset + 2] << 16)) +
36096      (this[offset + 3] * 0x1000000)
36097}
36098
36099Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
36100  if (!noAssert) checkOffset(offset, 4, this.length)
36101
36102  return (this[offset] * 0x1000000) +
36103    ((this[offset + 1] << 16) |
36104    (this[offset + 2] << 8) |
36105    this[offset + 3])
36106}
36107
36108Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
36109  offset = offset | 0
36110  byteLength = byteLength | 0
36111  if (!noAssert) checkOffset(offset, byteLength, this.length)
36112
36113  var val = this[offset]
36114  var mul = 1
36115  var i = 0
36116  while (++i < byteLength && (mul *= 0x100)) {
36117    val += this[offset + i] * mul
36118  }
36119  mul *= 0x80
36120
36121  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
36122
36123  return val
36124}
36125
36126Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
36127  offset = offset | 0
36128  byteLength = byteLength | 0
36129  if (!noAssert) checkOffset(offset, byteLength, this.length)
36130
36131  var i = byteLength
36132  var mul = 1
36133  var val = this[offset + --i]
36134  while (i > 0 && (mul *= 0x100)) {
36135    val += this[offset + --i] * mul
36136  }
36137  mul *= 0x80
36138
36139  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
36140
36141  return val
36142}
36143
36144Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
36145  if (!noAssert) checkOffset(offset, 1, this.length)
36146  if (!(this[offset] & 0x80)) return (this[offset])
36147  return ((0xff - this[offset] + 1) * -1)
36148}
36149
36150Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
36151  if (!noAssert) checkOffset(offset, 2, this.length)
36152  var val = this[offset] | (this[offset + 1] << 8)
36153  return (val & 0x8000) ? val | 0xFFFF0000 : val
36154}
36155
36156Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
36157  if (!noAssert) checkOffset(offset, 2, this.length)
36158  var val = this[offset + 1] | (this[offset] << 8)
36159  return (val & 0x8000) ? val | 0xFFFF0000 : val
36160}
36161
36162Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
36163  if (!noAssert) checkOffset(offset, 4, this.length)
36164
36165  return (this[offset]) |
36166    (this[offset + 1] << 8) |
36167    (this[offset + 2] << 16) |
36168    (this[offset + 3] << 24)
36169}
36170
36171Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
36172  if (!noAssert) checkOffset(offset, 4, this.length)
36173
36174  return (this[offset] << 24) |
36175    (this[offset + 1] << 16) |
36176    (this[offset + 2] << 8) |
36177    (this[offset + 3])
36178}
36179
36180Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
36181  if (!noAssert) checkOffset(offset, 4, this.length)
36182  return ieee754.read(this, offset, true, 23, 4)
36183}
36184
36185Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
36186  if (!noAssert) checkOffset(offset, 4, this.length)
36187  return ieee754.read(this, offset, false, 23, 4)
36188}
36189
36190Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
36191  if (!noAssert) checkOffset(offset, 8, this.length)
36192  return ieee754.read(this, offset, true, 52, 8)
36193}
36194
36195Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
36196  if (!noAssert) checkOffset(offset, 8, this.length)
36197  return ieee754.read(this, offset, false, 52, 8)
36198}
36199
36200function checkInt (buf, value, offset, ext, max, min) {
36201  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
36202  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
36203  if (offset + ext > buf.length) throw new RangeError('Index out of range')
36204}
36205
36206Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
36207  value = +value
36208  offset = offset | 0
36209  byteLength = byteLength | 0
36210  if (!noAssert) {
36211    var maxBytes = Math.pow(2, 8 * byteLength) - 1
36212    checkInt(this, value, offset, byteLength, maxBytes, 0)
36213  }
36214
36215  var mul = 1
36216  var i = 0
36217  this[offset] = value & 0xFF
36218  while (++i < byteLength && (mul *= 0x100)) {
36219    this[offset + i] = (value / mul) & 0xFF
36220  }
36221
36222  return offset + byteLength
36223}
36224
36225Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
36226  value = +value
36227  offset = offset | 0
36228  byteLength = byteLength | 0
36229  if (!noAssert) {
36230    var maxBytes = Math.pow(2, 8 * byteLength) - 1
36231    checkInt(this, value, offset, byteLength, maxBytes, 0)
36232  }
36233
36234  var i = byteLength - 1
36235  var mul = 1
36236  this[offset + i] = value & 0xFF
36237  while (--i >= 0 && (mul *= 0x100)) {
36238    this[offset + i] = (value / mul) & 0xFF
36239  }
36240
36241  return offset + byteLength
36242}
36243
36244Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
36245  value = +value
36246  offset = offset | 0
36247  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
36248  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
36249  this[offset] = (value & 0xff)
36250  return offset + 1
36251}
36252
36253function objectWriteUInt16 (buf, value, offset, littleEndian) {
36254  if (value < 0) value = 0xffff + value + 1
36255  for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
36256    buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
36257      (littleEndian ? i : 1 - i) * 8
36258  }
36259}
36260
36261Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
36262  value = +value
36263  offset = offset | 0
36264  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
36265  if (Buffer.TYPED_ARRAY_SUPPORT) {
36266    this[offset] = (value & 0xff)
36267    this[offset + 1] = (value >>> 8)
36268  } else {
36269    objectWriteUInt16(this, value, offset, true)
36270  }
36271  return offset + 2
36272}
36273
36274Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
36275  value = +value
36276  offset = offset | 0
36277  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
36278  if (Buffer.TYPED_ARRAY_SUPPORT) {
36279    this[offset] = (value >>> 8)
36280    this[offset + 1] = (value & 0xff)
36281  } else {
36282    objectWriteUInt16(this, value, offset, false)
36283  }
36284  return offset + 2
36285}
36286
36287function objectWriteUInt32 (buf, value, offset, littleEndian) {
36288  if (value < 0) value = 0xffffffff + value + 1
36289  for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
36290    buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
36291  }
36292}
36293
36294Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
36295  value = +value
36296  offset = offset | 0
36297  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
36298  if (Buffer.TYPED_ARRAY_SUPPORT) {
36299    this[offset + 3] = (value >>> 24)
36300    this[offset + 2] = (value >>> 16)
36301    this[offset + 1] = (value >>> 8)
36302    this[offset] = (value & 0xff)
36303  } else {
36304    objectWriteUInt32(this, value, offset, true)
36305  }
36306  return offset + 4
36307}
36308
36309Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
36310  value = +value
36311  offset = offset | 0
36312  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
36313  if (Buffer.TYPED_ARRAY_SUPPORT) {
36314    this[offset] = (value >>> 24)
36315    this[offset + 1] = (value >>> 16)
36316    this[offset + 2] = (value >>> 8)
36317    this[offset + 3] = (value & 0xff)
36318  } else {
36319    objectWriteUInt32(this, value, offset, false)
36320  }
36321  return offset + 4
36322}
36323
36324Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
36325  value = +value
36326  offset = offset | 0
36327  if (!noAssert) {
36328    var limit = Math.pow(2, 8 * byteLength - 1)
36329
36330    checkInt(this, value, offset, byteLength, limit - 1, -limit)
36331  }
36332
36333  var i = 0
36334  var mul = 1
36335  var sub = 0
36336  this[offset] = value & 0xFF
36337  while (++i < byteLength && (mul *= 0x100)) {
36338    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
36339      sub = 1
36340    }
36341    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
36342  }
36343
36344  return offset + byteLength
36345}
36346
36347Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
36348  value = +value
36349  offset = offset | 0
36350  if (!noAssert) {
36351    var limit = Math.pow(2, 8 * byteLength - 1)
36352
36353    checkInt(this, value, offset, byteLength, limit - 1, -limit)
36354  }
36355
36356  var i = byteLength - 1
36357  var mul = 1
36358  var sub = 0
36359  this[offset + i] = value & 0xFF
36360  while (--i >= 0 && (mul *= 0x100)) {
36361    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
36362      sub = 1
36363    }
36364    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
36365  }
36366
36367  return offset + byteLength
36368}
36369
36370Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
36371  value = +value
36372  offset = offset | 0
36373  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
36374  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
36375  if (value < 0) value = 0xff + value + 1
36376  this[offset] = (value & 0xff)
36377  return offset + 1
36378}
36379
36380Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
36381  value = +value
36382  offset = offset | 0
36383  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
36384  if (Buffer.TYPED_ARRAY_SUPPORT) {
36385    this[offset] = (value & 0xff)
36386    this[offset + 1] = (value >>> 8)
36387  } else {
36388    objectWriteUInt16(this, value, offset, true)
36389  }
36390  return offset + 2
36391}
36392
36393Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
36394  value = +value
36395  offset = offset | 0
36396  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
36397  if (Buffer.TYPED_ARRAY_SUPPORT) {
36398    this[offset] = (value >>> 8)
36399    this[offset + 1] = (value & 0xff)
36400  } else {
36401    objectWriteUInt16(this, value, offset, false)
36402  }
36403  return offset + 2
36404}
36405
36406Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
36407  value = +value
36408  offset = offset | 0
36409  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
36410  if (Buffer.TYPED_ARRAY_SUPPORT) {
36411    this[offset] = (value & 0xff)
36412    this[offset + 1] = (value >>> 8)
36413    this[offset + 2] = (value >>> 16)
36414    this[offset + 3] = (value >>> 24)
36415  } else {
36416    objectWriteUInt32(this, value, offset, true)
36417  }
36418  return offset + 4
36419}
36420
36421Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
36422  value = +value
36423  offset = offset | 0
36424  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
36425  if (value < 0) value = 0xffffffff + value + 1
36426  if (Buffer.TYPED_ARRAY_SUPPORT) {
36427    this[offset] = (value >>> 24)
36428    this[offset + 1] = (value >>> 16)
36429    this[offset + 2] = (value >>> 8)
36430    this[offset + 3] = (value & 0xff)
36431  } else {
36432    objectWriteUInt32(this, value, offset, false)
36433  }
36434  return offset + 4
36435}
36436
36437function checkIEEE754 (buf, value, offset, ext, max, min) {
36438  if (offset + ext > buf.length) throw new RangeError('Index out of range')
36439  if (offset < 0) throw new RangeError('Index out of range')
36440}
36441
36442function writeFloat (buf, value, offset, littleEndian, noAssert) {
36443  if (!noAssert) {
36444    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
36445  }
36446  ieee754.write(buf, value, offset, littleEndian, 23, 4)
36447  return offset + 4
36448}
36449
36450Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
36451  return writeFloat(this, value, offset, true, noAssert)
36452}
36453
36454Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
36455  return writeFloat(this, value, offset, false, noAssert)
36456}
36457
36458function writeDouble (buf, value, offset, littleEndian, noAssert) {
36459  if (!noAssert) {
36460    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
36461  }
36462  ieee754.write(buf, value, offset, littleEndian, 52, 8)
36463  return offset + 8
36464}
36465
36466Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
36467  return writeDouble(this, value, offset, true, noAssert)
36468}
36469
36470Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
36471  return writeDouble(this, value, offset, false, noAssert)
36472}
36473
36474// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
36475Buffer.prototype.copy = function copy (target, targetStart, start, end) {
36476  if (!start) start = 0
36477  if (!end && end !== 0) end = this.length
36478  if (targetStart >= target.length) targetStart = target.length
36479  if (!targetStart) targetStart = 0
36480  if (end > 0 && end < start) end = start
36481
36482  // Copy 0 bytes; we're done
36483  if (end === start) return 0
36484  if (target.length === 0 || this.length === 0) return 0
36485
36486  // Fatal error conditions
36487  if (targetStart < 0) {
36488    throw new RangeError('targetStart out of bounds')
36489  }
36490  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
36491  if (end < 0) throw new RangeError('sourceEnd out of bounds')
36492
36493  // Are we oob?
36494  if (end > this.length) end = this.length
36495  if (target.length - targetStart < end - start) {
36496    end = target.length - targetStart + start
36497  }
36498
36499  var len = end - start
36500  var i
36501
36502  if (this === target && start < targetStart && targetStart < end) {
36503    // descending copy from end
36504    for (i = len - 1; i >= 0; --i) {
36505      target[i + targetStart] = this[i + start]
36506    }
36507  } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
36508    // ascending copy from start
36509    for (i = 0; i < len; ++i) {
36510      target[i + targetStart] = this[i + start]
36511    }
36512  } else {
36513    Uint8Array.prototype.set.call(
36514      target,
36515      this.subarray(start, start + len),
36516      targetStart
36517    )
36518  }
36519
36520  return len
36521}
36522
36523// Usage:
36524//    buffer.fill(number[, offset[, end]])
36525//    buffer.fill(buffer[, offset[, end]])
36526//    buffer.fill(string[, offset[, end]][, encoding])
36527Buffer.prototype.fill = function fill (val, start, end, encoding) {
36528  // Handle string cases:
36529  if (typeof val === 'string') {
36530    if (typeof start === 'string') {
36531      encoding = start
36532      start = 0
36533      end = this.length
36534    } else if (typeof end === 'string') {
36535      encoding = end
36536      end = this.length
36537    }
36538    if (val.length === 1) {
36539      var code = val.charCodeAt(0)
36540      if (code < 256) {
36541        val = code
36542      }
36543    }
36544    if (encoding !== undefined && typeof encoding !== 'string') {
36545      throw new TypeError('encoding must be a string')
36546    }
36547    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
36548      throw new TypeError('Unknown encoding: ' + encoding)
36549    }
36550  } else if (typeof val === 'number') {
36551    val = val & 255
36552  }
36553
36554  // Invalid ranges are not set to a default, so can range check early.
36555  if (start < 0 || this.length < start || this.length < end) {
36556    throw new RangeError('Out of range index')
36557  }
36558
36559  if (end <= start) {
36560    return this
36561  }
36562
36563  start = start >>> 0
36564  end = end === undefined ? this.length : end >>> 0
36565
36566  if (!val) val = 0
36567
36568  var i
36569  if (typeof val === 'number') {
36570    for (i = start; i < end; ++i) {
36571      this[i] = val
36572    }
36573  } else {
36574    var bytes = Buffer.isBuffer(val)
36575      ? val
36576      : utf8ToBytes(new Buffer(val, encoding).toString())
36577    var len = bytes.length
36578    for (i = 0; i < end - start; ++i) {
36579      this[i + start] = bytes[i % len]
36580    }
36581  }
36582
36583  return this
36584}
36585
36586// HELPER FUNCTIONS
36587// ================
36588
36589var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
36590
36591function base64clean (str) {
36592  // Node strips out invalid characters like \n and \t from the string, base64-js does not
36593  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
36594  // Node converts strings with length < 2 to ''
36595  if (str.length < 2) return ''
36596  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
36597  while (str.length % 4 !== 0) {
36598    str = str + '='
36599  }
36600  return str
36601}
36602
36603function stringtrim (str) {
36604  if (str.trim) return str.trim()
36605  return str.replace(/^\s+|\s+$/g, '')
36606}
36607
36608function toHex (n) {
36609  if (n < 16) return '0' + n.toString(16)
36610  return n.toString(16)
36611}
36612
36613function utf8ToBytes (string, units) {
36614  units = units || Infinity
36615  var codePoint
36616  var length = string.length
36617  var leadSurrogate = null
36618  var bytes = []
36619
36620  for (var i = 0; i < length; ++i) {
36621    codePoint = string.charCodeAt(i)
36622
36623    // is surrogate component
36624    if (codePoint > 0xD7FF && codePoint < 0xE000) {
36625      // last char was a lead
36626      if (!leadSurrogate) {
36627        // no lead yet
36628        if (codePoint > 0xDBFF) {
36629          // unexpected trail
36630          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
36631          continue
36632        } else if (i + 1 === length) {
36633          // unpaired lead
36634          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
36635          continue
36636        }
36637
36638        // valid lead
36639        leadSurrogate = codePoint
36640
36641        continue
36642      }
36643
36644      // 2 leads in a row
36645      if (codePoint < 0xDC00) {
36646        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
36647        leadSurrogate = codePoint
36648        continue
36649      }
36650
36651      // valid surrogate pair
36652      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
36653    } else if (leadSurrogate) {
36654      // valid bmp char, but last char was a lead
36655      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
36656    }
36657
36658    leadSurrogate = null
36659
36660    // encode utf8
36661    if (codePoint < 0x80) {
36662      if ((units -= 1) < 0) break
36663      bytes.push(codePoint)
36664    } else if (codePoint < 0x800) {
36665      if ((units -= 2) < 0) break
36666      bytes.push(
36667        codePoint >> 0x6 | 0xC0,
36668        codePoint & 0x3F | 0x80
36669      )
36670    } else if (codePoint < 0x10000) {
36671      if ((units -= 3) < 0) break
36672      bytes.push(
36673        codePoint >> 0xC | 0xE0,
36674        codePoint >> 0x6 & 0x3F | 0x80,
36675        codePoint & 0x3F | 0x80
36676      )
36677    } else if (codePoint < 0x110000) {
36678      if ((units -= 4) < 0) break
36679      bytes.push(
36680        codePoint >> 0x12 | 0xF0,
36681        codePoint >> 0xC & 0x3F | 0x80,
36682        codePoint >> 0x6 & 0x3F | 0x80,
36683        codePoint & 0x3F | 0x80
36684      )
36685    } else {
36686      throw new Error('Invalid code point')
36687    }
36688  }
36689
36690  return bytes
36691}
36692
36693function asciiToBytes (str) {
36694  var byteArray = []
36695  for (var i = 0; i < str.length; ++i) {
36696    // Node's code seems to be doing this and not & 0x7F..
36697    byteArray.push(str.charCodeAt(i) & 0xFF)
36698  }
36699  return byteArray
36700}
36701
36702function utf16leToBytes (str, units) {
36703  var c, hi, lo
36704  var byteArray = []
36705  for (var i = 0; i < str.length; ++i) {
36706    if ((units -= 2) < 0) break
36707
36708    c = str.charCodeAt(i)
36709    hi = c >> 8
36710    lo = c % 256
36711    byteArray.push(lo)
36712    byteArray.push(hi)
36713  }
36714
36715  return byteArray
36716}
36717
36718function base64ToBytes (str) {
36719  return base64.toByteArray(base64clean(str))
36720}
36721
36722function blitBuffer (src, dst, offset, length) {
36723  for (var i = 0; i < length; ++i) {
36724    if ((i + offset >= dst.length) || (i >= src.length)) break
36725    dst[i + offset] = src[i]
36726  }
36727  return i
36728}
36729
36730function isnan (val) {
36731  return val !== val // eslint-disable-line no-self-compare
36732}
36733
36734/* WEBPACK VAR INJECTION */}.call(
vendor: 7,349 bytes, lines 36734-37045
36734exports, __webpack_require__(0).Buffer, __webpack_require__(8)))
36735
36736/***/ },
36737/* 1 */
36738/***/ function(module, exports, __webpack_require__) {
36739
36740/* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
36741  'use strict';
36742
36743  // Utils
36744  function assert (val, msg) {
36745    if (!val) throw new Error(msg || 'Assertion failed');
36746  }
36747
36748  // Could use `inherits` module, but don't want to move from single file
36749  // architecture yet.
36750  function inherits (ctor, superCtor) {
36751    ctor.super_ = superCtor;
36752    var TempCtor = function () {};
36753    TempCtor.prototype = superCtor.prototype;
36754    ctor.prototype = new TempCtor();
36755    ctor.prototype.constructor = ctor;
36756  }
36757
36758  // BN
36759
36760  function BN (number, base, endian) {
36761    if (BN.isBN(number)) {
36762      return number;
36763    }
36764
36765    this.negative = 0;
36766    this.words = null;
36767    this.length = 0;
36768
36769    // Reduction context
36770    this.red = null;
36771
36772    if (number !== null) {
36773      if (base === 'le' || base === 'be') {
36774        endian = base;
36775        base = 10;
36776      }
36777
36778      this._init(number || 0, base || 10, endian || 'be');
36779    }
36780  }
36781  if (typeof module === 'object') {
36782    module.exports = BN;
36783  } else {
36784    exports.BN = BN;
36785  }
36786
36787  BN.BN = BN;
36788  BN.wordSize = 26;
36789
36790  var Buffer;
36791  try {
36792    Buffer = __webpack_require__(0).Buffer;
36793  } catch (e) {
36794  }
36795
36796  BN.isBN = function isBN (num) {
36797    if (num instanceof BN) {
36798      return true;
36799    }
36800
36801    return num !== null && typeof num === 'object' &&
36802      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
36803  };
36804
36805  BN.max = function max (left, right) {
36806    if (left.cmp(right) > 0) return left;
36807    return right;
36808  };
36809
36810  BN.min = function min (left, right) {
36811    if (left.cmp(right) < 0) return left;
36812    return right;
36813  };
36814
36815  BN.prototype._init = function init (number, base, endian) {
36816    if (typeof number === 'number') {
36817      return this._initNumber(number, base, endian);
36818    }
36819
36820    if (typeof number === 'object') {
36821      return this._initArray(number, base, endian);
36822    }
36823
36824    if (base === 'hex') {
36825      base = 16;
36826    }
36827    assert(base === (base | 0) && base >= 2 && base <= 36);
36828
36829    number = number.toString().replace(/\s+/g, '');
36830    var start = 0;
36831    if (number[0] === '-') {
36832      start++;
36833    }
36834
36835    if (base === 16) {
36836      this._parseHex(number, start);
36837    } else {
36838      this._parseBase(number, base, start);
36839    }
36840
36841    if (number[0] === '-') {
36842      this.negative = 1;
36843    }
36844
36845    this.strip();
36846
36847    if (endian !== 'le') return;
36848
36849    this._initArray(this.toArray(), base, endian);
36850  };
36851
36852  BN.prototype._initNumber = function _initNumber (number, base, endian) {
36853    if (number < 0) {
36854      this.negative = 1;
36855      number = -number;
36856    }
36857    if (number < 0x4000000) {
36858      this.words = [ number & 0x3ffffff ];
36859      this.length = 1;
36860    } else if (number < 0x10000000000000) {
36861      this.words = [
36862        number & 0x3ffffff,
36863        (number / 0x4000000) & 0x3ffffff
36864      ];
36865      this.length = 2;
36866    } else {
36867      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
36868      this.words = [
36869        number & 0x3ffffff,
36870        (number / 0x4000000) & 0x3ffffff,
36871        1
36872      ];
36873      this.length = 3;
36874    }
36875
36876    if (endian !== 'le') return;
36877
36878    // Reverse the bytes
36879    this._initArray(this.toArray(), base, endian);
36880  };
36881
36882  BN.prototype._initArray = function _initArray (number, base, endian) {
36883    // Perhaps a Uint8Array
36884    assert(typeof number.length === 'number');
36885    if (number.length <= 0) {
36886      this.words = [ 0 ];
36887      this.length = 1;
36888      return this;
36889    }
36890
36891    this.length = Math.ceil(number.length / 3);
36892    this.words = new Array(this.length);
36893    for (var i = 0; i < this.length; i++) {
36894      this.words[i] = 0;
36895    }
36896
36897    var j, w;
36898    var off = 0;
36899    if (endian === 'be') {
36900      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
36901        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
36902        this.words[j] |= (w << off) & 0x3ffffff;
36903        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
36904        off += 24;
36905        if (off >= 26) {
36906          off -= 26;
36907          j++;
36908        }
36909      }
36910    } else if (endian === 'le') {
36911      for (i = 0, j = 0; i < number.length; i += 3) {
36912        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
36913        this.words[j] |= (w << off) & 0x3ffffff;
36914        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
36915        off += 24;
36916        if (off >= 26) {
36917          off -= 26;
36918          j++;
36919        }
36920      }
36921    }
36922    return this.strip();
36923  };
36924
36925  function parseHex (str, start, end) {
36926    var r = 0;
36927    var len = Math.min(str.length, end);
36928    for (var i = start; i < len; i++) {
36929      var c = str.charCodeAt(i) - 48;
36930
36931      r <<= 4;
36932
36933      // 'a' - 'f'
36934      if (c >= 49 && c <= 54) {
36935        r |= c - 49 + 0xa;
36936
36937      // 'A' - 'F'
36938      } else if (c >= 17 && c <= 22) {
36939        r |= c - 17 + 0xa;
36940
36941      // '0' - '9'
36942      } else {
36943        r |= c & 0xf;
36944      }
36945    }
36946    return r;
36947  }
36948
36949  BN.prototype._parseHex = function _parseHex (number, start) {
36950    // Create possibly bigger array to ensure that it fits the number
36951    this.length = Math.ceil((number.length - start) / 6);
36952    this.words = new Array(this.length);
36953    for (var i = 0; i < this.length; i++) {
36954      this.words[i] = 0;
36955    }
36956
36957    var j, w;
36958    // Scan 24-bit chunks and add them to the number
36959    var off = 0;
36960    for (i = number.length - 6, j = 0; i >= start; i -= 6) {
36961      w = parseHex(number, i, i + 6);
36962      this.words[j] |= (w << off) & 0x3ffffff;
36963      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
36964      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
36965      off += 24;
36966      if (off >= 26) {
36967        off -= 26;
36968        j++;
36969      }
36970    }
36971    if (i + 6 !== start) {
36972      w = parseHex(number, start, i + 6);
36973      this.words[j] |= (w << off) & 0x3ffffff;
36974      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
36975    }
36976    this.strip();
36977  };
36978
36979  function parseBase (str, start, end, mul) {
36980    var r = 0;
36981    var len = Math.min(str.length, end);
36982    for (var i = start; i < len; i++) {
36983      var c = str.charCodeAt(i) - 48;
36984
36985      r *= mul;
36986
36987      // 'a'
36988      if (c >= 49) {
36989        r += c - 49 + 0xa;
36990
36991      // 'A'
36992      } else if (c >= 17) {
36993        r += c - 17 + 0xa;
36994
36995      // '0' - '9'
36996      } else {
36997        r += c;
36998      }
36999    }
37000    return r;
37001  }
37002
37003  BN.prototype._parseBase = function _parseBase (number, base, start) {
37004    // Initialize as zero
37005    this.words = [ 0 ];
37006    this.length = 1;
37007
37008    // Find length of limb in base
37009    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
37010      limbLen++;
37011    }
37012    limbLen--;
37013    limbPow = (limbPow / base) | 0;
37014
37015    var total = number.length - start;
37016    var mod = total % limbLen;
37017    var end = Math.min(total, total - mod) + start;
37018
37019    var word = 0;
37020    for (var i = start; i < end; i += limbLen) {
37021      word = parseBase(number, i, i + limbLen, base);
37022
37023      this.imuln(limbPow);
37024      if (this.words[0] + word < 0x4000000) {
37025        this.words[0] += word;
37026      } else {
37027        this._iaddn(word);
37028      }
37029    }
37030
37031    if (mod !== 0) {
37032      var pow = 1;
37033      word = parseBase(number, i, number.length, base);
37034
37035      for (i = 0; i < mod; i++) {
37036        pow *= base;
37037      }
37038
37039      this.imuln(pow);
37040      if (this.words[0] + word < 0x4000000) {
37041        this.words[0] += word;
37042      } else {
37043        this._iaddn(word);
37044      }
37045    }
vendor: 68,018 bytes, lines 37045-39649
37045
37046  };
37047
37048  BN.prototype.copy = function copy (dest) {
37049    dest.words = new Array(this.length);
37050    for (var i = 0; i < this.length; i++) {
37051      dest.words[i] = this.words[i];
37052    }
37053    dest.length = this.length;
37054    dest.negative = this.negative;
37055    dest.red = this.red;
37056  };
37057
37058  BN.prototype.clone = function clone () {
37059    var r = new BN(null);
37060    this.copy(r);
37061    return r;
37062  };
37063
37064  BN.prototype._expand = function _expand (size) {
37065    while (this.length < size) {
37066      this.words[this.length++] = 0;
37067    }
37068    return this;
37069  };
37070
37071  // Remove leading `0` from `this`
37072  BN.prototype.strip = function strip () {
37073    while (this.length > 1 && this.words[this.length - 1] === 0) {
37074      this.length--;
37075    }
37076    return this._normSign();
37077  };
37078
37079  BN.prototype._normSign = function _normSign () {
37080    // -0 = 0
37081    if (this.length === 1 && this.words[0] === 0) {
37082      this.negative = 0;
37083    }
37084    return this;
37085  };
37086
37087  BN.prototype.inspect = function inspect () {
37088    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
37089  };
37090
37091  /*
37092
37093  var zeros = [];
37094  var groupSizes = [];
37095  var groupBases = [];
37096
37097  var s = '';
37098  var i = -1;
37099  while (++i < BN.wordSize) {
37100    zeros[i] = s;
37101    s += '0';
37102  }
37103  groupSizes[0] = 0;
37104  groupSizes[1] = 0;
37105  groupBases[0] = 0;
37106  groupBases[1] = 0;
37107  var base = 2 - 1;
37108  while (++base < 36 + 1) {
37109    var groupSize = 0;
37110    var groupBase = 1;
37111    while (groupBase < (1 << BN.wordSize) / base) {
37112      groupBase *= base;
37113      groupSize += 1;
37114    }
37115    groupSizes[base] = groupSize;
37116    groupBases[base] = groupBase;
37117  }
37118
37119  */
37120
37121  var zeros = [
37122    '',
37123    '0',
37124    '00',
37125    '000',
37126    '0000',
37127    '00000',
37128    '000000',
37129    '0000000',
37130    '00000000',
37131    '000000000',
37132    '0000000000',
37133    '00000000000',
37134    '000000000000',
37135    '0000000000000',
37136    '00000000000000',
37137    '000000000000000',
37138    '0000000000000000',
37139    '00000000000000000',
37140    '000000000000000000',
37141    '0000000000000000000',
37142    '00000000000000000000',
37143    '000000000000000000000',
37144    '0000000000000000000000',
37145    '00000000000000000000000',
37146    '000000000000000000000000',
37147    '0000000000000000000000000'
37148  ];
37149
37150  var groupSizes = [
37151    0, 0,
37152    25, 16, 12, 11, 10, 9, 8,
37153    8, 7, 7, 7, 7, 6, 6,
37154    6, 6, 6, 6, 6, 5, 5,
37155    5, 5, 5, 5, 5, 5, 5,
37156    5, 5, 5, 5, 5, 5, 5
37157  ];
37158
37159  var groupBases = [
37160    0, 0,
37161    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
37162    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
37163    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
37164    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
37165    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
37166  ];
37167
37168  BN.prototype.toString = function toString (base, padding) {
37169    base = base || 10;
37170    padding = padding | 0 || 1;
37171
37172    var out;
37173    if (base === 16 || base === 'hex') {
37174      out = '';
37175      var off = 0;
37176      var carry = 0;
37177      for (var i = 0; i < this.length; i++) {
37178        var w = this.words[i];
37179        var word = (((w << off) | carry) & 0xffffff).toString(16);
37180        carry = (w >>> (24 - off)) & 0xffffff;
37181        if (carry !== 0 || i !== this.length - 1) {
37182          out = zeros[6 - word.length] + word + out;
37183        } else {
37184          out = word + out;
37185        }
37186        off += 2;
37187        if (off >= 26) {
37188          off -= 26;
37189          i--;
37190        }
37191      }
37192      if (carry !== 0) {
37193        out = carry.toString(16) + out;
37194      }
37195      while (out.length % padding !== 0) {
37196        out = '0' + out;
37197      }
37198      if (this.negative !== 0) {
37199        out = '-' + out;
37200      }
37201      return out;
37202    }
37203
37204    if (base === (base | 0) && base >= 2 && base <= 36) {
37205      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
37206      var groupSize = groupSizes[base];
37207      // var groupBase = Math.pow(base, groupSize);
37208      var groupBase = groupBases[base];
37209      out = '';
37210      var c = this.clone();
37211      c.negative = 0;
37212      while (!c.isZero()) {
37213        var r = c.modn(groupBase).toString(base);
37214        c = c.idivn(groupBase);
37215
37216        if (!c.isZero()) {
37217          out = zeros[groupSize - r.length] + r + out;
37218        } else {
37219          out = r + out;
37220        }
37221      }
37222      if (this.isZero()) {
37223        out = '0' + out;
37224      }
37225      while (out.length % padding !== 0) {
37226        out = '0' + out;
37227      }
37228      if (this.negative !== 0) {
37229        out = '-' + out;
37230      }
37231      return out;
37232    }
37233
37234    assert(false, 'Base should be between 2 and 36');
37235  };
37236
37237  BN.prototype.toNumber = function toNumber () {
37238    var ret = this.words[0];
37239    if (this.length === 2) {
37240      ret += this.words[1] * 0x4000000;
37241    } else if (this.length === 3 && this.words[2] === 0x01) {
37242      // NOTE: at this stage it is known that the top bit is set
37243      ret += 0x10000000000000 + (this.words[1] * 0x4000000);
37244    } else if (this.length > 2) {
37245      assert(false, 'Number can only safely store up to 53 bits');
37246    }
37247    return (this.negative !== 0) ? -ret : ret;
37248  };
37249
37250  BN.prototype.toJSON = function toJSON () {
37251    return this.toString(16);
37252  };
37253
37254  BN.prototype.toBuffer = function toBuffer (endian, length) {
37255    assert(typeof Buffer !== 'undefined');
37256    return this.toArrayLike(Buffer, endian, length);
37257  };
37258
37259  BN.prototype.toArray = function toArray (endian, length) {
37260    return this.toArrayLike(Array, endian, length);
37261  };
37262
37263  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
37264    var byteLength = this.byteLength();
37265    var reqLength = length || Math.max(1, byteLength);
37266    assert(byteLength <= reqLength, 'byte array longer than desired length');
37267    assert(reqLength > 0, 'Requested array length <= 0');
37268
37269    this.strip();
37270    var littleEndian = endian === 'le';
37271    var res = new ArrayType(reqLength);
37272
37273    var b, i;
37274    var q = this.clone();
37275    if (!littleEndian) {
37276      // Assume big-endian
37277      for (i = 0; i < reqLength - byteLength; i++) {
37278        res[i] = 0;
37279      }
37280
37281      for (i = 0; !q.isZero(); i++) {
37282        b = q.andln(0xff);
37283        q.iushrn(8);
37284
37285        res[reqLength - i - 1] = b;
37286      }
37287    } else {
37288      for (i = 0; !q.isZero(); i++) {
37289        b = q.andln(0xff);
37290        q.iushrn(8);
37291
37292        res[i] = b;
37293      }
37294
37295      for (; i < reqLength; i++) {
37296        res[i] = 0;
37297      }
37298    }
37299
37300    return res;
37301  };
37302
37303  if (Math.clz32) {
37304    BN.prototype._countBits = function _countBits (w) {
37305      return 32 - Math.clz32(w);
37306    };
37307  } else {
37308    BN.prototype._countBits = function _countBits (w) {
37309      var t = w;
37310      var r = 0;
37311      if (t >= 0x1000) {
37312        r += 13;
37313        t >>>= 13;
37314      }
37315      if (t >= 0x40) {
37316        r += 7;
37317        t >>>= 7;
37318      }
37319      if (t >= 0x8) {
37320        r += 4;
37321        t >>>= 4;
37322      }
37323      if (t >= 0x02) {
37324        r += 2;
37325        t >>>= 2;
37326      }
37327      return r + t;
37328    };
37329  }
37330
37331  BN.prototype._zeroBits = function _zeroBits (w) {
37332    // Short-cut
37333    if (w === 0) return 26;
37334
37335    var t = w;
37336    var r = 0;
37337    if ((t & 0x1fff) === 0) {
37338      r += 13;
37339      t >>>= 13;
37340    }
37341    if ((t & 0x7f) === 0) {
37342      r += 7;
37343      t >>>= 7;
37344    }
37345    if ((t & 0xf) === 0) {
37346      r += 4;
37347      t >>>= 4;
37348    }
37349    if ((t & 0x3) === 0) {
37350      r += 2;
37351      t >>>= 2;
37352    }
37353    if ((t & 0x1) === 0) {
37354      r++;
37355    }
37356    return r;
37357  };
37358
37359  // Return number of used bits in a BN
37360  BN.prototype.bitLength = function bitLength () {
37361    var w = this.words[this.length - 1];
37362    var hi = this._countBits(w);
37363    return (this.length - 1) * 26 + hi;
37364  };
37365
37366  function toBitArray (num) {
37367    var w = new Array(num.bitLength());
37368
37369    for (var bit = 0; bit < w.length; bit++) {
37370      var off = (bit / 26) | 0;
37371      var wbit = bit % 26;
37372
37373      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
37374    }
37375
37376    return w;
37377  }
37378
37379  // Number of trailing zero bits
37380  BN.prototype.zeroBits = function zeroBits () {
37381    if (this.isZero()) return 0;
37382
37383    var r = 0;
37384    for (var i = 0; i < this.length; i++) {
37385      var b = this._zeroBits(this.words[i]);
37386      r += b;
37387      if (b !== 26) break;
37388    }
37389    return r;
37390  };
37391
37392  BN.prototype.byteLength = function byteLength () {
37393    return Math.ceil(this.bitLength() / 8);
37394  };
37395
37396  BN.prototype.toTwos = function toTwos (width) {
37397    if (this.negative !== 0) {
37398      return this.abs().inotn(width).iaddn(1);
37399    }
37400    return this.clone();
37401  };
37402
37403  BN.prototype.fromTwos = function fromTwos (width) {
37404    if (this.testn(width - 1)) {
37405      return this.notn(width).iaddn(1).ineg();
37406    }
37407    return this.clone();
37408  };
37409
37410  BN.prototype.isNeg = function isNeg () {
37411    return this.negative !== 0;
37412  };
37413
37414  // Return negative clone of `this`
37415  BN.prototype.neg = function neg () {
37416    return this.clone().ineg();
37417  };
37418
37419  BN.prototype.ineg = function ineg () {
37420    if (!this.isZero()) {
37421      this.negative ^= 1;
37422    }
37423
37424    return this;
37425  };
37426
37427  // Or `num` with `this` in-place
37428  BN.prototype.iuor = function iuor (num) {
37429    while (this.length < num.length) {
37430      this.words[this.length++] = 0;
37431    }
37432
37433    for (var i = 0; i < num.length; i++) {
37434      this.words[i] = this.words[i] | num.words[i];
37435    }
37436
37437    return this.strip();
37438  };
37439
37440  BN.prototype.ior = function ior (num) {
37441    assert((this.negative | num.negative) === 0);
37442    return this.iuor(num);
37443  };
37444
37445  // Or `num` with `this`
37446  BN.prototype.or = function or (num) {
37447    if (this.length > num.length) return this.clone().ior(num);
37448    return num.clone().ior(this);
37449  };
37450
37451  BN.prototype.uor = function uor (num) {
37452    if (this.length > num.length) return this.clone().iuor(num);
37453    return num.clone().iuor(this);
37454  };
37455
37456  // And `num` with `this` in-place
37457  BN.prototype.iuand = function iuand (num) {
37458    // b = min-length(num, this)
37459    var b;
37460    if (this.length > num.length) {
37461      b = num;
37462    } else {
37463      b = this;
37464    }
37465
37466    for (var i = 0; i < b.length; i++) {
37467      this.words[i] = this.words[i] & num.words[i];
37468    }
37469
37470    this.length = b.length;
37471
37472    return this.strip();
37473  };
37474
37475  BN.prototype.iand = function iand (num) {
37476    assert((this.negative | num.negative) === 0);
37477    return this.iuand(num);
37478  };
37479
37480  // And `num` with `this`
37481  BN.prototype.and = function and (num) {
37482    if (this.length > num.length) return this.clone().iand(num);
37483    return num.clone().iand(this);
37484  };
37485
37486  BN.prototype.uand = function uand (num) {
37487    if (this.length > num.length) return this.clone().iuand(num);
37488    return num.clone().iuand(this);
37489  };
37490
37491  // Xor `num` with `this` in-place
37492  BN.prototype.iuxor = function iuxor (num) {
37493    // a.length > b.length
37494    var a;
37495    var b;
37496    if (this.length > num.length) {
37497      a = this;
37498      b = num;
37499    } else {
37500      a = num;
37501      b = this;
37502    }
37503
37504    for (var i = 0; i < b.length; i++) {
37505      this.words[i] = a.words[i] ^ b.words[i];
37506    }
37507
37508    if (this !== a) {
37509      for (; i < a.length; i++) {
37510        this.words[i] = a.words[i];
37511      }
37512    }
37513
37514    this.length = a.length;
37515
37516    return this.strip();
37517  };
37518
37519  BN.prototype.ixor = function ixor (num) {
37520    assert((this.negative | num.negative) === 0);
37521    return this.iuxor(num);
37522  };
37523
37524  // Xor `num` with `this`
37525  BN.prototype.xor = function xor (num) {
37526    if (this.length > num.length) return this.clone().ixor(num);
37527    return num.clone().ixor(this);
37528  };
37529
37530  BN.prototype.uxor = function uxor (num) {
37531    if (this.length > num.length) return this.clone().iuxor(num);
37532    return num.clone().iuxor(this);
37533  };
37534
37535  // Not ``this`` with ``width`` bitwidth
37536  BN.prototype.inotn = function inotn (width) {
37537    assert(typeof width === 'number' && width >= 0);
37538
37539    var bytesNeeded = Math.ceil(width / 26) | 0;
37540    var bitsLeft = width % 26;
37541
37542    // Extend the buffer with leading zeroes
37543    this._expand(bytesNeeded);
37544
37545    if (bitsLeft > 0) {
37546      bytesNeeded--;
37547    }
37548
37549    // Handle complete words
37550    for (var i = 0; i < bytesNeeded; i++) {
37551      this.words[i] = ~this.words[i] & 0x3ffffff;
37552    }
37553
37554    // Handle the residue
37555    if (bitsLeft > 0) {
37556      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
37557    }
37558
37559    // And remove leading zeroes
37560    return this.strip();
37561  };
37562
37563  BN.prototype.notn = function notn (width) {
37564    return this.clone().inotn(width);
37565  };
37566
37567  // Set `bit` of `this`
37568  BN.prototype.setn = function setn (bit, val) {
37569    assert(typeof bit === 'number' && bit >= 0);
37570
37571    var off = (bit / 26) | 0;
37572    var wbit = bit % 26;
37573
37574    this._expand(off + 1);
37575
37576    if (val) {
37577      this.words[off] = this.words[off] | (1 << wbit);
37578    } else {
37579      this.words[off] = this.words[off] & ~(1 << wbit);
37580    }
37581
37582    return this.strip();
37583  };
37584
37585  // Add `num` to `this` in-place
37586  BN.prototype.iadd = function iadd (num) {
37587    var r;
37588
37589    // negative + positive
37590    if (this.negative !== 0 && num.negative === 0) {
37591      this.negative = 0;
37592      r = this.isub(num);
37593      this.negative ^= 1;
37594      return this._normSign();
37595
37596    // positive + negative
37597    } else if (this.negative === 0 && num.negative !== 0) {
37598      num.negative = 0;
37599      r = this.isub(num);
37600      num.negative = 1;
37601      return r._normSign();
37602    }
37603
37604    // a.length > b.length
37605    var a, b;
37606    if (this.length > num.length) {
37607      a = this;
37608      b = num;
37609    } else {
37610      a = num;
37611      b = this;
37612    }
37613
37614    var carry = 0;
37615    for (var i = 0; i < b.length; i++) {
37616      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
37617      this.words[i] = r & 0x3ffffff;
37618      carry = r >>> 26;
37619    }
37620    for (; carry !== 0 && i < a.length; i++) {
37621      r = (a.words[i] | 0) + carry;
37622      this.words[i] = r & 0x3ffffff;
37623      carry = r >>> 26;
37624    }
37625
37626    this.length = a.length;
37627    if (carry !== 0) {
37628      this.words[this.length] = carry;
37629      this.length++;
37630    // Copy the rest of the words
37631    } else if (a !== this) {
37632      for (; i < a.length; i++) {
37633        this.words[i] = a.words[i];
37634      }
37635    }
37636
37637    return this;
37638  };
37639
37640  // Add `num` to `this`
37641  BN.prototype.add = function add (num) {
37642    var res;
37643    if (num.negative !== 0 && this.negative === 0) {
37644      num.negative = 0;
37645      res = this.sub(num);
37646      num.negative ^= 1;
37647      return res;
37648    } else if (num.negative === 0 && this.negative !== 0) {
37649      this.negative = 0;
37650      res = num.sub(this);
37651      this.negative = 1;
37652      return res;
37653    }
37654
37655    if (this.length > num.length) return this.clone().iadd(num);
37656
37657    return num.clone().iadd(this);
37658  };
37659
37660  // Subtract `num` from `this` in-place
37661  BN.prototype.isub = function isub (num) {
37662    // this - (-num) = this + num
37663    if (num.negative !== 0) {
37664      num.negative = 0;
37665      var r = this.iadd(num);
37666      num.negative = 1;
37667      return r._normSign();
37668
37669    // -this - num = -(this + num)
37670    } else if (this.negative !== 0) {
37671      this.negative = 0;
37672      this.iadd(num);
37673      this.negative = 1;
37674      return this._normSign();
37675    }
37676
37677    // At this point both numbers are positive
37678    var cmp = this.cmp(num);
37679
37680    // Optimization - zeroify
37681    if (cmp === 0) {
37682      this.negative = 0;
37683      this.length = 1;
37684      this.words[0] = 0;
37685      return this;
37686    }
37687
37688    // a > b
37689    var a, b;
37690    if (cmp > 0) {
37691      a = this;
37692      b = num;
37693    } else {
37694      a = num;
37695      b = this;
37696    }
37697
37698    var carry = 0;
37699    for (var i = 0; i < b.length; i++) {
37700      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
37701      carry = r >> 26;
37702      this.words[i] = r & 0x3ffffff;
37703    }
37704    for (; carry !== 0 && i < a.length; i++) {
37705      r = (a.words[i] | 0) + carry;
37706      carry = r >> 26;
37707      this.words[i] = r & 0x3ffffff;
37708    }
37709
37710    // Copy rest of the words
37711    if (carry === 0 && i < a.length && a !== this) {
37712      for (; i < a.length; i++) {
37713        this.words[i] = a.words[i];
37714      }
37715    }
37716
37717    this.length = Math.max(this.length, i);
37718
37719    if (a !== this) {
37720      this.negative = 1;
37721    }
37722
37723    return this.strip();
37724  };
37725
37726  // Subtract `num` from `this`
37727  BN.prototype.sub = function sub (num) {
37728    return this.clone().isub(num);
37729  };
37730
37731  function smallMulTo (self, num, out) {
37732    out.negative = num.negative ^ self.negative;
37733    var len = (self.length + num.length) | 0;
37734    out.length = len;
37735    len = (len - 1) | 0;
37736
37737    // Peel one iteration (compiler can't do it, because of code complexity)
37738    var a = self.words[0] | 0;
37739    var b = num.words[0] | 0;
37740    var r = a * b;
37741
37742    var lo = r & 0x3ffffff;
37743    var carry = (r / 0x4000000) | 0;
37744    out.words[0] = lo;
37745
37746    for (var k = 1; k < len; k++) {
37747      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
37748      // note that ncarry could be >= 0x3ffffff
37749      var ncarry = carry >>> 26;
37750      var rword = carry & 0x3ffffff;
37751      var maxJ = Math.min(k, num.length - 1);
37752      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
37753        var i = (k - j) | 0;
37754        a = self.words[i] | 0;
37755        b = num.words[j] | 0;
37756        r = a * b + rword;
37757        ncarry += (r / 0x4000000) | 0;
37758        rword = r & 0x3ffffff;
37759      }
37760      out.words[k] = rword | 0;
37761      carry = ncarry | 0;
37762    }
37763    if (carry !== 0) {
37764      out.words[k] = carry | 0;
37765    } else {
37766      out.length--;
37767    }
37768
37769    return out.strip();
37770  }
37771
37772  // TODO(indutny): it may be reasonable to omit it for users who don't need
37773  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
37774  // multiplication (like elliptic secp256k1).
37775  var comb10MulTo = function comb10MulTo (self, num, out) {
37776    var a = self.words;
37777    var b = num.words;
37778    var o = out.words;
37779    var c = 0;
37780    var lo;
37781    var mid;
37782    var hi;
37783    var a0 = a[0] | 0;
37784    var al0 = a0 & 0x1fff;
37785    var ah0 = a0 >>> 13;
37786    var a1 = a[1] | 0;
37787    var al1 = a1 & 0x1fff;
37788    var ah1 = a1 >>> 13;
37789    var a2 = a[2] | 0;
37790    var al2 = a2 & 0x1fff;
37791    var ah2 = a2 >>> 13;
37792    var a3 = a[3] | 0;
37793    var al3 = a3 & 0x1fff;
37794    var ah3 = a3 >>> 13;
37795    var a4 = a[4] | 0;
37796    var al4 = a4 & 0x1fff;
37797    var ah4 = a4 >>> 13;
37798    var a5 = a[5] | 0;
37799    var al5 = a5 & 0x1fff;
37800    var ah5 = a5 >>> 13;
37801    var a6 = a[6] | 0;
37802    var al6 = a6 & 0x1fff;
37803    var ah6 = a6 >>> 13;
37804    var a7 = a[7] | 0;
37805    var al7 = a7 & 0x1fff;
37806    var ah7 = a7 >>> 13;
37807    var a8 = a[8] | 0;
37808    var al8 = a8 & 0x1fff;
37809    var ah8 = a8 >>> 13;
37810    var a9 = a[9] | 0;
37811    var al9 = a9 & 0x1fff;
37812    var ah9 = a9 >>> 13;
37813    var b0 = b[0] | 0;
37814    var bl0 = b0 & 0x1fff;
37815    var bh0 = b0 >>> 13;
37816    var b1 = b[1] | 0;
37817    var bl1 = b1 & 0x1fff;
37818    var bh1 = b1 >>> 13;
37819    var b2 = b[2] | 0;
37820    var bl2 = b2 & 0x1fff;
37821    var bh2 = b2 >>> 13;
37822    var b3 = b[3] | 0;
37823    var bl3 = b3 & 0x1fff;
37824    var bh3 = b3 >>> 13;
37825    var b4 = b[4] | 0;
37826    var bl4 = b4 & 0x1fff;
37827    var bh4 = b4 >>> 13;
37828    var b5 = b[5] | 0;
37829    var bl5 = b5 & 0x1fff;
37830    var bh5 = b5 >>> 13;
37831    var b6 = b[6] | 0;
37832    var bl6 = b6 & 0x1fff;
37833    var bh6 = b6 >>> 13;
37834    var b7 = b[7] | 0;
37835    var bl7 = b7 & 0x1fff;
37836    var bh7 = b7 >>> 13;
37837    var b8 = b[8] | 0;
37838    var bl8 = b8 & 0x1fff;
37839    var bh8 = b8 >>> 13;
37840    var b9 = b[9] | 0;
37841    var bl9 = b9 & 0x1fff;
37842    var bh9 = b9 >>> 13;
37843
37844    out.negative = self.negative ^ num.negative;
37845    out.length = 19;
37846    /* k = 0 */
37847    lo = Math.imul(al0, bl0);
37848    mid = Math.imul(al0, bh0);
37849    mid = (mid + Math.imul(ah0, bl0)) | 0;
37850    hi = Math.imul(ah0, bh0);
37851    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37852    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
37853    w0 &= 0x3ffffff;
37854    /* k = 1 */
37855    lo = Math.imul(al1, bl0);
37856    mid = Math.imul(al1, bh0);
37857    mid = (mid + Math.imul(ah1, bl0)) | 0;
37858    hi = Math.imul(ah1, bh0);
37859    lo = (lo + Math.imul(al0, bl1)) | 0;
37860    mid = (mid + Math.imul(al0, bh1)) | 0;
37861    mid = (mid + Math.imul(ah0, bl1)) | 0;
37862    hi = (hi + Math.imul(ah0, bh1)) | 0;
37863    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37864    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
37865    w1 &= 0x3ffffff;
37866    /* k = 2 */
37867    lo = Math.imul(al2, bl0);
37868    mid = Math.imul(al2, bh0);
37869    mid = (mid + Math.imul(ah2, bl0)) | 0;
37870    hi = Math.imul(ah2, bh0);
37871    lo = (lo + Math.imul(al1, bl1)) | 0;
37872    mid = (mid + Math.imul(al1, bh1)) | 0;
37873    mid = (mid + Math.imul(ah1, bl1)) | 0;
37874    hi = (hi + Math.imul(ah1, bh1)) | 0;
37875    lo = (lo + Math.imul(al0, bl2)) | 0;
37876    mid = (mid + Math.imul(al0, bh2)) | 0;
37877    mid = (mid + Math.imul(ah0, bl2)) | 0;
37878    hi = (hi + Math.imul(ah0, bh2)) | 0;
37879    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37880    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
37881    w2 &= 0x3ffffff;
37882    /* k = 3 */
37883    lo = Math.imul(al3, bl0);
37884    mid = Math.imul(al3, bh0);
37885    mid = (mid + Math.imul(ah3, bl0)) | 0;
37886    hi = Math.imul(ah3, bh0);
37887    lo = (lo + Math.imul(al2, bl1)) | 0;
37888    mid = (mid + Math.imul(al2, bh1)) | 0;
37889    mid = (mid + Math.imul(ah2, bl1)) | 0;
37890    hi = (hi + Math.imul(ah2, bh1)) | 0;
37891    lo = (lo + Math.imul(al1, bl2)) | 0;
37892    mid = (mid + Math.imul(al1, bh2)) | 0;
37893    mid = (mid + Math.imul(ah1, bl2)) | 0;
37894    hi = (hi + Math.imul(ah1, bh2)) | 0;
37895    lo = (lo + Math.imul(al0, bl3)) | 0;
37896    mid = (mid + Math.imul(al0, bh3)) | 0;
37897    mid = (mid + Math.imul(ah0, bl3)) | 0;
37898    hi = (hi + Math.imul(ah0, bh3)) | 0;
37899    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37900    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
37901    w3 &= 0x3ffffff;
37902    /* k = 4 */
37903    lo = Math.imul(al4, bl0);
37904    mid = Math.imul(al4, bh0);
37905    mid = (mid + Math.imul(ah4, bl0)) | 0;
37906    hi = Math.imul(ah4, bh0);
37907    lo = (lo + Math.imul(al3, bl1)) | 0;
37908    mid = (mid + Math.imul(al3, bh1)) | 0;
37909    mid = (mid + Math.imul(ah3, bl1)) | 0;
37910    hi = (hi + Math.imul(ah3, bh1)) | 0;
37911    lo = (lo + Math.imul(al2, bl2)) | 0;
37912    mid = (mid + Math.imul(al2, bh2)) | 0;
37913    mid = (mid + Math.imul(ah2, bl2)) | 0;
37914    hi = (hi + Math.imul(ah2, bh2)) | 0;
37915    lo = (lo + Math.imul(al1, bl3)) | 0;
37916    mid = (mid + Math.imul(al1, bh3)) | 0;
37917    mid = (mid + Math.imul(ah1, bl3)) | 0;
37918    hi = (hi + Math.imul(ah1, bh3)) | 0;
37919    lo = (lo + Math.imul(al0, bl4)) | 0;
37920    mid = (mid + Math.imul(al0, bh4)) | 0;
37921    mid = (mid + Math.imul(ah0, bl4)) | 0;
37922    hi = (hi + Math.imul(ah0, bh4)) | 0;
37923    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37924    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
37925    w4 &= 0x3ffffff;
37926    /* k = 5 */
37927    lo = Math.imul(al5, bl0);
37928    mid = Math.imul(al5, bh0);
37929    mid = (mid + Math.imul(ah5, bl0)) | 0;
37930    hi = Math.imul(ah5, bh0);
37931    lo = (lo + Math.imul(al4, bl1)) | 0;
37932    mid = (mid + Math.imul(al4, bh1)) | 0;
37933    mid = (mid + Math.imul(ah4, bl1)) | 0;
37934    hi = (hi + Math.imul(ah4, bh1)) | 0;
37935    lo = (lo + Math.imul(al3, bl2)) | 0;
37936    mid = (mid + Math.imul(al3, bh2)) | 0;
37937    mid = (mid + Math.imul(ah3, bl2)) | 0;
37938    hi = (hi + Math.imul(ah3, bh2)) | 0;
37939    lo = (lo + Math.imul(al2, bl3)) | 0;
37940    mid = (mid + Math.imul(al2, bh3)) | 0;
37941    mid = (mid + Math.imul(ah2, bl3)) | 0;
37942    hi = (hi + Math.imul(ah2, bh3)) | 0;
37943    lo = (lo + Math.imul(al1, bl4)) | 0;
37944    mid = (mid + Math.imul(al1, bh4)) | 0;
37945    mid = (mid + Math.imul(ah1, bl4)) | 0;
37946    hi = (hi + Math.imul(ah1, bh4)) | 0;
37947    lo = (lo + Math.imul(al0, bl5)) | 0;
37948    mid = (mid + Math.imul(al0, bh5)) | 0;
37949    mid = (mid + Math.imul(ah0, bl5)) | 0;
37950    hi = (hi + Math.imul(ah0, bh5)) | 0;
37951    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37952    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
37953    w5 &= 0x3ffffff;
37954    /* k = 6 */
37955    lo = Math.imul(al6, bl0);
37956    mid = Math.imul(al6, bh0);
37957    mid = (mid + Math.imul(ah6, bl0)) | 0;
37958    hi = Math.imul(ah6, bh0);
37959    lo = (lo + Math.imul(al5, bl1)) | 0;
37960    mid = (mid + Math.imul(al5, bh1)) | 0;
37961    mid = (mid + Math.imul(ah5, bl1)) | 0;
37962    hi = (hi + Math.imul(ah5, bh1)) | 0;
37963    lo = (lo + Math.imul(al4, bl2)) | 0;
37964    mid = (mid + Math.imul(al4, bh2)) | 0;
37965    mid = (mid + Math.imul(ah4, bl2)) | 0;
37966    hi = (hi + Math.imul(ah4, bh2)) | 0;
37967    lo = (lo + Math.imul(al3, bl3)) | 0;
37968    mid = (mid + Math.imul(al3, bh3)) | 0;
37969    mid = (mid + Math.imul(ah3, bl3)) | 0;
37970    hi = (hi + Math.imul(ah3, bh3)) | 0;
37971    lo = (lo + Math.imul(al2, bl4)) | 0;
37972    mid = (mid + Math.imul(al2, bh4)) | 0;
37973    mid = (mid + Math.imul(ah2, bl4)) | 0;
37974    hi = (hi + Math.imul(ah2, bh4)) | 0;
37975    lo = (lo + Math.imul(al1, bl5)) | 0;
37976    mid = (mid + Math.imul(al1, bh5)) | 0;
37977    mid = (mid + Math.imul(ah1, bl5)) | 0;
37978    hi = (hi + Math.imul(ah1, bh5)) | 0;
37979    lo = (lo + Math.imul(al0, bl6)) | 0;
37980    mid = (mid + Math.imul(al0, bh6)) | 0;
37981    mid = (mid + Math.imul(ah0, bl6)) | 0;
37982    hi = (hi + Math.imul(ah0, bh6)) | 0;
37983    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
37984    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
37985    w6 &= 0x3ffffff;
37986    /* k = 7 */
37987    lo = Math.imul(al7, bl0);
37988    mid = Math.imul(al7, bh0);
37989    mid = (mid + Math.imul(ah7, bl0)) | 0;
37990    hi = Math.imul(ah7, bh0);
37991    lo = (lo + Math.imul(al6, bl1)) | 0;
37992    mid = (mid + Math.imul(al6, bh1)) | 0;
37993    mid = (mid + Math.imul(ah6, bl1)) | 0;
37994    hi = (hi + Math.imul(ah6, bh1)) | 0;
37995    lo = (lo + Math.imul(al5, bl2)) | 0;
37996    mid = (mid + Math.imul(al5, bh2)) | 0;
37997    mid = (mid + Math.imul(ah5, bl2)) | 0;
37998    hi = (hi + Math.imul(ah5, bh2)) | 0;
37999    lo = (lo + Math.imul(al4, bl3)) | 0;
38000    mid = (mid + Math.imul(al4, bh3)) | 0;
38001    mid = (mid + Math.imul(ah4, bl3)) | 0;
38002    hi = (hi + Math.imul(ah4, bh3)) | 0;
38003    lo = (lo + Math.imul(al3, bl4)) | 0;
38004    mid = (mid + Math.imul(al3, bh4)) | 0;
38005    mid = (mid + Math.imul(ah3, bl4)) | 0;
38006    hi = (hi + Math.imul(ah3, bh4)) | 0;
38007    lo = (lo + Math.imul(al2, bl5)) | 0;
38008    mid = (mid + Math.imul(al2, bh5)) | 0;
38009    mid = (mid + Math.imul(ah2, bl5)) | 0;
38010    hi = (hi + Math.imul(ah2, bh5)) | 0;
38011    lo = (lo + Math.imul(al1, bl6)) | 0;
38012    mid = (mid + Math.imul(al1, bh6)) | 0;
38013    mid = (mid + Math.imul(ah1, bl6)) | 0;
38014    hi = (hi + Math.imul(ah1, bh6)) | 0;
38015    lo = (lo + Math.imul(al0, bl7)) | 0;
38016    mid = (mid + Math.imul(al0, bh7)) | 0;
38017    mid = (mid + Math.imul(ah0, bl7)) | 0;
38018    hi = (hi + Math.imul(ah0, bh7)) | 0;
38019    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38020    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
38021    w7 &= 0x3ffffff;
38022    /* k = 8 */
38023    lo = Math.imul(al8, bl0);
38024    mid = Math.imul(al8, bh0);
38025    mid = (mid + Math.imul(ah8, bl0)) | 0;
38026    hi = Math.imul(ah8, bh0);
38027    lo = (lo + Math.imul(al7, bl1)) | 0;
38028    mid = (mid + Math.imul(al7, bh1)) | 0;
38029    mid = (mid + Math.imul(ah7, bl1)) | 0;
38030    hi = (hi + Math.imul(ah7, bh1)) | 0;
38031    lo = (lo + Math.imul(al6, bl2)) | 0;
38032    mid = (mid + Math.imul(al6, bh2)) | 0;
38033    mid = (mid + Math.imul(ah6, bl2)) | 0;
38034    hi = (hi + Math.imul(ah6, bh2)) | 0;
38035    lo = (lo + Math.imul(al5, bl3)) | 0;
38036    mid = (mid + Math.imul(al5, bh3)) | 0;
38037    mid = (mid + Math.imul(ah5, bl3)) | 0;
38038    hi = (hi + Math.imul(ah5, bh3)) | 0;
38039    lo = (lo + Math.imul(al4, bl4)) | 0;
38040    mid = (mid + Math.imul(al4, bh4)) | 0;
38041    mid = (mid + Math.imul(ah4, bl4)) | 0;
38042    hi = (hi + Math.imul(ah4, bh4)) | 0;
38043    lo = (lo + Math.imul(al3, bl5)) | 0;
38044    mid = (mid + Math.imul(al3, bh5)) | 0;
38045    mid = (mid + Math.imul(ah3, bl5)) | 0;
38046    hi = (hi + Math.imul(ah3, bh5)) | 0;
38047    lo = (lo + Math.imul(al2, bl6)) | 0;
38048    mid = (mid + Math.imul(al2, bh6)) | 0;
38049    mid = (mid + Math.imul(ah2, bl6)) | 0;
38050    hi = (hi + Math.imul(ah2, bh6)) | 0;
38051    lo = (lo + Math.imul(al1, bl7)) | 0;
38052    mid = (mid + Math.imul(al1, bh7)) | 0;
38053    mid = (mid + Math.imul(ah1, bl7)) | 0;
38054    hi = (hi + Math.imul(ah1, bh7)) | 0;
38055    lo = (lo + Math.imul(al0, bl8)) | 0;
38056    mid = (mid + Math.imul(al0, bh8)) | 0;
38057    mid = (mid + Math.imul(ah0, bl8)) | 0;
38058    hi = (hi + Math.imul(ah0, bh8)) | 0;
38059    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38060    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
38061    w8 &= 0x3ffffff;
38062    /* k = 9 */
38063    lo = Math.imul(al9, bl0);
38064    mid = Math.imul(al9, bh0);
38065    mid = (mid + Math.imul(ah9, bl0)) | 0;
38066    hi = Math.imul(ah9, bh0);
38067    lo = (lo + Math.imul(al8, bl1)) | 0;
38068    mid = (mid + Math.imul(al8, bh1)) | 0;
38069    mid = (mid + Math.imul(ah8, bl1)) | 0;
38070    hi = (hi + Math.imul(ah8, bh1)) | 0;
38071    lo = (lo + Math.imul(al7, bl2)) | 0;
38072    mid = (mid + Math.imul(al7, bh2)) | 0;
38073    mid = (mid + Math.imul(ah7, bl2)) | 0;
38074    hi = (hi + Math.imul(ah7, bh2)) | 0;
38075    lo = (lo + Math.imul(al6, bl3)) | 0;
38076    mid = (mid + Math.imul(al6, bh3)) | 0;
38077    mid = (mid + Math.imul(ah6, bl3)) | 0;
38078    hi = (hi + Math.imul(ah6, bh3)) | 0;
38079    lo = (lo + Math.imul(al5, bl4)) | 0;
38080    mid = (mid + Math.imul(al5, bh4)) | 0;
38081    mid = (mid + Math.imul(ah5, bl4)) | 0;
38082    hi = (hi + Math.imul(ah5, bh4)) | 0;
38083    lo = (lo + Math.imul(al4, bl5)) | 0;
38084    mid = (mid + Math.imul(al4, bh5)) | 0;
38085    mid = (mid + Math.imul(ah4, bl5)) | 0;
38086    hi = (hi + Math.imul(ah4, bh5)) | 0;
38087    lo = (lo + Math.imul(al3, bl6)) | 0;
38088    mid = (mid + Math.imul(al3, bh6)) | 0;
38089    mid = (mid + Math.imul(ah3, bl6)) | 0;
38090    hi = (hi + Math.imul(ah3, bh6)) | 0;
38091    lo = (lo + Math.imul(al2, bl7)) | 0;
38092    mid = (mid + Math.imul(al2, bh7)) | 0;
38093    mid = (mid + Math.imul(ah2, bl7)) | 0;
38094    hi = (hi + Math.imul(ah2, bh7)) | 0;
38095    lo = (lo + Math.imul(al1, bl8)) | 0;
38096    mid = (mid + Math.imul(al1, bh8)) | 0;
38097    mid = (mid + Math.imul(ah1, bl8)) | 0;
38098    hi = (hi + Math.imul(ah1, bh8)) | 0;
38099    lo = (lo + Math.imul(al0, bl9)) | 0;
38100    mid = (mid + Math.imul(al0, bh9)) | 0;
38101    mid = (mid + Math.imul(ah0, bl9)) | 0;
38102    hi = (hi + Math.imul(ah0, bh9)) | 0;
38103    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38104    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
38105    w9 &= 0x3ffffff;
38106    /* k = 10 */
38107    lo = Math.imul(al9, bl1);
38108    mid = Math.imul(al9, bh1);
38109    mid = (mid + Math.imul(ah9, bl1)) | 0;
38110    hi = Math.imul(ah9, bh1);
38111    lo = (lo + Math.imul(al8, bl2)) | 0;
38112    mid = (mid + Math.imul(al8, bh2)) | 0;
38113    mid = (mid + Math.imul(ah8, bl2)) | 0;
38114    hi = (hi + Math.imul(ah8, bh2)) | 0;
38115    lo = (lo + Math.imul(al7, bl3)) | 0;
38116    mid = (mid + Math.imul(al7, bh3)) | 0;
38117    mid = (mid + Math.imul(ah7, bl3)) | 0;
38118    hi = (hi + Math.imul(ah7, bh3)) | 0;
38119    lo = (lo + Math.imul(al6, bl4)) | 0;
38120    mid = (mid + Math.imul(al6, bh4)) | 0;
38121    mid = (mid + Math.imul(ah6, bl4)) | 0;
38122    hi = (hi + Math.imul(ah6, bh4)) | 0;
38123    lo = (lo + Math.imul(al5, bl5)) | 0;
38124    mid = (mid + Math.imul(al5, bh5)) | 0;
38125    mid = (mid + Math.imul(ah5, bl5)) | 0;
38126    hi = (hi + Math.imul(ah5, bh5)) | 0;
38127    lo = (lo + Math.imul(al4, bl6)) | 0;
38128    mid = (mid + Math.imul(al4, bh6)) | 0;
38129    mid = (mid + Math.imul(ah4, bl6)) | 0;
38130    hi = (hi + Math.imul(ah4, bh6)) | 0;
38131    lo = (lo + Math.imul(al3, bl7)) | 0;
38132    mid = (mid + Math.imul(al3, bh7)) | 0;
38133    mid = (mid + Math.imul(ah3, bl7)) | 0;
38134    hi = (hi + Math.imul(ah3, bh7)) | 0;
38135    lo = (lo + Math.imul(al2, bl8)) | 0;
38136    mid = (mid + Math.imul(al2, bh8)) | 0;
38137    mid = (mid + Math.imul(ah2, bl8)) | 0;
38138    hi = (hi + Math.imul(ah2, bh8)) | 0;
38139    lo = (lo + Math.imul(al1, bl9)) | 0;
38140    mid = (mid + Math.imul(al1, bh9)) | 0;
38141    mid = (mid + Math.imul(ah1, bl9)) | 0;
38142    hi = (hi + Math.imul(ah1, bh9)) | 0;
38143    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38144    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
38145    w10 &= 0x3ffffff;
38146    /* k = 11 */
38147    lo = Math.imul(al9, bl2);
38148    mid = Math.imul(al9, bh2);
38149    mid = (mid + Math.imul(ah9, bl2)) | 0;
38150    hi = Math.imul(ah9, bh2);
38151    lo = (lo + Math.imul(al8, bl3)) | 0;
38152    mid = (mid + Math.imul(al8, bh3)) | 0;
38153    mid = (mid + Math.imul(ah8, bl3)) | 0;
38154    hi = (hi + Math.imul(ah8, bh3)) | 0;
38155    lo = (lo + Math.imul(al7, bl4)) | 0;
38156    mid = (mid + Math.imul(al7, bh4)) | 0;
38157    mid = (mid + Math.imul(ah7, bl4)) | 0;
38158    hi = (hi + Math.imul(ah7, bh4)) | 0;
38159    lo = (lo + Math.imul(al6, bl5)) | 0;
38160    mid = (mid + Math.imul(al6, bh5)) | 0;
38161    mid = (mid + Math.imul(ah6, bl5)) | 0;
38162    hi = (hi + Math.imul(ah6, bh5)) | 0;
38163    lo = (lo + Math.imul(al5, bl6)) | 0;
38164    mid = (mid + Math.imul(al5, bh6)) | 0;
38165    mid = (mid + Math.imul(ah5, bl6)) | 0;
38166    hi = (hi + Math.imul(ah5, bh6)) | 0;
38167    lo = (lo + Math.imul(al4, bl7)) | 0;
38168    mid = (mid + Math.imul(al4, bh7)) | 0;
38169    mid = (mid + Math.imul(ah4, bl7)) | 0;
38170    hi = (hi + Math.imul(ah4, bh7)) | 0;
38171    lo = (lo + Math.imul(al3, bl8)) | 0;
38172    mid = (mid + Math.imul(al3, bh8)) | 0;
38173    mid = (mid + Math.imul(ah3, bl8)) | 0;
38174    hi = (hi + Math.imul(ah3, bh8)) | 0;
38175    lo = (lo + Math.imul(al2, bl9)) | 0;
38176    mid = (mid + Math.imul(al2, bh9)) | 0;
38177    mid = (mid + Math.imul(ah2, bl9)) | 0;
38178    hi = (hi + Math.imul(ah2, bh9)) | 0;
38179    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38180    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
38181    w11 &= 0x3ffffff;
38182    /* k = 12 */
38183    lo = Math.imul(al9, bl3);
38184    mid = Math.imul(al9, bh3);
38185    mid = (mid + Math.imul(ah9, bl3)) | 0;
38186    hi = Math.imul(ah9, bh3);
38187    lo = (lo + Math.imul(al8, bl4)) | 0;
38188    mid = (mid + Math.imul(al8, bh4)) | 0;
38189    mid = (mid + Math.imul(ah8, bl4)) | 0;
38190    hi = (hi + Math.imul(ah8, bh4)) | 0;
38191    lo = (lo + Math.imul(al7, bl5)) | 0;
38192    mid = (mid + Math.imul(al7, bh5)) | 0;
38193    mid = (mid + Math.imul(ah7, bl5)) | 0;
38194    hi = (hi + Math.imul(ah7, bh5)) | 0;
38195    lo = (lo + Math.imul(al6, bl6)) | 0;
38196    mid = (mid + Math.imul(al6, bh6)) | 0;
38197    mid = (mid + Math.imul(ah6, bl6)) | 0;
38198    hi = (hi + Math.imul(ah6, bh6)) | 0;
38199    lo = (lo + Math.imul(al5, bl7)) | 0;
38200    mid = (mid + Math.imul(al5, bh7)) | 0;
38201    mid = (mid + Math.imul(ah5, bl7)) | 0;
38202    hi = (hi + Math.imul(ah5, bh7)) | 0;
38203    lo = (lo + Math.imul(al4, bl8)) | 0;
38204    mid = (mid + Math.imul(al4, bh8)) | 0;
38205    mid = (mid + Math.imul(ah4, bl8)) | 0;
38206    hi = (hi + Math.imul(ah4, bh8)) | 0;
38207    lo = (lo + Math.imul(al3, bl9)) | 0;
38208    mid = (mid + Math.imul(al3, bh9)) | 0;
38209    mid = (mid + Math.imul(ah3, bl9)) | 0;
38210    hi = (hi + Math.imul(ah3, bh9)) | 0;
38211    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38212    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
38213    w12 &= 0x3ffffff;
38214    /* k = 13 */
38215    lo = Math.imul(al9, bl4);
38216    mid = Math.imul(al9, bh4);
38217    mid = (mid + Math.imul(ah9, bl4)) | 0;
38218    hi = Math.imul(ah9, bh4);
38219    lo = (lo + Math.imul(al8, bl5)) | 0;
38220    mid = (mid + Math.imul(al8, bh5)) | 0;
38221    mid = (mid + Math.imul(ah8, bl5)) | 0;
38222    hi = (hi + Math.imul(ah8, bh5)) | 0;
38223    lo = (lo + Math.imul(al7, bl6)) | 0;
38224    mid = (mid + Math.imul(al7, bh6)) | 0;
38225    mid = (mid + Math.imul(ah7, bl6)) | 0;
38226    hi = (hi + Math.imul(ah7, bh6)) | 0;
38227    lo = (lo + Math.imul(al6, bl7)) | 0;
38228    mid = (mid + Math.imul(al6, bh7)) | 0;
38229    mid = (mid + Math.imul(ah6, bl7)) | 0;
38230    hi = (hi + Math.imul(ah6, bh7)) | 0;
38231    lo = (lo + Math.imul(al5, bl8)) | 0;
38232    mid = (mid + Math.imul(al5, bh8)) | 0;
38233    mid = (mid + Math.imul(ah5, bl8)) | 0;
38234    hi = (hi + Math.imul(ah5, bh8)) | 0;
38235    lo = (lo + Math.imul(al4, bl9)) | 0;
38236    mid = (mid + Math.imul(al4, bh9)) | 0;
38237    mid = (mid + Math.imul(ah4, bl9)) | 0;
38238    hi = (hi + Math.imul(ah4, bh9)) | 0;
38239    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38240    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
38241    w13 &= 0x3ffffff;
38242    /* k = 14 */
38243    lo = Math.imul(al9, bl5);
38244    mid = Math.imul(al9, bh5);
38245    mid = (mid + Math.imul(ah9, bl5)) | 0;
38246    hi = Math.imul(ah9, bh5);
38247    lo = (lo + Math.imul(al8, bl6)) | 0;
38248    mid = (mid + Math.imul(al8, bh6)) | 0;
38249    mid = (mid + Math.imul(ah8, bl6)) | 0;
38250    hi = (hi + Math.imul(ah8, bh6)) | 0;
38251    lo = (lo + Math.imul(al7, bl7)) | 0;
38252    mid = (mid + Math.imul(al7, bh7)) | 0;
38253    mid = (mid + Math.imul(ah7, bl7)) | 0;
38254    hi = (hi + Math.imul(ah7, bh7)) | 0;
38255    lo = (lo + Math.imul(al6, bl8)) | 0;
38256    mid = (mid + Math.imul(al6, bh8)) | 0;
38257    mid = (mid + Math.imul(ah6, bl8)) | 0;
38258    hi = (hi + Math.imul(ah6, bh8)) | 0;
38259    lo = (lo + Math.imul(al5, bl9)) | 0;
38260    mid = (mid + Math.imul(al5, bh9)) | 0;
38261    mid = (mid + Math.imul(ah5, bl9)) | 0;
38262    hi = (hi + Math.imul(ah5, bh9)) | 0;
38263    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38264    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
38265    w14 &= 0x3ffffff;
38266    /* k = 15 */
38267    lo = Math.imul(al9, bl6);
38268    mid = Math.imul(al9, bh6);
38269    mid = (mid + Math.imul(ah9, bl6)) | 0;
38270    hi = Math.imul(ah9, bh6);
38271    lo = (lo + Math.imul(al8, bl7)) | 0;
38272    mid = (mid + Math.imul(al8, bh7)) | 0;
38273    mid = (mid + Math.imul(ah8, bl7)) | 0;
38274    hi = (hi + Math.imul(ah8, bh7)) | 0;
38275    lo = (lo + Math.imul(al7, bl8)) | 0;
38276    mid = (mid + Math.imul(al7, bh8)) | 0;
38277    mid = (mid + Math.imul(ah7, bl8)) | 0;
38278    hi = (hi + Math.imul(ah7, bh8)) | 0;
38279    lo = (lo + Math.imul(al6, bl9)) | 0;
38280    mid = (mid + Math.imul(al6, bh9)) | 0;
38281    mid = (mid + Math.imul(ah6, bl9)) | 0;
38282    hi = (hi + Math.imul(ah6, bh9)) | 0;
38283    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38284    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
38285    w15 &= 0x3ffffff;
38286    /* k = 16 */
38287    lo = Math.imul(al9, bl7);
38288    mid = Math.imul(al9, bh7);
38289    mid = (mid + Math.imul(ah9, bl7)) | 0;
38290    hi = Math.imul(ah9, bh7);
38291    lo = (lo + Math.imul(al8, bl8)) | 0;
38292    mid = (mid + Math.imul(al8, bh8)) | 0;
38293    mid = (mid + Math.imul(ah8, bl8)) | 0;
38294    hi = (hi + Math.imul(ah8, bh8)) | 0;
38295    lo = (lo + Math.imul(al7, bl9)) | 0;
38296    mid = (mid + Math.imul(al7, bh9)) | 0;
38297    mid = (mid + Math.imul(ah7, bl9)) | 0;
38298    hi = (hi + Math.imul(ah7, bh9)) | 0;
38299    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38300    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
38301    w16 &= 0x3ffffff;
38302    /* k = 17 */
38303    lo = Math.imul(al9, bl8);
38304    mid = Math.imul(al9, bh8);
38305    mid = (mid + Math.imul(ah9, bl8)) | 0;
38306    hi = Math.imul(ah9, bh8);
38307    lo = (lo + Math.imul(al8, bl9)) | 0;
38308    mid = (mid + Math.imul(al8, bh9)) | 0;
38309    mid = (mid + Math.imul(ah8, bl9)) | 0;
38310    hi = (hi + Math.imul(ah8, bh9)) | 0;
38311    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38312    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
38313    w17 &= 0x3ffffff;
38314    /* k = 18 */
38315    lo = Math.imul(al9, bl9);
38316    mid = Math.imul(al9, bh9);
38317    mid = (mid + Math.imul(ah9, bl9)) | 0;
38318    hi = Math.imul(ah9, bh9);
38319    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
38320    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
38321    w18 &= 0x3ffffff;
38322    o[0] = w0;
38323    o[1] = w1;
38324    o[2] = w2;
38325    o[3] = w3;
38326    o[4] = w4;
38327    o[5] = w5;
38328    o[6] = w6;
38329    o[7] = w7;
38330    o[8] = w8;
38331    o[9] = w9;
38332    o[10] = w10;
38333    o[11] = w11;
38334    o[12] = w12;
38335    o[13] = w13;
38336    o[14] = w14;
38337    o[15] = w15;
38338    o[16] = w16;
38339    o[17] = w17;
38340    o[18] = w18;
38341    if (c !== 0) {
38342      o[19] = c;
38343      out.length++;
38344    }
38345    return out;
38346  };
38347
38348  // Polyfill comb
38349  if (!Math.imul) {
38350    comb10MulTo = smallMulTo;
38351  }
38352
38353  function bigMulTo (self, num, out) {
38354    out.negative = num.negative ^ self.negative;
38355    out.length = self.length + num.length;
38356
38357    var carry = 0;
38358    var hncarry = 0;
38359    for (var k = 0; k < out.length - 1; k++) {
38360      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
38361      // note that ncarry could be >= 0x3ffffff
38362      var ncarry = hncarry;
38363      hncarry = 0;
38364      var rword = carry & 0x3ffffff;
38365      var maxJ = Math.min(k, num.length - 1);
38366      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
38367        var i = k - j;
38368        var a = self.words[i] | 0;
38369        var b = num.words[j] | 0;
38370        var r = a * b;
38371
38372        var lo = r & 0x3ffffff;
38373        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
38374        lo = (lo + rword) | 0;
38375        rword = lo & 0x3ffffff;
38376        ncarry = (ncarry + (lo >>> 26)) | 0;
38377
38378        hncarry += ncarry >>> 26;
38379        ncarry &= 0x3ffffff;
38380      }
38381      out.words[k] = rword;
38382      carry = ncarry;
38383      ncarry = hncarry;
38384    }
38385    if (carry !== 0) {
38386      out.words[k] = carry;
38387    } else {
38388      out.length--;
38389    }
38390
38391    return out.strip();
38392  }
38393
38394  function jumboMulTo (self, num, out) {
38395    var fftm = new FFTM();
38396    return fftm.mulp(self, num, out);
38397  }
38398
38399  BN.prototype.mulTo = function mulTo (num, out) {
38400    var res;
38401    var len = this.length + num.length;
38402    if (this.length === 10 && num.length === 10) {
38403      res = comb10MulTo(this, num, out);
38404    } else if (len < 63) {
38405      res = smallMulTo(this, num, out);
38406    } else if (len < 1024) {
38407      res = bigMulTo(this, num, out);
38408    } else {
38409      res = jumboMulTo(this, num, out);
38410    }
38411
38412    return res;
38413  };
38414
38415  // Cooley-Tukey algorithm for FFT
38416  // slightly revisited to rely on looping instead of recursion
38417
38418  function FFTM (x, y) {
38419    this.x = x;
38420    this.y = y;
38421  }
38422
38423  FFTM.prototype.makeRBT = function makeRBT (N) {
38424    var t = new Array(N);
38425    var l = BN.prototype._countBits(N) - 1;
38426    for (var i = 0; i < N; i++) {
38427      t[i] = this.revBin(i, l, N);
38428    }
38429
38430    return t;
38431  };
38432
38433  // Returns binary-reversed representation of `x`
38434  FFTM.prototype.revBin = function revBin (x, l, N) {
38435    if (x === 0 || x === N - 1) return x;
38436
38437    var rb = 0;
38438    for (var i = 0; i < l; i++) {
38439      rb |= (x & 1) << (l - i - 1);
38440      x >>= 1;
38441    }
38442
38443    return rb;
38444  };
38445
38446  // Performs "tweedling" phase, therefore 'emulating'
38447  // behaviour of the recursive algorithm
38448  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
38449    for (var i = 0; i < N; i++) {
38450      rtws[i] = rws[rbt[i]];
38451      itws[i] = iws[rbt[i]];
38452    }
38453  };
38454
38455  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
38456    this.permute(rbt, rws, iws, rtws, itws, N);
38457
38458    for (var s = 1; s < N; s <<= 1) {
38459      var l = s << 1;
38460
38461      var rtwdf = Math.cos(2 * Math.PI / l);
38462      var itwdf = Math.sin(2 * Math.PI / l);
38463
38464      for (var p = 0; p < N; p += l) {
38465        var rtwdf_ = rtwdf;
38466        var itwdf_ = itwdf;
38467
38468        for (var j = 0; j < s; j++) {
38469          var re = rtws[p + j];
38470          var ie = itws[p + j];
38471
38472          var ro = rtws[p + j + s];
38473          var io = itws[p + j + s];
38474
38475          var rx = rtwdf_ * ro - itwdf_ * io;
38476
38477          io = rtwdf_ * io + itwdf_ * ro;
38478          ro = rx;
38479
38480          rtws[p + j] = re + ro;
38481          itws[p + j] = ie + io;
38482
38483          rtws[p + j + s] = re - ro;
38484          itws[p + j + s] = ie - io;
38485
38486          /* jshint maxdepth : false */
38487          if (j !== l) {
38488            rx = rtwdf * rtwdf_ - itwdf * itwdf_;
38489
38490            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
38491            rtwdf_ = rx;
38492          }
38493        }
38494      }
38495    }
38496  };
38497
38498  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
38499    var N = Math.max(m, n) | 1;
38500    var odd = N & 1;
38501    var i = 0;
38502    for (N = N / 2 | 0; N; N = N >>> 1) {
38503      i++;
38504    }
38505
38506    return 1 << i + 1 + odd;
38507  };
38508
38509  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
38510    if (N <= 1) return;
38511
38512    for (var i = 0; i < N / 2; i++) {
38513      var t = rws[i];
38514
38515      rws[i] = rws[N - i - 1];
38516      rws[N - i - 1] = t;
38517
38518      t = iws[i];
38519
38520      iws[i] = -iws[N - i - 1];
38521      iws[N - i - 1] = -t;
38522    }
38523  };
38524
38525  FFTM.prototype.normalize13b = function normalize13b (ws, N) {
38526    var carry = 0;
38527    for (var i = 0; i < N / 2; i++) {
38528      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
38529        Math.round(ws[2 * i] / N) +
38530        carry;
38531
38532      ws[i] = w & 0x3ffffff;
38533
38534      if (w < 0x4000000) {
38535        carry = 0;
38536      } else {
38537        carry = w / 0x4000000 | 0;
38538      }
38539    }
38540
38541    return ws;
38542  };
38543
38544  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
38545    var carry = 0;
38546    for (var i = 0; i < len; i++) {
38547      carry = carry + (ws[i] | 0);
38548
38549      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
38550      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
38551    }
38552
38553    // Pad with zeroes
38554    for (i = 2 * len; i < N; ++i) {
38555      rws[i] = 0;
38556    }
38557
38558    assert(carry === 0);
38559    assert((carry & ~0x1fff) === 0);
38560  };
38561
38562  FFTM.prototype.stub = function stub (N) {
38563    var ph = new Array(N);
38564    for (var i = 0; i < N; i++) {
38565      ph[i] = 0;
38566    }
38567
38568    return ph;
38569  };
38570
38571  FFTM.prototype.mulp = function mulp (x, y, out) {
38572    var N = 2 * this.guessLen13b(x.length, y.length);
38573
38574    var rbt = this.makeRBT(N);
38575
38576    var _ = this.stub(N);
38577
38578    var rws = new Array(N);
38579    var rwst = new Array(N);
38580    var iwst = new Array(N);
38581
38582    var nrws = new Array(N);
38583    var nrwst = new Array(N);
38584    var niwst = new Array(N);
38585
38586    var rmws = out.words;
38587    rmws.length = N;
38588
38589    this.convert13b(x.words, x.length, rws, N);
38590    this.convert13b(y.words, y.length, nrws, N);
38591
38592    this.transform(rws, _, rwst, iwst, N, rbt);
38593    this.transform(nrws, _, nrwst, niwst, N, rbt);
38594
38595    for (var i = 0; i < N; i++) {
38596      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
38597      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
38598      rwst[i] = rx;
38599    }
38600
38601    this.conjugate(rwst, iwst, N);
38602    this.transform(rwst, iwst, rmws, _, N, rbt);
38603    this.conjugate(rmws, _, N);
38604    this.normalize13b(rmws, N);
38605
38606    out.negative = x.negative ^ y.negative;
38607    out.length = x.length + y.length;
38608    return out.strip();
38609  };
38610
38611  // Multiply `this` by `num`
38612  BN.prototype.mul = function mul (num) {
38613    var out = new BN(null);
38614    out.words = new Array(this.length + num.length);
38615    return this.mulTo(num, out);
38616  };
38617
38618  // Multiply employing FFT
38619  BN.prototype.mulf = function mulf (num) {
38620    var out = new BN(null);
38621    out.words = new Array(this.length + num.length);
38622    return jumboMulTo(this, num, out);
38623  };
38624
38625  // In-place Multiplication
38626  BN.prototype.imul = function imul (num) {
38627    return this.clone().mulTo(num, this);
38628  };
38629
38630  BN.prototype.imuln = function imuln (num) {
38631    assert(typeof num === 'number');
38632    assert(num < 0x4000000);
38633
38634    // Carry
38635    var carry = 0;
38636    for (var i = 0; i < this.length; i++) {
38637      var w = (this.words[i] | 0) * num;
38638      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
38639      carry >>= 26;
38640      carry += (w / 0x4000000) | 0;
38641      // NOTE: lo is 27bit maximum
38642      carry += lo >>> 26;
38643      this.words[i] = lo & 0x3ffffff;
38644    }
38645
38646    if (carry !== 0) {
38647      this.words[i] = carry;
38648      this.length++;
38649    }
38650
38651    return this;
38652  };
38653
38654  BN.prototype.muln = function muln (num) {
38655    return this.clone().imuln(num);
38656  };
38657
38658  // `this` * `this`
38659  BN.prototype.sqr = function sqr () {
38660    return this.mul(this);
38661  };
38662
38663  // `this` * `this` in-place
38664  BN.prototype.isqr = function isqr () {
38665    return this.imul(this.clone());
38666  };
38667
38668  // Math.pow(`this`, `num`)
38669  BN.prototype.pow = function pow (num) {
38670    var w = toBitArray(num);
38671    if (w.length === 0) return new BN(1);
38672
38673    // Skip leading zeroes
38674    var res = this;
38675    for (var i = 0; i < w.length; i++, res = res.sqr()) {
38676      if (w[i] !== 0) break;
38677    }
38678
38679    if (++i < w.length) {
38680      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
38681        if (w[i] === 0) continue;
38682
38683        res = res.mul(q);
38684      }
38685    }
38686
38687    return res;
38688  };
38689
38690  // Shift-left in-place
38691  BN.prototype.iushln = function iushln (bits) {
38692    assert(typeof bits === 'number' && bits >= 0);
38693    var r = bits % 26;
38694    var s = (bits - r) / 26;
38695    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
38696    var i;
38697
38698    if (r !== 0) {
38699      var carry = 0;
38700
38701      for (i = 0; i < this.length; i++) {
38702        var newCarry = this.words[i] & carryMask;
38703        var c = ((this.words[i] | 0) - newCarry) << r;
38704        this.words[i] = c | carry;
38705        carry = newCarry >>> (26 - r);
38706      }
38707
38708      if (carry) {
38709        this.words[i] = carry;
38710        this.length++;
38711      }
38712    }
38713
38714    if (s !== 0) {
38715      for (i = this.length - 1; i >= 0; i--) {
38716        this.words[i + s] = this.words[i];
38717      }
38718
38719      for (i = 0; i < s; i++) {
38720        this.words[i] = 0;
38721      }
38722
38723      this.length += s;
38724    }
38725
38726    return this.strip();
38727  };
38728
38729  BN.prototype.ishln = function ishln (bits) {
38730    // TODO(indutny): implement me
38731    assert(this.negative === 0);
38732    return this.iushln(bits);
38733  };
38734
38735  // Shift-right in-place
38736  // NOTE: `hint` is a lowest bit before trailing zeroes
38737  // NOTE: if `extended` is present - it will be filled with destroyed bits
38738  BN.prototype.iushrn = function iushrn (bits, hint, extended) {
38739    assert(typeof bits === 'number' && bits >= 0);
38740    var h;
38741    if (hint) {
38742      h = (hint - (hint % 26)) / 26;
38743    } else {
38744      h = 0;
38745    }
38746
38747    var r = bits % 26;
38748    var s = Math.min((bits - r) / 26, this.length);
38749    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
38750    var maskedWords = extended;
38751
38752    h -= s;
38753    h = Math.max(0, h);
38754
38755    // Extended mode, copy masked part
38756    if (maskedWords) {
38757      for (var i = 0; i < s; i++) {
38758        maskedWords.words[i] = this.words[i];
38759      }
38760      maskedWords.length = s;
38761    }
38762
38763    if (s === 0) {
38764      // No-op, we should not move anything at all
38765    } else if (this.length > s) {
38766      this.length -= s;
38767      for (i = 0; i < this.length; i++) {
38768        this.words[i] = this.words[i + s];
38769      }
38770    } else {
38771      this.words[0] = 0;
38772      this.length = 1;
38773    }
38774
38775    var carry = 0;
38776    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
38777      var word = this.words[i] | 0;
38778      this.words[i] = (carry << (26 - r)) | (word >>> r);
38779      carry = word & mask;
38780    }
38781
38782    // Push carried bits as a mask
38783    if (maskedWords && carry !== 0) {
38784      maskedWords.words[maskedWords.length++] = carry;
38785    }
38786
38787    if (this.length === 0) {
38788      this.words[0] = 0;
38789      this.length = 1;
38790    }
38791
38792    return this.strip();
38793  };
38794
38795  BN.prototype.ishrn = function ishrn (bits, hint, extended) {
38796    // TODO(indutny): implement me
38797    assert(this.negative === 0);
38798    return this.iushrn(bits, hint, extended);
38799  };
38800
38801  // Shift-left
38802  BN.prototype.shln = function shln (bits) {
38803    return this.clone().ishln(bits);
38804  };
38805
38806  BN.prototype.ushln = function ushln (bits) {
38807    return this.clone().iushln(bits);
38808  };
38809
38810  // Shift-right
38811  BN.prototype.shrn = function shrn (bits) {
38812    return this.clone().ishrn(bits);
38813  };
38814
38815  BN.prototype.ushrn = function ushrn (bits) {
38816    return this.clone().iushrn(bits);
38817  };
38818
38819  // Test if n bit is set
38820  BN.prototype.testn = function testn (bit) {
38821    assert(typeof bit === 'number' && bit >= 0);
38822    var r = bit % 26;
38823    var s = (bit - r) / 26;
38824    var q = 1 << r;
38825
38826    // Fast case: bit is much higher than all existing words
38827    if (this.length <= s) return false;
38828
38829    // Check bit and return
38830    var w = this.words[s];
38831
38832    return !!(w & q);
38833  };
38834
38835  // Return only lowers bits of number (in-place)
38836  BN.prototype.imaskn = function imaskn (bits) {
38837    assert(typeof bits === 'number' && bits >= 0);
38838    var r = bits % 26;
38839    var s = (bits - r) / 26;
38840
38841    assert(this.negative === 0, 'imaskn works only with positive numbers');
38842
38843    if (this.length <= s) {
38844      return this;
38845    }
38846
38847    if (r !== 0) {
38848      s++;
38849    }
38850    this.length = Math.min(s, this.length);
38851
38852    if (r !== 0) {
38853      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
38854      this.words[this.length - 1] &= mask;
38855    }
38856
38857    return this.strip();
38858  };
38859
38860  // Return only lowers bits of number
38861  BN.prototype.maskn = function maskn (bits) {
38862    return this.clone().imaskn(bits);
38863  };
38864
38865  // Add plain number `num` to `this`
38866  BN.prototype.iaddn = function iaddn (num) {
38867    assert(typeof num === 'number');
38868    assert(num < 0x4000000);
38869    if (num < 0) return this.isubn(-num);
38870
38871    // Possible sign change
38872    if (this.negative !== 0) {
38873      if (this.length === 1 && (this.words[0] | 0) < num) {
38874        this.words[0] = num - (this.words[0] | 0);
38875        this.negative = 0;
38876        return this;
38877      }
38878
38879      this.negative = 0;
38880      this.isubn(num);
38881      this.negative = 1;
38882      return this;
38883    }
38884
38885    // Add without checks
38886    return this._iaddn(num);
38887  };
38888
38889  BN.prototype._iaddn = function _iaddn (num) {
38890    this.words[0] += num;
38891
38892    // Carry
38893    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
38894      this.words[i] -= 0x4000000;
38895      if (i === this.length - 1) {
38896        this.words[i + 1] = 1;
38897      } else {
38898        this.words[i + 1]++;
38899      }
38900    }
38901    this.length = Math.max(this.length, i + 1);
38902
38903    return this;
38904  };
38905
38906  // Subtract plain number `num` from `this`
38907  BN.prototype.isubn = function isubn (num) {
38908    assert(typeof num === 'number');
38909    assert(num < 0x4000000);
38910    if (num < 0) return this.iaddn(-num);
38911
38912    if (this.negative !== 0) {
38913      this.negative = 0;
38914      this.iaddn(num);
38915      this.negative = 1;
38916      return this;
38917    }
38918
38919    this.words[0] -= num;
38920
38921    if (this.length === 1 && this.words[0] < 0) {
38922      this.words[0] = -this.words[0];
38923      this.negative = 1;
38924    } else {
38925      // Carry
38926      for (var i = 0; i < this.length && this.words[i] < 0; i++) {
38927        this.words[i] += 0x4000000;
38928        this.words[i + 1] -= 1;
38929      }
38930    }
38931
38932    return this.strip();
38933  };
38934
38935  BN.prototype.addn = function addn (num) {
38936    return this.clone().iaddn(num);
38937  };
38938
38939  BN.prototype.subn = function subn (num) {
38940    return this.clone().isubn(num);
38941  };
38942
38943  BN.prototype.iabs = function iabs () {
38944    this.negative = 0;
38945
38946    return this;
38947  };
38948
38949  BN.prototype.abs = function abs () {
38950    return this.clone().iabs();
38951  };
38952
38953  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
38954    var len = num.length + shift;
38955    var i;
38956
38957    this._expand(len);
38958
38959    var w;
38960    var carry = 0;
38961    for (i = 0; i < num.length; i++) {
38962      w = (this.words[i + shift] | 0) + carry;
38963      var right = (num.words[i] | 0) * mul;
38964      w -= right & 0x3ffffff;
38965      carry = (w >> 26) - ((right / 0x4000000) | 0);
38966      this.words[i + shift] = w & 0x3ffffff;
38967    }
38968    for (; i < this.length - shift; i++) {
38969      w = (this.words[i + shift] | 0) + carry;
38970      carry = w >> 26;
38971      this.words[i + shift] = w & 0x3ffffff;
38972    }
38973
38974    if (carry === 0) return this.strip();
38975
38976    // Subtraction overflow
38977    assert(carry === -1);
38978    carry = 0;
38979    for (i = 0; i < this.length; i++) {
38980      w = -(this.words[i] | 0) + carry;
38981      carry = w >> 26;
38982      this.words[i] = w & 0x3ffffff;
38983    }
38984    this.negative = 1;
38985
38986    return this.strip();
38987  };
38988
38989  BN.prototype._wordDiv = function _wordDiv (num, mode) {
38990    var shift = this.length - num.length;
38991
38992    var a = this.clone();
38993    var b = num;
38994
38995    // Normalize
38996    var bhi = b.words[b.length - 1] | 0;
38997    var bhiBits = this._countBits(bhi);
38998    shift = 26 - bhiBits;
38999    if (shift !== 0) {
39000      b = b.ushln(shift);
39001      a.iushln(shift);
39002      bhi = b.words[b.length - 1] | 0;
39003    }
39004
39005    // Initialize quotient
39006    var m = a.length - b.length;
39007    var q;
39008
39009    if (mode !== 'mod') {
39010      q = new BN(null);
39011      q.length = m + 1;
39012      q.words = new Array(q.length);
39013      for (var i = 0; i < q.length; i++) {
39014        q.words[i] = 0;
39015      }
39016    }
39017
39018    var diff = a.clone()._ishlnsubmul(b, 1, m);
39019    if (diff.negative === 0) {
39020      a = diff;
39021      if (q) {
39022        q.words[m] = 1;
39023      }
39024    }
39025
39026    for (var j = m - 1; j >= 0; j--) {
39027      var qj = (a.words[b.length + j] | 0) * 0x4000000 +
39028        (a.words[b.length + j - 1] | 0);
39029
39030      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
39031      // (0x7ffffff)
39032      qj = Math.min((qj / bhi) | 0, 0x3ffffff);
39033
39034      a._ishlnsubmul(b, qj, j);
39035      while (a.negative !== 0) {
39036        qj--;
39037        a.negative = 0;
39038        a._ishlnsubmul(b, 1, j);
39039        if (!a.isZero()) {
39040          a.negative ^= 1;
39041        }
39042      }
39043      if (q) {
39044        q.words[j] = qj;
39045      }
39046    }
39047    if (q) {
39048      q.strip();
39049    }
39050    a.strip();
39051
39052    // Denormalize
39053    if (mode !== 'div' && shift !== 0) {
39054      a.iushrn(shift);
39055    }
39056
39057    return {
39058      div: q || null,
39059      mod: a
39060    };
39061  };
39062
39063  // NOTE: 1) `mode` can be set to `mod` to request mod only,
39064  //       to `div` to request div only, or be absent to
39065  //       request both div & mod
39066  //       2) `positive` is true if unsigned mod is requested
39067  BN.prototype.divmod = function divmod (num, mode, positive) {
39068    assert(!num.isZero());
39069
39070    if (this.isZero()) {
39071      return {
39072        div: new BN(0),
39073        mod: new BN(0)
39074      };
39075    }
39076
39077    var div, mod, res;
39078    if (this.negative !== 0 && num.negative === 0) {
39079      res = this.neg().divmod(num, mode);
39080
39081      if (mode !== 'mod') {
39082        div = res.div.neg();
39083      }
39084
39085      if (mode !== 'div') {
39086        mod = res.mod.neg();
39087        if (positive && mod.negative !== 0) {
39088          mod.iadd(num);
39089        }
39090      }
39091
39092      return {
39093        div: div,
39094        mod: mod
39095      };
39096    }
39097
39098    if (this.negative === 0 && num.negative !== 0) {
39099      res = this.divmod(num.neg(), mode);
39100
39101      if (mode !== 'mod') {
39102        div = res.div.neg();
39103      }
39104
39105      return {
39106        div: div,
39107        mod: res.mod
39108      };
39109    }
39110
39111    if ((this.negative & num.negative) !== 0) {
39112      res = this.neg().divmod(num.neg(), mode);
39113
39114      if (mode !== 'div') {
39115        mod = res.mod.neg();
39116        if (positive && mod.negative !== 0) {
39117          mod.isub(num);
39118        }
39119      }
39120
39121      return {
39122        div: res.div,
39123        mod: mod
39124      };
39125    }
39126
39127    // Both numbers are positive at this point
39128
39129    // Strip both numbers to approximate shift value
39130    if (num.length > this.length || this.cmp(num) < 0) {
39131      return {
39132        div: new BN(0),
39133        mod: this
39134      };
39135    }
39136
39137    // Very short reduction
39138    if (num.length === 1) {
39139      if (mode === 'div') {
39140        return {
39141          div: this.divn(num.words[0]),
39142          mod: null
39143        };
39144      }
39145
39146      if (mode === 'mod') {
39147        return {
39148          div: null,
39149          mod: new BN(this.modn(num.words[0]))
39150        };
39151      }
39152
39153      return {
39154        div: this.divn(num.words[0]),
39155        mod: new BN(this.modn(num.words[0]))
39156      };
39157    }
39158
39159    return this._wordDiv(num, mode);
39160  };
39161
39162  // Find `this` / `num`
39163  BN.prototype.div = function div (num) {
39164    return this.divmod(num, 'div', false).div;
39165  };
39166
39167  // Find `this` % `num`
39168  BN.prototype.mod = function mod (num) {
39169    return this.divmod(num, 'mod', false).mod;
39170  };
39171
39172  BN.prototype.umod = function umod (num) {
39173    return this.divmod(num, 'mod', true).mod;
39174  };
39175
39176  // Find Round(`this` / `num`)
39177  BN.prototype.divRound = function divRound (num) {
39178    var dm = this.divmod(num);
39179
39180    // Fast case - exact division
39181    if (dm.mod.isZero()) return dm.div;
39182
39183    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
39184
39185    var half = num.ushrn(1);
39186    var r2 = num.andln(1);
39187    var cmp = mod.cmp(half);
39188
39189    // Round down
39190    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
39191
39192    // Round up
39193    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
39194  };
39195
39196  BN.prototype.modn = function modn (num) {
39197    assert(num <= 0x3ffffff);
39198    var p = (1 << 26) % num;
39199
39200    var acc = 0;
39201    for (var i = this.length - 1; i >= 0; i--) {
39202      acc = (p * acc + (this.words[i] | 0)) % num;
39203    }
39204
39205    return acc;
39206  };
39207
39208  // In-place division by number
39209  BN.prototype.idivn = function idivn (num) {
39210    assert(num <= 0x3ffffff);
39211
39212    var carry = 0;
39213    for (var i = this.length - 1; i >= 0; i--) {
39214      var w = (this.words[i] | 0) + carry * 0x4000000;
39215      this.words[i] = (w / num) | 0;
39216      carry = w % num;
39217    }
39218
39219    return this.strip();
39220  };
39221
39222  BN.prototype.divn = function divn (num) {
39223    return this.clone().idivn(num);
39224  };
39225
39226  BN.prototype.egcd = function egcd (p) {
39227    assert(p.negative === 0);
39228    assert(!p.isZero());
39229
39230    var x = this;
39231    var y = p.clone();
39232
39233    if (x.negative !== 0) {
39234      x = x.umod(p);
39235    } else {
39236      x = x.clone();
39237    }
39238
39239    // A * x + B * y = x
39240    var A = new BN(1);
39241    var B = new BN(0);
39242
39243    // C * x + D * y = y
39244    var C = new BN(0);
39245    var D = new BN(1);
39246
39247    var g = 0;
39248
39249    while (x.isEven() && y.isEven()) {
39250      x.iushrn(1);
39251      y.iushrn(1);
39252      ++g;
39253    }
39254
39255    var yp = y.clone();
39256    var xp = x.clone();
39257
39258    while (!x.isZero()) {
39259      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
39260      if (i > 0) {
39261        x.iushrn(i);
39262        while (i-- > 0) {
39263          if (A.isOdd() || B.isOdd()) {
39264            A.iadd(yp);
39265            B.isub(xp);
39266          }
39267
39268          A.iushrn(1);
39269          B.iushrn(1);
39270        }
39271      }
39272
39273      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
39274      if (j > 0) {
39275        y.iushrn(j);
39276        while (j-- > 0) {
39277          if (C.isOdd() || D.isOdd()) {
39278            C.iadd(yp);
39279            D.isub(xp);
39280          }
39281
39282          C.iushrn(1);
39283          D.iushrn(1);
39284        }
39285      }
39286
39287      if (x.cmp(y) >= 0) {
39288        x.isub(y);
39289        A.isub(C);
39290        B.isub(D);
39291      } else {
39292        y.isub(x);
39293        C.isub(A);
39294        D.isub(B);
39295      }
39296    }
39297
39298    return {
39299      a: C,
39300      b: D,
39301      gcd: y.iushln(g)
39302    };
39303  };
39304
39305  // This is reduced incarnation of the binary EEA
39306  // above, designated to invert members of the
39307  // _prime_ fields F(p) at a maximal speed
39308  BN.prototype._invmp = function _invmp (p) {
39309    assert(p.negative === 0);
39310    assert(!p.isZero());
39311
39312    var a = this;
39313    var b = p.clone();
39314
39315    if (a.negative !== 0) {
39316      a = a.umod(p);
39317    } else {
39318      a = a.clone();
39319    }
39320
39321    var x1 = new BN(1);
39322    var x2 = new BN(0);
39323
39324    var delta = b.clone();
39325
39326    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
39327      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
39328      if (i > 0) {
39329        a.iushrn(i);
39330        while (i-- > 0) {
39331          if (x1.isOdd()) {
39332            x1.iadd(delta);
39333          }
39334
39335          x1.iushrn(1);
39336        }
39337      }
39338
39339      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
39340      if (j > 0) {
39341        b.iushrn(j);
39342        while (j-- > 0) {
39343          if (x2.isOdd()) {
39344            x2.iadd(delta);
39345          }
39346
39347          x2.iushrn(1);
39348        }
39349      }
39350
39351      if (a.cmp(b) >= 0) {
39352        a.isub(b);
39353        x1.isub(x2);
39354      } else {
39355        b.isub(a);
39356        x2.isub(x1);
39357      }
39358    }
39359
39360    var res;
39361    if (a.cmpn(1) === 0) {
39362      res = x1;
39363    } else {
39364      res = x2;
39365    }
39366
39367    if (res.cmpn(0) < 0) {
39368      res.iadd(p);
39369    }
39370
39371    return res;
39372  };
39373
39374  BN.prototype.gcd = function gcd (num) {
39375    if (this.isZero()) return num.abs();
39376    if (num.isZero()) return this.abs();
39377
39378    var a = this.clone();
39379    var b = num.clone();
39380    a.negative = 0;
39381    b.negative = 0;
39382
39383    // Remove common factor of two
39384    for (var shift = 0; a.isEven() && b.isEven(); shift++) {
39385      a.iushrn(1);
39386      b.iushrn(1);
39387    }
39388
39389    do {
39390      while (a.isEven()) {
39391        a.iushrn(1);
39392      }
39393      while (b.isEven()) {
39394        b.iushrn(1);
39395      }
39396
39397      var r = a.cmp(b);
39398      if (r < 0) {
39399        // Swap `a` and `b` to make `a` always bigger than `b`
39400        var t = a;
39401        a = b;
39402        b = t;
39403      } else if (r === 0 || b.cmpn(1) === 0) {
39404        break;
39405      }
39406
39407      a.isub(b);
39408    } while (true);
39409
39410    return b.iushln(shift);
39411  };
39412
39413  // Invert number in the field F(num)
39414  BN.prototype.invm = function invm (num) {
39415    return this.egcd(num).a.umod(num);
39416  };
39417
39418  BN.prototype.isEven = function isEven () {
39419    return (this.words[0] & 1) === 0;
39420  };
39421
39422  BN.prototype.isOdd = function isOdd () {
39423    return (this.words[0] & 1) === 1;
39424  };
39425
39426  // And first word and num
39427  BN.prototype.andln = function andln (num) {
39428    return this.words[0] & num;
39429  };
39430
39431  // Increment at the bit position in-line
39432  BN.prototype.bincn = function bincn (bit) {
39433    assert(typeof bit === 'number');
39434    var r = bit % 26;
39435    var s = (bit - r) / 26;
39436    var q = 1 << r;
39437
39438    // Fast case: bit is much higher than all existing words
39439    if (this.length <= s) {
39440      this._expand(s + 1);
39441      this.words[s] |= q;
39442      return this;
39443    }
39444
39445    // Add bit and propagate, if needed
39446    var carry = q;
39447    for (var i = s; carry !== 0 && i < this.length; i++) {
39448      var w = this.words[i] | 0;
39449      w += carry;
39450      carry = w >>> 26;
39451      w &= 0x3ffffff;
39452      this.words[i] = w;
39453    }
39454    if (carry !== 0) {
39455      this.words[i] = carry;
39456      this.length++;
39457    }
39458    return this;
39459  };
39460
39461  BN.prototype.isZero = function isZero () {
39462    return this.length === 1 && this.words[0] === 0;
39463  };
39464
39465  BN.prototype.cmpn = function cmpn (num) {
39466    var negative = num < 0;
39467
39468    if (this.negative !== 0 && !negative) return -1;
39469    if (this.negative === 0 && negative) return 1;
39470
39471    this.strip();
39472
39473    var res;
39474    if (this.length > 1) {
39475      res = 1;
39476    } else {
39477      if (negative) {
39478        num = -num;
39479      }
39480
39481      assert(num <= 0x3ffffff, 'Number is too big');
39482
39483      var w = this.words[0] | 0;
39484      res = w === num ? 0 : w < num ? -1 : 1;
39485    }
39486    if (this.negative !== 0) return -res | 0;
39487    return res;
39488  };
39489
39490  // Compare two numbers and return:
39491  // 1 - if `this` > `num`
39492  // 0 - if `this` == `num`
39493  // -1 - if `this` < `num`
39494  BN.prototype.cmp = function cmp (num) {
39495    if (this.negative !== 0 && num.negative === 0) return -1;
39496    if (this.negative === 0 && num.negative !== 0) return 1;
39497
39498    var res = this.ucmp(num);
39499    if (this.negative !== 0) return -res | 0;
39500    return res;
39501  };
39502
39503  // Unsigned comparison
39504  BN.prototype.ucmp = function ucmp (num) {
39505    // At this point both numbers have the same sign
39506    if (this.length > num.length) return 1;
39507    if (this.length < num.length) return -1;
39508
39509    var res = 0;
39510    for (var i = this.length - 1; i >= 0; i--) {
39511      var a = this.words[i] | 0;
39512      var b = num.words[i] | 0;
39513
39514      if (a === b) continue;
39515      if (a < b) {
39516        res = -1;
39517      } else if (a > b) {
39518        res = 1;
39519      }
39520      break;
39521    }
39522    return res;
39523  };
39524
39525  BN.prototype.gtn = function gtn (num) {
39526    return this.cmpn(num) === 1;
39527  };
39528
39529  BN.prototype.gt = function gt (num) {
39530    return this.cmp(num) === 1;
39531  };
39532
39533  BN.prototype.gten = function gten (num) {
39534    return this.cmpn(num) >= 0;
39535  };
39536
39537  BN.prototype.gte = function gte (num) {
39538    return this.cmp(num) >= 0;
39539  };
39540
39541  BN.prototype.ltn = function ltn (num) {
39542    return this.cmpn(num) === -1;
39543  };
39544
39545  BN.prototype.lt = function lt (num) {
39546    return this.cmp(num) === -1;
39547  };
39548
39549  BN.prototype.lten = function lten (num) {
39550    return this.cmpn(num) <= 0;
39551  };
39552
39553  BN.prototype.lte = function lte (num) {
39554    return this.cmp(num) <= 0;
39555  };
39556
39557  BN.prototype.eqn = function eqn (num) {
39558    return this.cmpn(num) === 0;
39559  };
39560
39561  BN.prototype.eq = function eq (num) {
39562    return this.cmp(num) === 0;
39563  };
39564
39565  //
39566  // A reduce context, could be using montgomery or something better, depending
39567  // on the `m` itself.
39568  //
39569  BN.red = function red (num) {
39570    return new Red(num);
39571  };
39572
39573  BN.prototype.toRed = function toRed (ctx) {
39574    assert(!this.red, 'Already a number in reduction context');
39575    assert(this.negative === 0, 'red works only with positives');
39576    return ctx.convertTo(this)._forceRed(ctx);
39577  };
39578
39579  BN.prototype.fromRed = function fromRed () {
39580    assert(this.red, 'fromRed works only with numbers in reduction context');
39581    return this.red.convertFrom(this);
39582  };
39583
39584  BN.prototype._forceRed = function _forceRed (ctx) {
39585    this.red = ctx;
39586    return this;
39587  };
39588
39589  BN.prototype.forceRed = function forceRed (ctx) {
39590    assert(!this.red, 'Already a number in reduction context');
39591    return this._forceRed(ctx);
39592  };
39593
39594  BN.prototype.redAdd = function redAdd (num) {
39595    assert(this.red, 'redAdd works only with red numbers');
39596    return this.red.add(this, num);
39597  };
39598
39599  BN.prototype.redIAdd = function redIAdd (num) {
39600    assert(this.red, 'redIAdd works only with red numbers');
39601    return this.red.iadd(this, num);
39602  };
39603
39604  BN.prototype.redSub = function redSub (num) {
39605    assert(this.red, 'redSub works only with red numbers');
39606    return this.red.sub(this, num);
39607  };
39608
39609  BN.prototype.redISub = function redISub (num) {
39610    assert(this.red, 'redISub works only with red numbers');
39611    return this.red.isub(this, num);
39612  };
39613
39614  BN.prototype.redShl = function redShl (num) {
39615    assert(this.red, 'redShl works only with red numbers');
39616    return this.red.shl(this, num);
39617  };
39618
39619  BN.prototype.redMul = function redMul (num) {
39620    assert(this.red, 'redMul works only with red numbers');
39621    this.red._verify2(this, num);
39622    return this.red.mul(this, num);
39623  };
39624
39625  BN.prototype.redIMul = function redIMul (num) {
39626    assert(this.red, 'redMul works only with red numbers');
39627    this.red._verify2(this, num);
39628    return this.red.imul(this, num);
39629  };
39630
39631  BN.prototype.redSqr = function redSqr () {
39632    assert(this.red, 'redSqr works only with red numbers');
39633    this.red._verify1(this);
39634    return this.red.sqr(this);
39635  };
39636
39637  BN.prototype.redISqr = function redISqr () {
39638    assert(this.red, 'redISqr works only with red numbers');
39639    this.red._verify1(this);
39640    return this.red.isqr(this);
39641  };
39642
39643  // Square root over p
39644  BN.prototype.redSqrt = function redSqrt () {
39645    assert(this.red, 'redSqrt works only with red numbers');
39646    this.red._verify1(this);
39647    return this.red.sqrt(this);
39648  };
39649
vendor: 8,763 bytes, lines 39650-40029
39650  BN.prototype.redInvm = function redInvm () {
39651    assert(this.red, 'redInvm works only with red numbers');
39652    this.red._verify1(this);
39653    return this.red.invm(this);
39654  };
39655
39656  // Return negative clone of `this` % `red modulo`
39657  BN.prototype.redNeg = function redNeg () {
39658    assert(this.red, 'redNeg works only with red numbers');
39659    this.red._verify1(this);
39660    return this.red.neg(this);
39661  };
39662
39663  BN.prototype.redPow = function redPow (num) {
39664    assert(this.red && !num.red, 'redPow(normalNum)');
39665    this.red._verify1(this);
39666    return this.red.pow(this, num);
39667  };
39668
39669  // Prime numbers with efficient reduction
39670  var primes = {
39671    k256: null,
39672    p224: null,
39673    p192: null,
39674    p25519: null
39675  };
39676
39677  // Pseudo-Mersenne prime
39678  function MPrime (name, p) {
39679    // P = 2 ^ N - K
39680    this.name = name;
39681    this.p = new BN(p, 16);
39682    this.n = this.p.bitLength();
39683    this.k = new BN(1).iushln(this.n).isub(this.p);
39684
39685    this.tmp = this._tmp();
39686  }
39687
39688  MPrime.prototype._tmp = function _tmp () {
39689    var tmp = new BN(null);
39690    tmp.words = new Array(Math.ceil(this.n / 13));
39691    return tmp;
39692  };
39693
39694  MPrime.prototype.ireduce = function ireduce (num) {
39695    // Assumes that `num` is less than `P^2`
39696    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
39697    var r = num;
39698    var rlen;
39699
39700    do {
39701      this.split(r, this.tmp);
39702      r = this.imulK(r);
39703      r = r.iadd(this.tmp);
39704      rlen = r.bitLength();
39705    } while (rlen > this.n);
39706
39707    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
39708    if (cmp === 0) {
39709      r.words[0] = 0;
39710      r.length = 1;
39711    } else if (cmp > 0) {
39712      r.isub(this.p);
39713    } else {
39714      r.strip();
39715    }
39716
39717    return r;
39718  };
39719
39720  MPrime.prototype.split = function split (input, out) {
39721    input.iushrn(this.n, 0, out);
39722  };
39723
39724  MPrime.prototype.imulK = function imulK (num) {
39725    return num.imul(this.k);
39726  };
39727
39728  function K256 () {
39729    MPrime.call(
39730      this,
39731      'k256',
39732      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
39733  }
39734  inherits(K256, MPrime);
39735
39736  K256.prototype.split = function split (input, output) {
39737    // 256 = 9 * 26 + 22
39738    var mask = 0x3fffff;
39739
39740    var outLen = Math.min(input.length, 9);
39741    for (var i = 0; i < outLen; i++) {
39742      output.words[i] = input.words[i];
39743    }
39744    output.length = outLen;
39745
39746    if (input.length <= 9) {
39747      input.words[0] = 0;
39748      input.length = 1;
39749      return;
39750    }
39751
39752    // Shift by 9 limbs
39753    var prev = input.words[9];
39754    output.words[output.length++] = prev & mask;
39755
39756    for (i = 10; i < input.length; i++) {
39757      var next = input.words[i] | 0;
39758      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
39759      prev = next;
39760    }
39761    prev >>>= 22;
39762    input.words[i - 10] = prev;
39763    if (prev === 0 && input.length > 10) {
39764      input.length -= 10;
39765    } else {
39766      input.length -= 9;
39767    }
39768  };
39769
39770  K256.prototype.imulK = function imulK (num) {
39771    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
39772    num.words[num.length] = 0;
39773    num.words[num.length + 1] = 0;
39774    num.length += 2;
39775
39776    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
39777    var lo = 0;
39778    for (var i = 0; i < num.length; i++) {
39779      var w = num.words[i] | 0;
39780      lo += w * 0x3d1;
39781      num.words[i] = lo & 0x3ffffff;
39782      lo = w * 0x40 + ((lo / 0x4000000) | 0);
39783    }
39784
39785    // Fast length reduction
39786    if (num.words[num.length - 1] === 0) {
39787      num.length--;
39788      if (num.words[num.length - 1] === 0) {
39789        num.length--;
39790      }
39791    }
39792    return num;
39793  };
39794
39795  function P224 () {
39796    MPrime.call(
39797      this,
39798      'p224',
39799      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
39800  }
39801  inherits(P224, MPrime);
39802
39803  function P192 () {
39804    MPrime.call(
39805      this,
39806      'p192',
39807      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
39808  }
39809  inherits(P192, MPrime);
39810
39811  function P25519 () {
39812    // 2 ^ 255 - 19
39813    MPrime.call(
39814      this,
39815      '25519',
39816      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
39817  }
39818  inherits(P25519, MPrime);
39819
39820  P25519.prototype.imulK = function imulK (num) {
39821    // K = 0x13
39822    var carry = 0;
39823    for (var i = 0; i < num.length; i++) {
39824      var hi = (num.words[i] | 0) * 0x13 + carry;
39825      var lo = hi & 0x3ffffff;
39826      hi >>>= 26;
39827
39828      num.words[i] = lo;
39829      carry = hi;
39830    }
39831    if (carry !== 0) {
39832      num.words[num.length++] = carry;
39833    }
39834    return num;
39835  };
39836
39837  // Exported mostly for testing purposes, use plain name instead
39838  BN._prime = function prime (name) {
39839    // Cached version of prime
39840    if (primes[name]) return primes[name];
39841
39842    var prime;
39843    if (name === 'k256') {
39844      prime = new K256();
39845    } else if (name === 'p224') {
39846      prime = new P224();
39847    } else if (name === 'p192') {
39848      prime = new P192();
39849    } else if (name === 'p25519') {
39850      prime = new P25519();
39851    } else {
39852      throw new Error('Unknown prime ' + name);
39853    }
39854    primes[name] = prime;
39855
39856    return prime;
39857  };
39858
39859  //
39860  // Base reduction engine
39861  //
39862  function Red (m) {
39863    if (typeof m === 'string') {
39864      var prime = BN._prime(m);
39865      this.m = prime.p;
39866      this.prime = prime;
39867    } else {
39868      assert(m.gtn(1), 'modulus must be greater than 1');
39869      this.m = m;
39870      this.prime = null;
39871    }
39872  }
39873
39874  Red.prototype._verify1 = function _verify1 (a) {
39875    assert(a.negative === 0, 'red works only with positives');
39876    assert(a.red, 'red works only with red numbers');
39877  };
39878
39879  Red.prototype._verify2 = function _verify2 (a, b) {
39880    assert((a.negative | b.negative) === 0, 'red works only with positives');
39881    assert(a.red && a.red === b.red,
39882      'red works only with red numbers');
39883  };
39884
39885  Red.prototype.imod = function imod (a) {
39886    if (this.prime) return this.prime.ireduce(a)._forceRed(this);
39887    return a.umod(this.m)._forceRed(this);
39888  };
39889
39890  Red.prototype.neg = function neg (a) {
39891    if (a.isZero()) {
39892      return a.clone();
39893    }
39894
39895    return this.m.sub(a)._forceRed(this);
39896  };
39897
39898  Red.prototype.add = function add (a, b) {
39899    this._verify2(a, b);
39900
39901    var res = a.add(b);
39902    if (res.cmp(this.m) >= 0) {
39903      res.isub(this.m);
39904    }
39905    return res._forceRed(this);
39906  };
39907
39908  Red.prototype.iadd = function iadd (a, b) {
39909    this._verify2(a, b);
39910
39911    var res = a.iadd(b);
39912    if (res.cmp(this.m) >= 0) {
39913      res.isub(this.m);
39914    }
39915    return res;
39916  };
39917
39918  Red.prototype.sub = function sub (a, b) {
39919    this._verify2(a, b);
39920
39921    var res = a.sub(b);
39922    if (res.cmpn(0) < 0) {
39923      res.iadd(this.m);
39924    }
39925    return res._forceRed(this);
39926  };
39927
39928  Red.prototype.isub = function isub (a, b) {
39929    this._verify2(a, b);
39930
39931    var res = a.isub(b);
39932    if (res.cmpn(0) < 0) {
39933      res.iadd(this.m);
39934    }
39935    return res;
39936  };
39937
39938  Red.prototype.shl = function shl (a, num) {
39939    this._verify1(a);
39940    return this.imod(a.ushln(num));
39941  };
39942
39943  Red.prototype.imul = function imul (a, b) {
39944    this._verify2(a, b);
39945    return this.imod(a.imul(b));
39946  };
39947
39948  Red.prototype.mul = function mul (a, b) {
39949    this._verify2(a, b);
39950    return this.imod(a.mul(b));
39951  };
39952
39953  Red.prototype.isqr = function isqr (a) {
39954    return this.imul(a, a.clone());
39955  };
39956
39957  Red.prototype.sqr = function sqr (a) {
39958    return this.mul(a, a);
39959  };
39960
39961  Red.prototype.sqrt = function sqrt (a) {
39962    if (a.isZero()) return a.clone();
39963
39964    var mod3 = this.m.andln(3);
39965    assert(mod3 % 2 === 1);
39966
39967    // Fast case
39968    if (mod3 === 3) {
39969      var pow = this.m.add(new BN(1)).iushrn(2);
39970      return this.pow(a, pow);
39971    }
39972
39973    // Tonelli-Shanks algorithm (Totally unoptimized and slow)
39974    //
39975    // Find Q and S, that Q * 2 ^ S = (P - 1)
39976    var q = this.m.subn(1);
39977    var s = 0;
39978    while (!q.isZero() && q.andln(1) === 0) {
39979      s++;
39980      q.iushrn(1);
39981    }
39982    assert(!q.isZero());
39983
39984    var one = new BN(1).toRed(this);
39985    var nOne = one.redNeg();
39986
39987    // Find quadratic non-residue
39988    // NOTE: Max is such because of generalized Riemann hypothesis.
39989    var lpow = this.m.subn(1).iushrn(1);
39990    var z = this.m.bitLength();
39991    z = new BN(2 * z * z).toRed(this);
39992
39993    while (this.pow(z, lpow).cmp(nOne) !== 0) {
39994      z.redIAdd(nOne);
39995    }
39996
39997    var c = this.pow(z, q);
39998    var r = this.pow(a, q.addn(1).iushrn(1));
39999    var t = this.pow(a, q);
40000    var m = s;
40001    while (t.cmp(one) !== 0) {
40002      var tmp = t;
40003      for (var i = 0; tmp.cmp(one) !== 0; i++) {
40004        tmp = tmp.redSqr();
40005      }
40006      assert(i < m);
40007      var b = this.pow(c, new BN(1).iushln(m - i - 1));
40008
40009      r = r.redMul(b);
40010      c = b.redSqr();
40011      t = t.redMul(c);
40012      m = i;
40013    }
40014
40015    return r;
40016  };
40017
40018  Red.prototype.invm = function invm (a) {
40019    var inv = a._invmp(this.m);
40020    if (inv.negative !== 0) {
40021      inv.negative = 0;
40022      return this.imod(inv).redNeg();
40023    } else {
40024      return this.imod(inv);
40025    }
40026  };
40027
40028  Red.prototype.pow = function pow (a, num) {
40029    if (num.isZero()) return new BN(1)
vendor: 4,249 bytes, lines 40029-40189
40029;
40030    if (num.cmpn(1) === 0) return a.clone();
40031
40032    var windowSize = 4;
40033    var wnd = new Array(1 << windowSize);
40034    wnd[0] = new BN(1).toRed(this);
40035    wnd[1] = a;
40036    for (var i = 2; i < wnd.length; i++) {
40037      wnd[i] = this.mul(wnd[i - 1], a);
40038    }
40039
40040    var res = wnd[0];
40041    var current = 0;
40042    var currentLen = 0;
40043    var start = num.bitLength() % 26;
40044    if (start === 0) {
40045      start = 26;
40046    }
40047
40048    for (i = num.length - 1; i >= 0; i--) {
40049      var word = num.words[i];
40050      for (var j = start - 1; j >= 0; j--) {
40051        var bit = (word >> j) & 1;
40052        if (res !== wnd[0]) {
40053          res = this.sqr(res);
40054        }
40055
40056        if (bit === 0 && current === 0) {
40057          currentLen = 0;
40058          continue;
40059        }
40060
40061        current <<= 1;
40062        current |= bit;
40063        currentLen++;
40064        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
40065
40066        res = this.mul(res, wnd[current]);
40067        currentLen = 0;
40068        current = 0;
40069      }
40070      start = 26;
40071    }
40072
40073    return res;
40074  };
40075
40076  Red.prototype.convertTo = function convertTo (num) {
40077    var r = num.umod(this.m);
40078
40079    return r === num ? r.clone() : r;
40080  };
40081
40082  Red.prototype.convertFrom = function convertFrom (num) {
40083    var res = num.clone();
40084    res.red = null;
40085    return res;
40086  };
40087
40088  //
40089  // Montgomery method engine
40090  //
40091
40092  BN.mont = function mont (num) {
40093    return new Mont(num);
40094  };
40095
40096  function Mont (m) {
40097    Red.call(this, m);
40098
40099    this.shift = this.m.bitLength();
40100    if (this.shift % 26 !== 0) {
40101      this.shift += 26 - (this.shift % 26);
40102    }
40103
40104    this.r = new BN(1).iushln(this.shift);
40105    this.r2 = this.imod(this.r.sqr());
40106    this.rinv = this.r._invmp(this.m);
40107
40108    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
40109    this.minv = this.minv.umod(this.r);
40110    this.minv = this.r.sub(this.minv);
40111  }
40112  inherits(Mont, Red);
40113
40114  Mont.prototype.convertTo = function convertTo (num) {
40115    return this.imod(num.ushln(this.shift));
40116  };
40117
40118  Mont.prototype.convertFrom = function convertFrom (num) {
40119    var r = this.imod(num.mul(this.rinv));
40120    r.red = null;
40121    return r;
40122  };
40123
40124  Mont.prototype.imul = function imul (a, b) {
40125    if (a.isZero() || b.isZero()) {
40126      a.words[0] = 0;
40127      a.length = 1;
40128      return a;
40129    }
40130
40131    var t = a.imul(b);
40132    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
40133    var u = t.isub(c).iushrn(this.shift);
40134    var res = u;
40135
40136    if (u.cmp(this.m) >= 0) {
40137      res = u.isub(this.m);
40138    } else if (u.cmpn(0) < 0) {
40139      res = u.iadd(this.m);
40140    }
40141
40142    return res._forceRed(this);
40143  };
40144
40145  Mont.prototype.mul = function mul (a, b) {
40146    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
40147
40148    var t = a.mul(b);
40149    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
40150    var u = t.isub(c).iushrn(this.shift);
40151    var res = u;
40152    if (u.cmp(this.m) >= 0) {
40153      res = u.isub(this.m);
40154    } else if (u.cmpn(0) < 0) {
40155      res = u.iadd(this.m);
40156    }
40157
40158    return res._forceRed(this);
40159  };
40160
40161  Mont.prototype.invm = function invm (a) {
40162    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
40163    var res = this.imod(a._invmp(this.m).mul(this.r2));
40164    return res._forceRed(this);
40165  };
40166})(typeof module === 'undefined' || module, this);
40167
40168/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(25)(module)))
40169
40170/***/ },
40171/* 2 */
40172/***/ function(module, exports, __webpack_require__) {
40173
40174var BN = __webpack_require__(1);
40175var stripHexPrefix = __webpack_require__(5);
40176
40177/**
40178 * Returns a BN object, converts a number value to a BN
40179 * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object
40180 * @return {Object} `output` BN object of the number
40181 * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number
40182 */
40183module.exports = function numberToBN(arg) {
40184  if (typeof arg === 'string' || typeof arg === 'number') {
40185    var multiplier = new BN(1); // eslint-disable-line
40186    var formattedString = String(arg).toLowerCase().trim();
40187    var isHexPrefixed = formattedString.substr(0, 2) === '0x' || formattedString.substr(0, 3) === '-0x';
40188    var stringArg = stripHexPrefix(formattedString); // eslint-disable-line
40189    if (stringArg.substr(0, 1) === '-') {
40190      stringArg = stripHexPrefix(stringArg.slice(1));
40191      multiplier = new BN(-1, 10);
40192    }
40193    stringArg = stringArg === '' ? '0' : stringArg;
40194
40195    if ((!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/))
40196      || stringArg.match(/^[a-fA-F]+$/)
40197      || (isHexPrefixed === true && stringArg.match(/^[0-9A-Fa-f]+$/))) {
40198      return new BN(stringArg, 16).mul(multiplier);
40199    }
40200
40201    if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) {
40202      return new BN(stringArg, 10).mul(multiplier);
40203    }
40204  } else if (typeof arg === 'object' && arg.toString && (!arg.pop && !arg.push)) {
40205    if (arg.toString(10).match(/^-?[0-9]+$/) && (arg.mul || arg.dividedToIntegerBy)) {
40206      return new BN(arg.toString(10), 10);
40207    }
40208  }
40209
40210  throw new Error('[number-to-bn] while converting number ' + JSON.stringify(arg) + ' to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.');
40211}
40212
40213
40214/***/ },
40215/* 3 */
40216/***/ function(module, exports, __webpack_require__) {
40217
40218"use strict";
40219/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
40220
40221var isHexPrefixed = __webpack_require__(7);
40222var stripHexPrefix = __webpack_require__(5);
40223
40224/**
40225 * Pads a `String` to have an even length
40226 * @param {String} value
40227 * @return {String} output
40228 */
40229function padToEven(value) {
40230  var a = value; // eslint-disable-line
40231
40232  if (typeof a !== 'string') {
40233    throw new Error('[ethjs-util] while padding to even, value must be string, is currently ' + typeof a + ', while padToEven.');
40234  }
40235
40236  if (a.length % 2) {
40237    a = '0' + a;
40238  }
40239
40240  return a;
40241}
40242
40243/**
40244 * Converts a `Number` into a hex `String`
40245 * @param {Number} i
40246 * @return {String}
40247 */
40248function intToHex(i) {
40249  var hex = i.toString(16); // eslint-disable-line
40250
40251  return '0x' + padToEven(hex);
40252}
40253
40254/**
40255 * Converts an `Number` to a `Buffer`
40256 * @param {Number} i
40257 * @return {Buffer}
40258 */
40259function intToBuffer(i) {
40260  var hex = intToHex(i);
40261
40262  return Buffer.from(hex.slice(2), 'hex');
40263}
40264
40265/**
40266 * Get the binary size of a string
40267 * @param {String} str
40268 * @return {Number}
40269 */
40270function getBinarySize(str) {
40271  if (typeof str !== 'string') {
40272    throw new Error('[ethjs-util] while getting binary size, method getBinarySize requires input \'str\' to be type String, got \'' + typeof str + '\'.');
40273  }
40274
40275  return Buffer.byteLength(str, 'utf8');
40276}
40277
40278/**
40279 * Returns TRUE if the first specified array contains all elements
40280 * from the second one. FALSE otherwise.
40281 *
40282 * @param {array} superset
40283 * @param {array} subset
40284 *
40285 * @returns {boolean}
40286 */
40287function arrayContainsArray(superset, subset, some) {
40288  if (Array.isArray(superset) !== true) {
40289    throw new Error('[ethjs-util] method arrayContainsArray requires input \'superset\' to be an array got type \'' + typeof superset + '\'');
40290  }
40291  if (Array.isArray(subset) !== true) {
40292    throw new Error('[ethjs-util] method arrayContainsArray requires input \'subset\' to be an array got type \'' + typeof subset + '\'');
40293  }
40294
40295  return subset[Boolean(some) && 'some' || 'every'](function (value) {
40296    return superset.indexOf(value) >= 0;
40297  });
40298}
40299
40300/**
40301 * Should be called to get utf8 from it's hex representation
40302 *
40303 * @method toUtf8
40304 * @param {String} string in hex
40305 * @returns {String} ascii string representation of hex value
40306 */
40307function toUtf8(hex) {
40308  var bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, '')), 'hex');
40309
40310  return bufferValue.toString('utf8');
40311}
40312
40313/**
40314 * Should be called to get ascii from it's hex representation
40315 *
40316 * @method toAscii
40317 * @param {String} string in hex
40318 * @returns {String} ascii string representation of hex value
40319 */
40320function toAscii(hex) {
40321  var str = ''; // eslint-disable-line
40322  var i = 0,
40323      l = hex.length; // eslint-disable-line
40324
40325  if (hex.substring(0, 2) === '0x') {
40326    i = 2;
40327  }
40328
40329  for (; i < l; i += 2) {
40330    var code = parseInt(hex.substr(i, 2), 16);
40331    str += String.fromCharCode(code);
40332  }
40333
40334  return str;
40335}
40336
40337/**
40338 * Should be called to get hex representation (prefixed by 0x) of utf8 string
40339 *
40340 * @method fromUtf8
40341 * @param {String} string
40342 * @param {Number} optional padding
40343 * @returns {String} hex representation of input string
40344 */
40345function fromUtf8(stringValue) {
40346  var str = new Buffer(stringValue, 'utf8');
40347
40348  return '0x' + padToEven(str.toString('hex')).replace(/^0+|0+$/g, '');
40349}
40350
40351/**
40352 * Should be called to get hex representation (prefixed by 0x) of ascii string
40353 *
40354 * @method fromAscii
40355 * @param {String} string
40356 * @param {Number} optional padding
40357 * @returns {String} hex representation of input string
40358 */
40359function fromAscii(stringValue) {
40360  var hex = ''; // eslint-disable-line
40361  for (var i = 0; i < stringValue.length; i++) {
40362    // eslint-disable-line
40363    var code = stringValue.charCodeAt(i);
40364    var n = code.toString(16);
40365    hex += n.length < 2 ? '0' + n : n;
40366  }
40367
40368  return '0x' + hex;
40369}
40370
40371/**
40372 * getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
40373 *
40374 * @method getKeys get specific key from inner object array of objects
40375 * @param {String} params
40376 * @param {String} key
40377 * @param {Boolean} allowEmpty
40378 * @returns {Array} output just a simple array of output keys
40379 */
40380function getKeys(params, key, allowEmpty) {
40381  if (!Array.isArray(params)) {
40382    throw new Error('[ethjs-util] method getKeys expecting type Array as \'params\' input, got \'' + typeof params + '\'');
40383  }
40384  if (typeof key !== 'string') {
40385    throw new Error('[ethjs-util] method getKeys expecting type Str
40385ing for input \'key\' got \'' + typeof key + '\'.');
40386  }
40387
40388  var result = []; // eslint-disable-line
40389
40390  for (var i = 0; i < params.length; i++) {
40391    // eslint-disable-line
40392    var value = params[i][key]; // eslint-disable-line
40393    if (allowEmpty && !value) {
40394      value = '';
40395    } else if (typeof value !== 'string') {
40396      throw new Error('invalid abi');
40397    }
40398    result.push(value);
40399  }
40400
40401  return result;
40402}
40403
40404/**
40405 * Is the string a hex string.
40406 *
40407 * @method check if string is hex string of specific length
40408 * @param {String} value
40409 * @param {Number} length
40410 * @returns {Boolean} output the string is a hex string
40411 */
40412function isHexString(value, length) {
40413  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
40414    return false;
40415  }
40416
40417  if (length && value.length !== 2 + 2 * length) {
40418    return false;
40419  }
40420
40421  return true;
40422}
40423
40424module.exports = {
40425  arrayContainsArray: arrayContainsArray,
40426  intToBuffer: intToBuffer,
40427  getBinarySize: getBinarySize,
40428  isHexPrefixed: isHexPrefixed,
40429  stripHexPrefix: stripHexPrefix,
40430  padToEven: padToEven,
40431  intToHex: intToHex,
40432  fromAscii: fromAscii,
40433  fromUtf8: fromUtf8,
40434  toAscii: toAscii,
40435  toUtf8: toUtf8,
40436  getKeys: getKeys,
40437  isHexString: isHexString
40438};
40439/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
40440
40441/***/ },
40442/* 4 */
40443/***/ function(module, exports, __webpack_require__) {
40444
40445/* WEBPACK VAR INJECTION */(function(process, global) {/**
40446 * [js-sha3]{@link https://github.com/emn178/js-sha3}
40447 *
40448 * @version 0.5.5
40449 * @author Chen, Yi-Cyuan [[email protected]]
40450 * @copyright Chen, Yi-Cyuan 2015-2016
40451 * @license MIT
40452 */
40453(function (root) {
40454  'use strict';
40455
40456  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
40457  if (NODE_JS) {
40458    root = global;
40459  }
40460  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;
40461  var HEX_CHARS = '0123456789abcdef'.split('');
40462  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
40463  var KECCAK_PADDING = [1, 256, 65536, 16777216];
40464  var PADDING = [6, 1536, 393216, 100663296];
40465  var SHIFT = [0, 8, 16, 24];
40466  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
40467            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 
40468            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 
40469            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
40470            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
40471  var BITS = [224, 256, 384, 512];
40472  var SHAKE_BITS = [128, 256];
40473  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];
40474
40475  var createOutputMethod = function (bits, padding, outputType) {
40476    return function (message) {
40477      return new Keccak(bits, padding, bits).update(message)[outputType]();
40478    }
40479  };
40480
40481  var createShakeOutputMethod = function (bits, padding, outputType) {
40482    return function (message, outputBits) {
40483      return new Keccak(bits, padding, outputBits).update(message)[outputType]();
40484    }
40485  };
40486
40487  var createMethod = function (bits, padding) {
40488    var method = createOutputMethod(bits, padding, 'hex');
40489    method.create = function () {
40490      return new Keccak(bits, padding, bits);
40491    };
40492    method.update = function (message) {
40493      return method.create().update(message);
40494    };
40495    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
40496      var type = OUTPUT_TYPES[i];
40497      method[type] = createOutputMethod(bits, padding, type);
40498    }
40499    return method;
40500  };
40501
40502  var createShakeMethod = function (bits, padding) {
40503    var method = createShakeOutputMethod(bits, padding, 'hex');
40504    method.create = function (outputBits) {
40505      return new Keccak(bits, padding, outputBits);
40506    };
40507    method.update = function (message, outputBits) {
40508      return method.create(outputBits).update(message);
40509    };
40510    for (var i = 0;i < OUTPUT_TYPES.length;++i) {
40511      var type = OUTPUT_TYPES[i];
40512      method[type] = createShakeOutputMethod(bits, padding, type);
40513    }
40514    return method;
40515  };
40516
40517  var algorithms = [
40518    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},
40519    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},
vendor: 11,326 bytes, lines 40520-40868
40520    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}
40521  ];
40522
40523  var methods = {};
40524
40525  for (var i = 0;i < algorithms.length;++i) {
40526    var algorithm = algorithms[i];
40527    var bits  = algorithm.bits;
40528    for (var j = 0;j < bits.length;++j) {
40529      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);
40530    }
40531  }
40532
40533  function Keccak(bits, padding, outputBits) {
40534    this.blocks = [];
40535    this.s = [];
40536    this.padding = padding;
40537    this.outputBits = outputBits;
40538    this.reset = true;
40539    this.block = 0;
40540    this.start = 0;
40541    this.blockCount = (1600 - (bits << 1)) >> 5;
40542    this.byteCount = this.blockCount << 2;
40543    this.outputBlocks = outputBits >> 5;
40544    this.extraBytes = (outputBits & 31) >> 3;
40545
40546    for (var i = 0;i < 50;++i) {
40547      this.s[i] = 0;
40548    }
40549  };
40550
40551  Keccak.prototype.update = function (message) {
40552    var notString = typeof message != 'string';
40553    if (notString && message.constructor == root.ArrayBuffer) {
40554      message = new Uint8Array(message);
40555    }
40556    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, 
40557        blockCount = this.blockCount, index = 0, s = this.s, i, code;
40558    
40559    while (index < length) {
40560      if (this.reset) {
40561        this.reset = false;
40562        blocks[0] = this.block;
40563        for (i = 1;i < blockCount + 1;++i) {
40564          blocks[i] = 0;
40565        }
40566      }
40567      if (notString) {
40568        for (i = this.start;index < length && i < byteCount;++index) {
40569          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
40570        }
40571      } else {
40572        for (i = this.start;index < length && i < byteCount;++index) {
40573          code = message.charCodeAt(index);
40574          if (code < 0x80) {
40575            blocks[i >> 2] |= code << SHIFT[i++ & 3];
40576          } else if (code < 0x800) {
40577            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
40578            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
40579          } else if (code < 0xd800 || code >= 0xe000) {
40580            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
40581            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
40582            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
40583          } else {
40584            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
40585            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
40586            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
40587            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
40588            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
40589          }
40590        }
40591      }
40592      this.lastByteIndex = i;
40593      if (i >= byteCount) {
40594        this.start = i - byteCount;
40595        this.block = blocks[blockCount];
40596        for (i = 0;i < blockCount;++i) {
40597          s[i] ^= blocks[i];
40598        }
40599        f(s);
40600        this.reset = true;
40601      } else {
40602        this.start = i;
40603      }
40604    }
40605    return this;
40606  };
40607
40608  Keccak.prototype.finalize = function () {
40609    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
40610    blocks[i >> 2] |= this.padding[i & 3];
40611    if (this.lastByteIndex == this.byteCount) {
40612      blocks[0] = blocks[blockCount];
40613      for (i = 1;i < blockCount + 1;++i) {
40614        blocks[i] = 0;
40615      }
40616    }
40617    blocks[blockCount - 1] |= 0x80000000;
40618    for (i = 0;i < blockCount;++i) {
40619      s[i] ^= blocks[i];
40620    }
40621    f(s);
40622  };
40623
40624  Keccak.prototype.toString = Keccak.prototype.hex = function () {
40625    this.finalize();
40626
40627    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
40628        extraBytes = this.extraBytes, i = 0, j = 0;
40629    var hex = '', block;
40630    while (j < outputBlocks) {
40631      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
40632        block = s[i];
40633        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
40634               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
40635               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
40636               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
40637      }
40638      if (j % blockCount == 0) {
40639        f(s);
40640        i = 0;
40641      }
40642    }
40643    if (extraBytes) {
40644      block = s[i];
40645      if (extraBytes > 0) {
40646        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
40647      }
40648      if (extraBytes > 1) {
40649        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
40650      }
40651      if (extraBytes > 2) {
40652        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
40653      }
40654    }
40655    return hex;
40656  };
40657
40658  Keccak.prototype.arrayBuffer = function () {
40659    this.finalize();
40660
40661    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
40662        extraBytes = this.extraBytes, i = 0, j = 0;
40663    var bytes = this.outputBits >> 3;
40664    var buffer;
40665    if (extraBytes) {
40666      buffer = new ArrayBuffer((outputBlocks + 1) << 2);
40667    } else {
40668      buffer = new ArrayBuffer(bytes);
40669    }
40670    var array = new Uint32Array(buffer);
40671    while (j < outputBlocks) {
40672      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
40673        array[j] = s[i];
40674      }
40675      if (j % blockCount == 0) {
40676        f(s);
40677      }
40678    }
40679    if (extraBytes) {
40680      array[i] = s[i];
40681      buffer = buffer.slice(0, bytes);
40682    }
40683    return buffer;
40684  };
40685
40686  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
40687
40688  Keccak.prototype.digest = Keccak.prototype.array = function () {
40689    this.finalize();
40690
40691    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, 
40692        extraBytes = this.extraBytes, i = 0, j = 0;
40693    var array = [], offset, block;
40694    while (j < outputBlocks) {
40695      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
40696        offset = j << 2;
40697        block = s[i];
40698        array[offset] = block & 0xFF;
40699        array[offset + 1] = (block >> 8) & 0xFF;
40700        array[offset + 2] = (block >> 16) & 0xFF;
40701        array[offset + 3] = (block >> 24) & 0xFF;
40702      }
40703      if (j % blockCount == 0) {
40704        f(s);
40705      }
40706    }
40707    if (extraBytes) {
40708      offset = j << 2;
40709      block = s[i];
40710      if (extraBytes > 0) {
40711        array[offset] = block & 0xFF;
40712      }
40713      if (extraBytes > 1) {
40714        array[offset + 1] = (block >> 8) & 0xFF;
40715      }
40716      if (extraBytes > 2) {
40717        array[offset + 2] = (block >> 16) & 0xFF;
40718      }
40719    }
40720    return array;
40721  };
40722
40723  var f = function (s) {
40724    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, 
40725        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, 
40726        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, 
40727        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
40728    for (n = 0;n < 48;n += 2) {
40729      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
40730      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
40731      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
40732      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
40733      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
40734      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
40735      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
40736      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
40737      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
40738      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
40739
40740      h = c8 ^ ((c2 << 1) | (c3 >>> 31));
40741      l = c9 ^ ((c3 << 1) | (c2 >>> 31));
40742      s[0] ^= h;
40743      s[1] ^= l;
40744      s[10] ^= h;
40745      s[11] ^= l;
40746      s[20] ^= h;
40747      s[21] ^= l;
40748      s[30] ^= h;
40749      s[31] ^= l;
40750      s[40] ^= h;
40751      s[41] ^= l;
40752      h = c0 ^ ((c4 << 1) | (c5 >>> 31));
40753      l = c1 ^ ((c5 << 1) | (c4 >>> 31));
40754      s[2] ^= h;
40755      s[3] ^= l;
40756      s[12] ^= h;
40757      s[13] ^= l;
40758      s[22] ^= h;
40759      s[23] ^= l;
40760      s[32] ^= h;
40761      s[33] ^= l;
40762      s[42] ^= h;
40763      s[43] ^= l;
40764      h = c2 ^ ((c6 << 1) | (c7 >>> 31));
40765      l = c3 ^ ((c7 << 1) | (c6 >>> 31));
40766      s[4] ^= h;
40767      s[5] ^= l;
40768      s[14] ^= h;
40769      s[15] ^= l;
40770      s[24] ^= h;
40771      s[25] ^= l;
40772      s[34] ^= h;
40773      s[35] ^= l;
40774      s[44] ^= h;
40775      s[45] ^= l;
40776      h = c4 ^ ((c8 << 1) | (c9 >>> 31));
40777      l = c5 ^ ((c9 << 1) | (c8 >>> 31));
40778      s[6] ^= h;
40779      s[7] ^= l;
40780      s[16] ^= h;
40781      s[17] ^= l;
40782      s[26] ^= h;
40783      s[27] ^= l;
40784      s[36] ^= h;
40785      s[37] ^= l;
40786      s[46] ^= h;
40787      s[47] ^= l;
40788      h = c6 ^ ((c0 << 1) | (c1 >>> 31));
40789      l = c7 ^ ((c1 << 1) | (c0 >>> 31));
40790      s[8] ^= h;
40791      s[9] ^= l;
40792      s[18] ^= h;
40793      s[19] ^= l;
40794      s[28] ^= h;
40795      s[29] ^= l;
40796      s[38] ^= h;
40797      s[39] ^= l;
40798      s[48] ^= h;
40799      s[49] ^= l;
40800
40801      b0 = s[0];
40802      b1 = s[1];
40803      b32 = (s[11] << 4) | (s[10] >>> 28);
40804      b33 = (s[10] << 4) | (s[11] >>> 28);
40805      b14 = (s[20] << 3) | (s[21] >>> 29);
40806      b15 = (s[21] << 3) | (s[20] >>> 29);
40807      b46 = (s[31] << 9) | (s[30] >>> 23);
40808      b47 = (s[30] << 9) | (s[31] >>> 23);
40809      b28 = (s[40] << 18) | (s[41] >>> 14);
40810      b29 = (s[41] << 18) | (s[40] >>> 14);
40811      b20 = (s[2] << 1) | (s[3] >>> 31);
40812      b21 = (s[3] << 1) | (s[2] >>> 31);
40813      b2 = (s[13] << 12) | (s[12] >>> 20);
40814      b3 = (s[12] << 12) | (s[13] >>> 20);
40815      b34 = (s[22] << 10) | (s[23] >>> 22);
40816      b35 = (s[23] << 10) | (s[22] >>> 22);
40817      b16 = (s[33] << 13) | (s[32] >>> 19);
40818      b17 = (s[32] << 13) | (s[33] >>> 19);
40819      b48 = (s[42] << 2) | (s[43] >>> 30);
40820      b49 = (s[43] << 2) | (s[42] >>> 30);
40821      b40 = (s[5] << 30) | (s[4] >>> 2);
40822      b41 = (s[4] << 30) | (s[5] >>> 2);
40823      b22 = (s[14] << 6) | (s[15] >>> 26);
40824      b23 = (s[15] << 6) | (s[14] >>> 26);
40825      b4 = (s[25] << 11) | (s[24] >>> 21);
40826      b5 = (s[24] << 11) | (s[25] >>> 21);
40827      b36 = (s[34] << 15) | (s[35] >>> 17);
40828      b37 = (s[35] << 15) | (s[34] >>> 17);
40829      b18 = (s[45] << 29) | (s[44] >>> 3);
40830      b19 = (s[44] << 29) | (s[45] >>> 3);
40831      b10 = (s[6] << 28) | (s[7] >>> 4);
40832      b11 = (s[7] << 28) | (s[6] >>> 4);
40833      b42 = (s[17] << 23) | (s[16] >>> 9);
40834      b43 = (s[16] << 23) | (s[17] >>> 9);
40835      b24 = (s[26] << 25) | (s[27] >>> 7);
40836      b25 = (s[27] << 25) | (s[26] >>> 7);
40837      b6 = (s[36] << 21) | (s[37] >>> 11);
40838      b7 = (s[37] << 21) | (s[36] >>> 11);
40839      b38 = (s[47] << 24) | (s[46] >>> 8);
40840      b39 = (s[46] << 24) | (s[47] >>> 8);
40841      b30 = (s[8] << 27) | (s[9] >>> 5);
40842      b31 = (s[9] << 27) | (s[8] >>> 5);
40843      b12 = (s[18] << 20) | (s[19] >>> 12);
40844      b13 = (s[19] << 20) | (s[18] >>> 12);
40845      b44 = (s[29] << 7) | (s[28] >>> 25);
40846      b45 = (s[28] << 7) | (s[29] >>> 25);
40847      b26 = (s[38] << 8) | (s[39] >>> 24);
40848      b27 = (s[39] << 8) | (s[38] >>> 24);
40849      b8 = (s[48] << 14) | (s[49] >>> 18);
40850      b9 = (s[49] << 14) | (s[48] >>> 18);
40851
40852      s[0] = b0 ^ (~b2 & b4);
40853      s[1] = b1 ^ (~b3 & b5);
40854      s[10] = b10 ^ (~b12 & b14);
40855      s[11] = b11 ^ (~b13 & b15);
40856      s[20] = b20 ^ (~b22 & b24);
40857      s[21] = b21 ^ (~b23 & b25);
40858      s[30] = b30 ^ (~b32 & b34);
40859      s[31] = b31 ^ (~b33 & b35);
40860      s[40] = b40 ^ (~b42 & b44);
40861      s[41] = b41 ^ (~b43 & b45);
40862      s[2] = b2 ^ (~b4 & b6);
40863      s[3] = b3 ^ (~b5 & b7);
40864      s[12] = b12 ^ (~b14 & b16);
40865      s[13] = b13 ^ (~b15 & b17);
40866      s[22] = b22 ^ (~b24 & b26);
40867      s[23] = b23 ^ (~b25 & b27);
40868      s[32] = b32 ^ (~b34 & b36);
40869      s[33] = b33 ^ (~b35 & b37);
40870      s[42] = b42 ^ (~b44 & b46);
40871      s[43] = b43 ^ (~b45 & b47);
40872      s[4] = b4 ^ (~b6 & b8);
40873      s[5] = b5 ^ (~b7 & b9);
40874      s[14] = b14 ^ (~b16 & b18);
40875      s[15] = b15 ^ (~b17 & b19);
40876      s[24] = b24 ^ (~b26 & b28);
40877      s[25] = b25 ^ (~b27 & b29);
40878      s[34] = b34 ^ (~b36 & b38);
40879      s[35] = b35 ^ (~b37 & b39);
40880      s[44] = b44 ^ (~b46 & b48);
40881      s[45] = b45 ^ (~b47 & b49);
40882      s[6] = b6 ^ (~b8 & b0);
40883      s[7] = b7 ^ (~b9 & b1);
40884      s[16] = b16 ^ (~b18 & b10);
40885      s[17] = b17 ^ (~b19 & b11);
40886      s[26] = b26 ^ (~b28 & b20);
40887      s[27] = b27 ^ (~b29 & b21);
40888      s[36] = b36 ^ (~b38 & b30);
40889      s[37] = b37 ^ (~b39 & b31);
40890      s[46] = b46 ^ (~b48 & b40);
40891      s[47] = b47 ^ (~b49 & b41);
40892      s[8] = b8 ^ (~b0 & b2);
40893      s[9] = b9 ^ (~b1 & b3);
40894      s[18] = b18 ^ (~b10 & b12);
40895      s[19] = b19 ^ (~b11 & b13);
40896      s[28] = b28 ^ (~b20 & b22);
40897      s[29] = b29 ^ (~b21 & b23);
40898      s[38] = b38 ^ (~b30 & b32);
40899      s[39] = b39 ^ (~b31 & b33);
40900      s[48] = b48 ^ (~b40 & b42);
40901      s[49] = b49 ^ (~b41 & b43);
40902
40903      s[0] ^= RC[n];
40904      s[1] ^= RC[n + 1];
40905    }
40906  }
40907
40908  if (COMMON_JS) {
40909    module.exports = methods;
40910  } else if (root) {
40911    for (var key in methods) {
40912      root[key] = methods[key];
40913    }
40914  }
40915}(this));
40916
40917/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24), __webpack_require__(8)))
40918
40919/***/ },
40920/* 5 */
40921/***/ function(module, exports, __webpack_require__) {
40922
40923var isHexPrefixed = __webpack_require__(7);
40924
40925/**
40926 * Removes '0x' from a given `String` is present
40927 * @param {String} str the string value
40928 * @return {String|Optional} a string by pass if necessary
40929 */
40930module.exports = function stripHexPrefix(str) {
40931  if (typeof str !== 'string') {
40932    return str;
40933  }
40934
40935  return isHexPrefixed(str) ? str.slice(2) : str;
40936}
40937
40938
40939/***/ },
40940/* 6 */
40941/***/ function(module, exports) {
40942
40943"use strict";
40944'use strict';
40945
40946function constructFilter(filterName, query) {
40947  function Filter(options) {
40948    var self = this;
40949    self.filterId = null;
40950    self.options = Object.assign({
40951      delay: 300,
40952      decoder: function decodeData(data) {
40953        return data;
40954      },
40955      defaultFilterObject: {}
40956    }, options || {});
40957
40958    self.watchers = {};
40959    self.interval = setInterval(function () {
40960      if (self.filterId !== null && Object.keys(self.watchers).length > 0) {
40961        query.getFilterChanges(self.filterId, function (changeError, changeResult) {
40962          var decodedChangeResults = [];
40963          var decodingError = null; // eslint-disable-line
40964
40965          if (!changeError) {
40966            try {
40967              changeResult.forEach(function (log, logIndex) {
40968                decodedChangeResults[logIndex] = changeResult[logIndex];
40969                decodedChangeResults[logIndex].data = self.options.decoder(decodedChangeResults[logIndex].data);
40970              });
40971            } catch (decodingErrorMesage) {
40972              decodingError = new Error('[ethjs-filter] while decoding filter change event data from RPC \'' + JSON.stringify(decodedChangeResults) + '\': ' + decodingErrorMesage);
40973            }
40974          }
40975
40976          Object.keys(self.watchers).forEach(function (id) {
40977            var watcher = self.watchers[id];
40978            if (watcher.stop === true) {
40979              delete self.watchers[id];
40980              return;
40981            }
40982
40983            if (decodingError) {
40984              watcher.reject(decodingError);
40985              watcher.callback(decodingError, null);
40986            } else {
40987              if (changeError) {
40988                watcher.reject(changeError);
40989              } else if (Array.isArray(decodedChangeResults) && changeResult.length > 0) {
40990                watcher.resolve(decodedChangeResults);
40991              }
40992
40993              watcher.callback(changeError, decodedChangeResults);
40994            }
40995          });
40996        });
40997      }
40998    }, self.options.delay);
40999  }
41000
41001  Filter.prototype.at = function atFilter(filterId) {
41002    var self = this;
41003    self.filterId = filterId;
41004  };
41005
41006  Filter.prototype.watch = function watchFilter(watchCallbackInput) {
41007    var callback = watchCallbackInput || function () {}; // eslint-disable-line
41008    var self = this;
41009    var id = Math.random().toString(36).substring(7);
41010    var output = new Promise(function (resolve, reject) {
41011      self.watchers[id] = { resolve: resolve, reject: reject, callback: callback, stop: false };
41012    });
41013
41014    output.stopWatching = function stopWatching() {
41015      self.watchers[id].stop = true;
41016    };
41017
41018    return output;
41019  };
41020
41021  Filter.prototype.uninstall = function uninstallFilter(cb) {
41022    var self = this;
41023    var callback = cb || function emptyCallback() {};
41024    self.watchers = Object.assign({});
41025    clearInterval(self.interval);
41026
41027    return new Promise(function (resolve, reject) {
41028      query.uninstallFilter(self.filterId, function (uninstallError, uninstallResilt) {
41029        if (uninstallError) {
41030          reject(uninstallError);
41031        } else {
41032          resolve(uninstallResilt);
41033        }
41034
41035        callback(uninstallError, uninstallResilt);
41036      });
41037    });
41038  };
41039
41040  Filter.prototype['new'] = function newFilter() {
41041    var callback = function callback() {}; // eslint-disable-line
41042    var self = this;
41043    var filterInputs = [];
41044    var args = [].slice.call(arguments); // eslint-disable-line
41045    // pop callback if provided
41046    if (typeof args[args.length - 1] === 'function') {
41047      callback = args.pop();
41048    }
41049
41050    // if a param object was presented, push that into the inputs
41051    if (filterName === 'Filter') {
41052      filterInputs.push(Object.assign(self.options.defaultFilterObject, args[args.length - 1] || {}));
41053    }
41054
41055    return new Promise(function (resolve, reject) {
41056      // add complex callback
41057      filterInputs.push(function (setupError, filterId) {
41058        if (!setupError) {
41059          self.filterId = filterId;
41060          resolve(filterId);
41061        } else {
41062          reject(setupError);
41063        }
41064
41065        callback(setupError, filterId);
41066      });
41067
41068      // apply filter, call new.. filter method
41069      query['new' + filterName].apply(query, filterInputs);
41070    });
41071  };
41072
41073  return Filter;
41074}
41075
41076/**
41077 * EthFilter constructor, intakes a query, helps manage filter event polling
41078 *
41079 * @method EthFilter
41080 * @param {Object} query the `ethjs-query` or `eth-query` object
41081 * @returns {Object} output an EthFilter instance
41082 * @throws error if new is not used
41083 */
41084
41085function EthFilter(query) {
41086  var self = this;
41087  if (!(self instanceof EthFilter)) {
41088    throw new Error('the EthFilter object must be instantiated with `new` flag.. (e.g. `const filters = new EthFilter(query);`)');
41089  }
41090  if (typeof query !== 'object') {
41091    throw new Error('the EthFilter object must be instantiated with an EthQuery instance (e.g. `const filters = new EthFilter(new EthQuery(provider));`). See github.com/ethjs/ethjs-query for more details..');
41092  }
41093
41094  self.Filter = constructFilter('Filter', query);
41095  self.BlockFilter = constructFilter('BlockFilter', query);
41096  self.PendingTransactionFilter = constructFilter('PendingTransactionFilter', query);
41097}
41098
41099// export EthFilter
41100module.exports = EthFilter;
41101
41102/***/ },
41103/* 7 */
41104/***/ function(module, exports) {
41105
41106/**
41107 * Returns a `Boolean` on whether or not the a `String` starts with '0x'
41108 * @param {String} str the string input value
41109 * @return {Boolean} a boolean if it is or is not hex prefixed
41110 * @throws if the str input is not a string
41111 */
41112module.exports = function isHexPrefixed(str) {
41113  if (typeof str !== 'string') {
41114    throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed.");
41115  }
41116
41117  return str.slice(0, 2) === '0x';
41118}
41119
41120
41121/***/ },
41122/* 8 */
41123/***/ function(module, exports) {
41124
41125var g;
41126
41127// This works in non-strict mode
41128g = (function() { return this; })();
41129
41130try {
41131	// This works if eval is allowed (see CSP)
41132	g = g || Function("return this")() || (1,eval)("this");
41133} catch(e) {
41134	// This works if the window reference is available
41135	if(typeof window === "object")
41136		g = window;
41137}
41138
41139// g can still be undefined, but nothing to do about it...
41140// We return undefined, instead of nothing here, so it's
41141// easier to handle this case. if(!global) { ...}
41142
41143module.exports = g;
41144
41145
41146/***/ },
41147/* 9 */
41148/***/ function(module, exports, __webpack_require__) {
41149
41150"use strict";
41151/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
41152
41153var EthQuery = __webpack_require__(18);
41154var EthFilter = __webpack_require__(6);
41155var EthContract = __webpack_require__(13);
41156var HttpProvider = __webpack_require__(17);
41157var abi = __webpack_require__(11);
41158// const getTxSuccess = require('ethjs-transaction-success'); // eslint-disable-line
41159var unit = __webpack_require__(20);
41160var keccak256 = __webpack_require__(4).keccak_256;
41161var toBN = __webpack_require__(2);
41162var BN = __webpack_require__(1);
41163var utils = __webpack_require__(3);
41164
41165module.exports = Eth;
41166
41167/**
41168 * Returns the ethjs Eth instance.
41169 *
41170 * @method Eth
41171 * @param {Object} cprovider the web3 standard provider object
41172 * @param {Object} options the Eth options object
41173 * @returns {Object} eth Eth object instance
41174 * @throws if the new flag is not used in construction
41175 */
41176
41177function Eth(cprovider, options) {
41178  if (!(this instanceof Eth)) {
41179    throw new Error('[ethjs] the Eth object requires you construct it with the "new" flag (i.e. `const eth = new Eth(...);`).');
41180  }
41181  var self = this;
41182  self.options = options || {};
41183  var query = new EthQuery(cprovider, self.options.query);
41184  Object.keys(Object.getPrototypeOf(query)).forEach(function (methodName) {
41185    self[methodName] = function () {
41186      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
41187        args[_key] = arguments[_key];
41188      }
41189
41190      return query[methodName].apply(query, args);
41191    };
41192  });
41193  self.filter = new EthFilter(query, self.options.query);
41194  self.contract = new EthContract(query, self.options.query);
41195  self.currentProvider = query.rpc.currentProvider;
41196  self.setProvider = query.setProvider;
41197}
41198
41199Eth.BN = BN;
41200Eth.isAddress = function (val) {
41201  return utils.isHexString(val, 20);
41202};
41203Eth.keccak256 = function (val) {
41204  return '0x' + keccak256(val);
41205};
41206Eth.Buffer = Buffer;
41207Eth.isHexString = utils.isHexString;
41208Eth.fromWei = unit.fromWei;
41209Eth.toWei = unit.toWei;
41210Eth.toBN = toBN;
41211Eth.abi = abi;
41212Eth.fromAscii = utils.fromAscii;
41213Eth.toAscii = utils.toAscii;
41214Eth.fromUtf8 = utils.fromUtf8;
41215Eth.toUtf8 = utils.toUtf8;
41216Eth.HttpProvider = HttpProvider;
41217/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
41218
41219/***/ },
41220/* 10 */
41221/***/ function(module, exports) {
41222
41223"use strict";
41224'use strict'
41225
41226exports.byteLength = byteLength
41227exports.toByteArray = toByteArray
41228exports.fromByteArray = fromByteArray
41229
41230var lookup = []
41231var revLookup = []
41232var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
41233
41234var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
41235for (var i = 0, len = code.length; i < len; ++i) {
41236  lookup[i] = code[i]
41237  revLookup[code.charCodeAt(i)] = i
41238}
41239
41240revLookup['-'.charCodeAt(0)] = 62
41241revLookup['_'.charCodeAt(0)] = 63
41242
41243function placeHoldersCount (b64) {
41244  var len = b64.length
41245  if (len % 4 > 0) {
41246    throw new Error('Invalid string. Length must be a multiple of 4')
41247  }
41248
41249  // the number of equal signs (place holders)
41250  // if there are two placeholders, than the two characters before it
41251  // represent one byte
41252  // if there is only one, then the three characters before it represent 2 bytes
41253  // this is just a cheap hack to not do indexOf twice
41254  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
41255}
41256
41257function byteLength (b64) {
41258  // base64 is 4/3 + up to two characters of the original data
41259  return b64.length * 3 / 4 - placeHoldersCount(b64)
41260}
41261
41262function toByteArray (b64) {
41263  var i, j, l, tmp, placeHolders, arr
41264  var len = b64.length
41265  placeHolders = placeHoldersCount(b64)
41266
41267  arr = new Arr(len * 3 / 4 - placeHolders)
41268
41269  // if there are placeholders, only get up to the last complete 4 chars
41270  l = placeHolders > 0 ? len - 4 : len
41271
41272  var L = 0
41273
41274  for (i = 0, j = 0; i < l; i += 4, j += 3) {
41275    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
41276    arr[L++] = (tmp >> 16) & 0xFF
41277    arr[L++] = (tmp >> 8) & 0xFF
41278    arr[L++] = tmp & 0xFF
41279  }
41280
41281  if (placeHolders === 2) {
41282    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
41283    arr[L++] = tmp & 0xFF
41284  } else if (placeHolders === 1) {
41285    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
41286    arr[L++] = (tmp >> 8) & 0xFF
41287    arr[L++] = tmp & 0xFF
41288  }
41289
41290  return arr
41291}
41292
41293function tripletToBase64 (num) {
41294  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
41295}
41296
41297function encodeChunk (uint8, start, end) {
41298  var tmp
41299  var output = []
41300  for (var i = start; i < end; i += 3) {
41301    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
41302    output.push(tripletToBase64(tmp))
41303  }
41304  return output.join('')
41305}
41306
41307function fromByteArray (uint8) {
41308  var tmp
41309  var len = uint8.length
41310  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
41311  var output = ''
41312  var parts = []
41313  var maxChunkLength = 16383 // must be multiple of 3
41314
41315  // go through the array every three bytes, we'll deal with trailing stuff later
41316  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
41317    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
41318  }
41319
41320  // pad the end with zeros, but make sure to not forget the extra bytes
41321  if (extraBytes === 1) {
41322    tmp = uint8[len - 1]
41323    output += lookup[tmp >> 2]
41324    output += lookup[(tmp << 4) & 0x3F]
41325    output += '=='
41326  } else if (extraBytes === 2) {
41327    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
41328    output += lookup[tmp >> 10]
41329    output += lookup[(tmp >> 4) & 0x3F]
41330    output += lookup[(tmp << 2) & 0x3F]
41331    output += '='
41332  }
41333
41334  parts.push(output)
41335
41336  return parts.join('')
41337}
41338
41339
41340/***/ },
41341/* 11 */
41342/***/ function(module, exports, __webpack_require__) {
41343
41344"use strict";
41345/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
41346
41347/* eslint-disable */
41348
41349var utils = __webpack_require__(12);
41350var uint256Coder = utils.uint256Coder;
41351var coderBoolean = utils.coderBoolean;
41352var coderFixedBytes = utils.coderFixedBytes;
41353var coderAddress = utils.coderAddress;
41354var coderDynamicBytes = utils.coderDynamicBytes;
41355var coderString = utils.coderString;
41356var coderArray = utils.coderArray;
41357var paramTypePart = utils.paramTypePart;
41358var getParamCoder = utils.getParamCoder;
41359
41360function Result() {}
41361
41362function encodeParams(types, values) {
41363  if (types.length !== values.length) {
41364    throw new Error('[ethjs-abi] while encoding params, types/values mismatch, Your contract requires ' + types.length + ' types (arguments), and you passed in ' + values.length);
41365  }
41366
41367  var parts = [];
41368
41369  types.forEach(function (type, index) {
41370    var coder = getParamCoder(type);
41371    parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });
41372  });
41373
41374  function alignSize(size) {
41375    return parseInt(32 * Math.ceil(size / 32));
41376  }
41377
41378  var staticSize = 0,
41379      dynamicSize = 0;
41380  parts.forEach(function (part) {
41381    if (part.dynamic) {
41382      staticSize += 32;
41383      dynamicSize += alignSize(part.value.length);
41384    } else {
41385      staticSize += alignSize(part.value.length);
41386    }
41387  });
41388
41389  var offset = 0,
41390      dynamicOffset = staticSize;
41391  var data = new Buffer(staticSize + dynamicSize);
41392
41393  parts.forEach(function (part, index) {
41394    if (part.dynamic) {
41395      uint256Coder.encode(dynamicOffset).copy(data, offset);
41396      offset += 32;
41397
41398      part.value.copy(data, dynamicOffset);
41399      dynamicOffset += alignSize(part.value.length);
41400    } else {
41401      part.value.copy(data, offset);
41402      offset += alignSize(part.value.length);
41403    }
41404  });
41405
41406  return '0x' + data.toString('hex');
41407}
41408
41409// decode bytecode data from output names and types
41410function decodeParams(names, types, data) {
41411  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
41412
41413  // Names is optional, so shift over all the parameters if not provided
41414  if (arguments.length < 3) {
41415    data = types;
41416    types = names;
41417    names = [];
41418  }
41419
41420  data = utils.hexOrBuffer(data);
41421  var values = new Result();
41422
41423  var offset = 0;
41424  types.forEach(function (type, index) {
41425    var coder = getParamCoder(type);
41426    if (coder.dynamic) {
41427      var dynamicOffset = uint256Coder.decode(data, offset);
41428      var result = coder.decode(data, dynamicOffset.value.toNumber());
41429      offset += dynamicOffset.consumed;
41430    } else {
41431      var result = coder.decode(data, offset);
41432      offset += result.consumed;
41433    }
41434    if (useNumberedParams) values[index] = result.value;
41435    if (names[index]) {
41436      values[names[index]] = result.value;
41437    }
41438  });
41439  return values;
41440}
41441
41442// encode method ABI object with values in an array, output bytecode
41443function encodeMethod(method, values) {
41444  var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';
41445  var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');
41446  var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);
41447
41448  return '' + signatureEncoded + paramsEncoded;
41449}
41450
41451// decode method data bytecode, from method ABI object
41452function decodeMethod(method, data) {
41453  var outputNames = utils.getKeys(method.outputs, 'name', true);
41454  var outputTypes = utils.getKeys(method.outputs, 'type');
41455
41456  return decodeParams(outputNames, outputTypes, utils.hexOrBuffer(data));
41457}
41458
41459// decode method data bytecode, from method ABI object
41460function encodeEvent(eventObject, values) {
41461  return encodeMethod(eventObject, values);
41462}
41463
41464function eventSignature(eventObject) {
41465  var signature = eventObject.name + '(' + utils.getKeys(eventObject.inputs, 'type').join(',') + ')';
41466  return '0x' + utils.keccak256(signature);
41467}
41468
41469// decode method data bytecode, from method ABI object
41470function decodeEvent(eventObject, data, topics) {
41471  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
41472
41473  var nonIndexed = eventObject.inputs.filter(function (input) {
41474    return !input.indexed;
41475  });
41476  var nonIndexedNames = utils.getKeys(nonIndexed, 'name', true);
41477  var nonIndexedTypes = utils.getKeys(nonIndexed, 'type');
41478  var event = decodeParams(nonIndexedNames, nonIndexedTypes, utils.hexOrBuffer(data), useNumberedParams);
41479  var topicOffset = eventObject.anonymous ? 0 : 1;
41480  eventObject.inputs.filter(function (input) {
41481    return input.indexed;
41482  }).map(function (input, i) {
41483    var topic = new Buffer(topics[i + topicOffset].slice(2), 'hex');
41484    var coder = getParamCoder(input.type);
41485    event[input.name] = coder.decode(topic, 0).value;
41486  });
41487  event._eventName = eventObject.name;
41488  return event;
41489}
41490
41491// Decode a specific log item with a specific event abi
41492function decodeLogItem(eventObject, log) {
41493  var useNumberedParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
41494
41495  if (eventObject && log.topics[0] === eventSignature(eventObject)) {
41496    return decodeEvent(eventObject, log.data, log.topics, useNumberedParams);
41497  }
41498}
41499
41500// Create a decoder for all events defined in an abi. It returns a function which is called
41501// on an array of log entries such as received from getLogs or getTransactionReceipt and parses
41502// any matching log entries
41503function logDecoder(abi) {
41504  var useNumberedParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
41505
41506  var eventMap = {};
41507  abi.filter(function (item) {
41508    return item.type === 'event';
41509  }).map(function (item) {
41510    eventMap[eventSignature(item)] = item;
41511  });
41512  return function (logItems) {
41513    return logItems.map(function (log) {
41514      return decodeLogItem(eventMap[log.topics[0]], log, useNumberedParams);
41515    }).filter(function (i) {
41516      return i;
41517    });
41518  };
41519}
41520
41521module.exports = {
41522  encodeParams: encodeParams,
41523  decodeParams: decodeParams,
41524  encodeMethod: encodeMethod,
41525  decodeMethod: decodeMethod,
41526  encodeEvent: encodeEvent,
41527  decodeEvent: decodeEvent,
41528  decodeLogItem: decodeLogItem,
41529  logDecoder: logDecoder,
41530  eventSignature: eventSignature
41531};
41532/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
41533
41534/***/ },
41535/* 12 */
41536/***/ function(module, exports, __webpack_require__) {
41537
41538"use strict";
41539/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
41540
41541var BN = __webpack_require__(1);
41542var numberToBN = __webpack_require__(2);
41543var keccak256 = __webpack_require__(4).keccak_256;
41544
41545// from ethereumjs-util
41546function stripZeros(aInput) {
41547  var a = aInput; // eslint-disable-line
41548  var first = a[0]; // eslint-disable-line
41549  while (a.length > 0 && first.toString() === '0') {
41550    a = a.slice(1);
41551    first = a[0];
41552  }
41553  return a;
41554}
41555
41556function bnToBuffer(bnInput) {
41557  var bn = bnInput; // eslint-disable-line
41558  var hex = bn.toString(16); // eslint-disable-line
41559  if (hex.length % 2) {
41560    hex = '0' + hex;
41561  }
41562  return stripZeros(new Buffer(hex, 'hex'));
41563}
41564
41565function isHexString(value, length) {
41566  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
41567    return false;
41568  }
41569  if (length && value.length !== 2 + 2 * length) {
41570    return false;
41571  }
41572  return true;
41573}
41574
41575function hexOrBuffer(valueInput, name) {
41576  var value = valueInput; // eslint-disable-line
41577  if (!Buffer.isBuffer(value)) {
41578    if (!isHexString(value)) {
41579      var error = new Error(name ? '[ethjs-abi] invalid ' + name : '[ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string');
41580      error.reason = '[ethjs-abi] invalid hex string, hex must be prefixed and alphanumeric (e.g. 0x023..)';
41581      error.value = value;
41582      throw error;
41583    }
41584
41585    value = value.substring(2);
41586    if (value.length % 2) {
41587      value = '0' + value;
41588    }
41589    value = new Buffer(value, 'hex');
41590  }
41591
41592  return value;
41593}
41594
41595function hexlify(value) {
41596  if (typeof value === 'number') {
41597    return '0x' + bnToBuffer(new BN(value)).toString('hex');
41598  } else if (value.mod || value.modulo) {
41599    return '0x' + bnToBuffer(value).toString('hex');
41600  } else {
41601    // eslint-disable-line
41602    return '0x' + hexOrBuffer(value).toString('hex');
41603  }
41604}
41605
41606// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
41607function getKeys(params, key, allowEmpty) {
41608  var result = []; // eslint-disable-line
41609
41610  if (!Array.isArray(params)) {
41611    throw new Error('[ethjs-abi] while getting keys, invalid params value ' + JSON.stringify(params));
41612  }
41613
41614  for (var i = 0; i < params.length; i++) {
41615    // eslint-disable-line
41616    var value = params[i][key]; // eslint-disable-line
41617    if (allowEmpty && !value) {
41618      value = '';
41619    } else if (typeof value !== 'string') {
41620      throw new Error('[ethjs-abi] while getKeys found invalid ABI data structure, type value not string');
41621    }
41622    result.push(value);
41623  }
41624
41625  return result;
41626}
41627
41628function coderNumber(size, signed) {
41629  return {
41630    encode: function encodeNumber(valueInput) {
41631      var value = valueInput; // eslint-disable-line
41632
41633      if (typeof value === 'object' && value.toString && (value.toTwos || value.dividedToIntegerBy)) {
41634        value = value.toString(10).split('.')[0];
41635      }
41636
41637      if (typeof value === 'string' || typeof value === 'number') {
41638        value = String(value).split('.')[0];
41639      }
41640
41641      value = numberToBN(value);
41642      value = value.toTwos(size * 8).maskn(size * 8);
41643      if (signed) {
41644        value = value.fromTwos(size * 8).toTwos(256);
41645      }
41646      return value.toArrayLike(Buffer, 'be', 32);
41647    },
41648    decode: function decodeNumber(data, offset) {
41649      var junkLength = 32 - size; // eslint-disable-line
41650      var value = new BN(data.slice(offset + junkLength, offset + 32)); // eslint-disable-line
41651      if (signed) {
41652        value = value.fromTwos(size * 8);
41653      } else {
41654        value = value.maskn(size * 8);
41655      }
41656      return {
41657        consumed: 32,
41658        value: new BN(value.toString(10))
41659      };
41660    }
41661  };
41662}
41663var uint256Coder = coderNumber(32, false);
41664
41665var coderBoolean = {
41666  encode: function encodeBoolean(value) {
41667    return uint256Coder.encode(value ? 1 : 0);
41668  },
41669  decode: function decodeBoolean(data, offset) {
41670    var result = uint256Coder.decode(data, offset); // eslint-disable-line
41671    return {
41672      consumed: result.consumed,
41673      value: !result.value.isZero()
41674    };
41675  }
41676};
41677
41678function coderFixedBytes(length) {
41679  return {
41680    encode: function encodeFixedBytes(valueInput) {
41681      var value = valueInput; // eslint-disable-line
41682      value = hexOrBuffer(value);
41683
41684      if (value.length === 32) {
41685        return value;
41686      }
41687
41688      var result = new Buffer(32); // eslint-disable-line
41689      result.fill(0);
41690      value.copy(result);
41691      return result;
41692    },
41693    decode: function decodeFixedBytes(data, offset) {
41694      if (data.length !== 0 && data.length < offset + 32) {
41695        throw new Error('[ethjs-abi] while decoding fixed bytes, invalid bytes data length: ' + length);
41696      }
41697
41698      return {
41699        consumed: 32,
41700        value: '0x' + data.slice(offset, offset + length).toString('hex')
41701      };
41702    }
41703  };
41704}
41705
41706var coderAddress = {
41707  encode: function encodeAddress(valueInput) {
41708    var value = valueInput; // eslint-disable-line
41709    var result = new Buffer(32); // eslint-disable-line
41710    if (!isHexString(value, 20)) {
41711      throw new Error('[ethjs-abi] while encoding address, invalid address value, not alphanumeric 20 byte hex string');
41712    }
41713    value = hexOrBuffer(value);
41714    result.fill(0);
41715    value.copy(result, 12);
41716    return result;
41717  },
41718  decode: function decodeAddress(data, offset) {
41719    if (data.length === 0) {
41720      return {
41721        consumed: 32,
41722        value: '0x'
41723      };
41724    }
41725    if (data.length !== 0 && data.length < offset + 32) {
41726      throw new Error('[ethjs-abi] while decoding address data, invalid address data, invalid byte length ' + data.length);
41727    }
41728    return {
41729      consumed: 32,
41730      value: '0x' + data.slice(offset + 12, offset + 32).toString('hex')
41731    };
41732  }
41733};
41734
41735function encodeDynamicBytesHelper(value) {
41736  var dataLength = parseInt(32 * Math.ceil(value.length / 32)); // eslint-disable-line
41737  var padding = new Buffer(dataLength - value.length); // eslint-disable-line
41738  padding.fill(0);
41739
41740  return Buffer.concat([uint256Coder.encode(value.length), value, padding]);
41741}
41742
41743function decodeDynamicBytesHelper(data, offset) {
41744  if (data.length !== 0 && data.length < offset + 32) {
41745    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32));
41746  }
41747
41748  var length = uint256Coder.decode(data, offset).value; // eslint-disable-line
41749  length = length.toNumber();
41750  if (data.length !== 0 && data.length < offset + 32 + length) {
41751    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32 + length));
41752  }
41753
41754  return {
41755    consumed: parseInt(32 + 32 * Math.ceil(length / 32), 10),
41756    value: data.slice(offset + 32, offset + 32 + length)
41757  };
41758}
41759
41760var coderDynamicBytes = {
41761  encode: function encodeDynamicBytes(value) {
41762    return encodeDynamicBytesHelper(hexOrBuffer(value));
41763  },
41764  decode: function decodeDynamicBytes(data, offset) {
41765    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line
41766    result.value = '0x' + result.value.toString('hex');
41767    return result;
41768  },
41769  dynamic: true
41770};
41771
41772var coderString = {
41773  encode: function encodeString(value) {
41774    return encodeDynamicBytesHelper(new Buffer(value, 'utf8'));
41775  },
41776  decode: function decodeString(data, offset) {
41777    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line
41778    result.value = result.value.toString('utf8');
41779    return result;
41780  },
41781  dynamic: true
41782};
41783
41784function coderArray(coder, lengthInput) {
41785  return {
41786    encode: function encodeArray(value) {
41787      var result = new Buffer(0); // eslint-disable-line
41788      var length = lengthInput; // eslint-disable-line
41789
41790      if (!Array.isArray(value)) {
41791        throw new Error('[ethjs-abi] while encoding array, invalid array data, not type Object (Array)');
41792      }
41793
41794      if (length === -1) {
41795        length = value.length;
41796        result = uint256Coder.encode(length);
41797      }
41798
41799      if (length !== value.length) {
41800        throw new Error('[ethjs-abi] while encoding array, size mismatch array length ' + length + ' does not equal ' + value.length);
41801      }
41802
41803      value.forEach(function (resultValue) {
41804        result = Buffer.concat([result, coder.encode(resultValue)]);
41805      });
41806
41807      return result;
41808    },
41809    decode: function decodeArray(data, offsetInput) {
41810      var length = lengthInput; // eslint-disable-line
41811      var offset = offsetInput; // eslint-disable-line
41812      // @TODO:
41813      // if (data.length < offset + length * 32) { throw new Error('invalid array'); }
41814
41815      var consumed = 0; // eslint-disable-line
41816      var decodeResult; // eslint-disable-line
41817
41818      if (length === -1) {
41819        decodeResult = uint256Coder.decode(data, offset);
41820        length = decodeResult.value.toNumber();
41821        consumed += decodeResult.consumed;
41822        offset += decodeResult.consumed;
41823      }
41824
41825      var value = []; // eslint-disable-line
41826
41827      for (var i = 0; i < length; i++) {
41828        // eslint-disable-line
41829        var loopResult = coder.decode(data, offset);
41830        consumed += loopResult.consumed;
41831        offset += loopResult.consumed;
41832        value.push(loopResult.value);
41833      }
41834
41835      return {
41836        consumed: consumed,
41837        value: value
41838      };
41839    },
41840    dynamic: lengthInput === -1
41841  };
41842}
41843
41844// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and
41845// build the coder up from its parts
41846var paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\[([0-9]*)\]))/);
41847
41848function getParamCoder(typeInput) {
41849  var type = typeInput; // eslint-disable-line
41850  var coder = null; // eslint-disable-line
41851  var invalidTypeErrorMessage = '[ethjs-abi] while getting param coder (getParamCoder) type value ' + JSON.stringify(type) + ' is either invalid or unsupported by ethjs-abi.';
41852
41853  while (type) {
41854    var part = type.match(paramTypePart); // eslint-disable-line
41855    if (!part) {
41856      throw new Error(invalidTypeErrorMessage);
41857    }
41858    type = type.substring(part[0].length);
41859
41860    var prefix = part[2] || part[4] || part[5]; // eslint-disable-line
41861    switch (prefix) {
41862      case 'int':case 'uint':
41863        if (coder) {
41864          throw new Error(invalidTypeErrorMessage);
41865        }
41866        var intSize = parseInt(part[3] || 256); // eslint-disable-line
41867        if (intSize === 0 || intSize > 256 || intSize % 8 !== 0) {
41868          throw new Error('[ethjs-abi] while getting param coder for type ' + type + ', invalid ' + prefix + '<N> width: ' + type);
41869        }
41870
41871        coder = coderNumber(intSize / 8, prefix === 'int');
41872        break;
41873
41874      case 'bool':
41875        if (coder) {
41876          throw new Error(invalidTypeErrorMessage);
41877        }
41878        coder = coderBoolean;
41879        break;
41880
41881      case 'string':
41882        if (coder) {
41883          throw new Error(invalidTypeErrorMessage);
41884        }
41885        coder = coderString;
41886        break;
41887
41888      case 'bytes':
41889        if (coder) {
41890          throw new Error(invalidTypeErrorMessage);
41891        }
41892        if (part[3]) {
41893          var size = parseInt(part[3]); // eslint-disable-line
41894          if (size === 0 || size > 32) {
41895            throw new Error('[ethjs-abi] while getting param coder for prefix bytes, invalid type ' + type + ', size ' + size + ' should be 0 or greater than 32');
41896          }
41897          coder = coderFixedBytes(size);
41898        } else {
41899          coder = coderDynamicBytes;
41900        }
41901        break;
41902
41903      case 'address':
41904        if (coder) {
41905          throw new Error(invalidTypeErrorMessage);
41906        }
41907        coder = coderAddress;
41908        break;
41909
41910      case '[]':
41911        if (!coder || coder.dynamic) {
41912          throw new Error(invalidTypeErrorMessage);
41913        }
41914        coder = coderArray(coder, -1);
41915        break;
41916
41917      // "[0-9+]"
41918      default:
41919        if (!coder || coder.dynamic) {
41920          throw new Error(invalidTypeErrorMessage);
41921        }
41922        var defaultSize = parseInt(part[6]); // eslint-disable-line
41923        coder = coderArray(coder, defaultSize);
41924    }
41925  }
41926
41927  if (!coder) {
41928    throw new Error(invalidTypeErrorMessage);
41929  }
41930  return coder;
41931}
41932
41933module.exports = {
41934  BN: BN,
41935  bnToBuffer: bnToBuffer,
41936  isHexString: isHexString,
41937  hexOrBuffer: hexOrBuffer,
41938  hexlify: hexlify,
41939  stripZeros: stripZeros,
41940
41941  keccak256: keccak256,
41942
41943  getKeys: getKeys,
41944  numberToBN: numberToBN,
41945  coderNumber: coderNumber,
41946  uint256Coder: uint256Coder,
41947  coderBoolean: coderBoolean,
41948  coderFixedBytes: coderFixedBytes,
41949  coderAddress: coderAddress,
41950  coderDynamicBytes: coderDynamicBytes,
41951  coderString: coderString,
41952  coderArray: coderArray,
41953  paramTypePart: paramTypePart,
41954  getParamCoder: getParamCoder
41955};
41956/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
41957
41958/***/ },
41959/* 13 */
41960/***/ function(module, exports, __webpack_require__) {
41961
41962"use strict";
41963'use strict';
41964
41965var abi = __webpack_require__(14); // eslint-disable-line
41966var keccak256 = __webpack_require__(4).keccak_256; // eslint-disable-line
41967var EthFilter = __webpack_require__(6); // eslint-disable-line
41968var getKeys = __webpack_require__(3).getKeys; // eslint-disable-line
41969var arrayContainsArray = __webpack_require__(3).arrayContainsArray;
41970
41971function hasTransactionObject(args) {
41972  var txObjectProperties = ['from', 'to', 'data', 'value', 'gasPrice', 'gas'];
41973  if (typeof args === 'object' && Array.isArray(args) === true && args.length > 0) {
41974    if (typeof args[args.length - 1] === 'object' && (Object.keys(args[args.length - 1]).length === 0 || arrayContainsArray(Object.keys(args[args.length - 1]), txObjectProperties, true))) {
41975      return true;
41976    }
41977  }
41978
41979  return false;
41980}
41981
41982function getConstructorFromABI(contractABI) {
41983  return contractABI.filter(function (json) {
41984    return json.type === 'constructor';
41985  })[0];
41986}
41987
41988function getCallableMethodsFromABI(contractABI) {
41989  return contractABI.filter(function (json) {
41990    return (json.type === 'function' || json.type === 'event') && json.name.length > 0;
41991  });
41992}
41993
41994function contractFactory(query) {
41995  return function ContractFactory(contractABI, contractBytecode, contractDefaultTxObject) {
41996    if (!Array.isArray(contractABI)) {
41997      throw new Error('[ethjs-contract] Contract ABI must be type Array, got type ' + typeof contractABI);
41998    }
41999    if (typeof contractBytecode !== 'undefined' && typeof contractBytecode !== 'string') {
42000      throw new Error('[ethjs-contract] Contract bytecode must be type String, got type ' + typeof contractBytecode);
42001    }
42002    if (typeof contractDefaultTxObject !== 'undefined' && typeof contractDefaultTxObject !== 'object') {
42003      throw new Error('[ethjs-contract] Contract default tx object must be type Object, got type ' + typeof contractABI);
42004    }
42005
42006    var output = {};
42007    output.at = function atContract(address) {
42008      function Contract() {
42009        var self = this;
42010        self.abi = contractABI || [];
42011        self.query = query;
42012        self.address = address || '0x';
42013        self.bytecode = contractBytecode || '0x';
42014        self.defaultTxObject = contractDefaultTxObject || {};
42015        self.filters = new EthFilter(query);
42016
42017        getCallableMethodsFromABI(contractABI).forEach(function (methodObject) {
42018          self[methodObject.name] = function contractMethod() {
42019            // eslint-disable-line
42020            var queryMethod = 'call'; // eslint-disable-line
42021            var providedTxObject = {}; // eslint-disable-line
42022            var methodCallback = function methodCallback() {}; // eslint-disable-line
42023            var methodArgs = [].slice.call(arguments); // eslint-disable-line
42024            if (typeof methodArgs[methodArgs.length - 1] === 'function') {
42025              methodCallback = methodArgs.pop();
42026            }
42027
42028            if (methodObject.type === 'function') {
42029              return new Promise(function (resolve, reject) {
42030                function newMethodCallback(callbackError, callbackResult) {
42031                  if (queryMethod === 'call' && !callbackError) {
42032                    try {
42033                      var decodedMethodResult = abi.decodeMethod(methodObject, callbackResult);
42034
42035                      resolve(decodedMethodResult);
42036                      methodCallback(null, decodedMethodResult);
42037                    } catch (decodeFormattingError) {
42038                      var decodingError = new Error('[ethjs-contract] while formatting incoming raw call data ' + JSON.stringify(callbackResult) + ' ' + decodeFormattingError);
42039
42040                      reject(decodingError);
42041                      methodCallback(decodingError, null);
42042                    }
42043                  } else if (queryMethod === 'sendTransaction' && !callbackError) {
42044                    resolve(callbackResult);
42045                    methodCallback(null, callbackResult);
42046                  } else {
42047                    reject(callbackError);
42048                    methodCallback(callbackError, null);
42049                  }
42050                }
42051
42052                if (hasTransactionObject(methodArgs)) providedTxObject = methodArgs.pop();
42053                var methodTxObject = Object.assign({}, self.defaultTxObject, providedTxObject, {
42054                  to: self.address
42055                });
42056                methodTxObject.data = abi.encodeMethod(methodObject, methodArgs);
42057
42058                if (methodObject.constant === false) {
42059                  queryMethod = 'sendTransaction';
42060                }
42061
42062                query[queryMethod](methodTxObject, newMethodCallback);
42063              });
42064            } else if (methodObject.type === 'event') {
42065              var _ret = function () {
42066                var filterInputTypes = getKeys(methodObject.inputs, 'type', false);
42067                var filterTopic = '0x' + keccak256(methodObject.name + '(' + filterInputTypes.join(',') + ')');
42068                var filterTopcis = [filterTopic];
42069                var argsObject = Object.assign({}, methodArgs[0]) || {};
42070
42071                return {
42072                  v: new self.filters.Filter(Object.assign({}, argsObject, {
42073                    decoder: function decoder(logData) {
42074                      return abi.decodeEvent(methodObject, logData, filterTopcis);
42075                    },
42076                    defaultFilterObject: Object.assign({}, methodArgs[0] || {}, {
42077                      to: self.address,
42078                      topics: filterTopcis
42079                    })
42080                  }))
42081                };
42082              }();
42083
42084              if (typeof _ret === "object") return _ret.v;
42085            }
42086          };
42087        });
42088      }
42089
42090      return new Contract();
42091    };
42092
42093    output['new'] = function newContract() {
42094      var providedTxObject = {}; // eslint-disable-line
42095      var newMethodCallback = function newMethodCallback() {}; // eslint-disable-line
42096      var newMethodArgs = [].slice.call(arguments); // eslint-disable-line
42097      if (typeof newMethodArgs[newMethodArgs.length - 1] === 'function') newMethodCallback = newMethodArgs.pop();
42098      if (hasTransactionObject(newMethodArgs)) providedTxObject = newMethodArgs.pop();
42099      var constructMethod = getConstructorFromABI(contractABI);
42100      var assembleTxObject = Object.assign({}, contractDefaultTxObject, providedTxObject);
42101
42102      // if contract bytecode was predefined
42103      if (contractBytecode) {
42104        assembleTxObject.data = contractBytecode;
42105      }
42106
42107      // if constructor bytecode
42108      if (constructMethod) {
42109        var constructBytecode = abi.encodeParams(getKeys(constructMethod.inputs, 'type'), newMethodArgs).substring(2); // eslint-disable-line
42110        assembleTxObject.data = '' + assembleTxObject.data + constructBytecode;
42111      }
42112
42113      return query.sendTransaction(assembleTxObject, newMethodCallback);
42114    };
42115
42116    return output;
42117  };
42118}
42119
42120function EthContract(query) {
42121  return contractFactory(query);
42122}
42123
42124module.exports = EthContract;
42125
42126/***/ },
42127/* 14 */
42128/***/ function(module, exports, __webpack_require__) {
42129
42130"use strict";
42131/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
42132
42133/* eslint-disable */
42134
42135var utils = __webpack_require__(15);
42136var uint256Coder = utils.uint256Coder;
42137var coderBoolean = utils.coderBoolean;
42138var coderFixedBytes = utils.coderFixedBytes;
42139var coderAddress = utils.coderAddress;
42140var coderDynamicBytes = utils.coderDynamicBytes;
42141var coderString = utils.coderString;
42142var coderArray = utils.coderArray;
42143var paramTypePart = utils.paramTypePart;
42144var getParamCoder = utils.getParamCoder;
42145
42146function Result() {}
42147
42148function encodeParams(types, values) {
42149  if (types.length !== values.length) {
42150    throw new Error('[ethjs-abi] while encoding params, types/values mismatch, Your contract requires ' + types.length + ' types (arguments), and you passed in ' + values.length);
42151  }
42152
42153  var parts = [];
42154
42155  types.forEach(function (type, index) {
42156    var coder = getParamCoder(type);
42157    parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });
42158  });
42159
42160  function alignSize(size) {
42161    return parseInt(32 * Math.ceil(size / 32));
42162  }
42163
42164  var staticSize = 0,
42165      dynamicSize = 0;
42166  parts.forEach(function (part) {
42167    if (part.dynamic) {
42168      staticSize += 32;
42169      dynamicSize += alignSize(part.value.length);
42170    } else {
42171      staticSize += alignSize(part.value.length);
42172    }
42173  });
42174
42175  var offset = 0,
42176      dynamicOffset = staticSize;
42177  var data = new Buffer(staticSize + dynamicSize);
42178
42179  parts.forEach(function (part, index) {
42180    if (part.dynamic) {
42181      uint256Coder.encode(dynamicOffset).copy(data, offset);
42182      offset += 32;
42183
42184      part.value.copy(data, dynamicOffset);
42185      dynamicOffset += alignSize(part.value.length);
42186    } else {
42187      part.value.copy(data, offset);
42188      offset += alignSize(part.value.length);
42189    }
42190  });
42191
42192  return '0x' + data.toString('hex');
42193}
42194
42195// decode bytecode data from output names and types
42196function decodeParams(names, types, data) {
42197  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
42198
42199  // Names is optional, so shift over all the parameters if not provided
42200  if (arguments.length < 3) {
42201    data = types;
42202    types = names;
42203    names = [];
42204  }
42205
42206  data = utils.hexOrBuffer(data);
42207  var values = new Result();
42208
42209  var offset = 0;
42210  types.forEach(function (type, index) {
42211    var coder = getParamCoder(type);
42212    if (coder.dynamic) {
42213      var dynamicOffset = uint256Coder.decode(data, offset);
42214      var result = coder.decode(data, dynamicOffset.value.toNumber());
42215      offset += dynamicOffset.consumed;
42216    } else {
42217      var result = coder.decode(data, offset);
42218      offset += result.consumed;
42219    }
42220    if (useNumberedParams) values[index] = result.value;
42221    if (names[index]) {
42222      values[names[index]] = result.value;
42223    }
42224  });
42225  return values;
42226}
42227
42228// encode method ABI object with values in an array, output bytecode
42229function encodeMethod(method, values) {
42230  var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';
42231  var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');
42232  var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);
42233
42234  return '' + signatureEncoded + paramsEncoded;
42235}
42236
42237// decode method data bytecode, from method ABI object
42238function decodeMethod(method, data) {
42239  var outputNames = utils.getKeys(method.outputs, 'name', true);
42240  var outputTypes = utils.getKeys(method.outputs, 'type');
42241
42242  return decodeParams(outputNames, outputTypes, utils.hexOrBuffer(data));
42243}
42244
42245// decode method data bytecode, from method ABI object
42246function encodeEvent(eventObject, values) {
42247  return encodeMethod(eventObject, values);
42248}
42249
42250function eventSignature(eventObject) {
42251  var signature = eventObject.name + '(' + utils.getKeys(eventObject.inputs, 'type').join(',') + ')';
42252  return '0x' + utils.keccak256(signature);
42253}
42254
42255// decode method data bytecode, from method ABI object
42256function decodeEvent(eventObject, data, topics) {
42257  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
42258
42259  var nonIndexed = eventObject.inputs.filter(function (input) {
42260    return !input.indexed;
42261  });
42262  var nonIndexedNames = utils.getKeys(nonIndexed, 'name', true);
42263  var nonIndexedTypes = utils.getKeys(nonIndexed, 'type');
42264  var event = decodeParams(nonIndexedNames, nonIndexedTypes, utils.hexOrBuffer(data), useNumberedParams);
42265  var topicOffset = eventObject.anonymous ? 0 : 1;
42266  eventObject.inputs.filter(function (input) {
42267    return input.indexed;
42268  }).map(function (input, i) {
42269    var topic = new Buffer(topics[i + topicOffset].slice(2), 'hex');
42270    var coder = getParamCoder(input.type);
42271    event[input.name] = coder.decode(topic, 0).value;
42272  });
42273  event._eventName = eventObject.name;
42274  return event;
42275}
42276
42277// Decode a specific log item with a specific event abi
42278function decodeLogItem(eventObject, log) {
42279  var useNumberedParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
42280
42281  if (eventObject && log.topics[0] === eventSignature(eventObject)) {
42282    return decodeEvent(eventObject, log.data, log.topics, useNumberedParams);
42283  }
42284}
42285
42286// Create a decoder for all events defined in an abi. It returns a function which is called
42287// on an array of log entries such as received from getLogs or getTransactionReceipt and parses
42288// any matching log entries
42289function logDecoder(abi) {
42290  var useNumberedParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
42291
42292  var eventMap = {};
42293  abi.filter(function (item) {
42294    return item.type === 'event';
42295  }).map(function (item) {
42296    eventMap[eventSignature(item)] = item;
42297  });
42298  return function (logItems) {
42299    return logItems.map(function (log) {
42300      return decodeLogItem(eventMap[log.topics[0]], log, useNumberedParams);
42301    }).filter(function (i) {
42302      return i;
42303    });
42304  };
42305}
42306
42307module.exports = {
42308  encodeParams: encodeParams,
42309  decodeParams: decodeParams,
42310  encodeMethod: encodeMethod,
42311  decodeMethod: decodeMethod,
42312  encodeEvent: encodeEvent,
42313  decodeEvent: decodeEvent,
42314  decodeLogItem: decodeLogItem,
42315  logDecoder: logDecoder,
42316  eventSignature: eventSignature
42317};
42318/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
42319
42320/***/ },
42321/* 15 */
42322/***/ function(module, exports, __webpack_require__) {
42323
42324"use strict";
42325/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
42326
42327var BN = __webpack_require__(1);
42328var numberToBN = __webpack_require__(2);
42329var keccak256 = __webpack_require__(4).keccak_256;
42330
42331// from ethereumjs-util
42332function stripZeros(aInput) {
42333  var a = aInput; // eslint-disable-line
42334  var first = a[0]; // eslint-disable-line
42335  while (a.length > 0 && first.toString() === '0') {
42336    a = a.slice(1);
42337    first = a[0];
42338  }
42339  return a;
42340}
42341
42342function bnToBuffer(bnInput) {
42343  var bn = bnInput; // eslint-disable-line
42344  var hex = bn.toString(16); // eslint-disable-line
42345  if (hex.length % 2) {
42346    hex = '0' + hex;
42347  }
42348  return stripZeros(new Buffer(hex, 'hex'));
42349}
42350
42351function isHexString(value, length) {
42352  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
42353    return false;
42354  }
42355  if (length && value.length !== 2 + 2 * length) {
42356    return false;
42357  }
42358  return true;
42359}
42360
42361function hexOrBuffer(valueInput, name) {
42362  var value = valueInput; // eslint-disable-line
42363  if (!Buffer.isBuffer(value)) {
42364    if (!isHexString(value)) {
42365      var error = new Error(name ? '[ethjs-abi] invalid ' + name : '[ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string');
42366      error.reason = '[ethjs-abi] invalid hex string, hex must be prefixed and alphanumeric (e.g. 0x023..)';
42367      error.value = value;
42368      throw error;
42369    }
42370
42371    value = value.substring(2);
42372    if (value.length % 2) {
42373      value = '0' + value;
42374    }
42375    value = new Buffer(value, 'hex');
42376  }
42377
42378  return value;
42379}
42380
42381function hexlify(value) {
42382  if (typeof value === 'number') {
42383    return '0x' + bnToBuffer(new BN(value)).toString('hex');
42384  } else if (value.mod || value.modulo) {
42385    return '0x' + bnToBuffer(value).toString('hex');
42386  } else {
42387    // eslint-disable-line
42388    return '0x' + hexOrBuffer(value).toString('hex');
42389  }
42390}
42391
42392// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
42393function getKeys(params, key, allowEmpty) {
42394  var result = []; // eslint-disable-line
42395
42396  if (!Array.isArray(params)) {
42397    throw new Error('[ethjs-abi] while getting keys, invalid params value ' + JSON.stringify(params));
42398  }
42399
42400  for (var i = 0; i < params.length; i++) {
42401    // eslint-disable-line
42402    var value = params[i][key]; // eslint-disable-line
42403    if (allowEmpty && !value) {
42404      value = '';
42405    } else if (typeof value !== 'string') {
42406      throw new Error('[ethjs-abi] while getKeys found invalid ABI data structure, type value not string');
42407    }
42408    result.push(value);
42409  }
42410
42411  return result;
42412}
42413
42414function coderNumber(size, signed) {
42415  return {
42416    encode: function encodeNumber(valueInput) {
42417      var value = valueInput; // eslint-disable-line
42418
42419      if (typeof value === 'object' && value.toString && (value.toTwos || value.dividedToIntegerBy)) {
42420        value = value.toString(10).split('.')[0];
42421      }
42422
42423      if (typeof value === 'string' || typeof value === 'number') {
42424        value = String(value).split('.')[0];
42425      }
42426
42427      value = numberToBN(value);
42428      value = value.toTwos(size * 8).maskn(size * 8);
42429      if (signed) {
42430        value = value.fromTwos(size * 8).toTwos(256);
42431      }
42432      return value.toArrayLike(Buffer, 'be', 32);
42433    },
42434    decode: function decodeNumber(data, offset) {
42435      var junkLength = 32 - size; // eslint-disable-line
42436      var value = new BN(data.slice(offset + junkLength, offset + 32)); // eslint-disable-line
42437      if (signed) {
42438        value = value.fromTwos(size * 8);
42439      } else {
42440        value = value.maskn(size * 8);
42441      }
42442      return {
42443        consumed: 32,
42444        value: new BN(value.toString(10))
42445      };
42446    }
42447  };
42448}
42449var uint256Coder = coderNumber(32, false);
42450
42451var coderBoolean = {
42452  encode: function encodeBoolean(value) {
42453    return uint256Coder.encode(value ? 1 : 0);
42454  },
42455  decode: function decodeBoolean(data, offset) {
42456    var result = uint256Coder.decode(data, offset); // eslint-disable-line
42457    return {
42458      consumed: result.consumed,
42459      value: !result.value.isZero()
42460    };
42461  }
42462};
42463
42464function coderFixedBytes(length) {
42465  return {
42466    encode: function encodeFixedBytes(valueInput) {
42467      var value = valueInput; // eslint-disable-line
42468      value = hexOrBuffer(value);
42469
42470      if (value.length === 32) {
42471        return value;
42472      }
42473
42474      var result = new Buffer(32); // eslint-disable-line
42475      result.fill(0);
42476      value.copy(result);
42477      return result;
42478    },
42479    decode: function decodeFixedBytes(data, offset) {
42480      if (data.length !== 0 && data.length < offset + 32) {
42481        throw new Error('[ethjs-abi] while decoding fixed bytes, invalid bytes data length: ' + length);
42482      }
42483
42484      return {
42485        consumed: 32,
42486        value: '0x' + data.slice(offset, offset + length).toString('hex')
42487      };
42488    }
42489  };
42490}
42491
42492var coderAddress = {
42493  encode: function encodeAddress(valueInput) {
42494    var value = valueInput; // eslint-disable-line
42495    var result = new Buffer(32); // eslint-disable-line
42496    if (!isHexString(value, 20)) {
42497      throw new Error('[ethjs-abi] while encoding address, invalid address value, not alphanumeric 20 byte hex string');
42498    }
42499    value = hexOrBuffer(value);
42500    result.fill(0);
42501    value.copy(result, 12);
42502    return result;
42503  },
42504  decode: function decodeAddress(data, offset) {
42505    if (data.length === 0) {
42506      return {
42507        consumed: 32,
42508        value: '0x'
42509      };
42510    }
42511    if (data.length !== 0 && data.length < offset + 32) {
42512      throw new Error('[ethjs-abi] while decoding address data, invalid address data, invalid byte length ' + data.length);
42513    }
42514    return {
42515      consumed: 32,
42516      value: '0x' + data.slice(offset + 12, offset + 32).toString('hex')
42517    };
42518  }
42519};
42520
42521function encodeDynamicBytesHelper(value) {
42522  var dataLength = parseInt(32 * Math.ceil(value.length / 32)); // eslint-disable-line
42523  var padding = new Buffer(dataLength - value.length); // eslint-disable-line
42524  padding.fill(0);
42525
42526  return Buffer.concat([uint256Coder.encode(value.length), value, padding]);
42527}
42528
42529function decodeDynamicBytesHelper(data, offset) {
42530  if (data.length !== 0 && data.length < offset + 32) {
42531    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32));
42532  }
42533
42534  var length = uint256Coder.decode(data, offset).value; // eslint-disable-line
42535  length = length.toNumber();
42536  if (data.length !== 0 && data.length < offset + 32 + length) {
42537    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32 + length));
42538  }
42539
42540  return {
42541    consumed: parseInt(32 + 32 * Math.ceil(length / 32), 10),
42542    value: data.slice(offset + 32, offset + 32 + length)
42543  };
42544}
42545
42546var coderDynamicBytes = {
42547  encode: function encodeDynamicBytes(value) {
42548    return encodeDynamicBytesHelper(hexOrBuffer(value));
42549  },
42550  decode: function decodeDynamicBytes(data, offset) {
42551    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line
42552    result.value = '0x' + result.value.toString('hex');
42553    return result;
42554  },
42555  dynamic: true
42556};
42557
42558var coderString = {
42559  encode: function encodeString(value) {
42560    return encodeDynamicBytesHelper(new Buffer(value, 'utf8'));
42561  },
42562  decode: function decodeString(data, offset) {
42563    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line
42564    result.value = result.value.toString('utf8');
42565    return result;
42566  },
42567  dynamic: true
42568};
42569
42570function coderArray(coder, lengthInput) {
42571  return {
42572    encode: function encodeArray(value) {
42573      var result = new Buffer(0); // eslint-disable-line
42574      var length = lengthInput; // eslint-disable-line
42575
42576      if (!Array.isArray(value)) {
42577        throw new Error('[ethjs-abi] while encoding array, invalid array data, not type Object (Array)');
42578      }
42579
42580      if (length === -1) {
42581        length = value.length;
42582        result = uint256Coder.encode(length);
42583      }
42584
42585      if (length !== value.length) {
42586        throw new Error('[ethjs-abi] while encoding array, size mismatch array length ' + length + ' does not equal ' + value.length);
42587      }
42588
42589      value.forEach(function (resultValue) {
42590        result = Buffer.concat([result, coder.encode(resultValue)]);
42591      });
42592
42593      return result;
42594    },
42595    decode: function decodeArray(data, offsetInput) {
42596      var length = lengthInput; // eslint-disable-line
42597      var offset = offsetInput; // eslint-disable-line
42598      // @TODO:
42599      // if (data.length < offset + length * 32) { throw new Error('invalid array'); }
42600
42601      var consumed = 0; // eslint-disable-line
42602      var decodeResult; // eslint-disable-line
42603
42604      if (length === -1) {
42605        decodeResult = uint256Coder.decode(data, offset);
42606        length = decodeResult.value.toNumber();
42607        consumed += decodeResult.consumed;
42608        offset += decodeResult.consumed;
42609      }
42610
42611      var value = []; // eslint-disable-line
42612
42613      for (var i = 0; i < length; i++) {
42614        // eslint-disable-line
42615        var loopResult = coder.decode(data, offset);
42616        consumed += loopResult.consumed;
42617        offset += loopResult.consumed;
42618        value.push(loopResult.value);
42619      }
42620
42621      return {
42622        consumed: consumed,
42623        value: value
42624      };
42625    },
42626    dynamic: lengthInput === -1
42627  };
42628}
42629
42630// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and
42631// build the coder up from its parts
42632var paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\[([0-9]*)\]))/);
42633
42634function getParamCoder(typeInput) {
42635  var type = typeInput; // eslint-disable-line
42636  var coder = null; // eslint-disable-line
42637  var invalidTypeErrorMessage = '[ethjs-abi] while getting param coder (getParamCoder) type value ' + JSON.stringify(type) + ' is either invalid or unsupported by ethjs-abi.';
42638
42639  while (type) {
42640    var part = type.match(paramTypePart); // eslint-disable-line
42641    if (!part) {
42642      throw new Error(invalidTypeErrorMessage);
42643    }
42644    type = type.substring(part[0].length);
42645
42646    var prefix = part[2] || part[4] || part[5]; // eslint-disable-line
42647    switch (prefix) {
42648      case 'int':case 'uint':
42649        if (coder) {
42650          throw new Error(invalidTypeErrorMessage);
42651        }
42652        var intSize = parseInt(part[3] || 256); // eslint-disable-line
42653        if (intSize === 0 || intSize > 256 || intSize % 8 !== 0) {
42654          throw new Error('[ethjs-abi] while getting param coder for type ' + type + ', invalid ' + prefix + '<N> width: ' + type);
42655        }
42656
42657        coder = coderNumber(intSize / 8, prefix === 'int');
42658        break;
42659
42660      case 'bool':
42661        if (coder) {
42662          throw new Error(invalidTypeErrorMessage);
42663        }
42664        coder = coderBoolean;
42665        break;
42666
42667      case 'string':
42668        if (coder) {
42669          throw new Error(invalidTypeErrorMessage);
42670        }
42671        coder = coderString;
42672        break;
42673
42674      case 'bytes':
42675        if (coder) {
42676          throw new Error(invalidTypeErrorMessage);
42677        }
42678        if (part[3]) {
42679          var size = parseInt(part[3]); // eslint-disable-line
42680          if (size === 0 || size > 32) {
42681            throw new Error('[ethjs-abi] while getting param coder for prefix bytes, invalid type ' + type + ', size ' + size + ' should be 0 or greater than 32');
42682          }
42683          coder = coderFixedBytes(size);
42684        } else {
42685          coder = coderDynamicBytes;
42686        }
42687        break;
42688
42689      case 'address':
42690        if (coder) {
42691          throw new Error(invalidTypeErrorMessage);
42692        }
42693        coder = coderAddress;
42694        break;
42695
42696      case '[]':
42697        if (!coder || coder.dynamic) {
42698          throw new Error(invalidTypeErrorMessage);
42699        }
42700        coder = coderArray(coder, -1);
42701        break;
42702
42703      // "[0-9+]"
42704      default:
42705        if (!coder || coder.dynamic) {
42706          throw new Error(invalidTypeErrorMessage);
42707        }
42708        var defaultSize = parseInt(part[6]); // eslint-disable-line
42709        coder = coderArray(coder, defaultSize);
42710    }
42711  }
42712
42713  if (!coder) {
42714    throw new Error(invalidTypeErrorMessage);
42715  }
42716  return coder;
42717}
42718
42719module.exports = {
42720  BN: BN,
42721  bnToBuffer: bnToBuffer,
42722  isHexString: isHexString,
42723  hexOrBuffer: hexOrBuffer,
42724  hexlify: hexlify,
42725  stripZeros: stripZeros,
42726
42727  keccak256: keccak256,
42728
42729  getKeys: getKeys,
42730  numberToBN: numberToBN,
42731  coderNumber: coderNumber,
42732  uint256Coder: uint256Coder,
42733  coderBoolean: coderBoolean,
42734  coderFixedBytes: coderFixedBytes,
42735  coderAddress: coderAddress,
42736  coderDynamicBytes: coderDynamicBytes,
42737  coderString: coderString,
42738  coderArray: coderArray,
42739  paramTypePart: paramTypePart,
42740  getParamCoder: getParamCoder
42741};
42742/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer))
42743
42744/***/ },
42745/* 16 */
42746/***/ function(module, exports, __webpack_require__) {
42747
42748"use strict";
42749'use strict';
42750
42751var schema = __webpack_require__(23);
42752var util = __webpack_require__(3);
42753var numberToBN = __webpack_require__(2);
42754var stripHexPrefix = __webpack_require__(5);
42755var padToEven = util.padToEven;
42756var arrayContainsArray = util.arrayContainsArray;
42757var getBinarySize = util.getBinarySize;
42758
42759/**
42760 * Format quantity values, either encode to hex or decode to BigNumber
42761 * should intake null, stringNumber, number, BN
42762 *
42763 * @method formatQuantity
42764 * @param {String|BigNumber|Number} value quantity or tag to convert
42765 * @param {Boolean} encode to hex or decode to BigNumber
42766 * @returns {Optional} output to BigNumber or string
42767 * @throws error if value is a float
42768 */
42769function formatQuantity(value, encode) {
42770  if (['string', 'number', 'object'].indexOf(typeof value) === -1 || value === null) {
42771    return value;
42772  }
42773
42774  var numberValue = numberToBN(value);
42775
42776  if (numberToBN(value).isNeg()) {
42777    throw new Error('[ethjs-format] while formatting quantity \'' + numberValue.toString(10) + '\', invalid negative number. Number must be positive or zero.');
42778  }
42779
42780  return encode ? '0x' + numberValue.toString(16) : numberValue;
42781}
42782
42783/**
42784 * Format quantity or tag, if tag bypass return, else format quantity
42785 * should intake null, stringNumber, number, BN, string tag
42786 *
42787 * @method formatQuantityOrTag
42788 * @param {String|BigNumber|Number} value quantity or tag to convert
42789 * @param {Boolean} encode encode the number to hex or decode to BigNumber
42790 * @returns {Object|String} output to BigNumber or string
42791 * @throws error if value is a float
42792 */
42793function formatQuantityOrTag(value, encode) {
42794  var output = value; // eslint-disable-line
42795
42796  // if the value is a tag, bypass
42797  if (schema.tags.indexOf(value) === -1) {
42798    output = formatQuantity(value, encode);
42799  }
42800
42801  return output;
42802}
42803
42804/**
42805 * FormatData under strict conditions hex prefix
42806 *
42807 * @method formatData
42808 * @param {String} value the bytes data to be formatted
42809 * @param {Number} byteLength the required byte length (usually 20 or 32)
42810 * @returns {String} output output formatted data
42811 * @throws error if minimum length isnt met
42812 */
42813function formatData(value, byteLength) {
42814  var output = value; // eslint-disable-line
42815  var outputByteLength = 0; // eslint-disable-line
42816
42817  // prefix only under strict conditions, else bypass
42818  if (typeof value === 'string') {
42819    output = '0x' + padToEven(stripHexPrefix(value));
42820    outputByteLength = getBinarySize(output);
42821  }
42822
42823  // throw if bytelength is not correct
42824  if (typeof byteLength === 'number' && value !== null && output !== '0x' // support empty values
42825  && (!/^[0-9A-Fa-f]+$/.test(stripHexPrefix(output)) || outputByteLength !== 2 + byteLength * 2)) {
42826    throw new Error('[ethjs-format] hex string \'' + output + '\' must be an alphanumeric ' + (2 + byteLength * 2) + ' utf8 byte hex (chars: a-fA-F) string, is ' + outputByteLength + ' bytes');
42827  }
42828
42829  return output;
42830}
42831
42832/**
42833 * Format object, even with random RPC caviets
42834 *
42835 * @method formatObject
42836 * @param {String|Array} formatter the unit to convert to, default ether
42837 * @param {Object} value the object value
42838 * @param {Boolean} encode encode to hex or decode to BigNumber
42839 * @returns {Object} output object
42840 * @throws error if value is a float
42841 */
42842function formatObject(formatter, value, encode) {
42843  var output = Object.assign({}, value); // eslint-disable-line
42844  var formatObject = null; // eslint-disable-line
42845
42846  // if the object is a string flag, then retreive the object
42847  if (typeof formatter === 'string') {
42848    if (formatter === 'Boolean|EthSyncing') {
42849      formatObject = Object.assign({}, schema.objects.EthSyncing);
42850    } else if (formatter === 'DATA|Transaction') {
42851      formatObject = Object.assign({}, schema.objects.Transaction);
42852    } else {
42853      formatObject = Object.assign({}, schema.objects[formatter]);
42854    }
42855  }
42856
42857  // check if all required data keys are fulfilled
42858  if (!arrayContainsArray(Object.keys(value), formatObject.__required)) {
42859    // eslint-disable-line
42860    throw new Error('[ethjs-format] object ' + JSON.stringify(value) + ' must contain properties: ' + formatObject.__required.join(', ')); // eslint-disable-line
42861  }
42862
42863  // assume formatObject is an object, go through keys and format each
42864  Object.keys(formatObject).forEach(function (valueKey) {
42865    if (valueKey !== '__required' && typeof value[valueKey] !== 'undefined') {
42866      output[valueKey] = format(formatObject[valueKey], value[valueKey], encode);
42867    }
42868  });
42869
42870  return output;
42871}
42872
42873/**
42874 * Format array
42875 *
42876 * @method formatArray
42877 * @param {String|Array} formatter the unit to convert to, default ether
42878 * @param {Object} value the value in question
42879 * @param {Boolean} encode encode to hex or decode to BigNumber
42880 * @param {Number} lengthRequirement the required minimum array length
42881 * @returns {Object} output object
42882 * @throws error if minimum length isnt met
42883 */
42884function formatArray(formatter, value, encode, lengthRequirement) {
42885  var output = value.slice(); // eslint-disable-line
42886  var formatObject = formatter; // eslint-disable-line
42887
42888  // if the formatter is an array or data, then make format object an array data
42889  if (formatter === 'Array|DATA') {
42890    formatObject = ['D'];
42891  }
42892
42893  // if formatter is a FilterChange and acts like a BlockFilter
42894  // or PendingTx change format object to tx hash array
42895  if (formatter === 'FilterChange' && typeof value[0] === 'string') {
42896    formatObject = ['D32'];
42897  }
42898
42899  // enforce minimum value length requirements
42900  if (encode === true && typeof lengthRequirement === 'number' && value.length < lengthRequirement) {
42901    throw new Error('array ' + JSON.stringify(value) + ' must contain at least ' + lengthRequirement + ' params, but only contains ' + value.length + '.'); // eslint-disable-line
42902  }
42903
42904  // make new array, avoid mutation
42905  formatObject = formatObject.slice();
42906
42907  // assume formatObject is an object, go through keys and format each
42908  value.forEach(function (valueKey, valueIndex) {
42909    // use key zero as formatter for all values, unless otherwise specified
42910    var formatObjectKey = 0; // eslint-disable-line
42911
42912    // if format array is exact, check each argument against formatter argument
42913    if (formatObject.length > 1) {
42914      formatObjectKey = valueIndex;
42915    }
42916
42917    output[valueIndex] = format(formatObject[formatObjectKey], valueKey, encode);
42918  });
42919
42920  return output;
42921}
42922
42923/**
42924 * Format various kinds of data to RPC spec or into digestable JS objects
42925 *
42926 * @method format
42927 * @param {String|Array} formatter the data formatter
42928 * @param {String|Array|Object|Null|Number} value the data value input
42929 * @param {Boolean} encode encode to hex or decode to BigNumbers, Strings, Booleans, Null
42930 * @param {Number} lengthRequirement the minimum data length requirement
42931 * @throws error if minimum length isnt met
42932 */
42933function format(formatter, value, encode, lengthRequirement) {
42934  var output = value; // eslint-disable-line
42935
42936  // if formatter is quantity or quantity or tag
42937  if (formatter === 'Q') {
42938    output = formatQuantity(value, encode);
42939  } else if (formatter === 'Q|T') {
42940    output = formatQuantityOrTag(value, encode);
42941  } else if (formatter === 'D') {
42942    output = formatData(value); // dont format data flagged objects like compiler output
42943  } else if (formatter === 'D20') {
42944    output = formatData(value, 20); // dont format data flagged objects like compiler output
42945  } else if (formatter === 'D32') {
42946    output = formatData(value, 32); // dont format data flagged objects like compiler output
42947  } else {
42948    // if value is an object or array
42949    if (typeof value === 'object' && value !== null && Array.isArray(value) === false) {
42950      output = formatObject(formatter, value, encode);
42951    } else if (Array.isArray(value)) {
42952      output = formatArray(formatter, value, encode, lengthRequirement);
42953    }
42954  }
42955
42956  return output;
42957}
42958
42959/**
42960 * Format RPC inputs generally to the node or TestRPC
42961 *
42962 * @method formatInputs
42963 * @param {Object} method the data formatter
42964 * @param {Array} inputs the data inputs
42965 * @returns {Array} output the formatted inputs array
42966 * @throws error if minimum length isnt met
42967 */
42968function formatInputs(method, inputs) {
42969  return format(schema.methods[method][0], inputs, true, schema.methods[method][2]);
42970}
42971
42972/**
42973 * Format RPC outputs generally from the node or TestRPC
42974 *
42975 * @method formatOutputs
42976 * @param {Object} method the data formatter
42977 * @param {Array|String|Null|Boolean|Object} outputs the data inputs
42978 * @returns {Array|String|Null|Boolean|Object} output the formatted data
42979 */
42980function formatOutputs(method, outputs) {
42981  return format(schema.methods[method][1], outputs, false);
42982}
42983
42984// export formatters
42985module.exports = {
42986  schema: schema,
42987  formatQuantity: formatQuantity,
42988  formatQuantityOrTag: formatQuantityOrTag,
42989  formatObject: formatObject,
42990  formatArray: formatArray,
42991  format: format,
42992  formatInputs: formatInputs,
42993  formatOutputs: formatOutputs
42994};
42995
42996/***/ },
42997/* 17 */
42998/***/ function(module, exports, __webpack_require__) {
42999
43000"use strict";
43001'use strict';
43002
43003/**
43004 * @original-authors:
43005 *   Marek Kotewicz <[email protected]>
43006 *   Marian Oancea <[email protected]>
43007 *   Fabian Vogelsteller <[email protected]>
43008 * @date 2015
43009 */
43010
43011// workaround to use httpprovider in different envs
43012var XHR2 = __webpack_require__(26);
43013
43014/*
43015""
43016responseText
43017:
43018""
43019responseType
43020:
43021""
43022responseURL
43023:
43024"https://ropsten.infura.io/"
43025responseXML
43026:
43027null
43028status
43029:
43030405
43031statusText
43032:
43033"Method Not Allowed"
43034timeout
43035:
430360
43037*/
43038
43039/**
43040 * InvalidResponseError helper for invalid errors.
43041 */
43042function invalidResponseError(request, host) {
43043  var responseError = new Error('[ethjs-provider-http] Invalid JSON RPC response from provider\n    host: ' + host + '\n    response: ' + String(request.responseText) + ' ' + JSON.stringify(request.responseText, null, 2) + '\n    responseURL: ' + request.responseURL + '\n    status: ' + request.status + '\n    statusText: ' + request.statusText + '\n  ');
43044  responseError.value = request;
43045  return responseError;
43046}
43047
43048/**
43049 * HttpProvider should be used to send rpc calls over http
43050 */
43051function HttpProvider(host, timeout) {
43052  if (!(this instanceof HttpProvider)) {
43053    throw new Error('[ethjs-provider-http] the HttpProvider instance requires the "new" flag in order to function normally (e.g. `const eth = new Eth(new HttpProvider());`).');
43054  }
43055  if (typeof host !== 'string') {
43056    throw new Error('[ethjs-provider-http] the HttpProvider instance requires that the host be specified (e.g. `new HttpProvider("http://localhost:8545")` or via service like infura `new HttpProvider("http://ropsten.infura.io")`)');
43057  }
43058
43059  var self = this;
43060  self.host = host;
43061  self.timeout = timeout || 0;
43062}
43063
43064/**
43065 * Should be used to make async request
43066 *
43067 * @method sendAsync
43068 * @param {Object} payload
43069 * @param {Function} callback triggered on end with (err, result)
43070 */
43071HttpProvider.prototype.sendAsync = function (payload, callback) {
43072  // eslint-disable-line
43073  var self = this;
43074  var request = new XHR2(); // eslint-disable-line
43075
43076  request.timeout = self.timeout;
43077  request.open('POST', self.host, true);
43078  request.setRequestHeader('Content-Type', 'application/json');
43079
43080  request.onreadystatechange = function () {
43081    if (request.readyState === 4 && request.timeout !== 1) {
43082      var result = request.responseText; // eslint-disable-line
43083      var error = null; // eslint-disable-line
43084
43085      try {
43086        result = JSON.parse(result);
43087      } catch (jsonError) {
43088        error = invalidResponseError(request, self.host);
43089      }
43090
43091      callback(error, result);
43092    }
43093  };
43094
43095  request.ontimeout = function () {
43096    callback('[ethjs-provider-http] CONNECTION TIMEOUT: http request timeout after ' + self.timeout + ' ms. (i.e. your connect has timed out for whatever reason, check your provider).', null);
43097  };
43098
43099  try {
43100    request.send(JSON.stringify(payload));
43101  } catch (error) {
43102    callback('[ethjs-provider-http] CONNECTION ERROR: Couldn\'t connect to node \'' + self.host 
43102+ '\': ' + JSON.stringify(error, null, 2), null);
43103  }
43104};
43105
43106module.exports = HttpProvider;
43107
43108/***/ },
43109/* 18 */
43110/***/ function(module, exports, __webpack_require__) {
43111
43112"use strict";
43113'use strict';
43114
43115var format = __webpack_require__(16);
43116var EthRPC = __webpack_require__(19);
43117
43118module.exports = Eth;
43119
43120function Eth(provider, options) {
43121  var self = this;
43122  var optionsObject = options || {};
43123
43124  if (!(this instanceof Eth)) {
43125    throw new Error('[ethjs-query] the Eth object requires the "new" flag in order to function normally (i.e. `const eth = new Eth(provider);`).');
43126  }
43127  if (typeof provider !== 'object') {
43128    throw new Error('[ethjs-query] the Eth object requires that the first input \'provider\' must be an object, got \'' + typeof provider + '\' (i.e. \'const eth = new Eth(provider);\')');
43129  }
43130
43131  self.options = Object.assign({
43132    debug: optionsObject.debug || false,
43133    logger: optionsObject.logger || console,
43134    jsonSpace: optionsObject.jsonSpace || 0
43135  });
43136  self.rpc = new EthRPC(provider);
43137  self.setProvider = self.rpc.setProvider;
43138}
43139
43140Eth.prototype.log = function log(message) {
43141  var self = this;
43142  if (self.options.debug) self.options.logger.log('[ethjs-query log] ' + message);
43143};
43144
43145Object.keys(format.schema.methods).forEach(function (rpcMethodName) {
43146  Object.defineProperty(Eth.prototype, rpcMethodName.replace('eth_', ''), {
43147    enumerable: true,
43148    value: generateFnFor(rpcMethodName, format.schema.methods[rpcMethodName])
43149  });
43150});
43151
43152function generateFnFor(method, methodObject) {
43153  return function outputMethod() {
43154    var protoCallback = function protoCallback() {}; // eslint-disable-line
43155    var inputs = null; // eslint-disable-line
43156    var inputError = null; // eslint-disable-line
43157    var self = this;
43158    var args = [].slice.call(arguments); // eslint-disable-line
43159    var protoMethod = method.replace('eth_', ''); // eslint-disable-line
43160
43161    if (args.length > 0 && typeof args[args.length - 1] === 'function') {
43162      protoCallback = args.pop();
43163    }
43164
43165    return new Promise(function (resolve, reject) {
43166      var cb = function cb(callbackError, callbackResult) {
43167        if (callbackError) {
43168          reject(callbackError);
43169          protoCallback(callbackError, null);
43170        } else {
43171          try {
43172            self.log('attempting method formatting for \'' + protoMethod + '\' with raw outputs: ' + JSON.stringify(callbackResult, null, self.options.jsonSpace));
43173            var methodOutputs = format.formatOutputs(method, callbackResult);
43174            self.log('method formatting success for \'' + protoMethod + '\' formatted result: ' + JSON.stringify(methodOutputs, null, self.options.jsonSpace));
43175
43176            resolve(methodOutputs);
43177            protoCallback(null, methodOutputs);
43178          } catch (outputFormattingError) {
43179            var outputError = new Error('[ethjs-query] while formatting outputs from RPC \'' + JSON.stringify(callbackResult, null, self.options.jsonSpace) + '\' for method \'' + protoMethod + '\' ' + outputFormattingError);
43180
43181            reject(outputError);
43182            protoCallback(outputError, null);
43183          }
43184        }
43185      };
43186
43187      if (args.length < methodObject[2]) {
43188        return cb(new Error('[ethjs-query] method \'' + protoMethod + '\' requires at least ' + methodObject[2] + ' input (format type ' + methodObject[0][0] + '), ' + args.length + ' provided. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#' + method.toLowerCase()));
43189      }
43190
43191      if (args.length > methodObject[0].length) {
43192        return cb(new Error('[ethjs-query] method \'' + protoMethod + '\' requires at most ' + methodObject[0].length + ' params, ' + args.length + ' provided \'' + JSON.stringify(args, null, self.options.jsonSpace) + '\'. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#' + method.toLowerCase()));
43193      }
43194
43195      if (methodObject[3] && args.length < methodObject[3]) {
43196        args.push('latest');
43197      }
43198
43199      self.log('attempting method formatting for \'' + protoMethod + '\' with inputs ' + JSON.stringify(args, null, self.options.jsonSpace));
43200
43201      try {
43202        inputs = format.formatInputs(method, args);
43203        self.log('method formatting success for \'' + protoMethod + '\' with formatted result: ' + JSON.stringify(inputs, null, self.options.jsonSpace));
43204      } catch (formattingError) {
43205        return cb(new Error('[ethjs-query] while formatting inputs \'' + JSON.stringify(args, null, self.options.jsonSpace) + '\' for method \'' + protoMethod + '\' error: ' + formattingError));
43206      }
43207
43208      return self.rpc.sendAsync({ method: method, params: inputs }, cb);
43209    });
43210  };
43211}
43212
43213/***/ },
43214/* 19 */
43215/***/ function(module, exports) {
43216
43217"use strict";
43218'use strict';
43219
43220module.exports = EthRPC;
43221
43222/**
43223 * Constructs the EthRPC instance
43224 *
43225 * @method EthRPC
43226 * @param {Object} cprovider the eth rpc provider web3 standard..
43227 * @param {Object} options the options, if any
43228 * @returns {Object} ethrpc instance
43229 */
43230function EthRPC(cprovider, options) {
43231  var self = this;
43232  var optionsObject = options || {};
43233
43234  if (!(this instanceof EthRPC)) {
43235    throw new Error('[ethjs-rpc] the EthRPC object requires the "new" flag in order to function normally (i.e. `const eth = new EthRPC(provider);`).');
43236  }
43237
43238  self.options = Object.assign({
43239    jsonSpace: optionsObject.jsonSpace || 0,
43240    max: optionsObject.max || 9999999999999
43241  });
43242  self.idCounter = Math.floor(Math.random() * self.options.max);
43243  self.setProvider = function (provider) {
43244    if (typeof provider !== 'object') {
43245      throw new Error('[ethjs-rpc] the EthRPC object requires that the first input \'provider\' must be an object, got \'' + typeof provider + '\' (i.e. \'const eth = new EthRPC(provider);\')');
43246    }
43247
43248    self.currentProvider = provider;
43249  };
43250  self.setProvider(cprovider);
43251}
43252
43253/**
43254 * The main send async method
43255 *
43256 * @method sendAsync
43257 * @param {Object} payload the rpc payload object
43258 * @param {Function} cb the async standard callback
43259 * @callback {Object|Array|Boolean|String} vary result instance output
43260 */
43261EthRPC.prototype.sendAsync = function sendAsync(payload, cb) {
43262  var self = this;
43263  self.idCounter = self.idCounter % self.options.max;
43264  var parsedPayload = createPayload(payload, self.idCounter++);
43265  self.currentProvider.sendAsync(parsedPayload, function (err, response) {
43266    var responseObject = response || {};
43267
43268    if (err || responseObject.error) {
43269      var payloadErrorMessage = '[ethjs-rpc] ' + (responseObject.error && 'rpc' || '') + ' error with payload ' + JSON.stringify(parsedPayload, null, self.options.jsonSpace) + ' ' + (String(err) || JSON.stringify(responseObject.error, null, self.options.jsonSpace));
43270      var payloadError = new Error(payloadErrorMessage);
43271      payloadError.value = err || responseObject.error;
43272      return cb(payloadError, null);
43273    }
43274
43275    return cb(null, responseObject.result);
43276  });
43277};
43278
43279/**
43280 * A simple create payload method
43281 *
43282 * @method createPayload
43283 * @param {Object} data the rpc payload data
43284 * @param {String} id the rpc data payload ID
43285 * @returns {Object} payload the completed payload object
43286 */
43287function createPayload(data, id) {
43288  return Object.assign({}, {
43289    id: id,
43290    jsonrpc: '2.0',
43291    params: []
43292  }, data);
43293}
43294
43295/***/ },
43296/* 20 */
43297/***/ function(module, exports, __webpack_require__) {
43298
43299"use strict";
43300'use strict';
43301
43302var BN = __webpack_require__(1);
43303var numberToBN = __webpack_require__(2);
43304
43305var zero = new BN(0);
43306var negative1 = new BN(-1);
43307
43308// complete ethereum unit map
43309var unitMap = {
43310  'noether': '0', // eslint-disable-line
43311  'wei': '1', // eslint-disable-line
43312  'kwei': '1000', // eslint-disable-line
43313  'Kwei': '1000', // eslint-disable-line
43314  'babbage': '1000', // eslint-disable-line
43315  'femtoether': '1000', // eslint-disable-line
43316  'mwei': '1000000', // eslint-disable-line
43317  'Mwei': '1000000', // eslint-disable-line
43318  'lovelace': '1000000', // eslint-disable-line
43319  'picoether': '1000000', // eslint-disable-line
43320  'gwei': '1000000000', // eslint-disable-line
43321  'Gwei': '1000000000', // eslint-disable-line
43322  'shannon': '1000000000', // eslint-disable-line
43323  'nanoether': '1000000000', // eslint-disable-line
43324  'nano': '1000000000', // eslint-disable-line
43325  'szabo': '1000000000000', // eslint-disable-line
43326  'microether': '1000000000000', // eslint-disable-line
43327  'micro': '1000000000000', // eslint-disable-line
43328  'finney': '1000000000000000', // eslint-disable-line
43329  'milliether': '1000000000000000', // eslint-disable-line
43330  'milli': '1000000000000000', // eslint-disable-line
43331  'ether': '1000000000000000000', // eslint-disable-line
43332  'kether': '1000000000000000000000', // eslint-disable-line
43333  'grand': '1000000000000000000000', // eslint-disable-line
43334  'mether': '1000000000000000000000000', // eslint-disable-line
43335  'gether': '1000000000000000000000000000', // eslint-disable-line
43336  'tether': '1000000000000000000000000000000' };
43337
43338/**
43339 * Returns value of unit in Wei
43340 *
43341 * @method getValueOfUnit
43342 * @param {String} unit the unit to convert to, default ether
43343 * @returns {BigNumber} value of the unit (in Wei)
43344 * @throws error if the unit is not correct:w
43345 */
43346function getValueOfUnit(unitInput) {
43347  var unit = unitInput ? unitInput.toLowerCase() : 'ether';
43348  var unitValue = unitMap[unit]; // eslint-disable-line
43349
43350  if (typeof unitValue !== 'string') {
43351    throw new Error('[ethjs-unit] the unit provided ' + unitInput + ' doesn\'t exists, please use the one of the following units ' + JSON.stringify(unitMap, null, 2));
43352  }
43353
43354  return new BN(unitValue, 10);
43355}
43356
43357function numberToString(arg) {
43358  if (typeof arg === 'string') {
43359    if (!arg.match(/^-?[0-9.]+$/)) {
43360      throw new Error('while converting number to string, invalid number value \'' + arg + '\', should be a number matching (^-?[0-9.]+).');
43361    }
43362    return arg;
43363  } else if (typeof arg === 'number') {
43364    return String(arg);
43365  } else if (typeof arg === 'object' && arg.toString && (arg.toTwos || arg.dividedToIntegerBy)) {
43366    if (arg.toPrecision) {
43367      return String(arg.toPrecision());
43368    } else {
43369      // eslint-disable-line
43370      return arg.toString(10);
43371    }
43372  }
43373  throw new Error('while converting number to string, invalid number value \'' + arg + '\' type ' + typeof arg + '.');
43374}
43375
43376function fromWei(weiInput, unit, optionsInput) {
43377  var wei = numberToBN(weiInput); // eslint-disable-line
43378  var negative = wei.lt(zero); // eslint-disable-line
43379  var base = getValueOfUnit(unit);
43380  var baseLength = unitMap[unit].length - 1 || 1;
43381  var options = optionsInput || {};
43382
43383  if (negative) {
43384    wei = wei.mul(negative1);
43385  }
43386
43387  var fraction = wei.mod(base).toString(10); // eslint-disable-line
43388
43389  while (fraction.length < baseLength) {
43390    fraction = '0' + fraction;
43391  }
43392
43393  if (!options.pad) {
43394    fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
43395  }
43396
43397  var whole = wei.div(base).toString(10); // eslint-disable-line
43398
43399  if (options.commify) {
43400    whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
43401  }
43402
43403  var value = '' + whole + (fraction == '0' ? '' : '.' + fraction); // eslint-disable-line
43404
43405  if (negative) {
43406    value = '-' + value;
43407  }
43408
43409  return value;
43410}
43411
43412function toWei(etherInput, unit) {
43413  var ether = numberToString(etherInput); // eslint-disable-line
43414  var base = getValueOfUnit(unit);
43415  var baseLength = unitMap[unit].length - 1 || 1;
43416
43417  // Is it negative?
43418  var negative = ether.substring(0, 1) === '-'; // eslint-disable-line
43419  if (negative) {
43420    ether = ether.substring(1);
43421  }
43422
43423  if (ether === '.') {
43424    throw new Error('[ethjs-unit] while converting number ' + etherInput + ' to wei, invalid value');
43425  }
43426
43427  // Split it into a whole and fractional part
43428  var comps = ether.split('.'); // eslint-disable-line
43429  if (comps.length > 2) {
43430    throw new Error('[ethjs-unit] while converting number ' + etherInput + ' to wei,  too many decimal points');
43431  }
43432
43433  var whole = comps[0],
43434      fraction = comps[1]; // eslint-disable-line
43435
43436  if (!whole) {
43437    whole = '0';
43438  }
43439  if (!fraction) {
43440    fraction = '0';
43441  }
43442  if (fraction.length > baseLength) {
43443    throw new Error('[ethjs-unit] while converting number ' + etherInput + ' to wei, too many decimal places');
43444  }
43445
43446  while (fraction.length < baseLength) {
43447    fraction += '0';
43448  }
43449
43450  whole = new BN(whole);
43451  fraction = new BN(fraction);
43452  var wei = whole.mul(base).add(fraction); // eslint-disable-line
43453
43454  if (negative) {
43455    wei = wei.mul(negative1);
43456  }
43457
43458  return new BN(wei.toString(10), 10);
43459}
43460
43461module.exports = {
43462  unitMap: unitMap,
43463  numberToString: numberToString,
43464  getValueOfUnit: getValueOfUnit,
43465  fromWei: fromWei,
43466  toWei: toWei
43467};
43468
43469/***/ },
43470/* 21 */
43471/***/ function(module, exports) {
43472
43473exports.read = function (buffer, offset, isLE, mLen, nBytes) {
43474  var e, m
43475  var eLen = nBytes * 8 - mLen - 1
43476  var eMax = (1 << eLen) - 1
43477  var eBias = eMax >> 1
43478  var nBits = -7
43479  var i = isLE ? (nBytes - 1) : 0
43480  var d = isLE ? -1 : 1
43481  var s = buffer[offset + i]
43482
43483  i += d
43484
43485  e = s & ((1 << (-nBits)) - 1)
43486  s >>= (-nBits)
43487  nBits += eLen
43488  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
43489
43490  m = e & ((1 << (-nBits)) - 1)
43491  e >>= (-nBits)
43492  nBits += mLen
43493  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
43494
43495  if (e === 0) {
43496    e = 1 - eBias
43497  } else if (e === eMax) {
43498    return m ? NaN : ((s ? -1 : 1) * Infinity)
43499  } else {
43500    m = m + Math.pow(2, mLen)
43501    e = e - eBias
43502  }
43503  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
43504}
43505
43506exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
43507  var e, m, c
43508  var eLen = nBytes * 8 - mLen - 1
43509  var eMax = (1 << eLen) - 1
43510  var eBias = eMax >> 1
43511  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
43512  var i = isLE ? 0 : (nBytes - 1)
43513  var d = isLE ? 1 : -1
43514  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
43515
43516  value = Math.abs(value)
43517
43518  if (isNaN(value) || value === Infinity) {
43519    m = isNaN(value) ? 1 : 0
43520    e = eMax
43521  } else {
43522    e = Math.floor(Math.log(value) / Math.LN2)
43523    if (value * (c = Math.pow(2, -e)) < 1) {
43524      e--
43525      c *= 2
43526    }
43527    if (e + eBias >= 1) {
43528      value += rt / c
43529    } else {
43530      value += rt * Math.pow(2, 1 - eBias)
43531    }
43532    if (value * c >= 2) {
43533      e++
43534      c /= 2
43535    }
43536
43537    if (e + eBias >= eMax) {
43538      m = 0
43539      e = eMax
43540    } else if (e + eBias >= 1) {
43541      m = (value * c - 1) * Math.pow(2, mLen)
43542      e = e + eBias
43543    } else {
43544      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
43545      e = 0
43546    }
43547  }
43548
43549  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
43550
43551  e = (e << mLen) | m
43552  eLen += mLen
43553  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
43554
43555  buffer[offset + i - d] |= s * 128
43556}
43557
43558
43559/***/ },
43560/* 22 */
43561/***/ function(module, exports) {
43562
43563var toString = {}.toString;
43564
43565module.exports = Array.isArray || function (arr) {
43566  return toString.call(arr) == '[object Array]';
43567};
43568
43569
43570/***/ },
43571/* 23 */
43572/***/ function(module, exports) {
43573
43574module.exports = {
43575	"methods": {
43576		"web3_clientVersion": [
43577			[],
43578			"S"
43579		],
43580		"web3_sha3": [
43581			[
43582				"S"
43583			],
43584			"D",
43585			1
43586		],
43587		"net_version": [
43588			[],
43589			"S"
43590		],
43591		"net_peerCount": [
43592			[],
43593			"Q"
43594		],
43595		"net_listening": [
43596			[],
43597			"B"
43598		],
43599		"personal_sign": [
43600			[
43601				"D20",
43602				"D",
43603				"S"
43604			],
43605			"D",
43606			2
43607		],
43608		"personal_ecRecover": [
43609			[
43610				"D",
43611				"D"
43612			],
43613			"D20",
43614			2
43615		],
43616		"eth_protocolVersion": [
43617			[],
43618			"S"
43619		],
43620		"eth_syncing": [
43621			[],
43622			"Boolean|EthSyncing"
43623		],
43624		"eth_coinbase": [
43625			[],
43626			"D20"
43627		],
43628		"eth_mining": [
43629			[],
43630			"B"
43631		],
43632		"eth_hashrate": [
43633			[],
43634			"Q"
43635		],
43636		"eth_gasPrice": [
43637			[],
43638			"Q"
43639		],
43640		"eth_accounts": [
43641			[],
43642			[
43643				"D20"
43644			]
43645		],
43646		"eth_blockNumber": [
43647			[],
43648			"Q"
43649		],
43650		"eth_getBalance": [
43651			[
43652				"D20",
43653				"Q|T"
43654			],
43655			"Q",
43656			1,
43657			2
43658		],
43659		"eth_getStorageAt": [
43660			[
43661				"D20",
43662				"Q",
43663				"Q|T"
43664			],
43665			"D",
43666			2,
43667			2
43668		],
43669		"eth_getTransactionCount": [
43670			[
43671				"D20",
43672				"Q|T"
43673			],
43674			"Q",
43675			1,
43676			2
43677		],
43678		"eth_getBlockTransactionCountByHash": [
43679			[
43680				"D32"
43681			],
43682			"Q",
43683			1
43684		],
43685		"eth_getBlockTransactionCountByNumber": [
43686			[
43687				"Q|T"
43688			],
43689			"Q",
43690			1
43691		],
43692		"eth_getUncleCountByBlockHash": [
43693			[
43694				"D32"
43695			],
43696			"Q",
43697			1
43698		],
43699		"eth_getUncleCountByBlockNumber": [
43700			[
43701				"Q"
43702			],
43703			"Q",
43704			1
43705		],
43706		"eth_getCode": [
43707			[
43708				"D20",
43709				"Q|T"
43710			],
43711			"D",
43712			1,
43713			2
43714		],
43715		"eth_sign": [
43716			[
43717				"D20",
43718				"D32"
43719			],
43720			"D",
43721			2
43722		],
43723		"eth_sendTransaction": [
43724			[
43725				"SendTransaction"
43726			],
43727			"D",
43728			1
43729		],
43730		"eth_sendRawTransaction": [
43731			[
43732				"D"
43733			],
43734			"D32",
43735			1
43736		],
43737		"eth_call": [
43738			[
43739				"CallTransaction",
43740				"Q|T"
43741			],
43742			"D",
43743			1,
43744			2
43745		],
43746		"eth_estimateGas": [
43747			[
43748				"EstimateTransaction",
43749				"Q|T"
43750			],
43751			"Q",
43752			1
43753		],
43754		"eth_getBlockByHash": [
43755			[
43756				"D32",
43757				"B"
43758			],
43759			"Block",
43760			2
43761		],
43762		"eth_getBlockByNumber": [
43763			[
43764				"Q|T",
43765				"B"
43766			],
43767			"Block",
43768			2
43769		],
43770		"eth_getTransactionByHash": [
43771			[
43772				"D32"
43773			],
43774			"Transaction",
43775			1
43776		],
43777		"eth_getTransactionByBlockHashAndIndex": [
43778			[
43779				"D32",
43780				"Q"
43781			],
43782			"Transaction",
43783			2
43784		],
43785		"eth_getTransactionByBlockNumberAndIndex": [
43786			[
43787				"Q|T",
43788				"Q"
43789			],
43790			"Transaction",
43791			2
43792		],
43793		"eth_getTransactionReceipt": [
43794			[
43795				"D32"
43796			],
43797			"Receipt",
43798			1
43799		],
43800		"eth_getUncleByBlockHashAndIndex": [
43801			[
43802				"D32",
43803				"Q"
43804			],
43805			"Block",
43806			1
43807		],
43808		"eth_getUncleByBlockNumberAndIndex": [
43809			[
43810				"Q|T",
43811				"Q"
43812			],
43813			"Block",
43814			2
43815		],
43816		"eth_getCompilers": [
43817			[],
43818			[
43819				"S"
43820			]
43821		],
43822		"eth_compileLLL": [
43823			[
43824				"S"
43825			],
43826			"D",
43827			1
43828		],
43829		"eth_compileSolidity": [
43830			[
43831				"S"
43832			],
43833			"D",
43834			1
43835		],
43836		"eth_compileSerpent": [
43837			[
43838				"S"
43839			],
43840			"D",
43841			1
43842		],
43843		"eth_newFilter": [
43844			[
43845				"Filter"
43846			],
43847			"Q",
43848			1
43849		],
43850		"eth_newBlockFilter": [
43851			[],
43852			"Q"
43853		],
43854		"eth_newPendingTransactionFilter": [
43855			[],
43856			"Q"
43857		],
43858		"eth_uninstallFilter": [
43859			[
43860				"Q"
43861			],
43862			"B",
43863			1
43864		],
43865		"eth_getFilterChanges": [
43866			[
43867				"Q"
43868			],
43869			[
43870				"FilterChange"
43871			],
43872			1
43873		],
43874		"eth_getFilterLogs": [
43875			[
43876				"Q"
43877			],
43878			[
43879				"FilterChange"
43880			],
43881			1
43882		],
43883		"eth_getLogs": [
43884			[
43885				"Filter"
43886			],
43887			[
43888				"FilterChange"
43889			],
43890			1
43891		],
43892		"eth_getWork": [
43893			[],
43894			[
43895				"D"
43896			]
43897		],
43898		"eth_submitWork": [
43899			[
43900				"D",
43901				"D32",
43902				"D32"
43903			],
43904			"B",
43905			3
43906		],
43907		"eth_submitHashrate": [
43908			[
43909				"D",
43910				"D"
43911			],
43912			"B",
43913			2
43914		],
43915		"db_putString": [
43916			[
43917				"S",
43918				"S",
43919				"S"
43920			],
43921			"B",
43922			2
43923		],
43924		"db_getString": [
43925			[
43926				"S",
43927				"S"
43928			],
43929			"S",
43930			2
43931		],
43932		"db_putHex": [
43933			[
43934				"S",
43935				"S",
43936				"D"
43937			],
43938			"B",
43939			2
43940		],
43941		"db_getHex": [
43942			[
43943				"S",
43944				"S"
43945			],
43946			"D",
43947			2
43948		],
43949		"shh_post": [
43950			[
43951				"SHHPost"
43952			],
43953			"B",
43954			1
43955		],
43956		"shh_version": [
43957			[],
43958			"S"
43959		],
43960		"shh_newIdentity": [
43961			[],
43962			"D"
43963		],
43964		"shh_hasIdentity": [
43965			[
43966				"D"
43967			],
43968			"B"
43969		],
43970		"shh_newGroup": [
43971			[],
43972			"D"
43973		],
43974		"shh_addToGroup": [
43975			[
43976				"D"
43977			],
43978			"B",
43979			1
43980		],
43981		"shh_newFilter": [
43982			[
43983				"SHHFilter"
43984			],
43985			"Q",
43986			1
43987		],
43988		"shh_uninstallFilter": [
43989			[
43990				"Q"
43991			],
43992			"B",
43993			1
43994		],
43995		"shh_getFilterChanges": [
43996			[
43997				"Q"
43998			],
43999			[
44000				"SHHFilterChange"
44001			],
44002			1
44003		],
44004		"shh_getMessages": [
44005			[
44006				"Q"
44007			],
44008			[
44009				"SHHFilterChange"
44010			],
44011			1
44012		]
44013	},
44014	"tags": [
44015		"latest",
44016		"earliest",
44017		"pending"
44018	],
44019	"objects": {
44020		"EthSyncing": {
44021			"__required": [],
44022			"startingBlock": "Q",
44023			"currentBlock": "Q",
44024			"highestBlock": "Q"
44025		},
44026		"SendTransaction": {
44027			"__required": [
44028				"from",
44029				"data"
44030			],
44031			"from": "D20",
44032			"to": "D20",
44033			"gas": "Q",
44034			"gasPrice": "Q",
44035			"value": "Q",
44036			"data": "D",
44037			"nonce": "Q"
44038		},
44039		"EstimateTransaction": {
44040			"__required": [],
44041			"from": "D20",
44042			"to": "D20",
44043			"gas": "Q",
44044			"gasPrice": "Q",
44045			"value": "Q",
44046			"data": "D",
44047			"nonce": "Q"
44048		},
44049		"CallTransaction": {
44050			"__required": [
44051				"to"
44052			],
44053			"from": "D20",
44054			"to": "D20",
44055			"gas": "Q",
44056			"gasPrice": "Q",
44057			"value": "Q",
44058			"data": "D",
44059			"nonce": "Q"
44060		},
44061		"Block": {
44062			"__required": [],
44063			"number": "Q",
44064			"hash": "D32",
44065			"parentHash": "D32",
44066			"nonce": "D",
44067			"sha3Uncles": "D",
44068			"logsBloom": "D",
44069			"transactionsRoot": "D",
44070			"stateRoot": "D",
44071			"receiptsRoot": "D",
44072			"miner": "D",
44073			"difficulty": "Q",
44074			"totalDifficulty": "Q",
44075			"extraData": "D",
44076			"size": "Q",
44077			"gasLimit": "Q",
44078			"gasUsed": "Q",
44079			"timestamp": "Q",
44080			"transactions": [
44081				"DATA|Transaction"
44082			],
44083			"uncles": [
44084				"D"
44085			]
44086		},
44087		"Transaction": {
44088			"__required": [],
44089			"hash": "D32",
44090			"nonce": "Q",
44091			"blockHash": "D32",
44092			"blockNumber": "Q",
44093			"transactionIndex": "Q",
44094			"from": "D20",
44095			"to": "D20",
44096			"value": "Q",
44097			"gasPrice": "Q",
44098			"gas": "Q",
44099			"input": "D"
44100		},
44101		"Receipt": {
44102			"__required": [],
44103			"transactionHash": "D32",
44104			"transactionIndex": "Q",
44105			"blockHash": "D32",
44106			"blockNumber": "Q",
44107			"cumulativeGasUsed": "Q",
44108			"gasUsed": "Q",
44109			"contractAddress": "D20",
44110			"logs": [
44111				"FilterChange"
44112			]
44113		},
44114		"Filter": {
44115			"__required": [],
44116			"fromBlock": "Q|T",
44117			"toBlock": "Q|T",
44118			"address": "Array|Data",
44119			"topics": [
44120				"D"
44121			]
44122		},
44123		"FilterChange": {
44124			"__required": [],
44125			"removed": "B",
44126			"logIndex": "Q",
44127			"transactionIndex": "Q",
44128			"transactionHash": "D32",
44129			"blockHash": "D32",
44130			"blockNumber": "Q",
44131			"address": "D20",
44132			"data": "Array|DATA",
44133			"topics": [
44134				"D"
44135			]
44136		},
44137		"SHHPost": {
44138			"__required": [
44139				"topics",
44140				"payload",
44141				"priority",
44142				"ttl"
44143			],
44144			"from": "D",
44145			"to": "D",
44146			"topics": [
44147				"D"
44148			],
44149			"payload": "D",
44150			"priority": "Q",
44151			"ttl": "Q"
44152		},
44153		"SHHFilter": {
44154			"__required": [
44155				"topics"
44156			],
44157			"to": "D",
44158			"topics": [
44159				"D"
44160			]
44161		},
44162		"SHHFilterChange": {
44163			"__required": [],
44164			"hash": "D",
44165			"from": "D",
44166			"to": "D",
44167			"expiry": "Q",
44168			"ttl": "Q",
44169			"sent": "Q",
44170			"topics": [
44171				"D"
44172			],
44173			"payload": "D",
44174			"workProved": "Q"
44175		},
44176		"SHHMessage": {
44177			"__required": [],
44178			"hash": "D",
44179			"from": "D",
44180			"to": "D",
44181			"expiry": "Q",
44182			"ttl": "Q",
44183			"sent": "Q",
44184			"topics": [
44185				"D"
44186			],
44187			"payload": "D",
44188			"workProved": "Q"
44189		}
44190	}
44191};
44192
44193/***/ },
44194/* 24 */
44195/***/ function(module, exports) {
44196
44197// shim for using process in browser
44198var process = module.exports = {};
44199
44200// cached from whatever global is present so that test runners that stub it
44201// don't break things.  But we need to wrap it in a try catch in case it is
44202// wrapped in strict mode code which doesn't define any globals.  It's inside a
44203// function because try/catches deoptimize in certain engines.
44204
44205var cachedSetTimeout;
44206var cachedClearTimeout;
44207
44208function defaultSetTimout() {
44209    throw new Error('setTimeout has not been defined');
44210}
44211function defaultClearTimeout () {
44212    throw new Error('clearTimeout has not been defined');
44213}
44214(function () {
44215    try {
44216        if (typeof setTimeout === 'function') {
44217            cachedSetTimeout = setTimeout;
44218        } else {
44219            cachedSetTimeout = defaultSetTimout;
44220        }
44221    } catch (e) {
44222        cachedSetTimeout = defaultSetTimout;
44223    }
44224    try {
44225        if (typeof clearTimeout === 'function') {
44226            cachedClearTimeout = clearTimeout;
44227        } else {
44228            cachedClearTimeout = defaultClearTimeout;
44229        }
44230    } catch (e) {
44231        cachedClearTimeout = defaultClearTimeout;
44232    }
44233} ())
44234function runTimeout(fun) {
44235    if (cachedSetTimeout === setTimeout) {
44236        //normal enviroments in sane situations
44237        return setTimeout(fun, 0);
44238    }
44239    // if setTimeout wasn't available but was latter defined
44240    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
44241        cachedSetTimeout = setTimeout;
44242        return setTimeout(fun, 0);
44243    }
44244    try {
44245        // when when somebody has screwed with setTimeout but no I.E. maddness
44246        return cachedSetTimeout(fun, 0);
44247    } catch(e){
44248        try {
44249            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
44250            return cachedSetTimeout.call(null, fun, 0);
44251        } catch(e){
44252            // 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
44253            return cachedSetTimeout.call(this, fun, 0);
44254        }
44255    }
44256
44257
44258}
44259function runClearTimeout(marker) {
44260    if (cachedClearTimeout === clearTimeout) {
44261        //normal enviroments in sane situations
44262        return clearTimeout(marker);
44263    }
44264    // if clearTimeout wasn't available but was latter defined
44265    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
44266        cachedClearTimeout = clearTimeout;
44267        return clearTimeout(marker);
44268    }
44269    try {
44270        // when when somebody has screwed with setTimeout but no I.E. maddness
44271        return cachedClearTimeout(marker);
44272    } catch (e){
44273        try {
44274            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
44275            return cachedClearTimeout.call(null, marker);
44276        } catch (e){
44277            // 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.
44278            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
44279            return cachedClearTimeout.call(this, marker);
44280        }
44281    }
44282
44283
44284
44285}
44286var queue = [];
44287var draining = false;
vendor: 2,863 bytes, lines 44288-44423
44288var currentQueue;
44289var queueIndex = -1;
44290
44291function cleanUpNextTick() {
44292    if (!draining || !currentQueue) {
44293        return;
44294    }
44295    draining = false;
44296    if (currentQueue.length) {
44297        queue = currentQueue.concat(queue);
44298    } else {
44299        queueIndex = -1;
44300    }
44301    if (queue.length) {
44302        drainQueue();
44303    }
44304}
44305
44306function drainQueue() {
44307    if (draining) {
44308        return;
44309    }
44310    var timeout = runTimeout(cleanUpNextTick);
44311    draining = true;
44312
44313    var len = queue.length;
44314    while(len) {
44315        currentQueue = queue;
44316        queue = [];
44317        while (++queueIndex < len) {
44318            if (currentQueue) {
44319                currentQueue[queueIndex].run();
44320            }
44321        }
44322        queueIndex = -1;
44323        len = queue.length;
44324    }
44325    currentQueue = null;
44326    draining = false;
44327    runClearTimeout(timeout);
44328}
44329
44330process.nextTick = function (fun) {
44331    var args = new Array(arguments.length - 1);
44332    if (arguments.length > 1) {
44333        for (var i = 1; i < arguments.length; i++) {
44334            args[i - 1] = arguments[i];
44335        }
44336    }
44337    queue.push(new Item(fun, args));
44338    if (queue.length === 1 && !draining) {
44339        runTimeout(drainQueue);
44340    }
44341};
44342
44343// v8 likes predictible objects
44344function Item(fun, array) {
44345    this.fun = fun;
44346    this.array = array;
44347}
44348Item.prototype.run = function () {
44349    this.fun.apply(null, this.array);
44350};
44351process.title = 'browser';
44352process.browser = true;
44353process.env = {};
44354process.argv = [];
44355process.version = ''; // empty string to avoid regexp issues
44356process.versions = {};
44357
44358function noop() {}
44359
44360process.on = noop;
44361process.addListener = noop;
44362process.once = noop;
44363process.off = noop;
44364process.removeListener = noop;
44365process.removeAllListeners = noop;
44366process.emit = noop;
44367
44368process.binding = function (name) {
44369    throw new Error('process.binding is not supported');
44370};
44371
44372process.cwd = function () { return '/' };
44373process.chdir = function (dir) {
44374    throw new Error('process.chdir is not supported');
44375};
44376process.umask = function() { return 0; };
44377
44378
44379/***/ },
44380/* 25 */
44381/***/ function(module, exports) {
44382
44383module.exports = function(module) {
44384	if(!module.webpackPolyfill) {
44385		module.deprecate = function() {};
44386		module.paths = [];
44387		// module.parent = undefined by default
44388		if(!module.children) module.children = [];
44389		Object.defineProperty(module, "loaded", {
44390			enumerable: true,
44391			configurable: false,
44392			get: function() { return module.l; }
44393		});
44394		Object.defineProperty(module, "id", {
44395			enumerable: true,
44396			configurable: false,
44397			get: function() { return module.i; }
44398		});
44399		module.webpackPolyfill = 1;
44400	}
44401	return module;
44402}
44403
44404
44405/***/ },
44406/* 26 */
44407/***/ function(module, exports) {
44408
44409module.exports = XMLHttpRequest;
44410
44411
44412/***/ },
44413/* 27 */
44414/***/ function(module, exports, __webpack_require__) {
44415
44416module.exports = __webpack_require__(9);
44417
44418
44419/***/ }
44420/******/ ])
44421});
44422;
44423//# sourceMappingURL=ethjs.js.map</script>
44423
44424
44425    
44425<script type="text/javascript">
44426    (function(){
44427
44428    const abiData = window.abiJSONData;
44429
44430    function el(query) {
44431      return document.querySelector(query);
44432    }
44433
44434    function handleValue(value) {
44435      return String(value).trim().toLowerCase();
44436    }
44437
44438    function isNumericNumber(numberValue) {
44439      return String(numberValue).match("[0-9]+");
44440    }
44441
44442    function result(val) {
44443      el('#result').style.display = 'block';
44444      el('#result').innerHTML = val;
44445      el('#valueUnit').scrollIntoView();
44446    }
44447
44448    function padToEven(str) {
44449      return str.length % 2 ? `0${str}` : str;
44450    }
44451
44452    function formatNumberData(rawStringBase10Number) {
44453      return '0x' + padToEven((new Eth.BN(rawStringBase10Number, 10)).toString('hex'));
44454    }
44455
44456
44457    function drawInputNumber(name, type, inputID) {
44458      el('#dataWrapper').innerHTML += `
44459         <br /> <br />
44460
44461        <label>${name} (${type})</label> <br />
44462        <input type="number" id="input_${inputID}" class="unitValue" placeholder="" value="0" />
44463
44464        <select id="input_${inputID}_format" class="unitSelector" data-target="input_${inputID}">
44465          <option value="wei">no formatting</option>
44466
44467          <option value="wei">wei</option>
44468
44469          <option value="gwei">Gwei</option>
44470
44471          <option value="ether">ether</option>
44472        </select>
44473      `;
44474    }
44475
44476    function placeholder(type) {
44477      if (type.indexOf('byte') !== -1) {
44478        return 'Exmaple: 0x00';
44479      }
44480
44481      if (type.indexOf('address') !== -1) {
44482        return 'Example: 0xbf8b454Fd4962317dbe3A534058Ab5b533e28524';
44483      }
44484    }
44485
44486    function drawInputText(name, type, inputID) {
44487      const valueData = type.indexOf('byte') !== -1 ? '0x' : '';
44488
44489      el('#dataWrapper').innerHTML += `
44490         <br /> <br />
44491
44492        <label>${name} (${type})</label> <br />
44493        <input type="text" id="input_${inputID}" placeholder="${placeholder(type)}" value="${valueData}" />
44494      `;
44495    }
44496
44497
44498    function drawInput(name, type, inputID) {
44499      if (String(type).indexOf('int') !== -1) {
44500        drawInputNumber(name, type, inputID);
44501      } else {
44502        drawInputText(name, type, inputID);
44503      }
44504    }
44505
44506    function filterABI(rawAbi, methodName) {
44507      return rawAbi.filter(function(methodObject){
44508        if (methodObject.name === methodName) { return methodObject; }
44509      })[0];
44510    }
44511
44512    function drawInputs(contractName, methodName) {
44513      const methodABIObject = filterABI(abiData[contractName].abi, methodName);
44514
44515      methodABIObject.inputs.forEach(function(inputObject, inputIndex) {
44516        drawInput(inputObject.name, inputObject.type, inputIndex);
44517      });
44518
44519      buildUnitSelectors();
44520    }
44521
44522    function transactionContract(dataKind) {
44523      if (dataKind === 'submitTransaction' || dataKind === 'confirmTransaction') {
44524        return 'multiSigDailyLimit';
44525      }
44526
44527      if (dataKind === 'transfer' || dataKind === 'transferFrom' || dataKind === 'approve') {
44528        return 'token';
44529      }
44530    }
44531
44532
44533    function dataKindChange(eventValue) {
44534      const dataKind = eventValue.target.value;
44535      el('#dataWrapper').innerHTML = '';
44536      el('#data').value = '--';
44537      el('#data').type = 'hidden';
44538
44539      if (dataKind === 'noData') {
44540        el('#data').value = '0x';
44541        return;
44542      }
44543
44544      if (dataKind === 'custom') {
44545        el('#data').type = 'text';
44546        el('#data').value = '0x';
44547        return;
44548      }
44549
44550      drawInputs(transactionContract(dataKind), dataKind);
44551      return;
44552    }
44553
44554    function selectNewUnit(eventValue) {
44555      const unitSelected = eventValue.target.value;
44556      const targetEl = el(`#${eventValue.target.dataset.target}`);
44557      targetEl.value = '';
44558    }
44559
44560    function buildUnitSelector(selectorEl) {
44561      selectorEl.addEventListener('change', selectNewUnit);
44562    }
44563
44564    function buildUnitSelectors() {
44565      document.querySelectorAll('.unitSelector').forEach(buildUnitSelector);
44566    }
44567
44568    function openAddressQRCode(eventValue) {
44569      const privateKey = handleValue(eventValue.target.value);
44570
44571      if (!Eth.isHexString(privateKey, 32) || privateKey.length === 0) {
44572        result('Error while processing private key: your private key is not a 64 byte hex prefixed (0x...) Ethereum private key.');
44573        return;
44574      }
44575
44576      const address = ethAccount.privateToAccount(privateKey).address;
44577
44578      const signedAddressQRCode = new QRious({
44579        element: document.getElementById('addressQR'),
44580        size: 500,
44581        value: address,
44582      });
44583
44584      el('#from').value = address;
44585      el('#addressValue').innerHTML = address;
44586      el('#privateKeyWrapper').style.display = 'none';
44587      el('#result').style.display = 'none';
44588      el('#transactionFields').style.display = 'block';
44589      el('#addressQRWrapper').style.display = 'block';
44590    }
44591
44592    function closeAddressQRCode() {
44593      el('#addressQRWrapper').style.display = 'none';
44594    }
44595
44596    function closeTransactionQRCode() {
44597      el('#signedTransactionDataWrapper').style.display = 'none';
44598    }
44599
44600    function openTransactionDataWrapper() {
44601      el('#transactionDataWrapper').style.display = 'block';
44602    }
44603
44604    function checkDataForErrors(privateKey, to, value, gas, gasPrice, nonce, data) {
44605      if (!Eth.isHexString(privateKey, 32) || privateKey.length === 0) {
44606        return 'Private key must be a 64 byte hex prefix hex string.';
44607      }
44608
44609      if (!isNumericNumber(nonce) || nonce.length === 0) {
44610        return 'The "Nonce" must be numeric and is required';
44611      }
44612
44613      if (!isNumericNumber(gas) || gas.length === 0 || gas === '0') {
44614        return 'The "Gas Value" must be numeric and is required.';
44615      }
44616
44617      if (!isNumericNumber(gasPrice) || gasPrice.length === 0 || gasPrice === '0') {
44618        return 'The "Gas Price" must be numeric and is required.';
44619      }
44620
44621      if (!Eth.isAddress(to) || to.length === 0) {
44622        return 'Your transaction "To Address" must be a hex prefixed Ethereum address and is required.';
44623      }
44624
44625      if (!isNumericNumber(value) || value.length === 0) {
44626        return 'Your transaction "Value" must be numeric.';
44627      }
44628
44629      if (!Eth.isHexString(data)) {
44630        return 'Data must be a hex prefix hex string.';
44631      }
44632
44633      return null;
44634    }
44635
44636    function checkBasicSignedTxErrors(signedTransactionData) {
44637      if (signedTransactionData.length < 0) {
44638        return 'The signed transaction data is malformed and cannot be nothin or so small in length.';
44639      }
44640
44641      return null;
44642    }
44643
44644    function formatTransactionData(rawData) {
44645      return JSON.stringify(Object.assign({}, {
44646        to: rawData.to,
44647        value: formatNumberData(rawData.value),
44648        gas: formatNumberData(rawData.gas),
44649        gasPrice: formatNumberData(rawData.gasPrice),
44650        nonce: formatNumberData(rawData.nonce),
44651        data: rawData.data,
44652      }), null, 2);
44653    }
44654
44655    function showSignedTransactionData(signedTxData, rawSignedTxData) {
44656      result('Transaction successfully signed.');
44657      el('#rawSignedTransactionData').innerHTML = '';
44658      el('#signedTransactionData').innerHTML = '';
44659      el('#signedTransactionDataWrapper').style.display = 'block';
44660      el('#signedTransactionData').innerHTML = signedTxData;
44661      el('#rawSignedTransactionData').innerHTML = formatTransactionData(rawSignedTxData);
44662      el('#signedTransactionDataQRCode').scrollIntoView();
44663
44664      const signedTransactionQRCode = new QRious({
44665        element: document.getElementById('signedTransactionDataQRCode'),
44666        size: 500,
44667        value: signedTxData,
44668      });
44669    }
44670
44671    function transactionData() {
44672      try {
44673        const dataKind = el('#dataKind').value;
44674        const dataContract = transactionContract(dataKind);
44675
44676        if (dataKind === 'noData') {
44677          return '0x';
44678        }
44679
44680        if (dataKind === 'custom') {
44681          return handleValue(el('#data').value);
44682        }
44683
44684        const methodObject = filterABI(abiData[dataContract].abi, dataKind);
44685
44686        const inputs = methodObject.inputs.map(function(inputObject, inputIndex){
44687          if (inputObject.type.indexOf('int') !== -1) {
44688            return Eth.toWei(el(`#input_${inputIndex}`).value, el(`#input_${inputIndex}_format`).value).toString(10);
44689          } else {
44690            return el(`#input_${inputIndex}`).value;
44691          }
44692        });
44693
44694        return ethAbi.encodeMethod(methodObject, inputs);
44695      } catch (txError) {
44696        result(`There was an error while processing your transaction data: ${txError} ${txError.value}`);
44697      }
44698    }
44699
44700    function signTransaction() {
44701      try {
44702        const privateKey = handleValue(el('#privateKey').value);
44703        const to = handleValue(el('#to').value);
44704
44705        const valueUnit = handleValue(el('#valueUnit').value);
44706        const value = Eth.toWei(handleValue(el('#value').value), valueUnit).toString(10);
44707
44708        const gasUnit = handleValue(el('#gasUnit').value);
44709        const gas = Eth.toWei(handleValue(el('#gas').value), gasUnit).toString(10);
44710
44711        const gasPriceUnit = handleValue(el('#gasPriceUnit').value);
44712        const gasPrice = Eth.toWei(handleValue(el('#gasPrice').value), gasPriceUnit).toString(10);
44713
44714        const nonce = handleValue(el('#nonce').value);
44715        const data = transactionData();
44716
44717        if (!data) { return; }
44718
44719        const dataError = checkDataForErrors(privateKey, to, value, gas, gasPrice, nonce, data);
44720
44721        if (dataError) {
44722          result('Error with transaction data: ' + String(dataError));
44723          return;
44724        } else {
44725          const rawTransactionData = {
44726            to: to,
44727            value: new Eth.BN(value, 10),
44728            gas: new Eth.BN(gas, 10),
44729            gasPrice: new Eth.BN(gasPrice, 10),
44730            nonce: new Eth.BN(nonce, 10),
44731            data: data,
44732          };
44733          const signedTxData = ethSigner.sign(Object.assign({}, rawTransactionData), privateKey);
44734
44735          const basicSignedTxDataErrors = checkBasicSignedTxErrors(signedTxData);
44736
44737          if (basicSignedTxDataErrors) {
44738            result('Error with signed transaction data: ' + String(basicSignedTxDataErrors));
44739            return;
44740          }
44741
44742          showSignedTransactionData(signedTxData, rawTransactionData);
44743        }
44744
44745      } catch (transactionError) {
44746        result('Error while processing transaction data: ' + String(transactionError));
44747        return;
44748      }
44749    }
44750
44751    function onlineWarning() {
44752      el('#onlineWarning').style.display = 'block';
44753    }
44754
44755    function status() {
44756      if (navigator.onLine) {
44757        onlineWarning();
44758      }
44759    }
44760
44761    function attemptBasicGoogleConnection(callback){
44762      try {
44763        const xmlhttp = new XMLHttpRequest();
44764        xmlhttp.onreadystatechange = function(){
44765          if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
44766            callback();
44767          }
44768        }
44769        xmlhttp.open("GET", 'https://ethjs.github.io/', true);
44770        xmlhttp.send();
44771      } catch (error) {
44772      }
44773    }
44774
44775    function load() {
44776      el('#dataKind').addEventListener('click', dataKindChange);
44777
44778      el('#signTransaction').addEventListener('click', signTransaction);
44779      el('#closeAddressQR').addEventListener('click', closeAddressQRCode);
44780      el('#closeTransactionQRCodeQR').addEventListener('click', closeTransactionQRCode);
44781
44782      el('#nonce').addEventListener('change', openTransactionDataWrapper);
44783      el('#nonce').addEventListener('keyup', openTransactionDataWrapper);
44784
44785      el('#privateKey').addEventListener('change', openAddressQRCode);
44786      el('#privateKey').addEventListener('keyup', openAddressQRCode);
44787
44788      buildUnitSelectors();
44789    }
44790
44791    attemptBasicGoogleConnection(onlineWarning);
44792
44793    window.addEventListener('load', load);
44794
44795    })();
44796    </script>
44796
44797
44798  </body>
44799
44800</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.