izelnakri / eth

Ethereum utilities for Elixir
MIT License
119 stars 44 forks source link

fix: trim leading zeroes in `r`, `s` values in signatures #101

Closed lurodrigo closed 1 year ago

lurodrigo commented 1 year ago

According to the Ethereum Yellowpaper:

When interpreting RLP data, if an expected fragment is decoded as a scalar and leading zeroes are found in the byte sequence, clients are required to consider it non-canonical and treat it in the same manner as otherwise invalid RLP data, dismissing it completely.

Thus, the r and s in signatures values must have leading zeroes trimmed. Currently we don't have them trimmed which occasionally leads to transactions being rejected when broadcasting. This PR addresses this.

I wasn't able to run the tests successfully using the instructions provided in the main repo's README and some of them don't even do ganache calls, which suggest the test suite is out of date or I made something wrong? With your help I can make the necessary test updates.

izelnakri commented 1 year ago

Hi @lurodrigo ! Apologies for not reviewing this PR earlier, I'm having a look now!