feat(ffi): extend at-rest encryption to iOS/macOS - #322
Merged
Conversation
kafkade
enabled auto-merge (squash)
July 27, 2026 23:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends local-at-rest encryption from the CLI to every native platform. The shared Rust FFI previously opened the working store (
vault.db) as a plain SQLite file, so on iOS/iPadOS/macOS account names, transaction descriptions, amounts, and commodities were readable from a locked device's filesystem or an unencrypted backup. This routes all working-store opens through SQLCipher, keyed by a subkey derived from the already-unlocked vault key, and migrates any existing plaintext store in place.What's included
crates/ldgr-ffi/) — a sharedopen_encrypted_dbhelper applies the SQLCipher key via a raw-hexPRAGMA key(derived through HKDF-SHA256 from the vault key) and forces a page read so a wrong key fails fast. All three open sites (create, open, open-with-session-key) now go through it. SQLCipher is enabled per target:bundled-sqlcipher-vendored-opensslfor iOS/macOS, plain SQLite on watchOS (which never opens a vault).needs_migration()+migrate()/migrateWithSessionKey(): it re-materializes the store as SQLCipher, verifies the schema version and every table's row count before swapping, and keeps the original asvault.db.plaintext.bakfor backout. Password unlock migrates with the password; biometric unlock migrates with the cached session key so the user is never forced to re-enter it.apps/ios/,bindings/swift/) —LdgrClientgains asyncneedsMigration/migrate/migrateWithSessionKeywrappers, andUnlockViewruns the upgrade inline (brief "Encrypting…" state, no separate screen) before opening.apps/web/) — the web app is already encrypted at rest by design (sql.js runs only in memory and is sealed into the AES-256-GCM vault container before it is written to IndexedDB); this adds a regression test asserting the persisted blob is ciphertext (no SQLite header, no known plaintext tokens) and that Web Storage holds no vault secrets. No SQLCipher/rusqlite is added to the WASM graph.Related Issues
Closes #315
Relates to #295
Type of Change
Component
crates/ldgr-core/— Core library (crypto, accounting, storage)crates/ldgr-cli/— CLI toolcrates/ldgr-server/— Sync serverbindings/swift/— UniFFI Swift bindingsapps/ios/— iOS / iPadOS / watchOS appapps/web/— Web app (Next.js + WASM)docs/— DocumentationPrimary change is in
crates/ldgr-ffi/(the shared Rust FFI working-store layer), which has no dedicated checkbox above.Privacy Checklist
PRAGMA keyis set)Checklist
cargo test --workspace) — 743 passed / 0 failed; webnpm test32 passed; Swiftswift test3 passed (incl. at-rest test on a real macOS SQLCipher slice)cargo clippy --workspace -- -D warnings)cargo fmt --check)