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

Improve the verification of v value in signature #15

Merged
merged 8 commits into from
Oct 25, 2023

Conversation

joii2020
Copy link
Collaborator

@joii2020 joii2020 commented Oct 23, 2023

Verify the range of v in sign more strictly based on official documentation or code.

  • Bitcoin: Certainly, there are no issues. Simply adhere to BIP137 in its entirety.
  • Ethereum: Based on his code, it could be 0, 1, 27, or 28. However, according to the description in EIP155, it could also be v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36.
    I see EIP-155 mentioned here

Test cases are being improved.

@XuJiandong
Copy link
Collaborator

@janx Could you review this change, especially the Ethereum part.

@XuJiandong XuJiandong changed the title [WIP] Improve the verification of v value in signature Improve the verification of v value in signature Oct 23, 2023
c/auth.c Show resolved Hide resolved
c/auth.c Outdated

// where the V value will be 27 or 28 for legacy reasons
// https://ethereum.github.io/yellowpaper/paper.pdf
if (recid == 27 || recid == 28) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

37 and 38 are also possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, mainnet is this value. If we support mainnet, do we still need to support others? Or should we simply not support these?

Copy link

@KaoImin KaoImin Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chain relpay protection recovery id is calculated with this method: {0,1} + CHAIN_ID * 2 + 35 since EIP-155. It should be to consider. I don't think it is a good way to keep some available CHAIN_IDs. Because it's user's work.

@XuJiandong XuJiandong requested a review from KaoImin October 24, 2023 09:32
c/auth.c Outdated
Comment on lines 241 to 242
// where the V value will be 27 or 28 for legacy reasons
// https://ethereum.github.io/yellowpaper/paper.pdf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation seems not exact.

@KaoImin
Copy link

KaoImin commented Oct 24, 2023

LGTM except the annotation

@XuJiandong XuJiandong merged commit 4d02f6b into nervosnetwork:main Oct 25, 2023
2 checks passed
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.

3 participants