go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

checkSignature this method why need >= 4

Open SuperEdison opened this issue 1 year ago • 1 comments

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

SuperEdison avatar May 02 '24 07:05 SuperEdison

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.

weiihann avatar May 03 '24 14:05 weiihann

thanks @weiihann for answering

holiman avatar May 07 '24 12:05 holiman

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

SuperEdison avatar May 14 '24 14:05 SuperEdison

i just used eth_sign, i always get 27

SuperEdison avatar May 15 '24 03:05 SuperEdison

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?

SuperEdison avatar May 15 '24 07:05 SuperEdison