Skip to content

ADR 0020 — Tiers 2–3 are sealed with age; the chain covers a salted digest, the ciphertext sits beside it

Status: accepted · 2026-10-03 · extends ADR 0015, amends nothing in ADR 0014

Context. SPEC §4 promised since v0.2 that tiers 2 and 3 would be "encrypted with the owner's key (a later version)", and SECURITY.md promised a key that never leaves the owner's machine. The adversary is anyone who obtains the files: a stolen laptop, a sync folder, a backup, a disk sold on. Encrypting a payload asks one question of the format that everything else hangs on: what does the hash chain cover once the payload is ciphertext? RFC 0025 worked out three answers and what each breaks. Over the plaintext (A): every existing hash survives and a crossing package needs nothing new, but verify without the key can check no hash past the first sealed line, so a lost key loses the chain as well as the words, and an unsalted hash of a short payload lets an adversary confirm a guess. Over the ciphertext (B): verify is today's code and the second implementation needs no cryptography, but age sealing is randomised and a header changes with its recipients, so adding a recovery key or a new laptop rewrites the chain with a lineage entry every time, a circle member gets ciphertext it cannot open or an opened copy nothing binds to the hash, and the conformance fixture can never regenerate to the same head. A benchmark (docs/rfcs/bench-encryption-2026-10.md) measured per-line age at 128–214 µs to seal and 145–194 µs to open on a slow core, 2.2 times a plain line, keyed verify of three million lines in eight to ten minutes against under three keyless, memory flat.

Decision. Option C of RFC 0029, as the RFC states it after the captain's answers of 2026-10-02:

  1. A sealed line keeps a plain payload that is a reference, and carries the content sealed in payload_enc, outside the hash as id is. The sealed bytes are canonical_json({payload, salt}), the digest their SHA-256, the reference {"schema": "sealed/v1", "of": <the real schema>, "digest"}; payload_enc is the age file, X25519 recipients, binary, as standard base64. The pre-image of SPEC §3 does not change. A verifier without the key checks the whole chain and the sealed-line rule and reports what it did not open; one with the key opens every sealed line and treats a digest mismatch as the record's error, exactly as ADR 0015 treats a present attachment whose bytes do not match its name.
  2. The salt is inside the sealed bytes and the digest, 16 random bytes, so the digest confirms nothing to anyone without the key.
  3. The envelope stays plain: at, end, tz, source, kind, tier, recorded_at. A day is listed, a line located, a chain verified, all without a key. What that gives away (the shape of a life, not its words) is stated in RFC 0029 §2, and sealing kind and source is declined for 0.3.
  4. One identity per record, two recipients or none. The long-term secret is the owner's X25519 identity; the public recipients are in logbook.json; the identity lives at <config dir>/logbook/identities/<owner_id>.txt or where LOGBOOK_IDENTITY_FILE points, never in the record and never in a variable that is on disk; key init refuses to seal until a recovery recipient exists; no passphrase by default. Adding or rotating a recipient reseals payload_enc and the sealed files, changes no hash, and appends one rekey/v1 line.
  5. A writer without the identity refuses tiers 2–3 (it cannot dedupe through the blinded index) and writes tier 1. export writes opened payloads by default, the interchange form of ADR 0017, and the lines verbatim under --sealed.
  6. Attachments are sealed under their plaintext name, the age header the marker, raised and never lowered, so a verbatim reference resolves and two lines sharing bytes share one file.
  7. The index moves to the cache directory and blinds raw_id under a key it keeps sealed to the recipients; the search table holds no words of a sealed line.
  8. A 0.3 implementation reads 0.2 without migration: the hash rule did not change. Sealing the past is a migration with lineage and a migration/v1 line; the plain files are not kept beside the record.
  9. A crossing package reseals sealed lines and files to the destination's recipient from policy/crossing.json, or ships them opened under --open; the owner's hashed fields cross verbatim either way, so RFC 0005's promise holds.
  10. Per-line age, not a record data key. The benchmark's numbers did not force the variant and its costs were not wanted: a key inside the record and a construction the age CLI cannot open. The 20,000 lines a second floor is tier-1-only; sealed lines get a floor of 4,000 a second at two recipients.

Consequences. Level 1 conformance stays an afternoon: one new field outside the hash and one payload shape. Level 2 adds age, and the second implementation's fixture is a sealed sample with a published example identity. verify grows a report of sealed, opened and plain lines. A lost key loses the words of tiers 2–3 and never the chain. Encryption at rest protects copies made after it is turned on; a backup from before holds the plaintext, and seal --all says so once. The price is a record about 2.2 times larger per sealed line and a keyed verify three times slower than a keyless one, both measured and accepted. Every rule of this ADR is SPEC §1, §1.1, §2, §3, §3.1, §4 and §6 as of v0.3, and RFC 0029 is the record of how it was reached.