aboutsummaryrefslogtreecommitdiff
path: root/node_modules/elliptic/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/elliptic/lib
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/elliptic/lib')
-rw-r--r--node_modules/elliptic/lib/elliptic/curve/edwards.js14
-rw-r--r--node_modules/elliptic/lib/elliptic/curve/short.js1
2 files changed, 7 insertions, 8 deletions
diff --git a/node_modules/elliptic/lib/elliptic/curve/edwards.js b/node_modules/elliptic/lib/elliptic/curve/edwards.js
index 6e9fb7742..a8965eaec 100644
--- a/node_modules/elliptic/lib/elliptic/curve/edwards.js
+++ b/node_modules/elliptic/lib/elliptic/curve/edwards.js
@@ -74,10 +74,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) {
@@ -91,7 +91,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);
@@ -168,7 +168,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() {
@@ -249,7 +250,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
@@ -425,7 +426,6 @@ Point.prototype.eqXToP = function eqXToP(x) {
if (this.x.cmp(rx) === 0)
return true;
}
- return false;
};
// Compatibility with BaseCurve
diff --git a/node_modules/elliptic/lib/elliptic/curve/short.js b/node_modules/elliptic/lib/elliptic/curve/short.js
index 0a09d2497..5a0e86032 100644
--- a/node_modules/elliptic/lib/elliptic/curve/short.js
+++ b/node_modules/elliptic/lib/elliptic/curve/short.js
@@ -921,7 +921,6 @@ JPoint.prototype.eqXToP = function eqXToP(x) {
if (this.x.cmp(rx) === 0)
return true;
}
- return false;
};
JPoint.prototype.inspect = function inspect() {