bn.js 4.11.3 → 4.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +2 -0
- package/README.md +7 -5
- package/lib/bn.js +392 -383
- package/package.json +1 -1
- package/util/genCombMulTo10.js +8 -7
- package/.travis.yml +0 -15
- package/test/arithmetic-test.js +0 -635
- package/test/binary-test.js +0 -228
- package/test/constructor-test.js +0 -149
- package/test/fixtures.js +0 -264
- package/test/pummel/dh-group-test.js +0 -23
- package/test/red-test.js +0 -263
- package/test/utils-test.js +0 -345
package/.npmignore
CHANGED
package/README.md
CHANGED
|
@@ -40,12 +40,12 @@ is the list of them in the order of appearance in the function name:
|
|
|
40
40
|
The only available postfix at the moment is:
|
|
41
41
|
|
|
42
42
|
* `n` - which means that the argument of the function must be a plain JavaScript
|
|
43
|
-
|
|
43
|
+
Number. Decimals are not supported.
|
|
44
44
|
|
|
45
45
|
### Examples
|
|
46
46
|
|
|
47
47
|
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
|
48
|
-
* `a.
|
|
48
|
+
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
|
49
49
|
* `a.iushln(13)` - shift bits of `a` left by 13
|
|
50
50
|
|
|
51
51
|
## Instructions
|
|
@@ -63,7 +63,9 @@ either `le` (little-endian) or `be` (big-endian).
|
|
|
63
63
|
pad to length, throwing if already exceeding
|
|
64
64
|
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
|
65
65
|
which must behave like an `Array`
|
|
66
|
-
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available)
|
|
66
|
+
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
|
67
|
+
compatibility with browserify and similar tools, use this instead:
|
|
68
|
+
`a.toArrayLike(Buffer, endian, length)`
|
|
67
69
|
* `a.bitLength()` - get number of bits occupied
|
|
68
70
|
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
|
69
71
|
(example: `1010000` has 4 zero bits)
|
|
@@ -81,7 +83,7 @@ either `le` (little-endian) or `be` (big-endian).
|
|
|
81
83
|
* `a.eq(b)` - `a` equals `b` (`n`)
|
|
82
84
|
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
|
83
85
|
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
|
84
|
-
* `
|
|
86
|
+
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
|
85
87
|
|
|
86
88
|
### Arithmetics
|
|
87
89
|
|
|
@@ -150,7 +152,7 @@ Or:
|
|
|
150
152
|
var red = BN.mont(num);
|
|
151
153
|
```
|
|
152
154
|
|
|
153
|
-
To reduce numbers with [Montgomery trick][
|
|
155
|
+
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
|
154
156
|
`.red(num)`, but slower than `BN.red(primeName)`.
|
|
155
157
|
|
|
156
158
|
### Converting numbers
|