Skip to content

Encryption & Erasure Coding

Backdit separates owner confidentiality (guaranteed before a byte leaves your machine) from host-side sealing (enforced inside OS-locked, zeroized-on-drop memory buffers on the remote storage host).

Backdit Zero-Knowledge Client Pipeline and RS 8+6 DistributionLocal archives are striped into 64 MiB chunks, compressed with Zstd, encrypted with XChaCha20-Poly1305, Reed-Solomon 8+6 encoded into 14 shards across distinct host accounts preferring diverse observed connection networks, and HPKE-sealed inside OS-locked, zeroized-on-drop host memory buffers.1. Zero-Knowledge Vault & RS (8+6) Host SealingRestore from any 8 of 14 shards01 · LOCAL INPUTArchive / Path64 MiB stripe splitSYMPACK2 packing(<= 256 small files)02 · CLIENT CRYPTOZstd + XChaCha20Zstd level 3 compressXChaCha20-Poly1305Per-stripe 24B nonce03 · ERASURE RS(8+6)14 Equal Shards8 data + 6 parity (1.75x)SHA-256 verified per shard04 · REMOTE HOST MEMORYRFC 9180 HPKE Sealed14 accounts; <= 2/public /24 /48OS-locked buffer, zeroized on dropmlock / VirtualLock -> BKDTHOSTSecurity & Fault-Tolerance BoundariesZero plaintext on wire or disk: filenames, file bytes, and PackIndex stay sealed under owner BIP-39 keys.Host Proof-of-Possession + HPKE wrapping ensures hosts never persist unsealed bytes from untrusted uploaders.

1. Key Hierarchy (HKDF-SHA256 from 24 BIP-39 Words)

Section titled “1. Key Hierarchy (HKDF-SHA256 from 24 BIP-39 Words)”

Backdit generates a 24-word BIP-39 mnemonic (256 bits of CSPRNG entropy) and expands it with HKDF-SHA256 (salt b"backdit/key-hierarchy") into five domain-separated 32-byte root keys:

  1. backdit/account-signing: Ed25519 master account key (AccountId).
  2. backdit/file-root: Symmetric root key for client-side file and pack encryption.
  3. backdit/storage-recipient: X25519 keypair used for RFC 9180 HPKE host sealing and Proof-of-Possession.
  4. backdit/recovery: Encryption root for Recovery Capsules and Tier 2 segments.
  5. backdit/locator: Deterministic blind DHT locator key for clean-machine discovery.

Each installed machine generates its own local Ed25519 device keypair (identity.bundle, 0o600), authorized by a signed DeviceCertificate (365d default lifetime) with DeviceRevocation support. Secret structs wrap zeroize::Zeroizing and redact fields in Debug.

2. Client Striping, Compression, AEAD & RS 8+6

Section titled “2. Client Striping, Compression, AEAD & RS 8+6”
  1. Striping: Files split into fixed stripes (default_stripe_mib = 64, configurable 16, 32, or 64 MiB).
  2. Compression: Each stripe is compressed with Zstd level 3 before encryption. Decompression enforces a bounded reader (.take(maximum_original_length + 1)) against Zstd decompression bombs.
  3. AEAD Encryption (XChaCha20-Poly1305): Compressed bytes are encrypted with file_root and a per-stripe 24-byte nonce derived by XORing the little-endian chunk_index into the file’s random 24-byte base nonce (derive_chunk_nonce).
  4. Reed-Solomon 8+6 (ERASURE_K = 8, ERASURE_M = 6): Ciphertext is padded to a multiple of 8 and encoded into 14 equal shards (1.75x storage overhead). Any 8 of 14 shards reconstruct the stripe, surviving up to 6 simultaneous host losses. AEAD-verified 0..8 trial unpadding removes padding on decode without extra length tables.
  5. Parallel Integrity: rayon hashes every shard with SHA-256 (rs_merkle) and records hashes in FileManifest and PlacementRecord.

Uploading thousands of tiny files individually as 8+6 placements would multiply metadata and round-trips. Batch uploads and Direct Local-Path directory backups bundle small files into immutable 64 MiB (PACK_TARGET) containers:

  • Up to MAX_PACK_MEMBERS = 256 files per pack (48-byte header + contiguous member payloads + encrypted PackIndex).
  • PackIndex is sealed with XChaCha20-Poly1305 keyed via HKDF("backdit/pack-index-key/1", recovery_key).
  • Each pack uploads as one physical 8+6 object (14 placements total), while individual files keep logical FileManifest entries pointing to their byte offsets.

Even though shards are already client-encrypted, hosts run receiver-side sealing (HostSealer) so an untrusted uploader cannot force raw unsealed payloads onto a host’s drive:

  1. Proof-of-Possession: During session admission (Hello -> Challenge -> Prove), the host sends a one-time HPKE ProofChallenge (PROOF_INFO = b"backdit/storage-key-proof/hpke") to the owner’s X25519 storage-recipient key (120s TTL).
  2. OS-Locked Memory Buffer (LockedBuffer): Incoming shard bytes stream into OS-locked anonymous memory (VirtualAlloc + VirtualLock + WerRegisterExcludedMemoryBlock on Windows; mmap + mlock + MADV_DONTDUMP on Unix/Linux), failing closed if locking is unavailable and zeroizing on drop (64 MiB per buffer, 128 MiB process budget). Per src/storage/memory.rs, this covers the LockedBuffer allocation itself rather than external library stack copies or full-system dumps.
  3. In-Place HPKE Sealing & Audit Tree: Inside LockedBuffer, the host seals the shard using RFC 9180 HPKE Base mode (X25519HkdfSha256, HkdfSha256, ChaCha20Poly1305, BKDTSEAL, 72 B overhead), computes a 64 KiB-block SealedAuditTree, and binds the root into a signed StorageReceipt.
  4. Atomic Disk Write (BKDTHOST): Only the HPKE-sealed object is published via temp -> fsync -> hard_link into 256 NTFS-safe hex subdirectories (chunks_dir), optionally wrapped by a local host_store.key (host_store_encryption = true, BKDTOUTR).