Skip to content
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

Merged
merged 2 commits into from
Sep 23, 2021
Merged

Support ledger-produced signature #164

merged 2 commits into from
Sep 23, 2021

Conversation

kaitoo1
Copy link
Collaborator

@kaitoo1 kaitoo1 commented Sep 23, 2021

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

@kaitoo1 kaitoo1 requested a review from benny-conn September 23, 2021 04:35
@kaitoo1 kaitoo1 self-assigned this Sep 23, 2021
@kaitoo1 kaitoo1 requested a review from Robinnnnn September 23, 2021 04:35
server/auth.go Outdated
v := sig[64]
// Ledger-produced signatures have v = 0 or 1
if v == 0 || v == 1 {
v = v + 27
Copy link
Collaborator

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)

Copy link
Collaborator Author

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
Copy link
Collaborator

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

Copy link
Collaborator Author

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 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants