@@ -467,10 +467,10 @@ EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
467
467
if ( ! y . red )
468
468
y = y . toRed ( this . red ) ;
469
469
470
- // x^2 = (y^2 - 1 ) / (d y^2 + 1 )
470
+ // x^2 = (y^2 - c^2 ) / (c^2 d y^2 - a )
471
471
var y2 = y . redSqr ( ) ;
472
- var lhs = y2 . redSub ( this . one ) ;
473
- var rhs = y2 . redMul ( this . d ) . redAdd ( this . one ) ;
472
+ var lhs = y2 . redSub ( this . c2 ) ;
473
+ var rhs = y2 . redMul ( this . d ) . redMul ( this . c2 ) . redSub ( this . a ) ;
474
474
var x2 = lhs . redMul ( rhs . redInvm ( ) ) ;
475
475
476
476
if ( x2 . cmp ( this . zero ) === 0 ) {
@@ -484,7 +484,7 @@ EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
484
484
if ( x . redSqr ( ) . redSub ( x2 ) . cmp ( this . zero ) !== 0 )
485
485
throw new Error ( 'invalid point' ) ;
486
486
487
- if ( x . isOdd ( ) !== odd )
487
+ if ( x . fromRed ( ) . isOdd ( ) !== odd )
488
488
x = x . redNeg ( ) ;
489
489
490
490
return this . point ( x , y ) ;
@@ -561,7 +561,8 @@ Point.prototype.inspect = function inspect() {
561
561
Point . prototype . isInfinity = function isInfinity ( ) {
562
562
// XXX This code assumes that zero is always zero in red
563
563
return this . x . cmpn ( 0 ) === 0 &&
564
- this . y . cmp ( this . z ) === 0 ;
564
+ ( this . y . cmp ( this . z ) === 0 ||
565
+ ( this . zOne && this . y . cmp ( this . curve . c ) === 0 ) ) ;
565
566
} ;
566
567
567
568
Point . prototype . _extDbl = function _extDbl ( ) {
@@ -642,7 +643,7 @@ Point.prototype._projDbl = function _projDbl() {
642
643
// E = C + D
643
644
var e = c . redAdd ( d ) ;
644
645
// H = (c * Z1)^2
645
- var h = this . curve . _mulC ( this . c . redMul ( this . z ) ) . redSqr ( ) ;
646
+ var h = this . curve . _mulC ( this . z ) . redSqr ( ) ;
646
647
// J = E - 2 * H
647
648
var j = e . redSub ( h ) . redSub ( h ) ;
648
649
// X3 = c * (B - E) * J
@@ -818,7 +819,6 @@ Point.prototype.eqXToP = function eqXToP(x) {
818
819
if ( this . x . cmp ( rx ) === 0 )
819
820
return true ;
820
821
}
821
- return false ;
822
822
} ;
823
823
824
824
// Compatibility with BaseCurve
@@ -1941,7 +1941,6 @@ JPoint.prototype.eqXToP = function eqXToP(x) {
1941
1941
if ( this . x . cmp ( rx ) === 0 )
1942
1942
return true ;
1943
1943
}
1944
- return false ;
1945
1944
} ;
1946
1945
1947
1946
JPoint . prototype . inspect = function inspect ( ) {
@@ -8751,7 +8750,7 @@ utils.encode = function encode(arr, enc) {
8751
8750
} , { } ] , 30 :[ function ( require , module , exports ) {
8752
8751
module . exports = {
8753
8752
"name" : "elliptic" ,
8754
- "version" : "6.4.0 " ,
8753
+ "version" : "6.4.1 " ,
8755
8754
"description" : "EC cryptography" ,
8756
8755
"main" : "lib/elliptic.js" ,
8757
8756
"files" : [
0 commit comments