-
-> BigNum in pure javascript
-
-[](http://travis-ci.org/indutny/bn.js)
-
-## Install
-`npm install --save bn.js`
-
-## Usage
-
-```js
-const BN = require('bn.js');
-
-var a = new BN('dead', 16);
-var b = new BN('101010', 2);
-
-var res = a.add(b);
-console.log(res.toString(10)); // 57047
-```
-
-**Note**: decimals are not supported in this library.
-
-## Notation
-
-### Prefixes
-
-There are several prefixes to instructions that affect the way the work. Here
-is the list of them in the order of appearance in the function name:
-
-* `i` - perform operation in-place, storing the result in the host object (on
- which the method was invoked). Might be used to avoid number allocation costs
-* `u` - unsigned, ignore the sign of operands when performing operation, or
- always return positive value. Second case applies to reduction operations
- like `mod()`. In such cases if the result will be negative - modulo will be
- added to the result to make it positive
-
-### Postfixes
-
-The only available postfix at the moment is:
-
-* `n` - which means that the argument of the function must be a plain JavaScript
- Number. Decimals are not supported.
-
-### Examples
-
-* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
-* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
-* `a.iushln(13)` - shift bits of `a` left by 13
-
-## Instructions
-
-Prefixes/postfixes are put in parens at the of the line. `endian` - could be
-either `le` (little-endian) or `be` (big-endian).
-
-### Utilities
-
-* `a.clone()` - clone number
-* `a.toString(base, length)` - convert to base-string and pad with zeroes
-* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
-* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
-* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
- pad to length, throwing if already exceeding
-* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
- which must behave like an `Array`
-* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
- compatibility with browserify and similar tools, use this instead:
- `a.toArrayLike(Buffer, endian, length)`
-* `a.bitLength()` - get number of bits occupied
-* `a.zeroBits()` - return number of less-significant consequent zero bits
- (example: `1010000` has 4 zero bits)
-* `a.byteLength()` - return number of bytes occupied
-* `a.isNeg()` - true if the number is negative
-* `a.isEven()` - no comments
-* `a.isOdd()` - no comments
-* `a.isZero()` - no comments
-* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
- depending on the comparison result (`ucmp`, `cmpn`)
-* `a.lt(b)` - `a` less than `b` (`n`)
-* `a.lte(b)` - `a` less than or equals `b` (`n`)
-* `a.gt(b)` - `a` greater than `b` (`n`)
-* `a.gte(b)` - `a` greater than or equals `b` (`n`)
-* `a.eq(b)` - `a` equals `b` (`n`)
-* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
-* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
-* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
-
-### Arithmetics
-
-* `a.neg()` - negate sign (`i`)
-* `a.abs()` - absolute value (`i`)
-* `a.add(b)` - addition (`i`, `n`, `in`)
-* `a.sub(b)` - subtraction (`i`, `n`, `in`)
-* `a.mul(b)` - multiply (`i`, `n`, `in`)
-* `a.sqr()` - square (`i`)
-* `a.pow(b)` - raise `a` to the power of `b`
-* `a.div(b)` - divide (`divn`, `idivn`)
-* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
-* `a.divRound(b)` - rounded division
-
-### Bit operations
-
-* `a.or(b)` - or (`i`, `u`, `iu`)
-* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
- with `andn` in future)
-* `a.xor(b)` - xor (`i`, `u`, `iu`)
-* `a.setn(b)` - set specified bit to `1`
-* `a.shln(b)` - shift left (`i`, `u`, `iu`)
-* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
-* `a.testn(b)` - test if specified bit is set
-* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
-* `a.bincn(b)` - add `1 << b` to the number
-* `a.notn(w)` - not (for the width specified by `w`) (`i`)
-
-### Reduction
-
-* `a.gcd(b)` - GCD
-* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
-* `a.invm(b)` - inverse `a` modulo `b`
-
-## Fast reduction
-
-When doing lots of reductions using the same modulo, it might be beneficial to
-use some tricks: like [Montgomery multiplication][0], or using special algorithm
-for [Mersenne Prime][1].
-
-### Reduction context
-
-To enable this tricks one should create a reduction context:
-
-```js
-var red = BN.red(num);
-```
-where `num` is just a BN instance.
-
-Or:
-
-```js
-var red = BN.red(primeName);
-```
-
-Where `primeName` is either of these [Mersenne Primes][1]:
-
-* `'k256'`
-* `'p224'`
-* `'p192'`
-* `'p25519'`
-
-Or:
-
-```js
-var red = BN.mont(num);
-```
-
-To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
-`.red(num)`, but slower than `BN.red(primeName)`.
-
-### Converting numbers
-
-Before performing anything in reduction context - numbers should be converted
-to it. Usually, this means that one should:
-
-* Convert inputs to reducted ones
-* Operate on them in reduction context
-* Convert outputs back from the reduction context
-
-Here is how one may convert numbers to `red`:
-
-```js
-var redA = a.toRed(red);
-```
-Where `red` is a reduction context created using instructions above
-
-Here is how to convert them back:
-
-```js
-var a = redA.fromRed();
-```
-
-### Red instructions
-
-Most of the instructions from the very start of this readme have their
-counterparts in red context:
-
-* `a.redAdd(b)`, `a.redIAdd(b)`
-* `a.redSub(b)`, `a.redISub(b)`
-* `a.redShl(num)`
-* `a.redMul(b)`, `a.redIMul(b)`
-* `a.redSqr()`, `a.redISqr()`
-* `a.redSqrt()` - square root modulo reduction context's prime
-* `a.redInvm()` - modular inverse of the number
-* `a.redNeg()`
-* `a.redPow(b)` - modular exponentiation
-
-## LICENSE
-
-This software is licensed under the MIT License.
-
-[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
-[1]: https://en.wikipedia.org/wiki/Mersenne_prime
diff --git a/node_modules/bn.js/lib/bn.js b/node_modules/bn.js/lib/bn.js
deleted file mode 100644
index 3a4371e..0000000
--- a/node_modules/bn.js/lib/bn.js
+++ /dev/null
@@ -1,3446 +0,0 @@
-(function (module, exports) {
- 'use strict';
-
- // Utils
- function assert (val, msg) {
- if (!val) throw new Error(msg || 'Assertion failed');
- }
-
- // Could use `inherits` module, but don't want to move from single file
- // architecture yet.
- function inherits (ctor, superCtor) {
- ctor.super_ = superCtor;
- var TempCtor = function () {};
- TempCtor.prototype = superCtor.prototype;
- ctor.prototype = new TempCtor();
- ctor.prototype.constructor = ctor;
- }
-
- // BN
-
- function BN (number, base, endian) {
- if (BN.isBN(number)) {
- return number;
- }
-
- this.negative = 0;
- this.words = null;
- this.length = 0;
-
- // Reduction context
- this.red = null;
-
- if (number !== null) {
- if (base === 'le' || base === 'be') {
- endian = base;
- base = 10;
- }
-
- this._init(number || 0, base || 10, endian || 'be');
- }
- }
- if (typeof module === 'object') {
- module.exports = BN;
- } else {
- exports.BN = BN;
- }
-
- BN.BN = BN;
- BN.wordSize = 26;
-
- var Buffer;
- try {
- if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
- Buffer = window.Buffer;
- } else {
- Buffer = require('buffer').Buffer;
- }
- } catch (e) {
- }
-
- BN.isBN = function isBN (num) {
- if (num instanceof BN) {
- return true;
- }
-
- return num !== null && typeof num === 'object' &&
- num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
- };
-
- BN.max = function max (left, right) {
- if (left.cmp(right) > 0) return left;
- return right;
- };
-
- BN.min = function min (left, right) {
- if (left.cmp(right) < 0) return left;
- return right;
- };
-
- BN.prototype._init = function init (number, base, endian) {
- if (typeof number === 'number') {
- return this._initNumber(number, base, endian);
- }
-
- if (typeof number === 'object') {
- return this._initArray(number, base, endian);
- }
-
- if (base === 'hex') {
- base = 16;
- }
- assert(base === (base | 0) && base >= 2 && base <= 36);
-
- number = number.toString().replace(/\s+/g, '');
- var start = 0;
- if (number[0] === '-') {
- start++;
- this.negative = 1;
- }
-
- if (start < number.length) {
- if (base === 16) {
- this._parseHex(number, start, endian);
- } else {
- this._parseBase(number, base, start);
- if (endian === 'le') {
- this._initArray(this.toArray(), base, endian);
- }
- }
- }
- };
-
- BN.prototype._initNumber = function _initNumber (number, base, endian) {
- if (number < 0) {
- this.negative = 1;
- number = -number;
- }
- if (number < 0x4000000) {
- this.words = [ number & 0x3ffffff ];
- this.length = 1;
- } else if (number < 0x10000000000000) {
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff
- ];
- this.length = 2;
- } else {
- assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff,
- 1
- ];
- this.length = 3;
- }
-
- if (endian !== 'le') return;
-
- // Reverse the bytes
- this._initArray(this.toArray(), base, endian);
- };
-
- BN.prototype._initArray = function _initArray (number, base, endian) {
- // Perhaps a Uint8Array
- assert(typeof number.length === 'number');
- if (number.length <= 0) {
- this.words = [ 0 ];
- this.length = 1;
- return this;
- }
-
- this.length = Math.ceil(number.length / 3);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
-
- var j, w;
- var off = 0;
- if (endian === 'be') {
- for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
- w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- } else if (endian === 'le') {
- for (i = 0, j = 0; i < number.length; i += 3) {
- w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- }
- return this.strip();
- };
-
- function parseHex4Bits (string, index) {
- var c = string.charCodeAt(index);
- // 'A' - 'F'
- if (c >= 65 && c <= 70) {
- return c - 55;
- // 'a' - 'f'
- } else if (c >= 97 && c <= 102) {
- return c - 87;
- // '0' - '9'
- } else {
- return (c - 48) & 0xf;
- }
- }
-
- function parseHexByte (string, lowerBound, index) {
- var r = parseHex4Bits(string, index);
- if (index - 1 >= lowerBound) {
- r |= parseHex4Bits(string, index - 1) << 4;
- }
- return r;
- }
-
- BN.prototype._parseHex = function _parseHex (number, start, endian) {
- // Create possibly bigger array to ensure that it fits the number
- this.length = Math.ceil((number.length - start) / 6);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
-
- // 24-bits chunks
- var off = 0;
- var j = 0;
-
- var w;
- if (endian === 'be') {
- for (i = number.length - 1; i >= start; i -= 2) {
- w = parseHexByte(number, start, i) << off;
- this.words[j] |= w & 0x3ffffff;
- if (off >= 18) {
- off -= 18;
- j += 1;
- this.words[j] |= w >>> 26;
- } else {
- off += 8;
- }
- }
- } else {
- var parseLength = number.length - start;
- for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
- w = parseHexByte(number, start, i) << off;
- this.words[j] |= w & 0x3ffffff;
- if (off >= 18) {
- off -= 18;
- j += 1;
- this.words[j] |= w >>> 26;
- } else {
- off += 8;
- }
- }
- }
-
- this.strip();
- };
-
- function parseBase (str, start, end, mul) {
- var r = 0;
- var len = Math.min(str.length, end);
- for (var i = start; i < len; i++) {
- var c = str.charCodeAt(i) - 48;
-
- r *= mul;
-
- // 'a'
- if (c >= 49) {
- r += c - 49 + 0xa;
-
- // 'A'
- } else if (c >= 17) {
- r += c - 17 + 0xa;
-
- // '0' - '9'
- } else {
- r += c;
- }
- }
- return r;
- }
-
- BN.prototype._parseBase = function _parseBase (number, base, start) {
- // Initialize as zero
- this.words = [ 0 ];
- this.length = 1;
-
- // Find length of limb in base
- for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
- limbLen++;
- }
- limbLen--;
- limbPow = (limbPow / base) | 0;
-
- var total = number.length - start;
- var mod = total % limbLen;
- var end = Math.min(total, total - mod) + start;
-
- var word = 0;
- for (var i = start; i < end; i += limbLen) {
- word = parseBase(number, i, i + limbLen, base);
-
- this.imuln(limbPow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
-
- if (mod !== 0) {
- var pow = 1;
- word = parseBase(number, i, number.length, base);
-
- for (i = 0; i < mod; i++) {
- pow *= base;
- }
-
- this.imuln(pow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
-
- this.strip();
- };
-
- BN.prototype.copy = function copy (dest) {
- dest.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- dest.words[i] = this.words[i];
- }
- dest.length = this.length;
- dest.negative = this.negative;
- dest.red = this.red;
- };
-
- BN.prototype.clone = function clone () {
- var r = new BN(null);
- this.copy(r);
- return r;
- };
-
- BN.prototype._expand = function _expand (size) {
- while (this.length < size) {
- this.words[this.length++] = 0;
- }
- return this;
- };
-
- // Remove leading `0` from `this`
- BN.prototype.strip = function strip () {
- while (this.length > 1 && this.words[this.length - 1] === 0) {
- this.length--;
- }
- return this._normSign();
- };
-
- BN.prototype._normSign = function _normSign () {
- // -0 = 0
- if (this.length === 1 && this.words[0] === 0) {
- this.negative = 0;
- }
- return this;
- };
-
- BN.prototype.inspect = function inspect () {
- return (this.red ? '-
- - Sindre Sorhus' open source work is supported by the community on GitHub Sponsors and Dev - -
- Special thanks to: -
-