3

I've been studying EIP712 and tried to implement some testing using truffle and Web3js. However, I noticed that web3.eth.accounts.sign() is compliant with EIP191, therefore I cannot retrieve the signer address correctly by using ECDSA.recover from OZ repository.

In this respect, my question is: which alternatives can be used to develop some tests for this new cryptographic signature standard? I've noticed that Metamask has this method signTypedData_V4, which sticks to the current signature version of OZ draft. I would like to know if I can hash and sign by this standard without Metamask assistance.

Links to ECDSA and EIP712 (draft) contracts from OZ:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/draft-EIP712.sol

Thanks to all of you in advance.

2 Answers2

1

You can use the method signTypedData from @metamask/eth-sig-util.

https://github.com/MetaMask/eth-sig-util/blob/main/src/sign-typed-data.ts#L521

Anderson Silva
  • 332
  • 2
  • 6
0

You need to use @truffle/hdwallet-provider for your signature to pass the test.

MadeInDreams
  • 1,991
  • 5
  • 33
  • 64