Skip to content

Commit af4b506

Browse files
committed
Merge pull request #5 from crypto-browserify/bump-bn
bump bn-js
2 parents 9b4d263 + 59519e5 commit af4b506

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

index.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function crt(msg, priv) {
1414
var blinds = blind(priv);
1515
var len = priv.modulus.byteLength();
1616
var mod = bn.mont(priv.modulus);
17-
var blinded = new bn(msg).mul(blinds.blinder).mod(priv.modulus);
17+
var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
1818
var c1 = blinded.toRed(bn.mont(priv.prime1));
1919
var c2 = blinded.toRed(bn.mont(priv.prime2));
2020
var qinv = priv.coefficient;
@@ -24,23 +24,17 @@ function crt(msg, priv) {
2424
var m2 = c2.redPow(priv.exponent2);
2525
m1 = m1.fromRed();
2626
m2 = m2.fromRed();
27-
var h = m1.isub(m2).imul(qinv).mod(p);
27+
var h = m1.isub(m2).imul(qinv).umod(p);
2828
h.imul(q);
2929
m2.iadd(h);
30-
var out = new Buffer(m2.imul(blinds.unblinder).mod(priv.modulus).toArray());
31-
if (out.length < len) {
32-
var prefix = new Buffer(len - out.length);
33-
prefix.fill(0);
34-
out = Buffer.concat([prefix, out], len);
35-
}
36-
return out;
30+
return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
3731
}
3832
crt.getr = getr;
3933
function getr(priv) {
4034
var len = priv.modulus.byteLength();
4135
var r = new bn(randomBytes(len));
42-
while (r.cmp(priv.modulus) >= 0 || !r.mod(priv.prime1) || !r.mod(priv.prime2)) {
36+
while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
4337
r = new bn(randomBytes(len));
4438
}
4539
return r;
46-
}
40+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "",
1010
"license": "MIT",
1111
"dependencies": {
12-
"bn.js": "^2.0.0",
12+
"bn.js": "^3.0.0",
1313
"randombytes": "^2.0.1"
1414
},
1515
"repository": {

test.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)