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

checkSignature this method why need >= 4 #29694

Closed
SuperEdison opened this issue May 2, 2024 · 5 comments
Closed

checkSignature this method why need >= 4 #29694

SuperEdison opened this issue May 2, 2024 · 5 comments

Comments

@SuperEdison
Copy link

This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use discord or the Ethereum stack exchange at https://ethereum.stackexchange.com.
image
when secp256 checkSignature method, why signature[64]>=4, v is 27 or 28 right?
could anyone tell me, please

@weiihann
Copy link
Contributor

weiihann commented May 3, 2024

sig[64] implies the recovery ID, which only has possible values of 0, 1, 2 or 3. Hence, if the recovery ID is greater than or equal to 4, then it's not a valid recovery id.

This link could be helpful.

@holiman
Copy link
Contributor

holiman commented May 7, 2024

thanks @weiihann for answering

@holiman holiman closed this as completed May 7, 2024
@SuperEdison
Copy link
Author

why i always get 27 or 28 by signMessage of metamask?how to handle this

@SuperEdison
Copy link
Author

i just used eth_sign, i always get 27

@SuperEdison
Copy link
Author

i have totally knew what happen, first one it is be eth_sign method by metamask that can't be recover by go-ethereum, because eth_sign is deprecated, so we need to use personal_sign method to solve it. second we need to sub 27 if v == 27 or 28, and we need to sub 35 and sub chainID * 2 if v is over 30 @weiihann that's right?

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

No branches or pull requests

3 participants