-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support ledger-produced signature #164
Conversation
server/auth.go
Outdated
v := sig[64] | ||
// Ledger-produced signatures have v = 0 or 1 | ||
if v == 0 || v == 1 { | ||
v = v + 27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be sig[64] += 27
, to update the actual value at that index (instead of just the variable v)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
if v == 0 || v == 1 { | ||
v = v + 27 | ||
} | ||
if v != 27 && v != 28 { | ||
return false, errors.New("invalid signature (V is not 27 or 28)") | ||
} | ||
sig[64] -= 27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol weird that we subtract it later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it ends up being 0 or 1 anyway 🙃
Ledger-produced signatures have v = 0 or 1, meaning they fail the existing signature validation which expects v to be 27 or 28.
Manually making an exception to allow v to be 0 or 1 seems to be an accepted solution for now.
The issue is documented in this Github Issue
More info: https://ethereum.stackexchange.com/questions/103307/cannot-verifiy-a-signature-produced-by-ledger-in-solidity-using-ecrecover