Carter–Wegman-style universal hash family. #
h_{a,b}(x) = a * x + b (mod p),
Main result: linearHashFamily.universal2
Linear family over ZMod p:
h_{a,b}(x) = a * x + b (mod p),
This is a special case of
family H_1 in Wegman, Carter 1979).
where:
pis prime,a ≠ 0inZMod p,(a, b)is chosen uniformly from (ZMod p)² with a ≠ 0.
Equations
- linearHashFamily p i x = (↑i).1 * x + (↑i).2
Instances For
def
generalLinearHashFamily
(p : ℕ)
[Fact (Nat.Prime p)]
(a : ℕ)
:
HashFamily (LinearIndex p) (Fin a) (ZMod p)
Hash family H_1 in Wegman, Carter 1979).
``h_{a,b}(x) = a * x + b (mod p),``
where:
pis prime,a ≠ 0inZMod p,(a, b)is chosen uniformly from (ZMod p)² with a ≠ 0.- x < a
Note that x is automatically cast to ℕ and then to ZMod p, which involves a modulo operation.
The family is universal-2 for a < p.
Equations
- generalLinearHashFamily p a i x = (↑i).1 * ↑↑x + (↑i).2
Instances For
Universality of the generalLinearHashFamily, where inputs can be restricted.