1. Architectural Objectives of the ZV3 Format
The ZV3 STREAM AEAD container format was designed to solve three fundamental challenges in client-side browser cryptography:
- Memory Bounding: The format must be streamable in $O(1)$ memory, enabling a browser tab with a 150 MB heap ceiling to encrypt and decrypt multi-gigabyte files.
- Cross-Platform Bit-Identity: Vaults generated on a web browser must be bit-for-bit compatible with desktop CLI tools (PowerShell/Bash) and native mobile engines.
- Chunk Re-Ordering & Truncation Defense: An adversary must not be able to swap chunks, delete chunks, or truncate the file without triggering immediate AEAD tag verification failure.
2. The 57-Byte Container Header Layout
Every .zsafe (or legacy .zev) file begins with exactly 57 unencrypted header bytes:
Offset (B) | Size | Encoding | Field Name | Description
-----------+------+-----------+-----------------+----------------------------------------
0 .. 3 | 4 B | ASCII | MAGIC | Constant: "ZV3\0" (0x5A 0x56 0x33 0x00)
4 | 1 B | Uint8 | VERSION | Container schema version (0x03)
5 | 1 B | Uint8 | FLAGS | Bit 0: Keyfile 2FA (0x01); Bit 1: Duress (0x02); Bit 2: Argon2id (0x04)
6 .. 9 | 4 B | Uint32 BE | CHUNK_SIZE | Default: 4,194,304 bytes (4 MB)
10 .. 41 | 32 B | Raw Bytes | SALT | CSPRNG salt for Argon2id (64MB) or PBKDF2-SHA512
42 .. 48 | 7 B | Raw Bytes | BASE_IV_PREFIX | CSPRNG 7-byte prefix for chunk IVs
49 .. 56 | 8 B | Uint64 BE | MANIFEST_OFFSET | Byte offset of encrypted tail catalog
3. Interactive 57-Byte Header Inspector
Click any byte segment below to examine its encoding, range, and cryptographic security invariants:
Fixed 4-byte ASCII constant (0x5A 0x56 0x33 0x00). Formally identifies the file as a Version 3 STREAM AEAD container. Parsers instantly reject any file lacking these 4 bytes before deriving keys.
4. Chunk Wire Framing & 12-Byte IV Construction
AES-GCM mandates that an Initialization Vector (IV) must never repeat under the same key. A repeating IV completely destroys GCM authenticity.
ZevSafe guarantees mathematical IV uniqueness for every chunk:
IV (12 Bytes) = BaseIVPrefix (7B) || Uint32BE(chunkIndex) (4B) || isLast (1B)
- BaseIVPrefix (7 Bytes): 56 bits of CSPRNG randomness generated per container.
- Chunk Index (4 Bytes Big-Endian): Strictly sequential integer ($0, 1, 2, \dots$). Enforces chunk ordering; swapping chunk 2 and chunk 3 causes IV mismatch and immediate decryption failure.
- isLast Flag (1 Byte): Set to
0x00for intermediate chunks and0x01for the final chunk. Prevents truncation attacks (an adversary deleting the end of the file cannot pass authentication).
5. 42-Byte Associated Authenticated Data (AAD) Invariant
To bind container metadata directly into each cryptographic block without encrypting the metadata, ZevSafe injects a 42-byte Associated Authenticated Data (AAD) vector into every AES-GCM computation:
AAD (42 Bytes) = Magic(4B) || Version(1B) || Salt(32B) || Uint32BE(chunkIndex)(4B) || isLast(1B)
Because the salt and chunk position are authenticated inside the tag, an adversary cannot copy valid ciphertext chunks from Vault A into Vault B, or reorder chunks within the same vault.
6. The 48-Byte Tail Manifest Envelope Trailer
At the byte offset designated by MANIFEST_OFFSET, the encrypted directory catalog is stored:
[Salt (32B) | IV (12B) | PlainLen (4B BE) | Ciphertext (M Bytes) | GCM_Tag (16B)]
This design enables $O(1)$ random directory access: Vault Explorer seeks directly to the manifest offset, decrypts the JSON directory tree, and presents the entire folder hierarchy in under 20 ms without decrypting any multi-gigabyte file chunks.