feat(desktop): #142 PR-B — master-key lifecycle + pairing wrap primitive #148
No reviewers
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit!148
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/desktop-master-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 2 of 3 for #142 slice 1 (restructured — see the issue comment). Builds on PR #147 (device identity, merged).
The gap: the account master key never existed on desktop —
CryptoService::set_master_keyhad zero callers, so every path that needs it errored "Master key not loaded" (folder decryption, KEM keypair generation, sharing, and the pairing wrap this milestone ships).Landed here
ensure_ready()generates on first run (32-byte master key + random KEK, AES-256-GCM-wrapped via the previously-dormantencrypt_master_key/decrypt_master_keyhelpers, persisted asencrypted_master_key+mk_nonce+mk_kekkeychain entries) or reloads from store on "restart". At-rest model = KEK-in-keychain: the OS keychain is the boundary; the wrap keeps the master key out of plaintext storage. A passphrase-derived KEK (Argon2id, with #15's floor parameters) replaces the random KEK when the passphrase-unlock surface lands (documented in-code).unlock_sessioncommand: unlocking now loads/creates the master key — no silent unlock without key material. Wired intounlock_with_biometric(biometric auth failure keeps the app locked) and theauthStore.unlock()frontend flip, which was previously a pure UI toggle that touched no key material.pair_wrap_master_keycommand (the PR-C approve primitive): encapsulates the unlocked master key to a new device's wrapping public key. Single-KEM ml-kem-768 — the server stores exactly onewrapping_pub_key+kem_algorithmper wrap, and the new device holds its decapsulation secret from its own init call, persisting it encrypted under the master key it just unwrapped.Tests: cargo test 20/20 in src-tauri (5 MasterKeyService incl. tamper + restart-reload + missing-KEK; +1 existing recovery test matched by filter). vitest 1283 pass / 1 skip; typecheck clean; lint 0 errors.
Next: PR-C pairing UI — initiator QR/secret surface + approver sheet calling
pair_wrap_master_key+sign_dataper F-M8 (03-ux-flows.md).