-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leading zeros are stripped from signature values #711
Comments
web3.eth.accounts.recoverTransaction(serializedTx) is also one of the methods that is unable to deal with the shorter zero-prunned RLP Encoded strings. |
Hi @SurfingNerd, thanks for investigating this issue, and the reproduction script. I suspect that this is a bug in web3, as it's probably treating How did you create/obtain that transaction? it would be really helpful to know this. @nivida, have you encountered something similar? |
@alcuadrado I came to the same conclusion, thus reported it at web3.js: web3/web3.js#2902 |
Thanks @d10r! This is being tracked in web3/web3.js#2777 |
@alcuadrado i obtained this signature by an Infineon security2go smart card. (therefore i can't provide the Private Key, since it is secure stored in the hardware) |
This should now be resolved in #812 by storing R & S as |
I'm opening this issue mainly to document some unexpected behavior in this library: When signing a transaction, the
r
ands
values get their leading zeros removed.This behavior doesn't invalidate the signatures, but can make comparing them non-obvious, as using
Buffer.prototype.equals
can give false negatives. As a workaround, ethereumjs-util's stripZeros can be used before comparing ther
ands
buffers:The root of this behavior is that this library's internal representation mimics the protocol-level rlp-encoded transaction representation. This is being reevaluated and may change in a future major version.
The text was updated successfully, but these errors were encountered: