This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
[braindump] Transparent file encryption/decryption #449
Labels
need/triage
Needs initial labeling and prioritization
Hi,
I wanted to add this to #448 but it seemed like only one piece of the puzzle for that braindump. Therefore a new one for just transparent file encryption/decryption.
The goal is to have at least transparent file decryption (encryption is desired too). Programs using IPFS should not need to worry about encryption keys in arguments for commands. That would potentially alow attack vectors as the key would be part of the command. Hence my initial idea (posted as a comment in #448) is a bit bad in this regard but i'm just adding it below for completeness sake.
Idea 1 (not the best one)
Implement it in IPFS commands. So that you get something like, for example, a
ipfs add <file> --encryption-key <aes key>
. Likewise for getting a file. A benefit here is that you can also call this construct with the web API making the encryption fully transparent for API users (they only need the AES key, the IPFS client does the encryption/decryption)Idea 2
New ipfs command:
ipfs add-denc-jwt <cid> <json file>
denc
stands for decryption-encryption.Regarding the
jwt
in there. I'd just go for a standard format for describing files with encryption and decryption keys. JWT seems like a nice standard so i'd probably use that, but it can be something else too.The command allows one to specify a
<cid>
and a JWT file used on that CID. The files added via this command are only locally known to the local IPFS node. The JWT file is on the user's pc and never leaves it.How this is added is up for debate. It could just be
<cid>-jwt.json
files or it could be an internal SQLite database maintaining a mapping between CID files and JWT files. It would be my preference to just have files and stat them for existence.Transparent decryption
Once a JWT file is added, the internal IPFS commands should take that JWT into account when a given CID is fetched.
So say for example this CID is encrypted: QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T [1] and a JWT is provided for that file too. Then a command like
ipfs cat QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
should check ifQmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T-jwt.json
exists and apply whatever decryption it describes. The result ofipfs cat QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
in this case should be the decrypted content.If there is no
QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T-jwt.json
then the content is still shown as is. Thus just the encrypted useless content.Again note that the jwt file is never added to the IPFS network and isn't used in any communication that lieave the pc. Not bitswap either. The file should only be used on commands that are going to present the data to the user. So like
ipfs cat
and a couple others.Transparent encryption
For encryption there are a couple possible ways i can imagine for it to work out.
ipfs add
that takes in a jwt.json file. Something like:ipfs add <my super secret file> --denc-jwt <jwt file>
. This would not add the jwt file to the local IPFS data, the user still has to do that manually withipfs add-denc-jwt <cid> <json file>
ipfs-encrypt
which would then be called like:ipfs-encrypt <my file to encrypt> --denc-jwt <jwt file> | ipfs add
In this hypothetical command it would first encrypt a file and then add that encrypted file to ipfs using the vanillaipfs add
command.I'm happy to receive any feedback you folks have!
P.S. I'd be very much open to do a call with interested parties to make up a design for this.
CC @Stebalien @aschmahmann
[1] It's big buck bunny and not encrypted, but just for the example of it.
The text was updated successfully, but these errors were encountered: