What is a CID?
A Content Identifier (CID) is a cryptographic hash that uniquely identifies content in IPFS. The same content always produces the same CID, enabling verifiable, immutable storage. Example:bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
Why CID Matters in Keep
In traditional cloud storage, you pay for space regardless of what you store. With Keep, you pay for specific content identified by its CID. This creates a binding between your payment and your data.The Problem We’re Solving
Without CID pre-computation, we run into a couple of issues:- Upload without paying: Store files on IPFS first, then never actually pay
- Pay once, upload many: Reuse a single payment for multiple different files
- Content substitution: Pay for one file, upload something completely different
- No verification: Server can’t prove the payment matches the content stored
How we hacked this
We compute the CID before creating the blockchain deposit, making it a cryptographic commitment:How It Works
1. CID Computation
When you upload files, the server:- SHA-256 hashing
- dagPB codec (IPFS directory structure)
- CAR (Content Addressable aRchive) format
2. CID in Blockchain Deposit
The CID becomes part of your on-chain deposit:- Same user + same CID = same deposit account
- Different CID = different deposit account
- Can’t reuse deposits for different content
3. Verification on Upload
When files are actually stored on Storacha:- You uploaded the exact content you paid for
- No tampering occurred
- Payment is bound to verified content
Benefits
Payment Integrity
Deposits are locked to specific content, preventing fraud
Content Verification
Server verifies uploaded content matches committed CID
Deterministic Accounts
Same content produces same on-chain deposit account
Renewal Capability
CID serves as stable identifier for storage renewals
Multi-File Uploads
For directories with multiple files, Keep generates a root CID that represents all files:- Whole directory:
ipfs://{rootCID}/ - Individual file:
ipfs://{rootCID}/file1.jpg - File by its own CID:
ipfs://{fileCID}
Security Properties
Prevents Double-Spending
Prevents Content Substitution
Enables Renewals
Advanced Details
CID Format & Structure
CID Format & Structure
Keep uses CIDv1 with base32 encoding:Breaking it down:
- b: base32 encoding
- afy: CID version 1
- bei…: SHA-256 hash of content
On-Chain Account Derivation
On-Chain Account Derivation
Deposit accounts are deterministically derived using:This creates an address that:
- Is unique per user per content
- Can be found without storing addresses
- Prevents duplicate deposits
Why Server-Side Computation?
Why Server-Side Computation?
You might wonder: why not compute CID in the browser?Reasons for server-side:
- File Size: Large files could exhaust browser memory
- Consistency: Server ensures correct IPFS compatibility
- Performance: Server has more resources for hashing
- Immediate Verification: Server validates before blockchain transaction