sahib / brig

File synchronization on top of ipfs with git like interface & web based UI
https://brig.readthedocs.io
GNU Affero General Public License v3.0
568 stars 33 forks source link

proposal: change encryption (back) to random key generation #66

Closed sahib closed 3 years ago

sahib commented 3 years ago

On Stage() we're currently do the following things before adding the file to ipfs, all of them requiring a seekable stream:

See this function as reference.

We probably can live without the compression guessing. Getting rid of the hash is harder, then we need another encryption guessing mechanism. Current scheme is: If a file was initially added, compute the content hash+size and derive the key from it. If the file is modified the existing key is taken over. The idea here was that we want to enable de-duplication for same or similar files. This is however defeated by the way our encryption works: Each blocks influences the next block. So changes will result in a avalanche of changed cipher text. A single bit changed in the start of the file will therefore result in a completely different ciphertext. My plan to fix is to either wait for encryption support in IPFS or build some block layer in brig ourselves.

Until that happens (far future in any case) we should switch back to random key generation, which would allow us to get rid of the seekable stream requirement, also boosting performance since we need to read the stream only once.