Documentation

CslibFrontier.Probability.BitString.AffineHash.ThreeWise

Three-wise independence and prefix-collision conditioning of Boolean affine hashes #

Over the two-element Boolean ring Bool, any two distinct nonzero vectors u, v : BitString n are linearly independent over GF(2): there is no non-unit scalar in {0, 1}, so u ≠ 0, v ≠ 0, and u ≠ v suffice to solve (a ⬝ᵥ u, a ⬝ᵥ v) = (d₂, d₃) simultaneously for every pair (d₂, d₃). Consequently, the Boolean affine family Cslib.BitString.LinearHash.affineHash (x ↦ A x + b) is three-wise independent (IsKWiseIndependentHash 3) for all dimensions k, n : ℕ, with no finite-field extension arithmetic.

Postcomposing with the prefix restriction prefixProj k r preserves three-wise independence. Furthermore, for distinct inputs y ≠ y₀ (δ = y + y₀ ≠ 0), conditioning a uniform affine seed (A, b) on the prefix collision prefixProj k r (A y + b) = prefixProj k r (A y₀ + b) is realized explicitly by an idempotent additive homomorphism adjustAffineSeed r (y + y₀) that projects the first min r k rows of A onto {row | row ⬝ᵥ (y + y₀) = false} along the first true coordinate of y + y₀, scaling each supported seed's probability by (2 : ℝ) ^ (min r k). This supplies the constructible three-wise independent hash family used in [HHRVW2020], Section 4.2, Theorem 4.5 (pp. 21–25).

Main definitions #

Main results #

References #

Simultaneous Boolean dot products and 3-wise independence #

Boolean affine hashing is three-wise independent for all output and input widths k, n.

One-bit affine hashing as a single dot product is three-wise independent: x ↦ t ⬝ (1, x) for a uniformly random t ∈ {0,1}^(d+1). It is the one-row family affineHash with seed (Fin.tail t, t 0). Labelling n points by d = ⌈log₂ n⌉ binary digits gives a three-wise independent sample space of 2 ^ (d + 1) < 4 n points [ABI86].

Prefix restriction and fixed-width zero padding #

Additive homomorphism projecting a k-bit string onto its first min r k coordinates.

Restricting to the first min r k coordinates is surjective.

Truncating affineHash to its first min r k output bits preserves 3-wise independence.

Zero-pad a k-bit string after its first r coordinates, retaining fixed output width k.

Two k-bit strings have equal zero-padded r-prefixes iff their min r k-bit prefixes agree.

On words, zeroPadPrefix takes min r k bits and pads the remaining k - min r k bits with false.

Additive projection onto prefix-colliding affine seeds #

Basis mask at the first true coordinate of δ, or 0 when δ = 0.

The word representation of pivotMask δ is listSingle n ((List.ofFn δ).idxOf true).

Additive homomorphism projecting a row row : BitString n onto {row | row ⬝ᵥ δ = false} when δ ≠ 0.

Additive homomorphism projecting an affine hash seed (A, b) onto the subgroup of seeds whose first min r k rows are orthogonal to δ. For δ = y + y₀ (y ≠ y₀), this is exactly the set of seeds where prefixProj k r (affineHash s y) = prefixProj k r (affineHash s y₀).

theorem Cslib.BitString.LinearHash.prefixProj_affineHash_adjustAffineSeed {k n : ℕ} (r : ℕ) {y y₀ : BitString n} (hy : y ≠ y₀) (s : (Fin k → BitString n) × BitString k) :
(prefixProj k r) (affineHash ((adjustAffineSeed r (y + y₀)) s) y) = (prefixProj k r) (affineHash ((adjustAffineSeed r (y + y₀)) s) y₀)

For distinct y ≠ y₀, every seed output by adjustAffineSeed r (y + y₀) collides on the first min r k bits of y and y₀.

theorem Cslib.BitString.LinearHash.toReal_map_adjustAffineSeed_eq {k n : ℕ} (r : ℕ) {y y₀ : BitString n} (hy : y ≠ y₀) {s₀ : (Fin k → BitString n) × BitString k} (hs₀ : (prefixProj k r) (affineHash s₀ y) = (prefixProj k r) (affineHash s₀ y₀)) :

Exact conditional-seed scaling: for distinct y ≠ y₀, mapping a uniformly random affine seed by adjustAffineSeed r (y + y₀) assigns to every prefix-colliding seed s₀ mass exactly (2 : ℝ) ^ (min r k) times its uniform mass.

Word-level seed adjustment and exact agreement #

Word-level implementation of adjustAffineSeed: adjust each of the first min r k rows of the k × n matrix prefix of seed to be orthogonal to y + y₀, preserving the remaining rows and the k-bit offset.

On fixed-width words, wordAdjustAffineSeed agrees with adjustAffineSeed under packAffineSeed and unpackAffineSeed.

@[simp]
theorem Cslib.BitString.LinearHash.length_wordAdjustAffineSeed (k n r : ℕ) (y y₀ seed : List Bool) :
(wordAdjustAffineSeed k n r y y₀ seed).length = k * n + k