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).
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:
backdit/account-signing: Ed25519 master account key (AccountId).backdit/file-root: Symmetric root key for client-side file and pack encryption.backdit/storage-recipient: X25519 keypair used for RFC 9180 HPKE host sealing and Proof-of-Possession.backdit/recovery: Encryption root for Recovery Capsules and Tier 2 segments.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”- Striping: Files split into fixed stripes (
default_stripe_mib = 64, configurable16,32, or64 MiB). - 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. - AEAD Encryption (
XChaCha20-Poly1305): Compressed bytes are encrypted withfile_rootand a per-stripe 24-byte nonce derived by XORing the little-endianchunk_indexinto the file’s random 24-byte base nonce (derive_chunk_nonce). - Reed-Solomon
8+6(ERASURE_K = 8,ERASURE_M = 6): Ciphertext is padded to a multiple of8and encoded into14equal shards (1.75xstorage overhead). Any8of14shards reconstruct the stripe, surviving up to6simultaneous host losses. AEAD-verified0..8trial unpadding removes padding on decode without extra length tables. - Parallel Integrity:
rayonhashes every shard withSHA-256(rs_merkle) and records hashes inFileManifestandPlacementRecord.
3. Small-File Packing (SYMPACK2)
Section titled “3. Small-File Packing (SYMPACK2)”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 = 256files per pack (48-byte header + contiguous member payloads + encryptedPackIndex). PackIndexis sealed withXChaCha20-Poly1305keyed viaHKDF("backdit/pack-index-key/1", recovery_key).- Each pack uploads as one physical
8+6object (14placements total), while individual files keep logicalFileManifestentries pointing to their byte offsets.
4. Host-Side RFC 9180 HPKE in Locked RAM
Section titled “4. Host-Side RFC 9180 HPKE in Locked RAM”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:
- Proof-of-Possession: During session admission (
Hello -> Challenge -> Prove), the host sends a one-time HPKEProofChallenge(PROOF_INFO = b"backdit/storage-key-proof/hpke") to the owner’s X25519storage-recipientkey (120sTTL). - OS-Locked Memory Buffer (
LockedBuffer): Incoming shard bytes stream into OS-locked anonymous memory (VirtualAlloc+VirtualLock+WerRegisterExcludedMemoryBlockon Windows;mmap+mlock+MADV_DONTDUMPon Unix/Linux), failing closed if locking is unavailable and zeroizing on drop (64 MiBper buffer,128 MiBprocess budget). Persrc/storage/memory.rs, this covers theLockedBufferallocation itself rather than external library stack copies or full-system dumps. - In-Place HPKE Sealing & Audit Tree: Inside
LockedBuffer, the host seals the shard using RFC 9180 HPKE Base mode (X25519HkdfSha256,HkdfSha256,ChaCha20Poly1305,BKDTSEAL,72 Boverhead), computes a64 KiB-blockSealedAuditTree, and binds the root into a signedStorageReceipt. - Atomic Disk Write (
BKDTHOST): Only the HPKE-sealed object is published viatemp -> fsync -> hard_linkinto256NTFS-safe hex subdirectories (chunks_dir), optionally wrapped by a localhost_store.key(host_store_encryption = true,BKDTOUTR).