Content-Addressing & Merkle Trees
Cloudillo implements a merkle tree structure using content-addressed identifiers throughout its architecture. Every action, file, and data blob is identified by the cryptographic hash of its content, creating an immutable, verifiable chain of trust.
What is Content-Addressing?
Content-addressing means identifying data by what it is (its content) rather than where it is (its location). Instead of using arbitrary IDs or URLs, Cloudillo computes a cryptographic hash of the content itself and uses that hash as the identifier.
Benefits
- β Immutable: Content cannot change without changing its identifier
- β Tamper-Evident: Any modification is immediately detectable
- β Deduplicatable: Identical content produces identical identifiers
- β Verifiable: Anyone can recompute and verify hashes independently
- β Cacheable: Content-addressed data can be cached forever
- β Trustless: No need to trust storage providersβverify the hash
Hash Function
Cloudillo uses SHA-256 for all content-addressing:
- Algorithm: SHA-256 (256-bit Secure Hash Algorithm)
- Encoding: Base64url without padding (URL-safe)
- Output: 43-character base64-encoded string
- Collision Resistance: Cryptographically secure
Merkle Tree Structure
Cloudillo’s content-addressing creates a variable-depth merkle tree where actions can reference other actions recursively. The example below shows a six-level hierarchy for a POST action with image attachments:
Level 1: Blob Data
Raw bytes of actual content (images, videos, documents).
Level 2: Variant IDs (b1~…)
Content-addressed blob identifiers computed as SHA256(blob_bytes).
Level 3: File Descriptor (d2,…)
Encoded string listing all available variants of a file.
Format (variants separated by ;, fields by :):
Example:
The d2 format uses , as the ID separator inside variant IDs (b1,abc123).
An optional leading R={root} field carries the document-tree root.
Level 4: File ID (f1~…)
Content-addressed file identifier computed as SHA256(descriptor_string).
Level 5: Action Token (JWT)
Cryptographically signed JSON Web Token representing a user action.
Structure:
Level 6: Action ID (a1~…)
Content-addressed action identifier computed as SHA256(complete_jwt_token).
Hash Versioning Scheme
All identifiers use a versioned prefix format for future-proofing:
Current Prefixes
| Prefix | Resource Type | Hash Input | Example |
|---|---|---|---|
a1~ |
Action | Entire JWT token | a1~8kR3mN9pQ2vL6xW... |
f1~ |
File | File descriptor string | f1~Qo2E3G8TJZ2HTGh... |
d2, |
Descriptor | (not a hash, the encoded format itself) | d2,vis.tn:b1,abc:f=avif:... |
b1~ |
Blob | Blob bytes (raw data) | b1~abc123def456ghi... |
Version Scheme
- Version 1: SHA-256 with base64url encoding (no padding)
- Future versions: Can upgrade to SHA-3, BLAKE3, etc.
- Backward compatibility: Old content remains valid forever
- Algorithm agility: Migrate to new algorithms without breaking existing references
Example upgrade path:
Merkle Tree Properties
Content-addressing gives the tree several properties for free:
- Immutability: Changing any content changes its ID, so the original is
never overwritten β edits produce a new action with a new
a1~...ID. - Tamper-evidence: A modification anywhere propagates upward. Altering a
thumbnail changes its
b1~...ID, which changes the descriptor, thef1~...file ID, and breaks the post’s attachment reference β verification fails. - Deduplication: Identical content yields identical IDs, so a file shared by many users is stored once.
Chain of Trust
Each reply references its parent by content hash (the p claim), binding a
thread together cryptographically:
Modifying the Post would change its ID and break the Comment’s reference, which would break the Reply’s β the whole thread is bound together.
Proof of Authenticity
Cloudillo provides two complementary layers of proof:
Layer 1: Author Identity (Cryptographic Signatures)
Action tokens are signed with ES384 (ECDSA with P-384 curve and SHA-384 hash):
Verification:
- Fetch alice’s public keys from
https://cl-o.alice.example.com/api/me(thekeysarray) - Verify signature using public key
- β Proves Alice created this action
Layer 2: Content Integrity (Content Hashes)
All identifiers are SHA-256 hashes:
Verification:
- Download content
- Recompute hash
- Compare with claimed identifier
- β Proves content hasn’t been tampered with
Verification Example
Scenario: Verify a LIKE action on a POST with image attachment.
DAG Structure
Cloudillo’s action system forms a Directed Acyclic Graph (DAG) with these properties:
Multiple Roots
Unlike a traditional tree with one root, Cloudillo has multiple independent threads:
Each top-level post is a root node. Comments and reactions form child nodes.
Performance Implications
Caching Strategy
Content-addressed data is immutable, enabling aggressive caching:
Benefits:
- Browsers cache forever (max-age = 1 year)
- CDN cache forever
- No cache invalidation needed
- Reduces bandwidth for federated instances
Security Considerations
Trust Model
Cloudillo’s merkle tree creates a trustless verification model:
| What | Verification Method | Trust Required |
|---|---|---|
| Author identity | JWT signature (ES384) | DNS + Public key infrastructure |
| Content integrity | SHA-256 hash | None (pure mathematics) |
| Parent references | Content hashes | None (pure mathematics) |
| Attachment integrity | SHA-256 hash chain | None (pure mathematics) |
Storage providers don’t need to be trusted: Even if a storage provider is malicious, they cannot:
- Modify content without breaking hashes β
- Forge signatures without private keys β
- Create false parent references β
- Tamper with attachments without detection β
Users verify everything cryptographicallyβno trust required.
Attack Resistance
Known attacks and mitigations:
| Attack | Mitigation |
|---|---|
| Modify action content | Hash mismatch detected |
| Forge author signature | Signature verification fails |
| Swap file attachment | Hash mismatch detected |
| Modify parent reference | Breaks cryptographic chain |
| Replay old actions | Timestamp validation, deduplication |
| Storage provider tampering | Hash verification fails |
See Also
- Actions & Action Tokens - How action tokens are created and verified
- File Storage & Processing - How file content-addressing works
- Identity System - Cryptographic signing keys for actions
- Access Control - How access tokens work alongside content-addressing
- System Architecture - Overall system design