Content Encryption #270
Description
Currently, ipfs does not support any sort of encryption in-line. Users can always encrypt content before adding it into ipfs, which is a solid solution (and a good separation of concerns) but it leaves a bit to be desired for people who just want to use ipfs directly.
There are two main ways that we can have encrypted content in ipfs, both encrypt the actual content, but the first is essentially 'encrypt the data, then add it to ipfs'. The second is 'add the data to ipfs, then encrypt each dag node individually'.
Encrypt First
When encrypting the content first, the dag structure is still plaintext. This has several implications, primarily:
- Attackers can glean information about the size of the file, its chunking algorithm, and its importer layout parameters without having the encryption keys.
- Content can be replicated through the network by nodes who don't know the encryption keys.
Being able to have other peers replicate your content without the encryption keys is a very nice feature to have.
Encrypt Second (or Encrypt the Dag)
To add a bit more secrecy to your data, you can encrypt the raw dag nodes. This definitely prevents anyone without the right keys from gleaning much information about the object in question (does it have links? what is the object type? how big is the whole structure?)
This sort of encryption would be required to encrypt things other than files, like directories, or arbitrary ipld nodes.
UX
So the previous part needs a fair amount of thought, but once we get an idea of how we want to do that, we need a way of actually interacting with encrypted objects. A proposal I have is to adopt something like:
ipfs cat QmFooBarEncrypted#enckey:1bf72d9ef
Where 1bf72d9ef is the key to decrypt the data referenced by QmFooBarEncrypted.
This is nice because with a browser extension, you could achieve the same effect in a browser without leaking the keys to anyone else (since the hash fragment is never sent to the server).
This is definitely a WIP proposal, i'll be updating it as I think through things more and discuss.