-
Notifications
You must be signed in to change notification settings - Fork 0
09 Robust Blob Storage and Chunk Transfers
Corresponding Specifications:
sys-arch/05-robust-file-blob-subsystem-architecture.md,sys-arch/ui-ux-10-files-media-gallery-transfer-architecture.md
Key Crates:crates/siar-blob-manifest,crates/siar-storage
Large files (photos, audio recordings, documents, offline maps, firmware updates) are stored and transferred using BLAKE3 Merkle Tree Manifests:
[BlobId: Root Hash]
/ \
[Node Hash 0] [Node Hash 1]
/ \ / \
[Leaf 0] [Leaf 1] [Leaf 2] [Leaf 3]
| | | |
[64 KiB] [64 KiB] [64 KiB] [64 KiB]
Implemented in siar-blob-manifest:
pub struct BlobManifest {
pub blob_id: BlobId, // Merkle Tree Root Hash
pub total_size_bytes: u64, // Total uncompressed payload size
pub chunk_size_bytes: u32, // Default 65,536 bytes (64 KiB)
pub total_chunks: u32, // Number of discrete chunks
pub mime_type: String, // e.g. "image/avif", "audio/opus"
pub chunk_hashes: Vec<blake3::Hash>, // List of all leaf BLAKE3 hashes
pub encryption_iv: [u8; 12], // Initialization vector for AEAD
pub signature: Signature, // Publisher Ed25519 signature
}Transfer progress is tracked using compact bitsets (ChunkBitmap), allowing transfers to be paused, resumed across reboots, or pulled simultaneously from multiple nearby mesh peers:
Chunk Map: [ 1 1 1 1 | 1 1 0 0 | 0 0 1 1 | 0 0 0 0 ] (8/16 Chunks Complete - 50%)
^ Peer A ^ Missing ^ Peer B ^ Not started
sequenceDiagram
participant Receiver as Receiving Client
participant PeerA as Nearby BLE Peer
participant PeerB as Nearby Wi-Fi Direct Peer
Receiver->>Receiver: Inspect ChunkBitmap (Missing Chunks 6, 7, 12, 13, 14, 15)
Receiver->>PeerA: Request Chunk 6, 7 (over BLE)
Receiver->>PeerB: Request Chunk 12, 13, 14, 15 (over Wi-Fi)
PeerA-->>Receiver: Stream Chunk 6 + BLAKE3 Tag
Receiver->>Receiver: Verify BLAKE3(Chunk 6) == Manifest.chunk_hashes[6]
Receiver->>Receiver: Decrypt & Commit Chunk 6 to Disk
Receiver->>Receiver: Update ChunkBitmap (Bit 6 = 1)
PeerB-->>Receiver: Stream Chunks 12..15
Receiver->>Receiver: Verify & Commit
Receiver->>Receiver: Reconstruct Full File & Emit UI Notification
To guarantee privacy while still enabling physical mules to deduplicate identical payloads:
- Each 64 KiB chunk
$C_i$ is encrypted with ChaCha20-Poly1305. - The chunk key
$K_i$ is derived from its plaintext hash:$K_i = \text{HKDF}(\text{BLAKE3}(C_i))$ . - Intermediate relay nodes can verify the chunk integrity against the Merkle branch without possessing the conversation's master decryption key.
To protect embedded flash storage (e.g. Android internal storage or Raspberry Pi SD cards):
- High-Water Mark (Default 4 GB): When blob storage exceeds the configured threshold, background pruning activates.
-
LRU Priority:
- Thumbnails and cached group media older than 30 days are purged first.
- Direct 1-on-1 media attachments are retained until user explicitly deletes them.
- Emergency SOS attachments are strictly pinned and never automatically evicted.
SIAR — Survivable Identity & Autonomous Routing
Open Source Mesh & DTN Communications Platform | Dual Licensed under MIT / Apache-2.0 / Commercial
Documentation Index • GitHub Repository • System Specifications
- 04-Autonomous-Routing-and-Policy-Engine
- 05-Proximity-and-Hardware-Transports
- 06-Delay-Tolerant-Networking-and-Bundle-Forwarding
- 07-Battery-Aware-Scheduling-and-Emergency-Mesh
- 08-Offline-Event-Log-and-Outbox-Engine
- 09-Robust-Blob-Storage-and-Chunk-Transfers
- 10-Crash-Recovery-and-Data-Portability
- 11-Realtime-Audio-Video-Calling-Architecture
- 12-Cross-Platform-Client-Architecture
- 13-Messaging-Timeline-Composer-and-Inbox
- 14-Contacts-Groups-and-Security-Center
- 15-Nearby-Discovery-and-Out-of-Band-Pairing
- 16-Notifications-Presence-and-Background-Lifecycle
- 17-Local-Knowledge-Retrieval-and-Search
- 25-Design-System-Tokens-and-Responsive-Layouts
- 26-UI-UX-Performance-Testing-and-Quality-Gates
- 18-Protocol-Extensions-and-WASM-Plugins
- 19-Headless-Daemons-and-Embedded-Nodes
- 20-C-ABI-FFI-and-Native-Language-Bindings
- 21-Testing-Fuzzing-and-Network-Diagnostics
- 22-Getting-Started-and-Developer-Guide
- 23-Off-Grid-Survival-and-Field-Operations-Guide
- 24-System-Comparison-and-Benchmarking