ec: use isSecondKey in recoverPubKey

This commit is contained in:
Fedor Indutny
2015-11-02 16:01:33 -05:00
parent 2477fae5cd
commit f5bd12fa53
+6 -2
View File
@@ -186,8 +186,12 @@ EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
throw new Error('Unable to find sencond key candinate');
// 1.1. Let x = r + jn.
r = this.curve.pointFromX(r, isYOdd);
var eNeg = e.neg().umod(n);
if (isSecondKey)
r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
else
r = this.curve.pointFromX(r, isYOdd);
var eNeg = n.sub(e);
// 1.6.1 Compute Q = r^-1 (sR - eG)
// Q = r^-1 (sR + -eG)