--- eip: 8812 title: Post-Quantum Agent Attestations description: Post-quantum signed daily action logs for ERC-8004 agents, anchored on chain by validator quorum author: Alexandros Titonis (@alextitonis) discussions-to: https://ethereum-magicians.org/t/erc-8004-trustless-agents/25098 status: Draft type: Standards Track category: ERC created: 2026-12-05 requires: 712, 8004 --- ## Abstract This ERC lets an [ERC-8004](./eip-8004.md) agent publish a verifiable, post-quantum record of what it did. The agent advertises an ML-DSA public key (NIST FIPS 204) in its registration file. For each UTC day, it commits to its action log with a Merkle root and signs a canonical message containing that root with its ML-DSA key. Independent validators check each signed log against the chain and post a validation response to the ERC-8004 Validation Registry. A day's messages from all agents covered by an anchor are committed to a single Merkle root that an anchor contract records only when signed by a quorum of registered validators. Anyone can later prove that an agent's log for a given day is genuine, unchanged and validated. ## Motivation ERC-8004 gives agents an identity, a reputation channel and generic validation hooks, but it does not say how an agent proves its own history. Agents that act on chain (trading, paying, voting) produce records that users and other agents need to trust: 1. **Authenticity.** A log served by an agent's operator can be edited after the fact. A signature by a key bound to the agent identity, plus an on-chain commitment, prevents that. 2. **Post-quantum durability.** Agent identities and wallets on EVM chains rely on ECDSA (secp256k1). A sufficiently large quantum computer could forge ECDSA signatures from public keys that are already on chain. Records meant to be trusted for years should not depend on it. ML-DSA (FIPS 204) is a standardised lattice signature scheme that is not known to be vulnerable to quantum attacks. 3. **Cheap independent checking.** Verifying ML-DSA on chain is expensive (millions of gas). This ERC keeps signature verification off chain, done by validators, and puts only a small quorum-signed commitment on chain. 4. **Interoperability.** A common log and commitment format lets any explorer, wallet or agent verify any agent the same way, and lets validator networks serve many agent operators. ## Specification The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. ### Hashing - `leaf(data) = keccak256(0x00 || data)` - `node(left, right) = keccak256(0x01 || left || right)` - A Merkle tree over an ordered list of leaves is built level by level, pairing adjacent nodes left to right; a lone last node at any level is carried up unchanged. The root of a one-leaf tree is that leaf. ### Registration file extension An agent implementing this ERC MUST add a `postQuantum` object to its ERC-8004 registration file: ```json "postQuantum": { "alg": "ML-DSA-65", "publicKey": "0x…", "logs": "https://agent.example/pq/{day}" } ``` - `alg` MUST be one of `ML-DSA-44`, `ML-DSA-65`, `ML-DSA-87` (FIPS 204) or `SLH-DSA-SHA2-128s`, `SLH-DSA-SHA2-192s`, `SLH-DSA-SHA2-256s` (FIPS 205). `ML-DSA-65` is RECOMMENDED. Verifiers SHOULD support every listed algorithm. - `publicKey` is the hex-encoded FIPS 204 public key. - `logs` is a URL template; `{day}` is replaced by the UTC date `YYYY-MM-DD`. It MUST return the attestation object defined below. - An agent MAY add the agent's `supportedTrust` entry `"pq-log-v1"`. - A key rotation is a change of the registration file (`setAgentURI`). Verifiers MUST use the key that was in effect for the day being checked; agents SHOULD keep earlier keys in `postQuantum.previousKeys` as `{ "publicKey", "until" }`. ### Daily action log For each UTC day in which the agent acted, it produces an ordered list of **entries**. An entry is a UTF-8 string with `|`-separated fields: ``` ||||…| ``` - `kind` is application-defined (e.g. `swap`, `transfer`, `vote`). - Entries that correspond to an on-chain transaction MUST end with that transaction's hash, so validators can check it. - Entries MUST be ordered by time, then by their order in the agent's own records. `entriesRoot` is the Merkle root over `leaf(utf8(entry))` for every entry, in order. Days without entries are not attested. ### Signed message The agent signs the UTF-8 bytes of this JSON object, serialised with no whitespace and keys in exactly this order: ```json {"v":1,"standard":"pq-agent-log","agentRegistry":"eip155::","agentId":,"day":"YYYY-MM-DD","entries":,"root":"0x"} ``` The signature is a FIPS 204 or FIPS 205 signature (pure mode, not pre-hash) over those bytes with an empty context string. Binding `agentRegistry` and `agentId` prevents a signature from being replayed for another agent or chain. ### Attestation object The `logs` URL for a day MUST return: ```json { "agentRegistry": "eip155:…", "agentId": 0, "day": "YYYY-MM-DD", "alg": "ML-DSA-65", "publicKey": "0x…", "entries": ["…"], "message": "…", "signature": "0x…", "anchor": { "contract": "0x…", "chainId": 0, "dayRoot": "0x…", "proof": [{ "hash": "0x…", "left": true }] } } ``` `anchor` is present once the day is anchored. `proof` is the Merkle path from `leaf(utf8(message))` to `dayRoot`. ### Validation A validator checking an attestation MUST: 1. verify `signature` over `message` with `publicKey` under `alg`, and that `publicKey` is the agent's key for that day; 2. check that `message` is the canonical serialisation for this agent, day, entry count and `entriesRoot`; 3. recompute `entriesRoot` from `entries`; 4. for every entry ending in a transaction hash, fetch the transaction receipt on the agent's chain and check that the transaction succeeded, was sent from or by one of the agent's advertised wallets, and is consistent with the entry. The validator then records its result through the ERC-8004 Validation Registry: - `requestHash` = `keccak256(utf8(message))`; - `response` = `100` if all checks pass, else `0`; - `tag` = `"pq-log-v1"`; - `responseURI` MAY point to the validator's report. When the validator is a quorum contract (below), the agent's `validationRequest` names that contract as `validatorAddress`. ### Anchor contract An anchor contract records one Merkle root per UTC day over `leaf(utf8(message))` for every agent it covers, ordered by (`agentRegistry`, `agentId`). It MUST implement: ```solidity interface IAgentLogAnchor { /// Emitted when a day is anchored. event DayAnchored(uint32 indexed day, bytes32 root, uint32 agents, address[] validators); /// Records `root` for `day` (unix day number, UTC) covering `agents` signed messages. /// `signatures` are EIP-712 signatures of AnchorDay(uint32 day, bytes32 root, uint32 agents) /// by distinct registered validators. MUST revert if fewer than `quorum()` are valid, /// if `day` is not yet finished, or if `day` is already anchored. function anchorDay(uint32 day, bytes32 root, uint32 agents, bytes[] calldata signatures) external; /// The anchored root for `day`, or zero. function rootOf(uint32 day) external view returns (bytes32); /// Number of distinct validator signatures required. function quorum() external view returns (uint256); /// Whether `validator` may sign anchors. function isValidator(address validator) external view returns (bool); } ``` The [EIP-712](./eip-712.md) domain MUST use the anchor contract's address and chain id. How validators are registered, selected, rewarded or penalised is out of scope. ## Rationale - **Off-chain verification, on-chain commitment.** Verifying ML-DSA in the EVM costs over a million gas per signature; daily logs for many agents fit in one 32-byte root and a few validator signatures. - **ML-DSA.** It is the NIST primary post-quantum signature standard (FIPS 204), with mature audited libraries. Stateless signing suits agents that sign from several machines. SLH-DSA (FIPS 205) is allowed from the start as a hedge: it rests only on hash functions, so a break in lattice assumptions would not reach it. Its signatures are larger (7.8 to 29.8 KB), which only affects the off-chain log. Stateful hash-based schemes (XMSS, LMS) are left out because a reused state breaks them. - **Domain-separated Merkle tree.** The 0x00/0x01 prefixes stop an inner node being passed off as a leaf. - **Daily granularity.** One signature and one anchor per day keeps cost flat. Agents needing finer granularity can sign more often; the format does not change. - **Reusing the ERC-8004 Validation Registry.** Validation results stay where agent tooling already looks. - **ECDSA quorum signatures on the anchor.** They are cheap to verify on chain. The anchor proves timing and agreement; authenticity of the log itself rests on the agent's ML-DSA signature. ## Backwards Compatibility Fully additive. Agents without a `postQuantum` object are unaffected. Existing ERC-8004 registries need no change. ## Test Cases The [test vectors](../assets/erc-8812/test-vectors.json) contain: a deterministic ML-DSA-65 key pair (FIPS 204 key generation from a fixed seed), three log entries and their `entriesRoot`, the canonical message and its deterministic signature, the message leaf, and a three-agent day tree with its root and the Merkle proof for the middle agent. ## Reference Implementation A deployment on Robinhood Chain (chain id 4663) signs the daily trade logs of about 1,000 ERC-8004 trading agents with ML-DSA-65 and anchors them daily: anchor contract `0xD73082220034a009f51408d902bb0De7416644E1` (verified source). Signing, the Merkle tree and the attestation API are open source in the fly.ai repository (`mine/src/quantum.ts`), and an in-browser verifier is part of its web client. Open-source client packages (JavaScript and Python) implement the signing, the tree and the proof check for any agent. That deployment predates this draft: its message uses the keys `fly` and `trades` instead of `agentId` and `entries`, and its anchor is posted by a single keeper. A quorum anchor contract implementing `IAgentLogAnchor` is being rolled out, and the message format will follow this specification as it settles. ## Security Considerations - **Agent identity is still ECDSA.** The ERC-8004 identity and the agent's wallets remain secp256k1. This ERC protects the integrity of the record, not the agent's funds or control. - **Key custody.** Whoever holds the ML-DSA secret key can sign logs for the agent. Operators deriving keys from a master secret MUST protect it like a signing key. Compromise requires rotating the key in the registration file; verifiers MUST then distrust signatures made with the old key after the rotation time. - **Withheld days.** An agent can decline to publish a day. Absence of an attestation is not evidence of inactivity; validators MAY flag on-chain activity by an agent's wallets that has no matching entry. - **Validator collusion.** A quorum can anchor a root containing a bad message, but cannot forge the agent's ML-DSA signature; anyone can re-run the checks and detect it. Penalties are left to the validation protocol. - **Deterministic signing.** FIPS 204 permits deterministic signing; implementations that do so MUST still use a side-channel-resistant library. - **Quantum adversary on the anchor.** Validator signatures are ECDSA. A forged anchor would only commit to roots that must still contain valid ML-DSA signatures to be accepted by verifiers. ## Copyright Copyright and related rights waived via [CC0](../LICENSE.md).