Add `hashStruct()` for EIP-712 struct hash computation
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
Opening new issue as discussed here: https://github.com/ethereum/solidity/issues/14157#issuecomment-1537226011
## Abstract
Let's add function `type(S).hashStruct(s)` to compute `bytes32` hash from `S memory s` or `S calldata s` argument where `S` is struct compatible with EIP-712.
## Motivation
EIP-712 is pretty popular among Solidity projects, recently `typehash()` function were requested to be implemented here: https://github.com/ethereum/solidity/issues/14157. Having function to compute struct instance hash would be one more adoption step for this EIP.
## Specification
Implementation details could be borrowed form here: https://eips.ethereum.org/EIPS/eip-712
## Backwards Compatibility
Not required
Contributor guide
Research direction
Start by reading the linked discussion in issue #14157 and the EIP-712 specification, then trace the compiler entry points for the proposed type(S).hashStruct(s) function. Done means supporting memory and calldata struct arguments compatible with EIP-712 and producing the specified bytes32 struct hash, with coverage in the relevant compiler tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- blockchain, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100