feat(recovery): account-keyed recovery rekey (task 1.7, KEY-08) #63

Merged
amiryahaya merged 1 commit from feat/1.7-recovery-rekey into main 2026-11-05 17:24:13 +01:00
Owner

Closes #22 (task 1.7)

POST /api/recovery/rekey — the new-model completion step

  • Account-keyed (email lookup) — the DID is NOT rotated (unlike the legacy DID-migration /complete); this rotates the ACCOUNT's key material
  • Trustee-only gate (H-4): active setup with trustees + an approved recovery request required — the legacy no-trustee file-based bypass is rejected
  • KeyProof constant-time check (wrong proof → 403 + recovery.rekey_rejected audit)
  • Rotates KEM pubkey + algorithm + signing-keys JSON
  • All old device wraps deleted, recovering device's fresh wrap stored (new Device enrolled)
  • All sessions invalidated — both keying styles (user-id for OIDC/email logins, DID for wallet)
  • Request → Completed, setup deactivated (fresh setup + trustee shares re-established for new keys); recovery.rekeyed audited

KEY-17 anti-abuse (notify+cancel, cool-downs, trustee step-up) stays with task 3.8 per plan.

TDD

6 tests written FIRST — RED ×6 confirmed (endpoint absent), then implemented.
Suite 792 / 0 failed / 39 skipped (Release, green ×2) · coverage gate 81.77% ≥ 80

Closes #22 (task 1.7) ## `POST /api/recovery/rekey` — the new-model completion step - **Account-keyed** (email lookup) — the DID is NOT rotated (unlike the legacy DID-migration `/complete`); this rotates the ACCOUNT's key material - **Trustee-only gate (H-4)**: active setup **with trustees** + an **approved** recovery request required — the legacy no-trustee file-based bypass is rejected - KeyProof constant-time check (wrong proof → 403 + `recovery.rekey_rejected` audit) - Rotates KEM pubkey + algorithm + signing-keys JSON - **All old device wraps deleted**, recovering device's fresh wrap stored (new Device enrolled) - **All sessions invalidated** — both keying styles (user-id for OIDC/email logins, DID for wallet) - Request → Completed, setup deactivated (fresh setup + trustee shares re-established for new keys); `recovery.rekeyed` audited KEY-17 anti-abuse (notify+cancel, cool-downs, trustee step-up) stays with task 3.8 per plan. ## TDD 6 tests written FIRST — RED ×6 confirmed (endpoint absent), then implemented. **Suite 792 / 0 failed / 39 skipped (Release, green ×2) · coverage gate 81.77% ≥ 80**
feat(recovery): account-keyed recovery rekey — rotate keys, kill wraps+sessions (task 1.7, KEY-08)
All checks were successful
API CI / build-and-test (pull_request) Successful in 36m16s
ccbf638bc2
POST /api/recovery/rekey ([SsdidPublic], recovery-complete rate partition):
- ACCOUNT-keyed (email lookup), NOT DID rotation — the DID survives; this
  is the new-model counterpart to the legacy DID-migration complete endpoint
- Trustee-only gate (H-4): active setup WITH trustees + an APPROVED
  recovery request required; the legacy no-trustee file-based bypass is
  rejected (403)
- KeyProof constant-time checked; wrong proof audited (recovery.rekey_rejected)
- Rotates account KEM pubkey + algorithm + signing-keys JSON
- Deletes ALL old device wraps (compromised by hypothesis), stores the
  recovering device's fresh wrap (new Device enrolled, same shape as
  pairing approve)
- Invalidates ALL sessions — both keying styles (user id for OIDC/email,
  DID for wallet)
- Request → Completed, setup deactivated (fresh setup + trustee shares
  re-established for the new keys); recovery.rekeyed audited + activity

KEY-17 anti-abuse (notify+cancel, cool-downs, trustee step-up) stays with
task 3.8 per plan.

TDD: 6 tests written FIRST — RED ×6 confirmed (endpoint absent) — then
implemented. Suite 792 / 0 failed / 39 skipped (Release, green x2);
coverage gate 81.77% >= 80.
Sign in to join this conversation.
No description provided.