Skip to main content
After you read this page, you can read the engine keys and the adapter list from the chain, check a heartbeat, and decode each registry event and error. 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 key engineEncKey, the composeHash, 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

Records a heartbeat that the engine key signed. Any address can submit it, because the signature is the authorization. The digest has no EIP-191 prefix and no EIP-712 domain:
The checks run in this order:
  1. attestedBlock > block.number reverts HeartbeatAheadOfChain().
  2. attestedBlock <= lastHeartbeatBlock() reverts HeartbeatNotNewer(). This check is the replay guard.
  3. A malformed signature reverts with an OpenZeppelin ECDSA error. A signer other than engineSigKey() reverts InvalidEngineSignature().
Effects: sets 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 reverts OwnableUnauthorizedAccount(address account) when the caller is not owner().

setEngineIdentity

Replaces the whole engine identity in one call: both keys, the compose hash and the attestation evidence. Effects:
  • Stores sigKey, encKey and composeHash_.
  • Sets engineEvidenceHash to keccak256(abi.encode(tlsCertDer, quote, eventLog)). When all three are empty, it sets bytes32(0).
  • Adds 1 to version.
  • Emits EngineIdentitySet with the three evidence blobs as event data.
Reverts: ZeroEngineSigKey(), ZeroEngineEncKey(), OwnableUnauthorizedAccount(address). The registry does not check the quote. A reader checks it off chain. See Verification.

addDelegationAdapter

Appends adapter to the list and emits DelegationAdapterAdded(adapter).

removeDelegationAdapter

Removes 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 OpenZeppelin Ownable2StepUpgradeable and UUPSUpgradeable version 5.

Initialization

The deployment calls 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 each setEngineIdentity, 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 its anafiRegistry() returned this registry when the owner added it.
  • isDelegationAdapter(a) is true exactly when delegationAdapters() holds a.

Storage

All mutable state is in one ERC-7201 namespace, anafi.storage.AnafiRegistry, at slot 0xb5c5947aaa61057d86d25588a7fdf9a60e4e6b2511d9c0ad72aa5d6069a5a400. Use the view functions to read it.