Universe-reduced k-wise independent hashing via multiply-shift and trinomial polynomials #
To hash a w₀-bit universe Fin U (U ≤ 2 ^ w₀) into Fin (2 ^ b') in $O(1)$ Word-RAM
instructions without any polynomial universe restriction $U \le n^c$, we compose two stages:
- Dietzfelbinger multiply-shift universe reduction (
multiplyShiftReduced U w₀ (3 * b)), which maps keys inFin UintoFin (2 ^ min w₀ (3 * b))using a single(w₀ - 1)-bit odd-multiplier seedα ∈ Fin (2 ^ (w₀ - 1))Dietzfelbinger et al.. - Degree-
< ktrinomial binary-field polynomial evaluation (trinomialPolyHash), which maps the reduced key inFin (2 ^ min w₀ (3 * b))intoFin (2 ^ b')usingkfield coefficients inTrinomialField (reducedTrinomialStep w₀ b b')Vadhan, Section 3.5.5; Wegman and Carter.
Whenever the reduction stage is injective on a key set S : Finset (Fin U), the two-stage hash
family is exact k-wise independent on S (isKWiseIndependentHash_reducedPolyHash_of_injOn). By
2-universality of multiply-shift (isUniversalHash_multiplyShift) when 3 * b ≤ w₀ and exact
bijectivity of odd multiplication modulo 2 ^ w₀ when w₀ < 3 * b, the probability that a uniform
reduction seed α fails to be injective on S is at most
(#S * (#S - 1) : ℝ≥0∞) / 2 ^ (3 * b) ≤ (#S ^ 2 : ℝ≥0∞) / 2 ^ (3 * b)
(toOuterMeasure_not_injOn_multiplyShiftReduced_le).
Main definitions #
Cslib.Probability.multiplyShiftReduced: Dietzfelbinger multiply-shift reduction fromFin UtoFin (2 ^ min w₀ R).Cslib.Probability.reducedTargetBits,Cslib.Probability.reducedTrinomialStep,Cslib.Probability.reducedTrinomialDeg: trinomial field target bit-width, step, and degree parameters for reducedmin w₀ (3 * b)-bit keys andb'-bit outputs.Cslib.Probability.ReducedPolySeed,Cslib.Probability.reducedPolyHash: two-stage seed type and hash family fromFin UtoFin (2 ^ b').Cslib.Probability.reducedGoodTop: the finset of top-level multiply-shift seeds that are injective on a given finite key setS.
Main results #
Cslib.Probability.injective_multiplyShiftReduced_of_le: whenw₀ ≤ RandU ≤ 2 ^ w₀,multiplyShiftReduced U w₀ R αis injective onFin Ufor every seedα.Cslib.Probability.card_not_injOn_multiplyShiftReduced_le,Cslib.Probability.toOuterMeasure_not_injOn_multiplyShiftReduced_le: union bound on the number and probability of reduction seeds that fail to be injective onS : Finset (Fin U).Cslib.Probability.isKWiseIndependentHash_reducedPolyHash_of_injOn: for any fixed reduction seedαthat is injective onS, the restricted polynomial family isk-wise independent onS.Cslib.Probability.coupledWithin_reducedPolyHash_restrict: for anyT : Finset (Fin U)with#T ≤ k, the restriction ofreducedPolyHashtoTunder a uniform seed is coupled within(#T * (#T - 1) : ℝ≥0∞) / 2 ^ (3 * b)ofPMF.uniformOfFintype (T → Fin (2 ^ b')).
References #
Multiply-shift universe reduction to min w₀ R bits #
When w₀ ≤ R and U ≤ 2 ^ w₀, multiplyShiftReduced U w₀ R α is (2 * α + 1) * u % 2 ^ w₀,
which is injective on Fin U for every seed α.
For any distinct x, y : Fin U (U ≤ 2 ^ w₀, 0 < w₀), the number of seeds
α : Fin (2 ^ (w₀ - 1)) for which
multiplyShiftReduced U w₀ R α x = multiplyShiftReduced U w₀ R α y
is at most 2 ^ (w₀ - R) when R ≤ w₀, and 0 when w₀ < R.
Counting union bound on non-injective multiply-shift seeds:
for any S : Finset (Fin U) (U ≤ 2 ^ w₀, 0 < w₀), the number of seeds
α : Fin (2 ^ (w₀ - 1)) on which multiplyShiftReduced U w₀ R α fails to be injective on S
satisfies #(univ \ reducedGoodTop U w₀ R S) * 2 ^ R ≤ (#S * (#S - 1)) * 2 ^ (w₀ - 1).
Probability bound on non-injective multiply-shift seeds:
under a uniform seed α ← PMF.uniformOfFintype (Fin (2 ^ (w₀ - 1))), the probability that
multiplyShiftReduced U w₀ R α fails to be injective on S : Finset (Fin U) is at most
(#S * (#S - 1) : ℝ≥0∞) / 2 ^ R.
Two-stage reduced trinomial polynomial hash family #
Target bit-width max (min w₀ (3 * b)) (max b' 1) for the trinomial field stage.
Trinomial step parameter t = trinomialStepAux (reducedTargetBits w₀ b b') for the
second-stage polynomial hash over reduced min w₀ (3 * b)-bit keys and b'-bit outputs.
Trinomial field degree q = 2 * 3 ^ reducedTrinomialStep w₀ b b'.
The reduced key bit-width min w₀ (3 * b) is at most reducedTrinomialDeg w₀ b b'.
The reduced key universe 2 ^ min w₀ (3 * b) fits in 2 ^ reducedTrinomialDeg w₀ b b'.
The output bit-width b' is at most reducedTrinomialDeg w₀ b b'.
Top-level seed type Fin (2 ^ (w₀ - 1)) for the multiply-shift reduction stage.
Bottom-level seed type Fin k → Fin (2 ^ reducedTrinomialDeg w₀ b b') for the k-wise
independent trinomial polynomial stage.
Combined seed type ReducedTopSeed w₀ × ReducedBotSeed w₀ b b' k for the two-stage reduced
polynomial hash family.
Two-stage hash family reducedPolyHash U w₀ b b' k mapping u : Fin U to Fin (2 ^ b'):
first reduces u to min w₀ (3 * b) bits via multiplyShiftReduced U w₀ (3 * b) θ.1, then
evaluates the degree-< k trinomial polynomial hash with coefficients θ.2.
Conditional k-wise independence on any key set where the reduction is injective:
for any S : Finset (Fin U) and any reduction seed α : ReducedTopSeed w₀ that is injective on
S (Set.InjOn (multiplyShiftReduced U w₀ (3 * b) α) S), the restricted bottom-seed family
fun (β : ReducedBotSeed w₀ b b' k) (u : S) => reducedPolyHash U w₀ b b' k (α, β) u.val is exact
k-wise independent (IsKWiseIndependentHash k).
For any α ∈ reducedGoodTop U w₀ (3 * b) T, the restriction of reducedPolyHash to T
(#T ≤ k) under a uniform bottom seed is PMF.uniformOfFintype (T → Fin (2 ^ b')).
High-probability k-wise independence coupling (coupledWithin_reducedPolyHash_restrict):
for any T : Finset (Fin U) with #T ≤ k (0 < w₀, U ≤ 2 ^ w₀), the restriction of
reducedPolyHash U w₀ b b' k θ to T under a uniform seed
θ ← PMF.uniformOfFintype (ReducedPolySeed w₀ b b' k) is coupled within
(#T * (#T - 1) : ℝ≥0∞) / 2 ^ (3 * b) of PMF.uniformOfFintype (T → Fin (2 ^ b')).