Skip to main content

Module recovery

Module recovery 

Source
Expand description

Recovery-secret verification cadence and the guided re-wrap flow ( SSoT: Backup — Recovery Verification Cadence and § On Repeated Failure: Guided Re-Wrap).

This module owns the client half of the master-key recovery story that the server escrow surface (PUT/GET /v1/auth/escrow) and the core crypto (capsule_core::backup) make possible. It has two cohesive halves:

  • cadence — the pure, network-free scheduler and prompt state machine (RecoveryCadence → VerificationState): the 7 d → 90 d → 180 d ladder, re-arm triggers, snooze caps, and the escalation to a guided re-wrap. It is driven by a mocked clock and never blocks any flow.
  • RecoveryClient — the networked side: the cached copy of the escrow blob (EscrowCache), the stale-cache-aware verify, and the guided_rewrap that mints a fresh secret, re-wraps the same master key, and replaces the server escrow through the server’s escrow endpoint. It also stores and fetches the sealed identity beside the escrow (store_sealed_identity, fetch_sealed_identity, /v1/auth/escrow/identity, #544): the user identity key sealed under the master key, which a recovered device opens beside the recovered master key to come up as the same account. And it stores and lists the account’s album key escrows (store_album_keys, list_album_keys, /v1/auth/escrow/albums, #741): each album’s keys sealed under the master key, which a recovered device adopts so it can open the account’s assets.

The escrow blob on the wire is the opaque canonical-CBOR encoding of a WrappedSecret — byte-identical to what the server stores verbatim and to what the core restore path unwraps.

§The wire is the generated client, not a path this module builds

Both escrow operations are application/octet-stream in each direction, which is a media type spargen lowers, so both are generated and neither is narrowed out in build.rs. RecoveryClient therefore orchestrates AuthenticatedClient::fetch_escrow and store_escrow and hand-writes no request. That is not a preference: .claude/rules/capsule-sdk.md requires that everything which parses or serializes is generated, including the byte-serving endpoints, and the reason is this module’s own history. It used to build {api_root}/backup/escrow from a const — the Salvo document’s path — and when the contract was re-sourced from Kynos to /v1/auth/escrow nothing noticed, because a route in a string constant is checked by no gate and this module’s own mock answered whichever path it was handed.

Re-exports§

pub use cadence::BACKOFF_INTERVAL_SECS;
pub use cadence::CAP_INTERVAL_SECS;
pub use cadence::INITIAL_INTERVAL_SECS;
pub use cadence::MAX_CONSECUTIVE_SNOOZES;
pub use cadence::REWRAP_FAILURE_THRESHOLD;
pub use cadence::REWRAP_MIN_SESSIONS;
pub use cadence::RearmTrigger;
pub use cadence::RecoveryCadence;
pub use cadence::SnoozeDuration;
pub use cadence::VerificationState;

Modules§

cadence
The recovery-verification cadence scheduler and the prompt state machine the client UX renders (SSoT: Backup — Recovery Verification Cadence).

Structs§

AlbumKeysStored
What storing an album key escrow did: the server’s StoreAlbumKeysResponse, read.
EscrowCache
A client-side cached copy of the server escrow blob.
EscrowStored
What storing an escrow did: the server’s StoreEscrowResponse, read.
EscrowedAlbumKeys
One album’s key escrow as the server holds it: the album’s whole key state, sealed under the master key by Workspace::album_key_escrow, and opened by Workspace::adopt_album_key_escrows.
GuidedRewrap
The outcome of a guided re-wrap: everything the UX needs, surfaced as data.
MintedSecret
A freshly minted recovery secret, presented to the user exactly once. It doubles as the escrow wrap passphrase and (when enrolled) the Shamir-split seed — the single root of the single-root invariant.
RecoveryClient
The networked recovery client: escrow cache/refresh, stale-cache-aware local verification, and the guided re-wrap.
SealedIdentityStored
What storing a sealed identity did: the server’s StoreSealedIdentityResponse, read.
ShamirReissue
The Shamir shares re-issued during a guided re-wrap when the account had social recovery enrolled. The old shares are explicitly invalidated (they split the old seed) and surfaced as such.

Enums§

OldArtifactGuidance
Guidance the client surfaces after a rotation about backup artifacts exported under the old secret — pure data (a stable variant), never a localized string, so the client maps it to a catalog key.
RecoveryError
Everything the networked recovery flows can fail with. Callers switch on the typed variant (or its stable error.* code), never a bare HTTP status.