M3 phase-3 desktop client: pairing UI, unlock ladder, settings completion (tasks 3.1/3.2/3.4) #142

Closed
opened 2026-11-10 16:18:03 +01:00 by amiryahaya · 5 comments
Owner

Desktop-client portion of Phase 3 (Key Management & Multi-Device). Server-side contracts all landed (#136/#137/#138 + pairing endpoints /api/keys/authorize/init + approve + /api/keys/wraps, all tested). Gaps verified in clients/desktop 2026-11-10:

Slices:

  1. Pairing UI (task 3.2, KEY-05/IDA-07) — entirely MISSING: no client code references authorize/init or authorize/approve. Build the settings 'Add device' flow: enrolled device renders QR/secret (POST /api/keys/authorize/init → pairing_secret 256-bit, 10-min TTL), new device enters secret + wrapping pubkey, enrolled device sees approval sheet (device name/platform info) → POST approve (signed). Expiry + single-use handling surfaced.

  2. Unlock failure ladder (task 3.1 partial, KEY-04/09) — UnlockScreen has passphrase + biometric re-unlock but no failure ladder: consecutive-failure behavior (progressive delay/lockout hint), no attempt counter display. Server-side KEY-09 lockout exists; client UX needs the ladder.

  3. Devices & keys settings completion (task 3.4, KEY-07) — DevicesList exists with revoke + confirmation; add consequences copy (what revoke does to wraps/sessions), pending pairing approvals surfaced in settings.

  4. Recovery UI trustee-only completion (3.5 tail) — wizard aligned in PR #141 (server_share upload dropped, activation via setup_recovery_trustee_only); remaining: recovery_alert/recovery_cancelled notification actions route to the recovery page; owner cancel button on pending request (server endpoint /requests/{id}/cancel landed in #137).

Out of scope: 3.6 PRF unwrap (capability-gated, post-spike-0.2), 3.7 golden vectors (M7).

Acceptance: pairing works end-to-end on two desktop instances; unlock ladder UX matches F-M7/M8 equivalents; settings screens complete per KEY-07.

Desktop-client portion of Phase 3 (Key Management & Multi-Device). Server-side contracts all landed (#136/#137/#138 + pairing endpoints /api/keys/authorize/init + approve + /api/keys/wraps, all tested). Gaps verified in clients/desktop 2026-11-10: **Slices:** 1. **Pairing UI (task 3.2, KEY-05/IDA-07)** — entirely MISSING: no client code references authorize/init or authorize/approve. Build the settings 'Add device' flow: enrolled device renders QR/secret (POST /api/keys/authorize/init → pairing_secret 256-bit, 10-min TTL), new device enters secret + wrapping pubkey, enrolled device sees approval sheet (device name/platform info) → POST approve (signed). Expiry + single-use handling surfaced. 2. **Unlock failure ladder (task 3.1 partial, KEY-04/09)** — UnlockScreen has passphrase + biometric re-unlock but no failure ladder: consecutive-failure behavior (progressive delay/lockout hint), no attempt counter display. Server-side KEY-09 lockout exists; client UX needs the ladder. 3. **Devices & keys settings completion (task 3.4, KEY-07)** — DevicesList exists with revoke + confirmation; add consequences copy (what revoke does to wraps/sessions), pending pairing approvals surfaced in settings. 4. **Recovery UI trustee-only completion (3.5 tail)** — wizard aligned in PR #141 (server_share upload dropped, activation via setup_recovery_trustee_only); remaining: recovery_alert/recovery_cancelled notification actions route to the recovery page; owner cancel button on pending request (server endpoint /requests/{id}/cancel landed in #137). Out of scope: 3.6 PRF unwrap (capability-gated, post-spike-0.2), 3.7 golden vectors (M7). Acceptance: pairing works end-to-end on two desktop instances; unlock ladder UX matches F-M7/M8 equivalents; settings screens complete per KEY-07.
Author
Owner

SLICE-1 RESTRUCTURED 2026-11-11 — pairing UI has desktop prerequisites that don't exist yet (verified in code, not assumption):

  1. The master key is NEVER populated — CryptoService.set_master_key has zero callers; unlock is only a boolean flag. pair_wrap_master_key would hit 'Master key not loaded'.
  2. The desktop NEVER enrolled devices and never sent X-SSDID-Device-ID — the server requires the approver to be an enrolled device. Settings -> Devices was dead UI: the frontend invoked list_devices/revoke_device Rust commands that did not exist.
  3. sign_data was a placeholder that ALWAYS errored — KEY-16 requires the approve call to be signed by the enrolled device's key.
  4. Folder-encryption KEM keys are read from local settings nothing ever writes — the E2EE chain on desktop is dormant scaffolding (the 1281 vitest tests mock invoke, so none of this is visible in CI).

Restructured into three merged-PR steps (each testable/shippable):

  • PR-A device identity (PR #147, this series): Ed25519 keyring identity, fingerprint headers, idempotent enrollment at login, real sign_data, revived devices section. Done.
  • PR-B master-key lifecycle: generate at onboarding, AES-GCM keyring storage (dormant helpers exist), load at unlock (set_master_key), pair_wrap_master_key command (encapsulate to the new device's wrapping pubkey, pattern = encapsulate_folder_key). NOTE this partially covers slice 2's unlock ladder groundwork.
  • PR-C pairing UI (the original slice 1): initiator QR/secret surface + approver approve sheet (KEY-16 signed, fingerprint match), per F-M8 in 03-ux-flows.md.

Also discovered: failsulit-crypto cargo test was RED before any of this (shamir/ml_kem tests never updated for Zeroizing returns — fixed in PR #147) and symmetric::test_vector_bcrypt_hkdf KAT fails pre-existing (bcrypt 0.15.1 drift; regenerate with #15's KDF-floor work).

SLICE-1 RESTRUCTURED 2026-11-11 — pairing UI has desktop prerequisites that don't exist yet (verified in code, not assumption): 1. The master key is NEVER populated — CryptoService.set_master_key has zero callers; unlock is only a boolean flag. pair_wrap_master_key would hit 'Master key not loaded'. 2. The desktop NEVER enrolled devices and never sent X-SSDID-Device-ID — the server requires the approver to be an enrolled device. Settings -> Devices was dead UI: the frontend invoked list_devices/revoke_device Rust commands that did not exist. 3. sign_data was a placeholder that ALWAYS errored — KEY-16 requires the approve call to be signed by the enrolled device's key. 4. Folder-encryption KEM keys are read from local settings nothing ever writes — the E2EE chain on desktop is dormant scaffolding (the 1281 vitest tests mock invoke, so none of this is visible in CI). Restructured into three merged-PR steps (each testable/shippable): - **PR-A device identity** (PR #147, this series): Ed25519 keyring identity, fingerprint headers, idempotent enrollment at login, real sign_data, revived devices section. Done. - **PR-B master-key lifecycle**: generate at onboarding, AES-GCM keyring storage (dormant helpers exist), load at unlock (set_master_key), pair_wrap_master_key command (encapsulate to the new device's wrapping pubkey, pattern = encapsulate_folder_key). NOTE this partially covers slice 2's unlock ladder groundwork. - **PR-C pairing UI** (the original slice 1): initiator QR/secret surface + approver approve sheet (KEY-16 signed, fingerprint match), per F-M8 in 03-ux-flows.md. Also discovered: failsulit-crypto cargo test was RED before any of this (shamir/ml_kem tests never updated for Zeroizing returns — fixed in PR #147) and symmetric::test_vector_bcrypt_hkdf KAT fails pre-existing (bcrypt 0.15.1 drift; regenerate with #15's KDF-floor work).
Author
Owner

SLICE 1 COMPLETE 2026-11-11 — all three PRs merged (each with polled-green CI + evidence comments on the PRs):

  • PR-A #147 (squash e658f2b): per-install device identity — Ed25519 keyring identity, X-SSDID-Device-ID fingerprint headers (mirrors server DeviceFingerprint.Compute, unit-tested), idempotent enrollment at login (409-resolves), REAL sign_data (was always-error placeholder), revived the dead Settings->Devices section (list_devices/revoke_device commands now exist). Bonus: fixed pre-existing failsulit-crypto cargo-test compile breakage (shamir/ml_kem Zeroizing).
  • PR-B #148 (squash 8e6f7f5): master-key lifecycle — MasterKeyService (KEK-in-keychain at-rest model; create-at-first-unlock / load-at-restart; tamper + missing-KEK fail cleanly), unlock_session command (no silent unlock without key material), pair_wrap_master_key primitive (single-KEM ml-kem-768).
  • PR-C #149 (squash, merge 1d41fb0+): pairing UI end-to-end — PairingService (ephemeral ml-kem wrapping keypair held in-process, payload codec base64url(json{challenge_id, pairing_secret, kem_algorithm, wrapping_pub_key}), wrap blob = ml_kem_ct||AES-GCM(mk, shared-secret)), initiator surface (QR + copy + fingerprint + countdown + 4s polling, immediate first poll) and approver surface (paste -> Rust-side preview_pairing authoritative fingerprint -> KEY-16-signed approve), MasterKeyService::import adopts the transferred key (fixes the silent second-device fork).

CI fallout fixed along the way (all found by real runs): gitleaks benign filter now covers clients/desktop test paths + any /tests/ dir; SharedWithMePage (5 tests) + MySharesPage (file-wide default) moved to the #141 persistent-mock pattern; pairing preview moved out of jsdom (no WebCrypto) into the preview_pairing command.

Suite state: cargo 25/25 src-tauri (+ crypto crate green except the pre-existing bcrypt KAT, tracked with #15); vitest 1287/1skip.

REMAINING #142 slices: 2 (unlock failure ladder — note PR-B already landed the unlock-with-key-material groundwork), 3 (settings completion), 4 (recovery notification routing). One open design item for mobile waves: the desktop approver consumes a copy-paste payload; mobile QR scanning encodes the same payload — no protocol change needed.

SLICE 1 COMPLETE 2026-11-11 — all three PRs merged (each with polled-green CI + evidence comments on the PRs): - **PR-A #147** (squash e658f2b): per-install device identity — Ed25519 keyring identity, X-SSDID-Device-ID fingerprint headers (mirrors server DeviceFingerprint.Compute, unit-tested), idempotent enrollment at login (409-resolves), REAL sign_data (was always-error placeholder), revived the dead Settings->Devices section (list_devices/revoke_device commands now exist). Bonus: fixed pre-existing failsulit-crypto cargo-test compile breakage (shamir/ml_kem Zeroizing). - **PR-B #148** (squash 8e6f7f5): master-key lifecycle — MasterKeyService (KEK-in-keychain at-rest model; create-at-first-unlock / load-at-restart; tamper + missing-KEK fail cleanly), unlock_session command (no silent unlock without key material), pair_wrap_master_key primitive (single-KEM ml-kem-768). - **PR-C #149** (squash, merge 1d41fb0+): pairing UI end-to-end — PairingService (ephemeral ml-kem wrapping keypair held in-process, payload codec base64url(json{challenge_id, pairing_secret, kem_algorithm, wrapping_pub_key}), wrap blob = ml_kem_ct||AES-GCM(mk, shared-secret)), initiator surface (QR + copy + fingerprint + countdown + 4s polling, immediate first poll) and approver surface (paste -> Rust-side preview_pairing authoritative fingerprint -> KEY-16-signed approve), MasterKeyService::import adopts the transferred key (fixes the silent second-device fork). CI fallout fixed along the way (all found by real runs): gitleaks benign filter now covers clients/desktop test paths + any /__tests__/ dir; SharedWithMePage (5 tests) + MySharesPage (file-wide default) moved to the #141 persistent-mock pattern; pairing preview moved out of jsdom (no WebCrypto) into the preview_pairing command. Suite state: cargo 25/25 src-tauri (+ crypto crate green except the pre-existing bcrypt KAT, tracked with #15); vitest 1287/1skip. REMAINING #142 slices: 2 (unlock failure ladder — note PR-B already landed the unlock-with-key-material groundwork), 3 (settings completion), 4 (recovery notification routing). One open design item for mobile waves: the desktop approver consumes a copy-paste payload; mobile QR scanning encodes the same payload — no protocol change needed.
Author
Owner

SLICE 2 COMPLETE 2026-11-11 — PR #150 merged (squash 186a8f7; PR runs desktop-ci 38438 + security-ci 38437 green, polled before merge).

Unlock failure ladder (F-D4/F-M7) shipped:

  • Passphrase baseline: master key wrapped under Argon2id(passphrase, 128-bit salt) at KEY-13 FLOOR params (m=65536 KiB, t=3, p=1 — RFC 9106 opt-2, not the crate default p=4); floor (>= 14 chars OR >= 4 words) enforced at set time — this also CLOSED #15's passphrase-floor component (evidence comment posted there).
  • Ladder: biometric default with 3-strike hint -> passphrase step -> inline attempt counter (persistent across restarts) -> 30s-doubling lockout from the 5th failure -> 'I lost my devices' recovery escape hatch (F-M9). Any successful unlock resets the ladder.
  • Settings > Security: set/change/remove passphrase with live floor hint.

Bonus: unlock_session + biometric unlock now reset the ladder; verification is the GCM decrypt attempt itself (no verifier at rest to attack).

REMAINING #142: slice 3 (settings completion — devices consequences copy, pending approvals surfacing), slice 4 (recovery notification routing + owner cancel button).

SLICE 2 COMPLETE 2026-11-11 — PR #150 merged (squash 186a8f7; PR runs desktop-ci 38438 + security-ci 38437 green, polled before merge). Unlock failure ladder (F-D4/F-M7) shipped: - Passphrase baseline: master key wrapped under Argon2id(passphrase, 128-bit salt) at KEY-13 FLOOR params (m=65536 KiB, t=3, p=1 — RFC 9106 opt-2, not the crate default p=4); floor (>= 14 chars OR >= 4 words) enforced at set time — this also CLOSED #15's passphrase-floor component (evidence comment posted there). - Ladder: biometric default with 3-strike hint -> passphrase step -> inline attempt counter (persistent across restarts) -> 30s-doubling lockout from the 5th failure -> 'I lost my devices' recovery escape hatch (F-M9). Any successful unlock resets the ladder. - Settings > Security: set/change/remove passphrase with live floor hint. Bonus: unlock_session + biometric unlock now reset the ladder; verification is the GCM decrypt attempt itself (no verifier at rest to attack). REMAINING #142: slice 3 (settings completion — devices consequences copy, pending approvals surfacing), slice 4 (recovery notification routing + owner cancel button).
Author
Owner

SLICE 3 COMPLETE 2026-11-11 — PR #151 (settings completion + gotcha bundle, spans server + desktop; api-ci + security-ci + desktop-ci all green on the PR head, polled before merge).

Settings completion (task 3.4 / D6, KEY-07):

  • GET /api/keys/authorize/pending — secret-free pending-pairing surface (challenge id + device metadata + timestamps only; approval still requires the payload from the new device). Materialize-then-filter per SQLite conventions; AuthzMatrix row; 3 tests (metadata listing w/o secret fields, consumed-drops-off, cross-user isolation).
  • DevicesList: pending-approval banner (list_pending_pairings Rust command) + revoke dialog consequences copy (signed out immediately; key wrap deleted -> loses access to encrypted files; must sign in AND pair again).

GOTCHA BUNDLE (bundled per user request):

  • split_master_key DEAD SEAM FIXED — the recovery-setup wizard invoked 'split_master_key' (no args) while the Rust command was 'split_master_key_command' requiring wallet-era hex input; wizard was 100% broken. New no-arg command reads the loaded master key (PR-B).
  • bcrypt-hkdf KAT regenerated with provenance — the rename commit changed the HKDF domain salt AFTER the KAT was written and the crate's tests were compile-broken (drift invisible). Verified cryptographically; iOS already used the new string (platforms agree; only its test vector was stale). Clean re-publication (tiered KDF dormant), not a migration. This RESOLVES the pre-existing failing KAT noted during the 2026-11-11 hygiene pass.
  • Desktop lint 12 -> 0 warnings; docs/engineering-gotchas.md added (jsdom form submission, store-spy assertion targets, Once-chain mock rot, gitleaks path-filter discipline, Forgejo quirks, SQLite conventions, MTP crash-class errors).

Suites: server 990/0/39 (twice) + coverage gate 87.15%; cargo 31/31; vitest 1300/1skip; typecheck + lint clean (0 warnings).

REMAINING #142: slice 4 only (recovery notification routing + owner cancel button).

SLICE 3 COMPLETE 2026-11-11 — PR #151 (settings completion + gotcha bundle, spans server + desktop; api-ci + security-ci + desktop-ci all green on the PR head, polled before merge). Settings completion (task 3.4 / D6, KEY-07): - GET /api/keys/authorize/pending — secret-free pending-pairing surface (challenge id + device metadata + timestamps only; approval still requires the payload from the new device). Materialize-then-filter per SQLite conventions; AuthzMatrix row; 3 tests (metadata listing w/o secret fields, consumed-drops-off, cross-user isolation). - DevicesList: pending-approval banner (list_pending_pairings Rust command) + revoke dialog consequences copy (signed out immediately; key wrap deleted -> loses access to encrypted files; must sign in AND pair again). GOTCHA BUNDLE (bundled per user request): - split_master_key DEAD SEAM FIXED — the recovery-setup wizard invoked 'split_master_key' (no args) while the Rust command was 'split_master_key_command' requiring wallet-era hex input; wizard was 100% broken. New no-arg command reads the loaded master key (PR-B). - bcrypt-hkdf KAT regenerated with provenance — the rename commit changed the HKDF domain salt AFTER the KAT was written and the crate's tests were compile-broken (drift invisible). Verified cryptographically; iOS already used the new string (platforms agree; only its test vector was stale). Clean re-publication (tiered KDF dormant), not a migration. This RESOLVES the pre-existing failing KAT noted during the 2026-11-11 hygiene pass. - Desktop lint 12 -> 0 warnings; docs/engineering-gotchas.md added (jsdom form submission, store-spy assertion targets, Once-chain mock rot, gitleaks path-filter discipline, Forgejo quirks, SQLite conventions, MTP crash-class errors). Suites: server 990/0/39 (twice) + coverage gate 87.15%; cargo 31/31; vitest 1300/1skip; typecheck + lint clean (0 warnings). REMAINING #142: slice 4 only (recovery notification routing + owner cancel button).
Author
Owner

ALL FOUR SLICES SHIPPED — #142 COMPLETE (2026-11-11):

  • Slice 1 — pairing UI + desktop key foundations (restructured after the prerequisite sweep): PR #147 (device identity: Ed25519 keyring identity, fingerprint headers, idempotent enrollment, real sign_data, revived Devices section), PR #148 (master-key lifecycle: KEK-in-keychain, unlock loads key material, pair_wrap_master_key), PR #149 (pairing UI end-to-end: initiator QR/payload + approver sheet, KEY-16-signed, fingerprint match, fixes the silent second-device fork).
  • Slice 2 — unlock failure ladder: PR #150 (passphrase baseline under KEY-13 floor Argon2id m=64MiB/t=3/p=1, floor >= 14 chars OR >= 4 words at set time — closed #15's passphrase floor; 3-strike biometric -> passphrase -> attempt counter -> lockout -> recovery escape hatch). Also closed #15's passphrase-floor component.
  • Slice 3 — settings completion: PR #151 (pending-pairings banner surface /api/keys/authorize/pending secret-free, revoke consequences copy, split_master_key dead seam fixed, bcrypt KAT regenerated with rename-drift root cause, lint 12->0, docs/engineering-gotchas.md).
  • Slice 4 — recovery notification routing + owner cancel: PR #152 (recovery_*/share notification routing to /settings#recovery via useNotificationRouting, KEY-17 owner 'Not me — cancel' button on recovery_alert with the server's action_resource_id, confirm -> cancel_recovery_request, deep-link anchor). One CI fix en route: the share-page suites needed the 3s waitForLoaded timing pattern on top of slice 3's persistent mocks.

Final suite state on main (2299391): server 990/0/39 + coverage gate 87.15%, cargo 31/31 src-tauri (+ crypto crate green, KAT re-published), vitest 1301/1skip, typecheck + lint clean. Post-merge runs verified per PR; slices 1/3 deployed to staging via CD.

Out of scope (tracked elsewhere): task 3.3 opportunistic wrap upload (MIG-03), PRF (post-spike-0.2), golden vectors (M7), mobile pairing surfaces (mobile waves).

ALL FOUR SLICES SHIPPED — #142 COMPLETE (2026-11-11): - **Slice 1 — pairing UI + desktop key foundations** (restructured after the prerequisite sweep): PR #147 (device identity: Ed25519 keyring identity, fingerprint headers, idempotent enrollment, real sign_data, revived Devices section), PR #148 (master-key lifecycle: KEK-in-keychain, unlock loads key material, pair_wrap_master_key), PR #149 (pairing UI end-to-end: initiator QR/payload + approver sheet, KEY-16-signed, fingerprint match, fixes the silent second-device fork). - **Slice 2 — unlock failure ladder**: PR #150 (passphrase baseline under KEY-13 floor Argon2id m=64MiB/t=3/p=1, floor >= 14 chars OR >= 4 words at set time — closed #15's passphrase floor; 3-strike biometric -> passphrase -> attempt counter -> lockout -> recovery escape hatch). Also closed #15's passphrase-floor component. - **Slice 3 — settings completion**: PR #151 (pending-pairings banner surface /api/keys/authorize/pending secret-free, revoke consequences copy, split_master_key dead seam fixed, bcrypt KAT regenerated with rename-drift root cause, lint 12->0, docs/engineering-gotchas.md). - **Slice 4 — recovery notification routing + owner cancel**: PR #152 (recovery_*/share notification routing to /settings#recovery via useNotificationRouting, KEY-17 owner 'Not me — cancel' button on recovery_alert with the server's action_resource_id, confirm -> cancel_recovery_request, deep-link anchor). One CI fix en route: the share-page suites needed the 3s waitForLoaded timing pattern on top of slice 3's persistent mocks. Final suite state on main (2299391): server 990/0/39 + coverage gate 87.15%, cargo 31/31 src-tauri (+ crypto crate green, KAT re-published), vitest 1301/1skip, typecheck + lint clean. Post-merge runs verified per PR; slices 1/3 deployed to staging via CD. Out of scope (tracked elsewhere): task 3.3 opportunistic wrap upload (MIG-03), PRF (post-spike-0.2), golden vectors (M7), mobile pairing surfaces (mobile waves).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/failsulit#142
No description provided.