Skip to main content

Module keys

Module keys 

Source
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.
AccountFile
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 HybridSigningKey write-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.
DeviceKeys
This device’s key material: a stable id, a hybrid Device Signing Key (DSK), and a Device Encryption Key (DEK).
HardwareBackedSigner
Adapts a HardwareSigner to Signer: the Ed25519 half is produced in hardware, the ML-DSA-65 half in software from the sealed ξ seed, and the two are combined into a HybridSignature.
HybridSignature
A hybrid signature: a classical half (Ed25519 or ECDSA-P256) and an ML-DSA-65 half over the same message.
HybridSigningKey
A hybrid signing keypair (private) — the software composition, both halves in memory. The hardware-backed composition lives in HardwareBackedSigner (Ed25519 hardware half) and P256HybridSigningKey (P-256 hardware half); both drive the same HybridSignature/HybridVerifyingKey types.
HybridVerifyingKey
A hybrid public verifying key. Published in the device directory.
MasterKey
A 32-byte account master key.
P256HybridDek
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-Wing DekKeypair.
P256HybridSigningKey
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.
SoftwareSigner
A software HardwareSigner: the fallback for devices with no secure element.

Enums§

ClassicalAlgorithm
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.
DeviceDek
This device’s Device Encryption Key, in whichever of the two compositions the design allows.
HardwareSignerError
Failure surfaced by a HardwareSigner or HardwareKeyAgreement backend.

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§

HardwareKeyAgreement
The per-platform hardware key-agreement element — the ECDH analogue of HardwareSigner, implemented by native code (Swift/Kotlin) behind the capsule_sdk namespace’s FfiHardwareKeyAgreement foreign trait. It backs the hardware-bound classical half of the device encryption key (DEK): shipping secure elements expose ECDH-P256 (Secure Enclave P256.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).
HardwareSigner
The per-platform hardware secure element, implemented by native code (Swift/Kotlin) behind the capsule_sdk namespace’s FfiHardwareSigner foreign 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 mirrors super::kem::encapsulate_to_public for the P-256 variant. Returns the ciphertext ct_M ‖ ct_P (DEK_P256_CIPHERTEXT_LEN bytes) 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 ciphertext ct_M ‖ ct_X (DEK_CIPHERTEXT_LEN bytes) 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.