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 #
Cslib.BitString.LinearHash.prefixProj: additive homomorphism taking the firstmin r kbits.Cslib.BitString.LinearHash.zeroPadPrefix: zero-paddedk-bit view of the firstrbits.Cslib.BitString.LinearHash.pivotMask,Cslib.BitString.LinearHash.adjustRow,Cslib.BitString.LinearHash.adjustAffineSeed: additive projection onto the prefix-collision seed subgroup.Cslib.BitString.LinearHash.wordAdjustAffineSeed: total word-level implementation ofadjustAffineSeed(with word-level seed packing and evaluation inCslibFrontier.Probability.BitString.AffineHash.Word).
Main results #
Cslib.BitString.LinearHash.isThreeWiseIndependentHash_affineHash:affineHashis3-wise independent for allk, n : ℕ.Cslib.BitString.LinearHash.isKWiseIndependentHash_dotProduct_cons_true: the one-bit familyx ↦ t ⬝ (1, x)is3-wise independent, a sample space of2 ^ (d + 1)points for2 ^ dinputs [ABI86].Cslib.BitString.LinearHash.isThreeWiseIndependentHash_prefixProj_affineHash: truncated Boolean affine hashing is3-wise independent.Cslib.BitString.LinearHash.toReal_map_adjustAffineSeed_eq: mapping a uniform seed byadjustAffineSeed r (y + y₀)scales every prefix-colliding seed's mass by2 ^ (min r k).Cslib.BitString.LinearHash.wordAdjustAffineSeed_eq_packAffineSeed: exact agreement betweenwordAdjustAffineSeedandadjustAffineSeed.
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 #
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 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₀).
For distinct y ≠ y₀, every seed output by adjustAffineSeed r (y + y₀) collides on the first
min r k bits of y and 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.