Skip to main content

Module backup

Module backup 

Source
Expand description

The portable backup artifact and recovery mechanisms (SSoT: Backup and Recovery).

Two distinct things are kept separate:

  • the backup artifact — a deterministic, self-describing, signed tar of a library’s encrypted blobs, metadata blobs, provenance chains, the AMK ledger needed to decrypt them, and each album’s public authority ledger needed to verify them;
  • the master-key escrow — a small passphrase-wrapped blob that reconstructs the key hierarchy.

Recovery rests on one rule: holding the recovery secret restores every asset, even after every device is lost. The artifact carries its own AMK ledger, so it is self-sufficient.

Structs§

BackupArtifact
A verified, opened backup artifact, ready to restore.
BackupAsset
One asset to back up: its ciphertext, metadata blob, and full provenance chain.
BackupDoc
One sealed organization record riding the artifact: docs/{kind}/{doc_id}.
BackupInput
Everything needed to assemble an artifact.
RestoreReport
The outcome of a restore (chain-reconciliation; newer local state always wins).
RestoredAsset
A decrypted asset ready to write into a library (returned only on Commit).

Enums§

BackupDocKind
Which organization record a BackupDoc carries.
BackupError
Errors from backup export/restore and recovery.
RestoreMode
How aggressively a restore acts. Dry-run is the safe default.
VerifyOutcome
Outcome of a local recovery-secret verification.

Constants§

ARTIFACT_FORMAT_VERSION
The backup artifact format version.
RECOVERY_VERIFY_V1
Domain-separation label for the recovery-verification derived-tag compare (SSoT: Backup — Recovery Verification Cadence).
SHAMIR_SHARE_LEN
Encoded length of one share of the 32-byte seed: the evaluation point x, then 32 y bytes.
WRAP_PARAMS
The production Argon2id cost for the backup wrap key: the normal device tier.

Traits§

CiphertextSource
Where an asset’s STREAM ciphertext comes from when it is written into an artifact.

Functions§

escrow_master_key
Escrow the account master key under a recovery passphrase (Argon2id + AES-256-GCM).
export
Assemble a backup artifact in memory, drawing a fresh random wrap salt, at the production WRAP_PARAMS cost.
export_to
Write a backup artifact into out, drawing a fresh random wrap salt, at the production WRAP_PARAMS cost (production path), and return its length in bytes.
export_with_salt
Assemble a backup artifact with an explicit wrap salt (deterministic), at the production WRAP_PARAMS cost.
new_recovery_seed
Draw a fresh random 32-byte recovery seed.
recover_master_key
Recover the master key from its escrow blob and the recovery passphrase.
recover_seed
Reconstruct a seed from a set of Shamir shares (≥ 2 of the 3).
split_seed_2of3
Split a 32-byte recovery seed into 3 Shamir shares; any 2 reconstruct it, 1 reveals nothing. The default scheme from Backup — Opt-in: Shamir Secret Sharing.
verify_recovery_secret
Local-only verification that the user still holds the recovery secret: unwrap the cached escrow blob, then compare an HKDF-derived tag against the tag derived from the device-held master key (derived-tag compare — raw key bytes are never compared or surfaced). Zero network I/O by construction; the cadence, snooze, and refresh-before-fail policy live in the client.