programmingbitcoin
programmingbitcoin copied to clipboard
S256Point.verify and Signature class in ecc.py do not issue warning if "s" value is high
When an ECDSA signature is made with this library using PrivateKey.sign it is canonicalized so the s value is low, ie. so (& see Issue #296) :
s < N // 2
where
N = order of secp256k1 generator point G =
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
N // 2 =
7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 (exact)
However if a signature with high s that was obtained from some other cryptography library (eg. openssl or Python ecdsa package) is verified using S256Point.verify then no warning is issued that the s value is high and needs to be replaced with N - s to be accepted by the Bitcoin network.
Likewise in the Signature class, in the constructor and the parse method, no warning is issued if the s value is high.