Force lower s value per BIP62

This commit is contained in:
bip32jp 2015-01-02 17:45:38 +09:00
parent b4db267cd7
commit de1e5558dc

View file

@ -769,6 +769,12 @@
badrs++
} while (r.compareTo(BigInteger.ZERO) <= 0 || s.compareTo(BigInteger.ZERO) <= 0);
// Force lower s values per BIP62
var halfn = n.shiftRight(1);
if (s.compareTo(halfn) > 0) {
s = n.subtract(s);
};
var sig = serializeSig(r, s);
sig.push(parseInt(1, 10));