Skip to content

Commit

Permalink
6.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Aug 9, 2018
1 parent 776c9b0 commit 523da1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
17 changes: 8 additions & 9 deletions dist/elliptic.js
Expand Up @@ -467,10 +467,10 @@ EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
if (!y.red)
y = y.toRed(this.red);

// x^2 = (y^2 - 1) / (d y^2 + 1)
// x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
var y2 = y.redSqr();
var lhs = y2.redSub(this.one);
var rhs = y2.redMul(this.d).redAdd(this.one);
var lhs = y2.redSub(this.c2);
var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
var x2 = lhs.redMul(rhs.redInvm());

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

if (x.isOdd() !== odd)
if (x.fromRed().isOdd() !== odd)
x = x.redNeg();

return this.point(x, y);
Expand Down Expand Up @@ -561,7 +561,8 @@ Point.prototype.inspect = function inspect() {
Point.prototype.isInfinity = function isInfinity() {
// XXX This code assumes that zero is always zero in red
return this.x.cmpn(0) === 0 &&
this.y.cmp(this.z) === 0;
(this.y.cmp(this.z) === 0 ||
(this.zOne && this.y.cmp(this.curve.c) === 0));
};

Point.prototype._extDbl = function _extDbl() {
Expand Down Expand Up @@ -642,7 +643,7 @@ Point.prototype._projDbl = function _projDbl() {
// E = C + D
var e = c.redAdd(d);
// H = (c * Z1)^2
var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
var h = this.curve._mulC(this.z).redSqr();
// J = E - 2 * H
var j = e.redSub(h).redSub(h);
// X3 = c * (B - E) * J
Expand Down Expand Up @@ -818,7 +819,6 @@ Point.prototype.eqXToP = function eqXToP(x) {
if (this.x.cmp(rx) === 0)
return true;
}
return false;
};

// Compatibility with BaseCurve
Expand Down Expand Up @@ -1941,7 +1941,6 @@ JPoint.prototype.eqXToP = function eqXToP(x) {
if (this.x.cmp(rx) === 0)
return true;
}
return false;
};

JPoint.prototype.inspect = function inspect() {
Expand Down Expand Up @@ -8751,7 +8750,7 @@ utils.encode = function encode(arr, enc) {
},{}],30:[function(require,module,exports){
module.exports={
"name": "elliptic",
"version": "6.4.0",
"version": "6.4.1",
"description": "EC cryptography",
"main": "lib/elliptic.js",
"files": [
Expand Down

0 comments on commit 523da1c

Please sign in to comment.