# E10: Key Separation and Trust Roots (as of 2026-10-04)

**Status: separated by purpose, NOT independent.** Every key below is generated on, and stored on, the same VPS that runs the gateway. Someone with root on that host can use any of them.

An earlier auditor run said: "The keys came from the same server." That is still true. Nothing in this document creates external trust.

## Keys, by purpose

| Purpose | Algorithm | Location | Who can use it | What a holder can do |
|---|---|---|---|---|
| Contract authority (issuer, receipts) | Ed25519 key ring: rotating issuer keys under one root | `key_dir()/contract_keys/`; root at `/root/.cain-contract-root/root_ed25519.pem` (0600, outside the repo) | gateway process (root) | sign contracts and receipts that verify under the published root |
| Transition log MAC | HMAC-SHA256 | `CAIN_HMAC_KEY_DIR/governance_contract.key` | gateway process | forge contract state transitions, which defeats `cain_store_integrity` for contracts |
| RIG audit MAC | HMAC-SHA256 | `CAIN_HMAC_KEY_DIR/rig_identity.key` | gateway process | forge RIG registrations and revocations, which defeats `cain_store_integrity` for RIG rows |
| E8 commit boundary | Ed25519 | `<tenant dir>/contract_e8_ed25519.pem` | gateway process | issue E8 execution authorizations |
| SCITT notary (checkpoints) | Ed25519 | `CAIN_HMAC_KEY_DIR/scitt_notary_ed25519.pem` | gateway process | sign log checkpoints |
| E4 differential reports | Ed25519 | `CAIN_HMAC_KEY_DIR/differential_ed25519.pem` | gateway process | sign "what the replay computed" (not authority) |
| **E10 envelopes and attestations** | Ed25519 | `key_dir()/e10_attestation/attestation_ed25519.pem` (0600, created on first use) | gateway process | sign "this was the verified state" and "this is how the current state compares" (not authority) |
| Publisher (evidence bundles) | Ed25519 | `/root/.cain-publisher/publisher_ed25519.pem` (0600, outside the repo) | operator, run by hand from a clean worktree | countersign published bundles |

## What separation buys today

- **Domain separation.**
  - Every signature is over a domain-separated message (`CAIN/e10/v1/...`, `CAIN/contract/v1/...`, etc.).
  - A signature made for one purpose cannot be replayed as another, even if two purposes used the same key.
  - The E10 key is a different key from the contract key ring. Nothing in the fabric accepts an E10 signature as authority.
- **Blast-radius separation inside the software.** Leaking a key through a bug in one component does not hand over the others.
- **No separation against the host.** Anyone with root on the host has all of them.

## What `cain_store_integrity` protects against, given this

- **Protects against:** an attacker who can write the SQLite files but cannot read the key files. Examples: a leaked database backup that is restored, a SQL path in an unrelated route, a mis-scoped volume mount.
- **Does not protect against:** an attacker with root, or with read access to `CAIN_HMAC_KEY_DIR`.

## Rotation, revocation, recovery

| Key | Status |
|---|---|
| Contract key ring | Rotation and retirement IMPLEMENTED (`cain_contract_keys`); old issuer keys stay verifiable under the root. |
| HMAC keys | Rotation NOT IMPLEMENTED. Rotating them today would make every existing transition and RIG audit entry fail verification, which denies every contract. A rotation needs a signed key-epoch marker in each log first. **UNKNOWN / NOT IMPLEMENTED.** |
| E10 attestation key | Rotation NOT IMPLEMENTED. Replacing the file re-keys future attestations; older envelopes stop verifying, so they must be re-established. |
| Publisher key | Pinned in `PINNED_SIGNER_KEYS.json` and `/.well-known/cain-publisher-key.json`. Out-of-band distribution: **NONE.** It is published only on the same sites it signs for. |
| Recovery | No escrow, no HSM, no KMS: **NOT IMPLEMENTED.** |

## What would make trust independent (not done)

1. Hold the publisher and contract-root keys off the gateway host (HSM, KMS, or an offline machine), and distribute their public keys out of band (customer contract, DNS TXT, a transparency log the operator does not run).
2. Anchor the transition, receipt and RIG-audit heads outside the database, for example in SCITT checkpoints countersigned by a second party. That would also close the "truncation before first read" limit in `cain_store_integrity`.
3. An auditor-held verification key, so auditors can check evidence without trusting the operator's key list.

Until then, every verification result produced from this host must say **NOT INDEPENDENTLY VERIFIED**.
