_signTypedData result does not match address recovered from signature on the back-end side
See original GitHub issueDescribe the bug
When using signer._signTypedData
and MetaMask browser extension, the result of the function doesn’t match the recovered signature on the back-end.
Reproduction steps To reproduce this issue:
- create a new provider
const provider = new ethers.providers.Web3Provider(window.ethereum)
- create a signer calling
const signer = provider.current.getSigner()
- create a signature:
const signatureResult = await signer._signTypedData(
domain,
{ types: types.Auth}, // exclude the EIP712Domain type
message
);
- sign message via MetaMask;
After that, I make a request to the back-end server to verify the signed data and get JSON with data back, the error described above occurs as the result of this request.
Environment: Front-end:
- ethers.js
- useDapp
- Next.js
- TypeScript
Back-end:
- https://pypi.org/project/web3auth/ (custom open-source framework-agnostic solution for python, uses official ethereum library for python - https://github.com/ethereum/eth-account)
- Ganache
- Truffle
Current solution Currently, I rewrote the code to use the external provider’s sendAsync method like this:
provider.sendAsync(
{
method,
params: [
address,
JSON.stringify({
domain,
message,
primaryType,
types,
}),
],
}, (err, result) => ... )
This solved the issue for now. Maybe you could look up to this and propose a possible fix, or provide a better solution to the problem. Thank you in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
solidity cannot verify ethers.js signed data (signTypedData)
I am having a similar issue: using Metamask signTypedData_v4 to sign a message; I can recover address of signer in the browser but...
Read more >recover_message gives different address from EIP-712 ...
I'm trying to sign some data using EIP-712 with their Web3 client (Using Metamask in my case), and then recover the address on...
Read more >Signing and Verifying Ethereum Signatures
In this article, let's look at how you can perform off-chain computation using Ethereum signatures. Cryptographic signatures can be used to ...
Read more >EIP712 is here: What to expect and how to use it
Figure 1: a signature request from a dApp that does not use EIP712 ... compare the result to your wallet address, and then...
Read more >Documentation - Ethers.js
Performs a reverse lookup of the address in ENS using the Reverse Registrar. If the name does not exist, or the forward lookup...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Embarrassing to realize, I completely messed up with types…
fixed code
@ricmoo thank you for your help, I’m closing the issue.
Hello, @taayyohh. Sure, the problem is that I was passing an argument for types as an object with a ‘types’ key, which is the cause of the issue. So, consider { types: types.Auth } as a variable.