Skip to main content

Module albumstore

Module albumstore 

Source
Expand description

The durable album-key store: every album’s AMK ledger, write-tier + admin signing seeds, and attested authority state, sealed at rest under the account master key.

Album keys used to be session-scoped — minted per Workspace and dropped on close — so a reopened library could neither decrypt nor write its own prior assets. This module is the durable half of the key chain the keystore (Account) already provides for device identity keys: AccountFile persists the master key (passphrase-wrapped) and the device private keys (master-sealed); AlbumStore persists everything below the master key that an album needs.

§On-disk format

One file, {root}/.library/albums.cbor:

MasterKey::seal( canonical_cbor(AlbumStore) )     # nonce(12) ‖ AES-256-GCM(ct+tag)
  • Sealed under MasterKey::seal — the same AES-256-GCM random-nonce primitive AccountFile uses for the sealed device seeds. This is deliberately not backup::artifact::seal_ledger, whose nonce is derived deterministically from the wrap key so that re-exporting a backup is byte-identical. That property is right for a write-once artifact and catastrophic here: the store is rewritten on every create_album and rotate_epoch, so a fixed nonce under a fixed key would repeat (key, nonce) across different plaintexts and leak the keystream.
  • Canonical CBOR, sorted by album id (and each album’s AMK rows by epoch), so the plaintext is byte-stable for a given logical state.
  • Written temp-then-rename by capsule-library’s AlbumStoreFile::save, so a crash mid-write never leaves a half-written keystore where the previous good one was.
  • The AMK rows reuse the backup artifact’s row shape (album_id, epoch, amk), so keystore ↔ backup-ledger conversion is a map, not a translation table.

§Recovered (read-only) albums

A backup artifact escrows AMKs — read access — but never the write-tier or admin signing keys, which are MLS-distributed capabilities. It does carry each album’s public authority, the admin-signed epoch ledger (#468). An album restored from a backup into a library that never held it therefore lands here with write_tier_seed64 = None, admin_seed64 = None, and authority = Some(Reference(ledger)) (or None from a format-1 artifact, which carried no ledger): its photos decrypt, re-export, and verify, but it cannot author new writes until its signing capability is re-established. That is the honest state, and the lifecycle surfaces it as a typed error rather than minting a fresh admin key that attests nothing and no peer trusts. The ledger re-verifies on every load, like any other.

Structs§

AlbumStore
Every album this library holds key material for, sealed at rest under the account master key.
PersistedAlbum
One album’s persisted key material.

Enums§

AlbumStoreError
Errors from reading, writing, or decoding the album store.
EscrowCoverage
How an album key escrow the server holds stands against the album a device holds (PersistedAlbum::escrow_coverage). Only Superseded is a state the device may overwrite: every other one either needs nothing or would lose an epoch.
PersistedAuthority
One album’s persisted authority state, behind the AlbumAuthority seam.

Constants§

ALBUM_STORE_FILE
The store’s filename beneath {root}/.library/.

Type Aliases§

AmkRow
One escrowed album content key: (album_id, epoch, amk).