Content Addressable Files over Bitcoin


C:// is an immutable URI scheme for referencing B:// protocol files, a simple Bitcoin file storage protocol.

The file system is constructed from Bitcoin transactions, and is instantly serviced through HTTP/HTTPS endpoint.

content addressable

C:// generates filenames by SHA256-hashing the content uploaded through Bitcoin.

This means there's exactly one universal filename per unique content. (Known as Content Addressable Storage)


With B://'s default URI scheme, users can't verify authenticity of the files sent from B:// servers with 100% certainty. You still need to rely on a 3rd party Bitcoin node to verify, which involves trust.

With C://, every file URI is uniquely derived from its contents (not transaction id, but the SHA256 hash of the file buffer itself), so you can be 100% confident of the authenticity of the files you reference using the C:// scheme.

how it works

The "Write" part is handled by the B:// protocol, which means all B:// files are automatically compatible with C://.

C:// deals only with the referencing part.
  1. Write: Write with B://, a simple protocol for writing immutable files to Bitcoin
  2. Read: Read with C://, a content addressed URI scheme for B:// files. The URI is derived from the content.
Instead of using the B://{{transaction id}} URI scheme, you use the new C://{{sha256(content)}} to store and serve files. An example HTTP implementation:
With C://, you can use any Bitcoin file serve provider WITHOUT having to trust them at all, because you can effortlessly verify the authenticity 100% client-side. All you need to do is compare the URI with the SHA256 of the file itself.

Try example

The following URI is 100% derived from its contents by hashing the file content itself: c://6fa960b8aa85c3830724dfe99f6b14a3373d5c759e173307b70177ebb6a50b95


Here's the entire algorithm used to generate the filename. Very simple!
const fs = require('fs')
const crypto = require('crypto')

// 1. Extract "lb2" pushdata into buffer
let buf = Buffer.from(out.lb2, 'base64');

// 2. Generate SHA256 hash from the buffer
let hash = crypto.createHash('sha256').update(buf).digest('hex');

// 3. Write to file
fs.writeFile(process.cwd() + "/c/" + hash, buf, function(er) {

truly deterministic applications

Remember, applications are really nothing more than files.

If files can be immutably stored AND deterministically served, we can build absolutely deterministic applications.

We can even treat them like local files because it's now possible to use ANY 3rd party file server WITHOUT having to trust them.

  <link href="c://d836d81acb5d5e712c55c4f7911d93513fe1d7d0336353085aa5bd0f36b6998c" rel="stylesheet">
  <script src="c://8603b20b548270423fb03c2138c16f5f863ead4c48eb0999167df869e2eef8a6"></script>
  <img src="c://4e2d46dfc8b1e11da7b1e5e07ebef234f52ad3a4e52d30b31d01e6b376420312">
2. JavaScript
.then(function(res) {
  return res.json()
}).then(function(res) {