feat(desktop): #142 PR-A — per-install device identity (enrollment + KEY-16 signing) #147

Merged
amiryahaya merged 1 commit from feat/desktop-device-identity into main 2026-11-11 04:07:42 +01:00
Owner

Part 1 of 3 for #142 slice 1, restructured after a code sweep found the pairing UI has missing desktop prerequisites (discovery posted on #142).

Foundations this PR lands

  • failsulit-crypto ed25519 module (ed25519-dalek 2.2.0): raw 32-byte public keys and 64-byte signatures — byte-for-byte compatible with the server's Ed25519VerificationKey2020 verifier (chosen over ML-DSA for the device key specifically because the Rust crate emits raw ML-DSA keys while the .NET verifier requires X.509/DER — an interop gap not worth solving for the device-auth signature).
  • DeviceService: stable per-install device id (uuid) + Ed25519 signing key persisted in the OS keychain, never rotated silently. Fingerprint = hex(SHA-256("FailSulit-Desktop/|device-id")) — mirrors the server's DeviceFingerprint.Compute exactly (unit-tested against the convention). Idempotent enrollment: stored row id short-circuits; a 409 (marker lost) resolves the existing row from the device list.
  • ApiClient: sends X-SSDID-Device-ID on every request (the fingerprint half the server resolves); new 409 Conflict error mapping.
  • Enrollment hooks (best-effort, never block login): complete_login (email + OIDC), save_session (wallet flow), and session-restore in get_current_user.
  • Real sign_data — was a placeholder that always errored; now signs with the device Ed25519 key (the KEY-16 surface pairing approvals will use).
  • list_devices / revoke_device / ensure_device_enrolled commands — the Settings → Devices section previously invoked commands that did not exist (dead UI); it now works end-to-end.
  • A11y: aria-label on the icon-only revoke button (found by the new test).

Also fixed: pre-existing cargo-test compile breakage in failsulit-crypto (shamir/ml_kem tests never updated for Zeroizing returns — cargo test has been red in that crate).

Known pre-existing, untouched: symmetric::test_vector_bcrypt_hkdf KAT fails (bcrypt 0.15.1, file untouched since March). KAT hygiene lands with #15's KDF-floor work where the KATs are regenerated anyway.

Tests: cargo test — src-tauri 15/15, failsulit-crypto 33/34 (the pre-existing KAT). vitest 1283 pass / 1 skip (3 new). Typecheck clean; lint 0 errors.

Next in the series: PR-B master-key lifecycle (generate at onboarding, keyring storage, load at unlock, pair_wrap_master_key) → PR-C pairing UI (initiator QR + approver sheet).

Part 1 of 3 for #142 slice 1, restructured after a code sweep found the pairing UI has missing desktop prerequisites (discovery posted on #142). **Foundations this PR lands** - **failsulit-crypto `ed25519` module** (ed25519-dalek 2.2.0): raw 32-byte public keys and 64-byte signatures — byte-for-byte compatible with the server's Ed25519VerificationKey2020 verifier (chosen over ML-DSA for the device key specifically because the Rust crate emits raw ML-DSA keys while the .NET verifier requires X.509/DER — an interop gap not worth solving for the device-auth signature). - **DeviceService**: stable per-install device id (uuid) + Ed25519 signing key persisted in the OS keychain, never rotated silently. Fingerprint = hex(SHA-256("FailSulit-Desktop/<version>|device-id")) — mirrors the server's DeviceFingerprint.Compute exactly (unit-tested against the convention). Idempotent enrollment: stored row id short-circuits; a 409 (marker lost) resolves the existing row from the device list. - **ApiClient**: sends X-SSDID-Device-ID on every request (the fingerprint half the server resolves); new 409 Conflict error mapping. - **Enrollment hooks** (best-effort, never block login): `complete_login` (email + OIDC), `save_session` (wallet flow), and session-restore in `get_current_user`. - **Real `sign_data`** — was a placeholder that always errored; now signs with the device Ed25519 key (the KEY-16 surface pairing approvals will use). - **`list_devices` / `revoke_device` / `ensure_device_enrolled` commands** — the Settings → Devices section previously invoked commands that did not exist (dead UI); it now works end-to-end. - **A11y**: aria-label on the icon-only revoke button (found by the new test). **Also fixed**: pre-existing cargo-test compile breakage in failsulit-crypto (shamir/ml_kem tests never updated for Zeroizing returns — `cargo test` has been red in that crate). **Known pre-existing, untouched**: `symmetric::test_vector_bcrypt_hkdf` KAT fails (bcrypt 0.15.1, file untouched since March). KAT hygiene lands with #15's KDF-floor work where the KATs are regenerated anyway. **Tests**: cargo test — src-tauri 15/15, failsulit-crypto 33/34 (the pre-existing KAT). vitest 1283 pass / 1 skip (3 new). Typecheck clean; lint 0 errors. **Next in the series**: PR-B master-key lifecycle (generate at onboarding, keyring storage, load at unlock, `pair_wrap_master_key`) → PR-C pairing UI (initiator QR + approver sheet).
feat(desktop): #142 PR-A — per-install device identity (enrollment + KEY-16 signing)
All checks were successful
Security CI / security-scan (pull_request) Successful in 4m56s
b1c0aafcfe
Slice-1 prerequisite discovery: the desktop never enrolled devices, never
sent the fingerprint header, and sign_data was a placeholder that always
errored — so the server could never resolve an enrolled device and the
Settings -> Devices section invoked Rust commands that did not exist.

Foundations landed here (PR-B master-key lifecycle and PR-C pairing UI
build on this):

- failsulit-crypto: ed25519 module (ed25519-dalek 2.2.0) — raw 32-byte
  keys / 64-byte sigs, byte-compatible with the server's
  Ed25519VerificationKey2020 verifier; 5 unit tests
- DeviceService: stable per-install device id (uuid) + Ed25519 signing
  key persisted in the OS keychain (never rotate silently); fingerprint
  = hex(SHA-256('FailSulit-Desktop/<ver>|device-id')) mirrors the server's
  DeviceFingerprint.Compute; idempotent enrollment (409 resolves the
  existing row); 5 tests against an in-memory store (no OS keychain in
  cargo test)
- ApiClient: X-SSDID-Device-ID header on every request + new 409 Conflict
  error mapping
- Enrollment hooks: best-effort at complete_login (email/OIDC),
  save_session (wallet), and session restore — failures never block login
- Real sign_data command (Ed25519 via device key, KEY-16 surface)
- New devices commands (list_devices / revoke_device /
  ensure_device_enrolled) — revives the dead Devices section end-to-end
- DevicesList: aria-label on the icon-only revoke button (a11y);
  DevicesList.test.tsx (3 tests); tauri mock cases for the new commands

Also fixes pre-existing cargo-test compile breakage in failsulit-crypto
(shamir/ml_kem tests never updated for Zeroizing returns — cargo test
has been red in this crate).

Known pre-existing (untouched, noted): symmetric::test_vector_bcrypt_hkdf
KAT fails (bcrypt 0.15.1, file untouched since March) — KAT hygiene lands
with #15's KDF-floor work where KATs are regenerated anyway.

cargo test: src-tauri 15/15, failsulit-crypto 33/34 (1 pre-existing).
vitest: 1283 pass / 1 skip (3 new); typecheck clean; lint 0 errors.
amiryahaya deleted branch feat/desktop-device-identity 2026-11-11 04:07:43 +01:00
Sign in to join this conversation.
No description provided.