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
- Users wish to keep the files they upload to BTFS private and inaccessible to anyone without authorization.
- Users want to be able to share their private files with designated recipients.
- 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:
- Add a 'btfs encrypt' command, which can be used when users want to upload an encrypted file.
- 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.
- The peerId parameter is optional and defaults to the local peerId (i.e. only users themselves have access to the file).
- Add a 'btfs decrypt' command to decrypt the CID for users.
- 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.
- 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:
- Each node has its own public and private keys, which are easier and safer to use for file encryption and decryption.
- 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 Size | Encryption Time | Decryption Time | Machine |
---|---|---|---|
2.1 GB | 4.3s | 4.8s | 8C16G |
593 MB | 638ms | 985ms | 8C16G |
100 MB | 97ms | 153ms | 8C16G |
11 MB | 10ms | 15ms | 8C16G |
1.3 MB | 1.4ms | 2.3ms | 8C16G |
Backwards Compatibility
This new feature is backward-compatible and won’t cause breaking changes.
Updated 12 months ago