ERC-7812 · Review · ERC · 2024-11-08
ERC-7812: ZK Identity Registry
A single shared onchain registry where apps store commitments to private data in a Sparse Merkle Tree, so users can later prove facts about that data in zero knowledge without revealing it.
What problem does it solve?
Zero-knowledge identity and reputation systems (passport proofs, proof of attendance, credentials) each tend to deploy their own contract to hold commitments. That fragments trust, makes proofs hard to reuse across apps and chains, and forces every integrator to learn a new format.
ERC-7812 proposes one permissionless, immutable Evidence Registry that any such system can write into. Everything lives in a single provable database, so a single 32-byte root summarizes the whole registry and can be carried cross-chain.
How it works
Three roles:
- EvidenceDB: a provable key/value store (the reference uses a Sparse Merkle Tree of height 80 with Poseidon hashing). It must support add, update and remove, and give both inclusion and exclusion proofs. Only the registry may write to it.
- EvidenceRegistry: the singleton entry point. Its
addStatement,updateStatementandremoveStatementtake a 32-byte key and value. - Registrars: app-specific contracts (not standardized here) that decide what statements mean and who may write them.
Key points:
- Namespacing. The registry never uses your key directly. It stores under
isolatedKey = hash(msg.sender, key), so each registrar has its own namespace and nobody else can overwrite its cells. - Commitments. A statement is usually blinded with a private "commitment key" (a salt), so the onchain value reveals nothing.
- Root history. Every write emits
RootUpdated(prev, curr).getRootTimestamp(root)returns when a root was replaced,block.timestampfor the current root, and0for unknown roots. - Field limits. With a ZK-friendly hash, keys and values must be below the BN128 scalar field size.
A ZK circuit (Circom in the reference) proves that hash(registrar, key) -> value is, or is not, in the tree under a given public root.
Sample code
A registrar verifying a proof against a recent root, as the spec recommends:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
interface IEvidenceRegistry {
event RootUpdated(bytes32 indexed prev, bytes32 indexed curr);
function addStatement(bytes32 key, bytes32 value) external;
function removeStatement(bytes32 key) external;
function updateStatement(bytes32 key, bytes32 newValue) external;
function getRootTimestamp(bytes32 root) external view returns (uint256);
function getIsolatedKey(address source, bytes32 key) external view returns (bytes32);
}
interface IVerifier { function verify(bytes calldata proof, bytes32 root) external view returns (bool); }
contract AgeGate {
IEvidenceRegistry public immutable registry;
IVerifier public immutable verifier;
uint256 constant MAX_ROOT_AGE = 1 hours;
constructor(IEvidenceRegistry r, IVerifier v) { registry = r; verifier = v; }
function enter(bytes32 root, bytes calldata proof) external view returns (bool) {
// Pass the root in; don't read EvidenceDB.getRoot() onchain (front-running).
uint256 ts = registry.getRootTimestamp(root);
require(ts != 0 && block.timestamp - ts <= MAX_ROOT_AGE, "stale root");
return verifier.verify(proof, root);
}
}
Things to know
- Status: Review. The spec lists a canonical singleton deployed via the deterministic deployment proxy; confirm the address in the spec before integrating.
- The ERC is intentionally abstract. Concrete registrars (passports, POAPs, ERC-4337 account identity) are expected as separate proposals.
- Access control is entirely the registrar's job; the registry only guarantees namespace isolation.
- ZK verifiers need a correct trusted setup; a broken verifier can accept forged proofs.
- Use
getRootTimestampwith a root supplied by the caller rather than the live root, since the root can change between proof generation and inclusion.