how to confirm ethers signatures onchain? #3797
grapevinegizmos
started this conversation in
General
Replies: 1 comment
-
Was able to determine that Metamask prepends the header ""\x19Ethereum Signed Message:\n(message length) to the message before it computes the hash. If you prepend the same header to the message before calling the ECDSA.recover it will return the right address. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's fairly easy to get use ethers to get a metamask signature of a given piece of text, but how to confirm the signer onchain seems to be a bigger challenge than I thought). On a client side app with metamask installed I can call:
Metamask will pop the signing verification dialog, and return a signature.
You can pretty easily validate the address that produced the signature:
But if you want to send the signature to a smart contract, and confirm that a string message was signed by a particlar account, its not so easy.
The ECDSA package from OpenZeppelin has a recover() function but it only takes a hash as the "message', not a string, like "hello world". You can hash the string, but that doesn't return the right answer either:
Does not return the address of the signer.
Nor does
So how can validate you validate on-chain that the signature of a message produced off-chain by ethers is in fact the expected signer address??
Beta Was this translation helpful? Give feedback.
All reactions