[Naive Receiver] How do I sign data in Foundry? #64
-
I think I found how to exploit this contract, but I don't understand how to generate a NaiveReceiverTest::signature to pass in BasicForwarder::execute function. I found the similar vulnerability that been exploited using hardhat and ether.js library( const signature = await wallet.signTypedData(domain, types, data); But I don't understand how to get this signature function in Foundry, as there is no existing library that I can import to generate it. These are the last lines of my test that I am stuck on in Foundry: bytes32 memory domain = forwarder.domainSperator();
bytes32 memory types = forwarder.getRequestTypehash();
bytes32 memory dataHash = forwarder.getDataHash(request);
bytes memory signature = ??? ;
forwarder.execute(request,signature); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can get the signature from the forge cheat code So basically you would do the following to obtain the signature:
In addition make sure to supply the hash in a EIP721 compliant format. That means to use your
For more information have a look at the EIP712: https://eips.ethereum.org/EIPS/eip-712 |
Beta Was this translation helpful? Give feedback.
You can get the signature from the forge cheat code
vm.sign()
as explained here: https://book.getfoundry.sh/cheatcodes/sign.So basically you would do the following to obtain the signature:
In addition make sure to supply the hash in a EIP721 compliant format. That means to use your
dataHash
and hash it again with the following parameters:For more information have a look at the EIP712: https://eips.ethereum.org/EIPS/eip-712