enforce low S values on key signing, read BIP62 for details (reverted from commit 722e2efeae)

This commit is contained in:
“thoatbk” 2014-12-11 22:31:56 +01:00
parent 722e2efeae
commit 684c306833

View File

@ -160,11 +160,6 @@ Key.sign = function(hash, priv, k) {
var Q = Point.multiply(G, k);
var r = Q.x.mod(n);
var s = k.invm(n).mul(e.add(d.mul(r))).mod(n);
// use only low S values according to BIP62
var n_half = new bignum(n).div(2);
if (s.cmp(n_half) > 0) {
s = new bignum(n).sub(s);
}
} while (r.cmp(new bignum(0)) <= 0 || s.cmp(new bignum(0)) <= 0);
return {r: r, s: s};