Skip to content

Commit 523da1c

Browse files
committed
6.4.1
1 parent 776c9b0 commit 523da1c

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

dist/elliptic.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,10 @@ EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
467467
if (!y.red)
468468
y = y.toRed(this.red);
469469

470-
// x^2 = (y^2 - 1) / (d y^2 + 1)
470+
// x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
471471
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);
474474
var x2 = lhs.redMul(rhs.redInvm());
475475

476476
if (x2.cmp(this.zero) === 0) {
@@ -484,7 +484,7 @@ EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
484484
if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
485485
throw new Error('invalid point');
486486

487-
if (x.isOdd() !== odd)
487+
if (x.fromRed().isOdd() !== odd)
488488
x = x.redNeg();
489489

490490
return this.point(x, y);
@@ -561,7 +561,8 @@ Point.prototype.inspect = function inspect() {
561561
Point.prototype.isInfinity = function isInfinity() {
562562
// XXX This code assumes that zero is always zero in red
563563
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));
565566
};
566567

567568
Point.prototype._extDbl = function _extDbl() {
@@ -642,7 +643,7 @@ Point.prototype._projDbl = function _projDbl() {
642643
// E = C + D
643644
var e = c.redAdd(d);
644645
// 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();
646647
// J = E - 2 * H
647648
var j = e.redSub(h).redSub(h);
648649
// X3 = c * (B - E) * J
@@ -818,7 +819,6 @@ Point.prototype.eqXToP = function eqXToP(x) {
818819
if (this.x.cmp(rx) === 0)
819820
return true;
820821
}
821-
return false;
822822
};
823823

824824
// Compatibility with BaseCurve
@@ -1941,7 +1941,6 @@ JPoint.prototype.eqXToP = function eqXToP(x) {
19411941
if (this.x.cmp(rx) === 0)
19421942
return true;
19431943
}
1944-
return false;
19451944
};
19461945

19471946
JPoint.prototype.inspect = function inspect() {
@@ -8751,7 +8750,7 @@ utils.encode = function encode(arr, enc) {
87518750
},{}],30:[function(require,module,exports){
87528751
module.exports={
87538752
"name": "elliptic",
8754-
"version": "6.4.0",
8753+
"version": "6.4.1",
87558754
"description": "EC cryptography",
87568755
"main": "lib/elliptic.js",
87578756
"files": [

0 commit comments

Comments
 (0)