Expand description
Cryptographic primitives for payload encryption.
Implements a two-tier key derivation scheme using Argon2id:
-
Tier 1 (structural): Deterministic key derived from passphrase + fixed salt. Produces
perm_seed(coefficient permutation) andhhat_seed(STC matrix generation). Both encoder and decoder derive identical keys. -
Tier 2 (encryption): AES-256-GCM-SIV key derived from passphrase + random salt. The random salt is embedded in the payload frame, so the decoder recovers it from the extracted data.
AES-256-GCM-SIV is chosen over AES-256-GCM for its nonce-misuse resistance, which provides an extra safety margin since the nonce is randomly generated and embedded alongside the ciphertext.
Constants§
- FORTRESS_
EMPTY_ NONCE - Fixed nonce for Fortress empty-passphrase optimization. When passphrase is empty, we use this deterministic nonce so it doesn’t need to be embedded in the frame (saving 12 bytes). NOT secret — just a constant to feed into AES-GCM-SIV.
- FORTRESS_
EMPTY_ SALT - Fixed salt for Fortress empty-passphrase optimization. When passphrase is empty, we use this deterministic salt so it doesn’t need to be embedded in the frame (saving 16 bytes). The message is still AES-encrypted so the payload looks random for steganalysis resistance. NOT secret — just a constant to feed into AES key derivation.
- NONCE_
LEN - AES-GCM-SIV nonce length in bytes.
- SALT_
LEN - Argon2 salt length in bytes.
Functions§
- decrypt
- Decrypt ciphertext with AES-256-GCM-SIV.
- derive_
armor_ structural_ key - Derive the Armor structural key (Tier 1) from a passphrase.
- derive_
encryption_ key - Derive the AES-256 encryption key (Tier 2) from passphrase + random salt.
- derive_
fortress_ structural_ key - Derive the Fortress structural key from a passphrase.
- derive_
h264_ mvd_ structural_ key - Derive the H.264 Phase 3c MVD-domain structural key.
- derive_
per_ gop_ seed_ from_ master - H.264 Phase I.0.5: derive a per-GOP seed by mixing a master 32-byte seed
with
gop_idxand a domain label using SHA-256. - derive_
shadow_ structural_ key - Derive the Shadow structural key from a passphrase.
- derive_
structural_ key - Derive the structural key (Tier 1) from a passphrase.
- derive_
template_ key - Derive the DFT template key from a passphrase.
- encrypt
- Encrypt plaintext with AES-256-GCM-SIV.
- encrypt_
with - Encrypt plaintext with AES-256-GCM-SIV using caller-provided salt and nonce.