Expand description
Capsule’s key hierarchy (SSoT: Cryptography — Keys).
One backed-up root (the account master key) wraps device identity private keys and
anchors the AMK escrow. Album keys (AMKs) are random per-epoch keys; per-file keys are
derived from them. Device signing/encryption keys are hybrid HybridSigningKey /
kem::DekKeypair.
Re-exports§
pub use albumstore::ALBUM_STORE_FILE;pub use albumstore::AlbumStore;pub use albumstore::AlbumStoreError;pub use albumstore::AmkRow;pub use albumstore::EscrowCoverage;pub use albumstore::PersistedAlbum;pub use albumstore::PersistedAuthority;pub use directory::DekPublic;pub use directory::DeviceDirectory;pub use directory::DeviceEntry;pub use directory::DirectoryCore;pub use directory::DirectoryError;
Modules§
- albumstore
- 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.
- directory
- The signed device directory: how peers learn which device public keys to trust for a
user, and the anti-rollback
directory_version(SSoT: Cryptography — Keys § Device Directory).
Structs§
- Account
- A fully unlocked account in memory.
- Account
File - The encrypted-at-rest account: the master key wrapped under a passphrase, and the device/identity private keys sealed under the master key. Safe to persist to disk.
- Amk
- A random 32-byte album content key for one epoch. Holding it lets you decrypt; not
holding it means you cannot (secrecy is enforced by encryption, authorization by
signatures — see
HybridSigningKeywrite-tier keys). - AmkVersion
- The monotonic epoch identifier for an AMK (
amk_version). - DekKeypair
- A device encryption keypair (X-Wing = X25519 + ML-KEM-768). Holds both private halves; the public encapsulation key is derived on demand.
- Device
Keys - This device’s key material: a stable id, a hybrid Device Signing Key (DSK), and a Device Encryption Key (DEK).
- Hardware
Backed Signer - Adapts a
HardwareSignertoSigner: the Ed25519 half is produced in hardware, the ML-DSA-65 half in software from the sealedξseed, and the two are combined into aHybridSignature. - Hybrid
Signature - A hybrid signature: a classical half (Ed25519 or ECDSA-P256) and an ML-DSA-65 half over the same message.
- Hybrid
Signing Key - A hybrid signing keypair (private) — the software composition, both halves in memory.
The hardware-backed composition lives in
HardwareBackedSigner(Ed25519 hardware half) andP256HybridSigningKey(P-256 hardware half); both drive the sameHybridSignature/HybridVerifyingKeytypes. - Hybrid
Verifying Key - A hybrid public verifying key. Published in the device directory.
- Master
Key - A 32-byte account master key.
- P256
Hybrid Dek - A device encryption keypair whose classical half is a hardware-held P-256 key and whose
ML-KEM-768 half is software-sealed. The KEM analogue of
P256HybridSigningKey, and the hardware-bound counterpart of the software X-WingDekKeypair. - P256
Hybrid Signing Key - A hybrid device signing key whose classical half is a hardware-held P-256 key and whose
ML-DSA-65 half is software-sealed. The P-256 analogue of
HardwareBackedSigner. - Software
Signer - A software
HardwareSigner: the fallback for devices with no secure element.
Enums§
- Classical
Algorithm - The classical half of a hybrid device-key composition. Ed25519 is the software default; ECDSA-P256 is what shipping secure elements provide (Secure Enclave / StrongBox / TPM 2.0).
- DekBinding
- Where the DEK’s classical half lives, as recorded in the
AccountFile. - Device
Dek - This device’s Device Encryption Key, in whichever of the two compositions the design allows.
- Hardware
Signer Error - Failure surfaced by a
HardwareSignerorHardwareKeyAgreementbackend.
Constants§
- DEK_
CIPHERTEXT_ LEN - X-Wing ciphertext length:
ct_M (1088) ‖ ct_X (32). - DEK_
P256_ CIPHERTEXT_ LEN - P-256-hybrid DEK ciphertext length:
ct_M (1088) ‖ ct_P (65). - DEK_
P256_ PUBLIC_ LEN - P-256-hybrid DEK public-key length:
ek_M (1184) ‖ pk_P (65). - DEK_
PUBLIC_ LEN - X-Wing public-key length:
pk_M (1184) ‖ pk_X (32). - ESEED_
LEN - Length of the X-Wing encapsulation seed: ML-KEM coins
m(32) and the X25519 ephemeral (32). - KEY_
COMMITMENT_ LEN - The length of a
key_commitment. - SAFETY_
CODE_ CHUNK - The digits per displayed chunk. Both devices render the code in the same chunked, fixed-length shape so the human comparison is chunk-by-chunk rather than one long run.
- SAFETY_
CODE_ DIGITS - How many decimal digits a safety code carries. Under the commit-then-reveal ordering over nonce-bearing inputs a man in the middle gets one blind guess, so twelve digits bound it at one in 10^12.
Traits§
- Hardware
KeyAgreement - The per-platform hardware key-agreement element — the ECDH analogue of
HardwareSigner, implemented by native code (Swift/Kotlin) behind thecapsule_sdknamespace’sFfiHardwareKeyAgreementforeign trait. It backs the hardware-bound classical half of the device encryption key (DEK): shipping secure elements expose ECDH-P256 (Secure EnclaveP256.KeyAgreement, StrongBox ECDH, TPM 2.0 ECDH), so the DEK’s X25519 half of the X-Wing KEM is replaced by a hardware-held P-256 static key while the ML-KEM-768 half stays software-sealed. The element holds the P-256 private key and performs the ECDH so it never leaves hardware; Rust drives the ML-KEM half and the hybrid combiner (SSoT: Cryptography — Keys § Device Keys). - Hardware
Signer - The per-platform hardware secure element, implemented by native code (Swift/Kotlin) behind the
capsule_sdknamespace’sFfiHardwareSignerforeign trait. Rust calls into it to enroll a non-exportable Ed25519 key and to sign with it; the ML-DSA-65 half is handled in Rust. - Signer
- Produces hybrid signatures over arbitrary bytes and exposes the matching public key.
Functions§
- commitment_
matches - Whether revealed key bytes are the ones a commitment was made to. A mismatch is the abort path: the enrollee revealed keys it did not commit to, or the commitment was substituted.
- encapsulate_
to_ p256_ public - Encapsulate a fresh shared secret to a foreign P-256-hybrid public key
ek_M ‖ pk_P— the sender side, holding only the recipient’s public half. Pure software (no hardware): it mirrorssuper::kem::encapsulate_to_publicfor the P-256 variant. Returns the ciphertextct_M ‖ ct_P(DEK_P256_CIPHERTEXT_LENbytes) and the 32-byte combined shared secret. - encapsulate_
to_ public - Encapsulate a fresh shared secret to a foreign X-Wing public key
pk_M ‖ pk_X— the sender side when you hold only the recipient’s public half (e.g. a web-upload guest sealing an asset key to the link’s Drop Key, which travels in the URL fragment). Returns the X-Wing ciphertextct_M ‖ ct_X(DEK_CIPHERTEXT_LENbytes) and the 32-byte combined shared secret. Draws the encapsulation randomness from the OS CSPRNG. - key_
commitment - The enrollee’s commitment to its canonical advertised-key bytes, sent before the initiator reveals its own keys (see the module docs for why the order matters).
- safety_
code - The safety code both devices display, over the initiator’s and the enrollee’s canonical advertised-key bytes, in that order.