ERC-7969 DKIM Public Key Hash Registry (DomainKeys Identified Mail (DKIM) Registry)
Draft · Signatures & auth · created 2025-06-11
Allows domain owners to register the public key hash of DKIM, an email authentication technology, on-chain, so that anyone can trustlessly verify the validity of an email signature from the blockchain.
Why it is needed
DKIM is a signature technology that verifies whether an email was actually sent from its claimed domain, but this verification happens only within mail servers and DNS, with no way to check it on-chain. As account abstraction (ERC-4337) and zkEmail technology have grown, so has demand for trustlessly proving email ownership on-chain, but there has been no common standard for where and in what format to register and look up DKIM public keys. As a result, each project has managed DKIM public key hashes in its own way, making it difficult to build a compatible email verification foundation across wallets and contracts.
What to implement
event KeyHashRegistered(bytes32 domainHash, bytes32 keyHash);: An event emitted when a new DKIM public key hash is registered for a domain.event KeyHashRevoked(bytes32 domainHash);: An event emitted when a domain's DKIM public key hash is revoked.function isKeyHashValid( bytes32 domainHash, bytes32 keyHash ) external view returns (bool);: Looks up whether a given key hash is validly registered for a given domain hash.
In depth
Registry Structure
The registry stores a mapping from domainHash to keyHash, and then to a validity flag (bool). The domain owner computes and submits the hash of the DKIM public key extracted from the DNS TXT record, and third parties query this mapping to confirm whether a given domain has actually approved a given public key.
Domain Hash Rules
domainHash must be the hash of the full lowercase string of the domain or subdomain name. For example, example.com is hashed as keccak256(bytes("example.com")), and mail.example.com is hashed as a single hash of its full string. Because the registry treats domains and subdomains as independent entities, a key hash registered for example.com does not automatically apply to mail.example.com; each subdomain must be registered separately.
Key Hash and Public Key Format Rules
keyHash is a cryptographic hash of the DKIM public key. Implementers may use keccak256 or any secure hash function of their choice, such as Poseidon, which is suited to zero-knowledge proofs. The public key itself must be exactly the p= parameter value from the RFC 6376 DNS TXT record: base64-encoded, with no PEM headers, spaces, or line breaks, used as-is. The key must be a valid RSA public key and must exactly match the value published in DNS.
Registration Procedure
Registration proceeds by first fetching the DKIM public key from the domain's DNS TXT record, then extracting the p= parameter value, then computing the hash of the raw public key using the implementation's chosen hash function, and finally registering that hash in the registry. The source text illustrates this using an example record from RFC 6376 (p=MIGfMA0G...): hashing the entire public key string with keccak256 to produce keyHash, hashing the domain name "example.org" with keccak256 to produce domainHash, and then registering both via registry.setKeyHash(domainHash, keyHash).
Event
KeyHashRegistered must be emitted whenever a new DKIM public key hash is registered for a domain and must include both domainHash and keyHash. KeyHashRevoked must be emitted whenever a domain's key hash is revoked, and must include only domainHash, not the revoked keyHash.
Lookup Function
isKeyHashValid(domainHash, keyHash) is a view function that must return true if the given keyHash is validly registered for the given domainHash, and false otherwise. This single function is the only standard entry point for querying registry state externally.
Reference implementation
The reference implementation presented in the source text uses OpenZeppelin's Ownable to restrict setKeyHash, setKeyHashes (batch registration of multiple keys), and revokeKeyHash so that only the contract owner can call them. setKeyHash rejects a zero keyHash, and revokeKeyHash deletes the corresponding mapping entry, reverting it to false.
Proposal status
This ERC is currently in Draft status, not yet finalized, and is a proposal whose interface or detailed rules may change or whose discussion may stall.
Things to watch out for
- Private Key and Domain Control: Domain owners must keep their private keys and control over their domain secure.
- Registration Access Control: Registry implementations must have appropriate access control mechanisms to prevent unauthorized registration of key hashes.
- Key Rotation and Revocation: The registry must implement mechanisms capable of handling key rotation and revocation.
- Preventing Spam Registrations: Implementations should consider measures such as rate limiting to prevent spam registrations.
- Choice of Hash Algorithm: The algorithms used for domainHash and keyHash must be chosen carefully, and any future upgrade of the hash function must be adequately planned for.