@@ -3470,10 +3470,9 @@ function BaseCurve(type, conf) {
3470
3470
// Generalized Greg Maxwell's trick
3471
3471
var adjustCount = this . n && this . p . div ( this . n ) ;
3472
3472
if ( ! adjustCount || adjustCount . cmpn ( 100 ) > 0 ) {
3473
- this . _maxwellAdjust = 0 ;
3474
3473
this . redN = null ;
3475
3474
} else {
3476
- this . _maxwellAdjust = adjustCount . toNumber ( ) ;
3475
+ this . _maxwellTrick = true ;
3477
3476
this . redN = this . n . toRed ( this . red ) ;
3478
3477
}
3479
3478
}
@@ -4230,8 +4229,13 @@ Point.prototype.eqXToP = function eqXToP(x) {
4230
4229
if ( this . x . cmp ( rx ) === 0 )
4231
4230
return true ;
4232
4231
4232
+ var xc = x . clone ( ) ;
4233
4233
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
+
4235
4239
rx . redIAdd ( t ) ;
4236
4240
if ( this . x . cmp ( rx ) === 0 )
4237
4241
return true ;
@@ -5348,8 +5352,13 @@ JPoint.prototype.eqXToP = function eqXToP(x) {
5348
5352
if ( this . x . cmp ( rx ) === 0 )
5349
5353
return true ;
5350
5354
5355
+ var xc = x . clone ( ) ;
5351
5356
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
+
5353
5362
rx . redIAdd ( t ) ;
5354
5363
if ( this . x . cmp ( rx ) === 0 )
5355
5364
return true ;
@@ -5746,7 +5755,7 @@ EC.prototype.verify = function verify(msg, signature, key, enc) {
5746
5755
var u1 = sinv . mul ( msg ) . umod ( this . n ) ;
5747
5756
var u2 = sinv . mul ( r ) . umod ( this . n ) ;
5748
5757
5749
- if ( this . curve . _maxwellAdjust === 0 ) {
5758
+ if ( ! this . curve . _maxwellTrick ) {
5750
5759
var p = this . g . mulAdd ( u1 , key . getPublic ( ) , u2 ) ;
5751
5760
if ( p . isInfinity ( ) )
5752
5761
return false ;
@@ -8637,7 +8646,7 @@ if (typeof Object.create === 'function') {
8637
8646
} , { } ] , 26 :[ function ( require , module , exports ) {
8638
8647
module . exports = {
8639
8648
"name" : "elliptic" ,
8640
- "version" : "6.3.0 " ,
8649
+ "version" : "6.3.1 " ,
8641
8650
"description" : "EC cryptography" ,
8642
8651
"main" : "lib/elliptic.js" ,
8643
8652
"files" : [
0 commit comments