Truffle testing - Trying to use web3 to test EIP712, are there any alternatives?

Viewed 555

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 Answers

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

Related