This module defines notions of universality for families of hash functions.
A hash family is a family of functions Input → Output.
Rather than define it as a set of functions, we put the choice of function into a type Seed.
Universal-2 #
A function hash : Seed → Input → Output is Universal-2 if for any distinct inputs x and y,
the probability over a uniform random seed that hash s x = hash s y is at most 1 / |Output|.
This is formalized as (number of seeds causing collision) * |Output| ≤ |Seed|.
We also give an alternative definition, proven equivalent, which the AIs seem to like more. Let's see which we keep in the end...
Strongly-universal-n #
A family H is strongly universal (also known as "pairwise independent") if
for all x ≠ y and all a b : Output,
\Pr_i [h_i(x) = a ∧ h_i(y) = b] = 1 / |Output|^2
A hash family is a family of functions Input → Output.
Rather than define it as a set of functions, we put the choice of function into a type Seed.
Equations
- HashFamily Seed Input Output = (Seed → Input → Output)
Instances For
A hash function taking a seed and an input is universal-2 if for any distinct inputs x and y, the probability (over the seed) of a collision is at most 1/|Output|.
This is expressed as: (number of seeds causing collision) * |Output| ≤ |Seed|.
Equations
- hash.universal2 = ∀ ⦃x y : Input⦄, x ≠ y → Fintype.card ↑{s : Seed | hash s x = hash s y} * Fintype.card Output ≤ Fintype.card Seed
Instances For
The uniform probability of a predicate on Seed, modeled by counting.
Equations
- probUniform p = ↑(Fintype.card { i : Seed // p i }) / ↑(Fintype.card Seed)
Instances For
Alternative (equivalent) statement of universal-2 using probUniform.
A family H is universal2 if for all distinct x ≠ y, the collision probability is at most 1 / |Output|:
Pr_i [h_i(x) = h_i(y)] ≤ 1 / |Output|
A hash family is strongly-universal-n (also called "n-wise independent") if
- given
ndistinct inputsa₁, a₂, ... - and n (not necessarily distinct) outputs
b₁, b₂, ..., exactly|HashFamily|/(|Output|^n)functions takea₁tob₁a₂tob₂, etc.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Special case: a family H is strongly-universal-2
(also known as just "strongly universal", or "pairwise independent") if
for all x ≠ y and all a b : Output,
\Pr_i [h_i(x) = a ∧ h_i(y) = b] = 1 / |Output|^2.
Equations
- H.stronglyUniversal2 = ∀ ⦃x y : Input⦄, x ≠ y → ∀ (a b : Output), ↑(Fintype.card { i : Seed // H i x = a ∧ H i y = b }) = ↑(Fintype.card Seed) / ↑(Fintype.card Output) ^ 2
Instances For
Equivalent statement of strongly-universal-2 using probUniform.
A family H is stronglyUniversal2 if for all distinct x ≠ y, given two outputs a and b,
the probability to map x ↦ a and y ↦ b is exactly 1 / (|Output|^2).
stronglyUniversal2 is a special case of strongly_universal_n for n = 2.
stronglyUniversal2 implies universal2.
If n is greater than the cardinality of the input space, then any hash family is strongly universal-n (vacuously).
The composition of a universal2 function with an injective function is universal2.