Inconsistent signature notation with personal_sign
and Ledger #10850
Description
Describe the bug
This is quite a minor issue but I noticed that the signatures produced from personal_sign
when using a MetaMask account and a Ledger HW wallet account are inconsistent.
Steps to reproduce
In order to reproduce this, simply sign with a MetaMask account and a Ledger account, and see that the notation used for the signature recovery value (a.k.a. v-value) are inconsistent:
- Use
personal_sign
to sign a message with a MetaMask account- notice that the signature has
v ∊ {27, 28}
- notice that the signature has
- Use
personal_sign
to sign a message with an imported Ledger account- notice that the signature has
v ∊ {0, 1}
- notice that the signature has
Sample code
const [account] = await window.ethereum.request({ method: "eth_requestAccounts" });
console.log(await window.ethereum.request({
method: "personal_sign",
params: [account, "MetaMask rocks!"],
}));
Expected behavior
Expected the signature notation to be the same. Specifically v ∊ {27, 28}
as:
- That is what the "normal" MetaMask accounts do
- That is what the Ethereum JSON RPC example suggests is correct for the related
eth_sign
method - That is the notation used for transactions signatures
- That is how Ethereum nodes behave (e.g. Geth)
Browser details:
- OS: Fedora 33
- Hardware Wallet: Ledger Nano S Firmware version 1.6.1
- Browser: Firefox 87
- MetaMask Version: 9.3.0
Additional context
I believe that the fix is very easy. It looks like the Ledger keyring mistakenly converts from v ∊ {27, 28}
to v ∊ {0, 1}
notation: /~https://github.com/MetaMask/eth-ledger-bridge-keyring/blob/d525991401df398f288270f83e2c44b6804c76ee/index.js#L248