Expand description
Checksums for the delta engine.
Two layers, exactly as in the rsync algorithm:
- a weak rolling checksum (
RollingChecksum) that is cheap to compute andO(1)to slide one byte along a buffer, used to cheaply reject non-matching windows; and - a strong hash (
strong_hash) — the first 16 bytes of a BLAKE3 digest — used to confirm a candidate match found via the weak checksum.
§Rolling checksum definition
With modulus M = 65536 and a window of length L:
a = (Σ_k bytes[k]) mod M
b = (Σ_k (L - k) * bytes[k]) mod M // position-weighted, k = 0..L
checksum = a + b * MBecause M = 2^16, reducing modulo M is the same as masking the low 16
bits, and ordinary wrapping (mod 2^32) arithmetic is congruent modulo M.
We therefore accumulate with wrapping u32 ops and mask only when reading the
value out — this keeps rolling branch-free and exact.
Structs§
- Rolling
Checksum - Rolling weak checksum over a fixed-length window.
Constants§
- STRONG_
LEN - Length of the strong hash prefix kept per block, in bytes.
Functions§
- strong_
hash - Strong hash of
data: the firstSTRONG_LENbytes of its BLAKE3 digest.
Type Aliases§
- Strong
Hash - A 16-byte strong hash (BLAKE3 prefix).