File Share With Encryption

Simple Summary

Sharing a public file on BTFS is quite easy at the moment since all it requires is sending the CID to the recipient. However, users sometimes want to upload private files visible only to themselves or designated users, which is not attainable on BTFS owing to the inherent nature of its underlying structure, where anything uploaded to BTFS can potentially be accessed by others. To tackle its deficiency with respect to private files, we hereby put forward this BTIP proposal.

Abstract

This BTIP proposal aims to enable users to securely store and share private files on the publicly accessible BTFS by implementing a file encryption and decryption approach.

Motivation

  1. Users wish to keep the files they upload to BTFS private and inaccessible to anyone without authorization.
  2. Users want to be able to share their private files with designated recipients.
  3. Access to these private files is obtained through decryption using a simple private key or the private key of the corresponding node.

Specification

The process is illustrated in the following flowchart:
The process

  1. Add a 'btfs encrypt' command, which can be used when users want to upload an encrypted file.
  2. The command encrypts the file with the public key from the peerId and uploads it to the BTFS network to receive the CID of the encrypted file.
  3. The peerId parameter is optional and defaults to the local peerId (i.e. only users themselves have access to the file).
  4. Add a 'btfs decrypt' command to decrypt the CID for users.
  5. The peerId parameter is optional and defaults to the local peerId. If a peerId is provided in the parameters, the encrypted file corresponding to the CID will be downloaded from the BTFS network first.
  6. Users can decrypt the encrypted file with their own private key to obtain the plain text file.

Examples:

btfs encrypt ${file_path}
btfs encrypt ${file_path} --to=16Uiu2HAm63oRwPkf8qi92bFc1z6AVmD2ePvQfrkFyNgHRXjjKdtZ
 
btfs decrypt ${cid}
btfs decrypt ${file_path} --from=16Uiu2HAm63oRwPkf8qi92bFc1z6AVmD2ePvQfrkFyNgHRXjjKdtZ

Rationale

The reasons for choosing asymmetric encryption over symmetric encryption are as follows:

  1. Each node has its own public and private keys, which are easier and safer to use for file encryption and decryption.
  2. With symmetric encryption, private keys are shared across parties, making them less secure and more challenging to store for each encrypted file.

However, asymmetric encryption may impact system performance more than the symmetric solution, potentially affecting user experience.

We conducted tests to assess the impact on latency and found that asymmetric encryption meets our needs:

File SizeEncryption TimeDecryption TimeMachine
2.1 GB4.3s4.8s8C16G
593 MB638ms985ms8C16G
100 MB97ms153ms8C16G
11 MB10ms15ms8C16G
1.3 MB1.4ms2.3ms8C16G

Backwards Compatibility

This new feature is backward-compatible and won’t cause breaking changes.