8000 6.3.1 · etherscan-io/elliptic@c53f5cf · GitHub
[go: up one dir, main page]

Skip to content

Commit c53f5cf

Browse files
committed
6.3.1
1 parent 725bd91 commit c53f5cf

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

dist/elliptic.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,10 +3470,9 @@ function BaseCurve(type, conf) {
34703470
// Generalized Greg Maxwell's trick
34713471
var adjustCount = this.n && this.p.div(this.n);
34723472
if (!adjustCount || adjustCount.cmpn(100) > 0) {
3473-
this._maxwellAdjust = 0;
34743473
this.redN = null;
34753474
} else {
3476-
this._maxwellAdjust = adjustCount.toNumber();
3475+
this._maxwellTrick = true;
34773476
this.redN = this.n.toRed(this.red);
34783477
}
34793478
}
@@ -4230,8 +4229,13 @@ Point.prototype.eqXToP = function eqXToP(x) {
42304229
if (this.x.cmp(rx) === 0)
42314230
return true;
42324231

4232+
var xc = x.clone();
42334233
var t = this.curve.redN.redMul(this.z);
4234-
for (var i = 1; i <= this.curve._maxwellAdjust; i++) {
4234+
for (;;) {
4235+
xc.iadd(this.curve.n);
4236+
if (xc.cmp(this.curve.p) >= 0)
4237+
return false;
4238+
42354239
rx.redIAdd(t);
42364240
if (this.x.cmp(rx) === 0)
42374241
return true;
@@ -5348,8 +5352,13 @@ JPoint.prototype.eqXToP = function eqXToP(x) {
53485352
if (this.x.cmp(rx) === 0)
53495353
return true;
53505354

5355+
var xc = x.clone();
53515356
var t = this.curve.redN.redMul(zs);
5352-
for (var i = 1; i <= this.curve._maxwellAdjust; i++) {
5357+
for (;;) {
5358+
xc.iadd(this.curve.n);
5359+
if (xc.cmp(this.curve.p) >= 0)
5360+
return false;
5361+
53535362
rx.redIAdd(t);
53545363
if (this.x.cmp(rx) === 0)
53555364
return true;
@@ -5746,7 +5755,7 @@ EC.prototype.verify = function verify(msg, signature, key, enc) {
57465755
var u1 = sinv.mul(msg).umod(this.n);
57475756
var u2 = sinv.mul(r).umod(this.n);
57485757

5749-
if (this.curve._maxwellAdjust === 0) {
5758+
if (!this.curve._maxwellTrick) {
57505759
var p = this.g.mulAdd(u1, key.getPublic(), u2);
57515760
if (p.isInfinity())
57525761
return false;
@@ -8637,7 +8646,7 @@ if (typeof Object.create === 'function') {
86378646
},{}],26:[function(require,module,exports){
86388647
module.exports={
86398648
"name": "elliptic",
8640-
"version": "6.3.0",
8649+
"version": "6.3.1",
86418650
"description": "EC cryptography",
86428651
"main": "lib/elliptic.js",
86438652
"files": [

0 commit comments

Comments
 (0)
0