ethereum / eth-keys

A common API for Ethereum key operations.
MIT License
159 stars 64 forks source link

Fix coincurve backend signature validation #62

Closed jannikluhn closed 5 years ago

jannikluhn commented 5 years ago

What was wrong?

ECDSA signatures can be represented with a low or a high s: https://bitcoin.stackexchange.com/questions/83408/in-ecdsa-why-is-r-%E2%88%92s-mod-n-complementary-to-r-s

High-s signatures are forbidden in Ethereum, but only since Homestead, so eth-keys needs to support both forms. However, Coincurve rejects high-s signatures during verification.

This error was introduced with the non recoverable signatures (prior to this we just recovered the signer and compared, so we didn't use the Coincurve signature verification function).

How was it fixed?

Convert an incoming high-s signature to its equivalent low-s representation before passing it to coincurve. Also, add some tests for this.

Cute Animal Picture

Cute animal picture

pipermerriam commented 5 years ago

Going to wait until Monday to release this since I'm out of town over the weekend and we try to avoid cutting releases on Fridays in case anything un-expected happens.

jannikluhn commented 5 years ago

I ran both the py-evm fixtures and the failing Trinity test with this PR and everything seems to pass. So I think we can merge and release (would do it myself, but I don't have permissions in this repo).

carver commented 5 years ago

@jannikluhn v0.2.4 released with this merge!