AnafiRegistry is the root contract of each network. It runs behind an ERC-1967 proxy with UUPS upgrades. Use the proxy address from Deployments.
The registry does four things:
- It publishes the engine identity: the signer address
engineSigKey, the encryption keyengineEncKey, thecomposeHash, and a commitment to the attestation evidence. - It records the signed heartbeat of the engine.
- It lists the delegation adapters that this deployment trusts.
- Its
owner()is the admin and the upgrade authority of every Anafi proxy on the network.
Functions for anyone
attestHeartbeat
The digest has no EIP-191 prefix and no EIP-712 domain:
attestedBlock > block.numberrevertsHeartbeatAheadOfChain().attestedBlock <= lastHeartbeatBlock()revertsHeartbeatNotNewer(). This check is the replay guard.- A malformed signature reverts with an OpenZeppelin
ECDSAerror. A signer other thanengineSigKey()revertsInvalidEngineSignature().
lastHeartbeatBlock and lastHeartbeatTick, and emits HeartbeatAttested(attestedBlock, attestedTick).
attestedTick has no bound. The next accepted heartbeat replaces it.
Functions of the registry owner
Each function in this section revertsOwnableUnauthorizedAccount(address account) when the caller is not owner().
setEngineIdentity
Effects:
- Stores
sigKey,encKeyandcomposeHash_. - Sets
engineEvidenceHashtokeccak256(abi.encode(tlsCertDer, quote, eventLog)). When all three are empty, it setsbytes32(0). - Adds 1 to
version. - Emits
EngineIdentitySetwith the three evidence blobs as event data.
ZeroEngineSigKey(), ZeroEngineEncKey(), OwnableUnauthorizedAccount(address).
The registry does not check the quote. A reader checks it off chain. See Verification.
addDelegationAdapter
adapter to the list and emits DelegationAdapterAdded(adapter).
removeDelegationAdapter
adapter from the list and emits DelegationAdapterRemoved(adapter). Each later entry moves down one place, so the other entries keep their order. Reverts DelegationAdapterNotListed(address adapter) when the list does not hold adapter.
After this call, the removed adapter refuses each redeem with AdapterNotAllowed(). The call does not touch the grant of any account.
Ownership and upgrade
These functions come from OpenZeppelinOwnable2StepUpgradeable and UUPSUpgradeable version 5.
Initialization
initialize once, in the transaction that creates the proxy. A second call reverts InvalidInitialization(). The implementation contract locks its own initializer in its constructor.
It reverts ZeroEngineSigKey() or ZeroEngineEncKey() for a zero key, and OwnableInvalidOwner(address(0)) for a zero owner. After it, version() is 0 and the adapter list is empty.
Views
ANAFI_REGISTRY_ABI holds only engineEncKey, engineSigKey and delegationAdapters. For the other views, use parseAbi from viem with the signatures in the table.
Events
Errors
Invariants
owner()is never the zero address after initialization.version()goes up by exactly 1 on eachsetEngineIdentity, and never goes down.lastHeartbeatBlock()only goes up, and is never more than the block number of the transaction that set it.engineEvidenceHash()is zero exactly when the last identity change had three empty blobs, or when no change happened after initialization.delegationAdapters()holds no duplicate. Each entry has code, and itsanafiRegistry()returned this registry when the owner added it.isDelegationAdapter(a)is true exactly whendelegationAdapters()holdsa.
Storage
All mutable state is in one ERC-7201 namespace,anafi.storage.AnafiRegistry, at slot 0xb5c5947aaa61057d86d25588a7fdf9a60e4e6b2511d9c0ad72aa5d6069a5a400. Use the view functions to read it.