Files
Komediruzecki 8dadb7a359 feat(worker): field encryption at rest, server-side, per-user keys
Seals transaction text (description, beneficiary, payor, notes),
recurring rules (description, notes), bills (name, notes) and receipt
files with AES-256-GCM under a per-user data key, itself wrapped by a
master key from Workers Secrets (DATA_KEK_<n>). The Worker decrypts to
compute, so every feature keeps working; this protects a leaked D1
export, backup artifact or bucket, not the data from the operator. It
is not end-to-end encryption, which is dropped.

Ships dark: with no DATA_KEK_<n> every route keeps its original SQL and
nothing is sealed. With a key, SQL work over sealed text (LIKE, text
ORDER BY, GROUP BY) moves to JS over opened rows and reproduces
SQLite's answers exactly. Edits use a two-statement batch so they land
in whichever form the row is in when the backfill races them; the
backfill (*/20 cron) is the only place a row changes form, by
compare-and-set.

Migration 0031 adds users.dek_wrapped, text_enc on the three tables,
receipts.enc and a partial index. Schema only.

CI runs the worker suite keyless and keyed (test:sealed).
Design and rollout: docs/plans/field-encryption.md.
2026-09-11 02:39:02 +02:00
..