# Audit chain

Every action that uses or changes a key in Aegis Core is written to an audit record **in the same storage transaction** as the action itself, before its result is released. No operation can happen without its record, and no record can describe something that did not happen.

## What a record holds

Who acted (the token's holder, with its tenant), what they did, which key and version, which algorithm and provider, the outcome, and a link to the previous record. Records never hold key material, passphrases or plaintext. Changes to tokens, switches and runtime state are recorded the same way, before they take effect.

## Why it is a chain

Each record carries a keyed hash that covers the record before it. Removing, reordering or editing a record breaks every link after it, and the chain verifies end to end:

- `GET /v1/audit`: a page of records, filtered; each tenant's callers see only their tenant's records.
- `GET /v1/audit/verify`: checks every record, every link and the sealed head of the chain.

## Signed checkpoints

The vault signs **checkpoints** of the chain's head with two signatures, Ed25519 and ML-DSA-87, so the evidence holds while either algorithm does. Checkpoints can be exported to a witness off the machine, and the daemon keeps its own checkpoint, so a vault file replaced by an older copy of itself is refused at unseal.

- `GET /v1/audit/checkpoint`: a signed checkpoint.
- `GET /v1/audit/export`: records with their links and tags, one JSON object per line, for checking elsewhere.

## Check it offline, without trusting Aegis

The standalone `aegis-verify` checks an export against one or more checkpoints on any machine, with no network:

```bash
aegis-verify audit --records export.jsonl --checkpoint checkpoint.json --vault <vault id>
```

It recomputes every link and checks both signatures of each checkpoint. Pass `--vault` to pin the vault the evidence must come from. Exit status `0` means the chain is intact up to the newest checkpoint.

## In Aegis Cloud

The cloud's staff back office keeps its own audit chain of every staff action, signed the same way (Ed25519 and ML-DSA-87) and checked by the same `aegis-verify audit`. Customer-facing audit exports in the cloud app are (Planned).

Next: [Dual control](https://docs.qblackbit.com/concepts/dual-control.md).
