Expand description
At-rest keyring — Q39 slice A: wrapped galaxy DEKs in a keyring DBI.
One root key (RK) per store; one random 256-bit data-encryption key (DEK)
per galaxy, wrapped by KEK = hkdf32(rk, "wm/galaxy-dek/v1/<galaxy>")
with XChaCha20-Poly1305 and the same info string as AAD (so a wrapped DEK
cannot be transplanted between galaxies). A rk:check row (AEAD wrap of a
fixed known plaintext under RK) is the wrong-key discriminator, written in
the same transaction as the DEKs.
Slice A records remain plaintext. This module lands the key hierarchy and the open-time unlock path; record AEAD is slice B. Mode B (key file) never advertises crypto-erasure — its guarantee is physical purge only.
Design: docs/Q39_CRYPTO_ERASURE_DESIGN.md §2/§3/§7.
Layout decisions:
- The generated key file lives at the store root, next to the seal
key: when the open path’s final component is
lmdb(the standard<store-root>/lmdblayout) the key is<store-root>/.at_rest_key; other layouts (tests, custom paths) keep it inside the directory passed to the store open. The key therefore lives outside the directory that LMDB maintenance/restore tooling rewrites hardest. - The keyring DBI is not part of the store’s required schema: legacy
stores and strict read-only opens never create it, and
ensure_schemaleaves it optional. - A writable open with
WM_AT_REST_MODE=offonto a store whose keyring meta exists is refused (split-brain guard); read-only inspection still reports the mode.
Structs§
- Argon2
Params - Non-secret Argon2id parameters recorded in the keyring meta (mode C).
- AtRest
Config - Environment-driven at-rest configuration.
- AtRest
State - Unlocked keyring state for a writable at-rest store.
- AtRest
Status Present - Parsed keyring status for a store with at-rest state.
- Keyring
Meta - Non-secret keyring meta row (JSON).
- Migration
Galaxy State - Per-galaxy progress row in the slice-B background migration ledger.
- Migration
Ledger - The
migration:v1ledger row (keyring DBI).
Enums§
- AtRest
Mode - At-rest mode for a store.
- AtRest
Status - Read-only at-rest disclosure status (meta only — never resolves the RK).
Constants§
- AT_
REST_ KEY_ FILE - Default generated key-file name.
- AT_
REST_ KEY_ LEN - Root-key length (and generated key-file length) in bytes.
- DEK_
KEY_ PREFIX - Prefix of the
dek:<galaxy-db-name>rows holding wrapped galaxy DEKs. - KEYRING_
DB - LMDB DBI holding the at-rest key material.
- KEYRING_
FORMAT_ VERSION - Current keyring meta format version.
- KEYRING_
META_ KEY - Keyring row holding the (non-secret) meta JSON.
- MIGRATION_
LEDGER_ KEY - Keyring row holding the slice-B background-migration ledger (JSON).
- RK_
CHECK_ INFO - AAD (and known plaintext) for the
rk:checkrow. - RK_
CHECK_ KEY - Keyring row holding the wrong-key discriminator (AEAD wrap of a fixed
known plaintext under RK; AAD
wm/at-rest/rk-check/v1). - RK_
CHECK_ PLAINTEXT - Fixed known plaintext wrapped under RK into
rk:check.
Functions§
- generated_
key_ path - Resolve the generated key-file path for a store directory.