What is a .zsafe File? The Authenticated Container Format Explained

Explore the technical anatomy of the .zsafe file extension: how it encrypts directory structures, guarantees tamper resistance with AES-256-GCM AEAD, and maintains 100% backward compatibility with legacy .zev vaults.

1. What is a .zsafe File?

A .zsafe file (e.g. Personal_Vault.zsafe) is an authenticated, zero-knowledge cryptographic file container. It packages arbitrary files and complex nested directories into a single portable binary file that can only be unlocked with the correct master passphrase (and optional keyfile).

Operating under the ZV3\0 STREAM AEAD container specification, a .zsafe file is bit-for-bit identical across all platforms: a vault created in Google Chrome on Windows can be opened seamlessly on an Android phone, Mac, or offline Linux laptop.

2. Why .zsafe Over Standard ZIP or Encrypted Disks?

Most everyday encryption tools suffer from significant structural vulnerabilities:

3. The 3-Region Binary Container Structure

Every valid .zsafe container consists of three contiguous byte regions:

🏗️ Container Layout
  1. 57-Byte Header: Stores container flags, salt parameters, chunk dimensions, and a 64-bit pointer to the manifest.
  2. STREAM AEAD Payload: The encrypted data payload, split into uniform 4 MB chunks. Each chunk is encrypted with AES-256-GCM.
  3. Sealed Tail Manifest Catalog: An encrypted JSON catalog storing the directory tree, decoded in under 300 ms upon authentication.

4. The 57-Byte Container Header Layout

Every .zsafe file begins with exactly 57 unencrypted header bytes (V3_HEADER_SIZE = 57):

Binary Specification · 57-Byte Container Header Layout
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; Bit 1: Duress; Bit 2: Argon2id
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) / PBKDF2-SHA512
42 .. 48   | 7 B  | Raw Bytes | BASE_IV_PREFIX  | CSPRNG 7-byte prefix for chunk IV derivation
49 .. 56   | 8 B  | Uint64 BE | MANIFEST_OFFSET | Big-endian byte offset of encrypted tail catalog

5. Tamper Resistance & Chunk Authentication (AAD)

A critical flaw in naive chunked encryption schemes is chunk swapping or truncation attacks, where an attacker reorders chunks or deletes blocks.

ZevSafe eliminates this threat through Associated Authenticated Data (AAD). Before encrypting each 4 MB block, ZevSafe constructs a 42-byte AAD binding:

AAD Framing · Chunk-Level Integrity Binding
Chunk AAD Layout (42 Bytes):
[ Magic (4B) | Version (1B) | Salt (32B) | ChunkIndex (4B BE) | IsLast (1B) ]

Because this 42-byte buffer is authenticated by AES-256-GCM, any attempt to swap Chunk 2 with Chunk 3 or delete the final chunk causes authentication to fail immediately during decryption.

6. 100% Compatibility with Legacy .zev Archives

Prior to the .zsafe release, ZevSafe container files used the .zev extension. To avoid breaking user vaults, ZevSafe maintains 100% backward compatibility: