Fix to check for zero s value in sign function

If r OR s are zero then recalculate both r and s until they are both non-zero values.
This commit is contained in:
Rich Morgan 2014-05-28 11:34:18 -04:00
parent bc84d1e82b
commit eab5c2896e
1 changed files with 2 additions and 3 deletions

View File

@ -120,9 +120,8 @@ Key.prototype.signSync = function(hash) {
var G = ecparams.getG();
var Q = G.multiply(k);
var r = Q.getX().toBigInteger().mod(n);
} while (r.compareTo(BigInteger.ZERO) <= 0);
var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n);
var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n);
} while (r.compareTo(BigInteger.ZERO) <= 0 || s.compareTo(BigInteger.ZERO) <= 0);
return serializeSig(r, s);
};