You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed the following code for generating a Merkle leaf: bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount))));
The goal is to perform a double hash to prevent second pre-image attacks. However, bytes.concat seems unnecessary for a single bytes32 value.
I appreciate that bytes.concat() accepts a bytesX (x is an integer <= 32) and returns bytes memory which is what we want to pass to our keccak256 to get the 2nd hash, but abi.encode also does the same thing which seems a lot more straightforward?
Chisel
The text was updated successfully, but these errors were encountered:
foundry-merkle-airdrop-cu/src/MerkleAirdrop.sol
Line 70 in b4c627c
I noticed the following code for generating a Merkle leaf:
bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount))));
The goal is to perform a double hash to prevent second pre-image attacks. However, bytes.concat seems unnecessary for a single bytes32 value.
I would've suggested using
abi.encode
.bytes32 leaf = keccak256(abi.encode(keccak256(abi.encode(account, amount))));
I appreciate that bytes.concat() accepts a bytesX (x is an integer <= 32) and returns
bytes memory
which is what we want to pass to ourkeccak256
to get the 2nd hash, butabi.encode
also does the same thing which seems a lot more straightforward?Chisel
The text was updated successfully, but these errors were encountered: