I just can't get the MinimalForwarder Contract to successfully verify
my EIP712 signature.
Having thoroughly tested verifying the signature with tools like ethers or metamask eth-sig-utils works successfully however. (see code below). My last hope is that someone with clear eyes can help me resolve this issue. Thank you!
Code to reproduce
Here is the data I signed (both using Metamask, metamasks eth-sig-utils as well as ethers).
The resulting signature is the same.
const request = {
"value":0,
"gas":300000,
"nonce":0,
"from":"0x32a7914b011e1dd6b58980080cb525bc546bc164",
"to":"0x46f4cd7c9c6aca27becf45cc5d836dddac204d32",
"data":"0x7a7f274ddbf166cf3a3757674f041fbd4ccc1cd6444a3ccebd526e196b6d24f1283aaf0000000000000000000000000000000000000000000000000000000000000000a01f5e482a2b11c7a811a5abe748024b24814656ca1d1f6c3d9a27d49ff75e54ff2cea6183837101e37145bacb145089ccd294e3ab1c1a5cdb98bcf5a6a675e59e000000000000000000000000000000000000000000000000000000000000001b0000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d6652376235706441435750515767534a6648726639467771677739726634474e505958394a794a5036566b380000000000000000000000"
}
const ForwardRequestType: MessageTypeProperty[] = [
{ name: 'from', type: 'address' },
{ name: 'to', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'gas', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'data', type: 'bytes' }
]
const typedData = {
domain: {
name: 'MinimalForwarder',
version: '0.0.1',
chainId: 80001,
verifyingContract: '0x2db308bbecc75649a37e166680986044dbab483d',
},
primaryType: 'ForwardRequest',
types: {
ForwardRequest: ForwardRequestType
},
message: {
request: request
}
};
const signature = "0xa5cb69a356943e1ee9641e8d301def17726fe9c080371f22020599172387505d097a4c84d779193abc7a21dda67bdaddb8810e9771c055734f25ccdfc84756f21b";
the following successful test shows that the signature is indeed correct:
let recovered_address = ethers.utils.verifyTypedData(
typedDataFromApp.domain as TypedDataDomain,
{ ForwardRequest: TypedData.types.ForwardRequest },
request,
signature
);
expect(recovered_address1.toLowerCase()).to.equal(request.from);
(I also repeated this test with metamask eth-sig-utils, recovery also works here).
In contrast, this test FAILS (response from MinimalForwarder verify(): false):
const { fw } = await loadFixture(deployForwarder);
const res = await fw.verify(request, signature);
expect(res).to.equal(true);
Environment
OpenZeppelin MinimalForwarder contract 0.0.1
see code here