Skip to main content

Module crypt

Module crypt 

Source
Expand description

Replica encryption at rest (SPEC-ENGINE §3.4.2).

Every text column of a replica is XChaCha20-Poly1305 ciphertext under the place’s replica key rk (32 random bytes), with AAD place_id|table|row_key|column and a random 24-byte nonce per value. rk is stored wrapped by the machine’s replica master key mk; mk lives in the OS keychain (service lean-ctx-cloud, account replica-master) or, without one, in <config>/cloud/replica.key (0600, reported as at_rest: file key). LEAN_CTX_REPLICA_KEY_FILE forces the file path (tests, staging builds: no keychain dialogs).

Enums§

AtRest
Where mk is kept.

Functions§

aad
The AAD of one column value.
key_file
The file mk is kept in without a keychain.
master_key
The machine’s replica master key mk and where it is kept. The keychain is used unless LEAN_CTX_REPLICA_KEY_FILE is set, the platform has none, or keychain_required is false and the keychain fails; keychain_required (workspace policy require_keychain_at_rest) refuses the file fallback.
new_replica_key
A fresh per-place replica key.
open
Decrypt what seal made; fails on another key, AAD or a changed byte.
seal
Encrypt plain under key bound to aad: nonce ‖ ciphertext.
unwrap
Unwrap a stored rk; None when mk does not open it (replica_key_missing: the place is re-cloned).
wrap
Wrap rk for storage under mk.

Type Aliases§

Key
A 32-byte key that is wiped on drop.