ERC-7920 Composite EIP-712 signature (Composite EIP-712 Signatures)
Draft · Signatures & auth · created 2025-03-20
A standard that bundles multiple EIP-712 typed data messages into a Merkle tree so they can be handled with a single signature, while still allowing each message to be verified independently of the others.
Why it is needed
As more transactions are processed without ETH, users often need to sign multiple off-chain messages within a short period. For example, a user may have to sign once to set a spending limit, and then sign again to actually instruct that the funds be spent. Existing approaches to this problem each have drawbacks. Pre-approving a generous spending limit exposes the entire limit to theft risk. Combining multiple messages into a single signature reduces the number of signing requests but makes it impossible to verify an individual message without knowing the whole bundle. Sending a separate signing request for each message makes verification easy but causes repeated wallet pop-ups, degrading the user experience and causing confusion about what is being agreed to overall.
In depth
Composite signature generation process
Each message in the set [m1, m2, ..., mn] is encoded using EIP-712's encode and then hashed with keccak256 (hash = keccak256(encode(m))). These hashes serve as leaf nodes to build a Merkle tree, and the merkleRoot is computed. The user signs only this single merkleRoot, not the individual messages (signature = sign(merkleRoot)).
Both verification steps must pass
To verify that an individual message mx is included in a composite signature, two things are checked. First, the signer is recovered from the signature over the merkleRoot using ecrecover and compared against the expected signer (isValidSignature). Second, the leaf for mx is computed as keccak256(encode(mx)), and _verifyMerkleProof checks whether the given Merkle proof validly leads to the merkleRoot (isValidProof). isVerified becomes true only if both checks succeed.
The eth_signTypedData_v5 JSON-RPC method
This ERC adds the eth_signTypedData_v5 method to the Ethereum JSON-RPC. Its parameters are the signing account address (Address) and either a single TypedData object or an array of TypedData, and the signing account must already be unlocked. The return value consists of a 65-byte hex signature (signature), a 32-byte hex Merkle root (merkleRoot), and an array of arrays of Merkle proofs, one corresponding to each input message (proofs).
Merkle tree construction rules
The hash function is fixed to keccak256. For predictable, uniform proof sizes, the smallest k satisfying 2^(k-1) < n <= 2^k for n messages is computed, and the message list is padded with zero hashes to reach 2^k entries so the tree is balanced. In addition, the two child values are sorted lexicographically before computing the parent hash, guaranteeing an implicit verification path.
On-chain verification efficiency and flexible verification modes
The runtime of _verifyMerkleProof is O(log2(N)) for N signed messages. Applications can also verify a message on its own, or require that a specific combination of messages was signed together for validity, allowing stronger verification schemes to be designed.
Backward compatibility
When there is only a single message, the merkleRoot is simply keccak256(encode(message)), so eth_signTypedData_v5 produces the same signature as the existing eth_signTypedData_v4. This means v5 can be used as a drop-in replacement for v4 without changing any on-chain verification code.
Proposal status
This ERC is currently in Draft status; it has not been finalized and is a proposal whose content may still change or be discontinued.
Things to watch out for
- No replay protection: This ERC only covers how to construct a composite message and verify the signature; it does not include a mechanism to prevent replay. Applications must be able to safely handle the same message being submitted twice.
- Both checks are required when verifying a partial message: Verification must confirm both that the EIP-712 signature over the Merkle root is valid and that the Merkle proof is valid for that root.
- Ensuring user understanding: The wallet must show the user that they are signing multiple messages at once, and must display all message types before signing. To keep the request easy to understand, it is recommended that the number of messages signed at once be limited to 10.
- Consistency of Merkle tree construction: The hash function must be fixed to keccak256, the leaf count must be padded with zero hashes up to a power of two, and the two values must be sorted lexicographically before computing the parent hash.