Skip to content

buzhash64e: with rolling hash encryption #8920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Jun 13, 2025

Rather simple and very slow encryption code, needs to be tuned later IF we find this worthwhile doing.

Note:

  • the encryption of a buzhash64 current sum value must only depend on the sum value and the encryption key, NOT on the position in the current stream (thus: no AES-CTR or any other cipher that does not independently encrypt blocks, this is why ECB is used here) - otherwise it would cut the chunks not only based on the content but also based on position in the stream and that would cut differently and would destroy deduplication.
  • instead of encrypting just 64bit using ECB, we could collect e.g. 1024 sums, encrypt them all on in one .encrypt_many() call and then do another loop over the esums to decide where to cut. would be much less overhead than now, but needs maintaining yet another buffer efficiently.

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.06%. Comparing base (a7f8070) to head (c603fb4).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/borg/chunkers/__init__.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8920      +/-   ##
==========================================
- Coverage   82.07%   82.06%   -0.01%     
==========================================
  Files          77       77              
  Lines       13490    13491       +1     
  Branches     1996     1996              
==========================================
  Hits        11072    11072              
- Misses       1753     1754       +1     
  Partials      665      665              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann ThomasWaldmann force-pushed the buzhash64enc branch 2 times, most recently from 8f120dd to bf26a50 Compare June 16, 2025 22:49
Encrypting the rolling hash should make it better resist against attacks.

use aes128-ecb (slow, not optimized)
this will detect if there is anything going wrong
regarding deduplication with the encrypted buzhash mode.
@darkk
Copy link

darkk commented Jun 24, 2025

(As a sidenote on speed). I've found it quite interesting that fast PCG RNG (numpy's default prng) is predictable, but seed reconstruction out of 64 consecutive values is a non-trivial operation — 2¼ CPU-years of computation. However, it's still just a €108, if we assume a CPU core to cost 4 €/month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants