You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that there is a bug in splitSignatureToRSV function when attempting to sign permits via a Ledger wallet and then trying to pass the resulting signature to an on-chain Ethereum contract method that consumes it. This is due to how Ledger produces vrs signatures with a canonical v value of {0,1}, while Ethereum's ecrecover accepts a non-standard v value of {27,28}. More on that here and here.
Metamask handles this internally when signing a permit directly through it, since it uses ecsign that normalizes the v value for Ethereum. But the problem is when signing a permit internally on a Ledger and then relay the resulting signature to Metamask, the v value is still {0,1}.
This could be resolved by replacing splitSignatureToRSV by ether's splitSignature, since it handles normalizing the resulting v value to Ethereum (i.e., 0 -> 27, 1 -> 28). Plus, it includes handling other special types signatures that are also not handled in splitSignatureToRSV's implementation (i.e., EIP-2098 signatures).
The text was updated successfully, but these errors were encountered:
scorpion9979
changed the title
Bug when signing permits via a Ledger wallet
Bug when signing permits on a Ledger wallet
Jan 25, 2023
I noticed that there is a bug in
splitSignatureToRSV
function when attempting to sign permits via a Ledger wallet and then trying to pass the resulting signature to an on-chain Ethereum contract method that consumes it. This is due to how Ledger produces vrs signatures with a canonical v value of {0,1}, while Ethereum'secrecover
accepts a non-standard v value of {27,28}. More on that here and here.Metamask handles this internally when signing a permit directly through it, since it uses
ecsign
that normalizes the v value for Ethereum. But the problem is when signing a permit internally on a Ledger and then relay the resulting signature to Metamask, the v value is still {0,1}.This could be resolved by replacing
splitSignatureToRSV
by ether'ssplitSignature
, since it handles normalizing the resulting v value to Ethereum (i.e., 0 -> 27, 1 -> 28). Plus, it includes handling other special types signatures that are also not handled insplitSignatureToRSV
's implementation (i.e., EIP-2098 signatures).The text was updated successfully, but these errors were encountered: