Documentation

CslibFrontier.Crypto.Computational.DiscreteLog.GroupHash

Discrete-logarithm collision-resistant hash families #

Over a PrimeOrderGroupFamily, this module formalizes the encoded collision-resistance endpoint of Katz and Lindell's discrete-logarithm hash ([KL20], Section 9.4.2, Construction 9.78 and Theorem 9.79, pp. 357–359; [BS23], Section 8.5.1). The family samples a group description d ← setup n and a uniform group element h = α • g (groupHashSetup), and hashes a 2 * blockLen d-bit input x by splitting x into two blockLen d-bit halves (x₁, x₂) (read as natural numbers in little-endian binary via ofBits) and evaluating encode (x₁ • g + x₂ • h) (groupHash).

When 2 ^ blockLen d ≤ F.order d, the two blockLen d-bit halves represent elements strictly below the prime order q = F.order d. Any collision x ≠ y of length 2 * blockLen d with groupHash blockLen (d, encode d (α • g)) x = groupHash blockLen (d, encode d (α • g)) y satisfies x₁ + x₂ * α = y₁ + y₂ * α in ZMod q with (y₂ : ZMod q) ≠ x₂, so extractNat recovers the discrete logarithm α = (y₂ - x₂)⁻¹ * (x₁ - y₁) in deterministic polynomial time. This yields an exact zero-loss reduction (succProbability_collisionGameFor_groupHash_le_discreteLogGame) showing that F.DiscreteLog setup implies CollisionResistantForOn for groupHash (DiscreteLog.collisionResistantForOn_groupHash).

This is the collision-resistance reduction of Theorem 9.79 for the encoded outputs. It does not establish the packaging conditions discussed with Construction 9.78 ([KL20], pp. 357–358), which remain separate obligations for a client that needs a fixed-length compression function:

We also formalize the algebraic core of the multi-generator generalization ([KL20], Exercise 9.28, Construction 9.81, p. 363), multiGeneratorHash d hs xs = ∑ i, xs i • hs i, with its linear homomorphisms and coordinate-wise discrete-logarithm extraction identity (multiGeneratorHash_extract_of_eq).

Main definitions #

Main results #

References #

Discrete-logarithm hash family (Construction 9.78 & Theorem 9.79) #

Setup distribution for the discrete-logarithm hash family ([KL20], Construction 9.78, p. 358): draw d ← setup n and a uniform exponent α ← PMF.uniformOfFintype (ZMod (F.order d)), and output the public parameter (d, F.encode d (α • F.generator d)).

Domain validity predicate for groupHash: at group parameter pk = (d, h), valid inputs are bit strings of length 2 * blockLen d.

@[simp]
theorem Cslib.Crypto.PrimeOrderGroupFamily.validGroupHashInput_eq_true_iff (F : PrimeOrderGroupFamily) (blockLen : F.Desc → ℕ) (n : ℕ) (pk : F.Desc × List Bool) (x : List Bool) :
F.validGroupHashInput blockLen n pk x = true ↔ x.length = 2 * blockLen pk.1

Discrete-logarithm hash function ([KL20], Construction 9.78, p. 358), with the source's fixed input length 2 * blockLen d and an encoded group element as output: given public parameter pk = (d, h) and input x : List Bool, split x at w = blockLen d into (x.take w, x.drop w) and evaluate F.encodePedersenCommit (d, h, ofBits (x.take w), ofBits (x.drop w)).

@[simp]
theorem Cslib.Crypto.PrimeOrderGroupFamily.groupHash_encode (F : PrimeOrderGroupFamily) (blockLen : F.Desc → ℕ) (d : F.Desc) (h : F.Carrier d) (x : List Bool) :
F.groupHash blockLen (d, F.encode d h) x = F.encode d (F.pedersenCommit d h ↑(Turing.MultiTapeTM.ofBits (List.take (blockLen d) x)) ↑(Turing.MultiTapeTM.ofBits (List.drop (blockLen d) x)))

On an encoded group element F.encode d h, groupHash computes the encoding of F.pedersenCommit d h (ofBits (x.take (blockLen d))) (ofBits (x.drop (blockLen d))).

theorem Cslib.Crypto.PrimeOrderGroupFamily.groupHash_append_of_length_eq (F : PrimeOrderGroupFamily) (blockLen : F.Desc → ℕ) (d : F.Desc) (h : F.Carrier d) {x₁ x₂ : List Bool} (hx₁ : x₁.length = blockLen d) :
F.groupHash blockLen (d, F.encode d h) (x₁ ++ x₂) = F.encode d (F.pedersenCommit d h ↑(Turing.MultiTapeTM.ofBits x₁) ↑(Turing.MultiTapeTM.ofBits x₂))

When x₁ has length blockLen d, hashing the concatenation x₁ ++ x₂ under (d, F.encode d h) evaluates F.encode d (F.pedersenCommit d h (ofBits x₁) (ofBits x₂)).

theorem Cslib.Crypto.PrimeOrderGroupFamily.extractNat_eq_of_isCollisionFor_groupHash (F : PrimeOrderGroupFamily) (blockLen : F.Desc → ℕ) (n : ℕ) (d : F.Desc) (α : ZMod (F.order d)) {x y : List Bool} (hsize : 2 ^ blockLen d ≤ F.order d) (hcoll : isCollisionFor (F.groupHash blockLen) (F.validGroupHashInput blockLen) n (d, F.encode d (α • F.generator d)) x y = true) :

Collision extraction for groupHash (step 2 of the proof of [KL20], Theorem 9.79, pp. 358–359): if 2 ^ blockLen d ≤ F.order d, any valid collision (x, y) for groupHash blockLen under (d, F.encode d (α • F.generator d)) recovers α with extractNat.

Turn a groupHash collision finder into a discrete-logarithm adversary by splitting the two candidate colliding words at blockLen d and extracting α with extractNat in binary ([KL20], Theorem 9.79, pp. 358–359).

theorem Cslib.Crypto.PrimeOrderGroupFamily.succProbability_collisionGameFor_groupHash_le_discreteLogGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (blockLen : F.Desc → ℕ) (adversary : CollisionFinderFor (F.Desc × List Bool)) (n : ℕ) (hsize : ∀ d ∈ (setup n).support, 2 ^ blockLen d ≤ F.order d) :
(collisionGameFor (F.groupHashSetup setup) (F.groupHash blockLen) (F.validGroupHashInput blockLen) adversary n).succProbability ≤ (F.discreteLogGame setup (F.groupHashToDLAdversary blockLen adversary) n).succProbability

Exact collision-to-discrete-logarithm reduction ([KL20], Theorem 9.79, pp. 358–359): whenever every group d in the support of setup n satisfies 2 ^ blockLen d ≤ F.order d, the collision-finding success probability of adversary in collisionGameFor (F.groupHashSetup setup) (F.groupHash blockLen) (F.validGroupHashInput blockLen) is at most the discrete-logarithm success probability of F.groupHashToDLAdversary blockLen adversary.

Collision resistance of the discrete-logarithm hash family under the discrete-logarithm assumption ([KL20], Section 9.4.2, Theorem 9.79, pp. 358–359): if F.DiscreteLog setup holds, blockLen is computable in polynomial time in unary, and 2 ^ blockLen d ≤ F.order d for every supported group d ∈ (setup n).support at all sufficiently large n, then F.groupHash blockLen is collision-resistant on F.validGroupHashInput blockLen under F.groupHashSetup setup. This is the encoded collision-resistance endpoint: a fixed digest width, compression and an efficient setup are not established (see the module docstring).

Algebraic core of the multi-generator hash (Construction 9.81, Exercise 9.28) #

def Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] (d : F.Desc) (hs : ι → F.Carrier d) (xs : ι → ZMod (F.order d)) :

Algebraic multi-generator discrete-logarithm vector hash ([KL20], Exercise 9.28, Construction 9.81, p. 363; algebraic core only: hs is arbitrary, whereas KL's Gen fixes h₁ = g and samples the other hᵢ uniformly, and no key generation or game is defined here): given generators hs : ι → F.Carrier d and a scalar vector xs : ι → ZMod (F.order d), compute ∑ i, xs i • hs i.

theorem Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash_add (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] (d : F.Desc) (hs : ι → F.Carrier d) (xs ys : ι → ZMod (F.order d)) :
F.multiGeneratorHash d hs (xs + ys) = F.multiGeneratorHash d hs xs + F.multiGeneratorHash d hs ys

Additive homomorphism of multiGeneratorHash.

theorem Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash_sub (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] (d : F.Desc) (hs : ι → F.Carrier d) (xs ys : ι → ZMod (F.order d)) :
F.multiGeneratorHash d hs (xs - ys) = F.multiGeneratorHash d hs xs - F.multiGeneratorHash d hs ys

Subtractive homomorphism of multiGeneratorHash.

theorem Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash_smul (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] (d : F.Desc) (hs : ι → F.Carrier d) (c : ZMod (F.order d)) (xs : ι → ZMod (F.order d)) :
F.multiGeneratorHash d hs (c • xs) = c • F.multiGeneratorHash d hs xs

Scalar-multiplication homomorphism of multiGeneratorHash.

theorem Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash_smul_generator (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] (d : F.Desc) (αs xs : ι → ZMod (F.order d)) :
F.multiGeneratorHash d (fun (i : ι) => αs i • F.generator d) xs = (∑ i : ι, xs i * αs i) • F.generator d

When hs i = αs i • F.generator d for each i, multiGeneratorHash evaluates (∑ i, xs i * αs i) • F.generator d.

theorem Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash_smul_generator_eq_iff (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] (d : F.Desc) (αs xs ys : ι → ZMod (F.order d)) :
F.multiGeneratorHash d (fun (i : ι) => αs i • F.generator d) xs = F.multiGeneratorHash d (fun (i : ι) => αs i • F.generator d) ys ↔ ∑ i : ι, xs i * αs i = ∑ i : ι, ys i * αs i

Two input vectors xs, ys collide under hs i = αs i • F.generator d if and only if ∑ i, xs i * αs i = ∑ i, ys i * αs i in ZMod (F.order d).

theorem Cslib.Crypto.PrimeOrderGroupFamily.multiGeneratorHash_extract_of_eq (F : PrimeOrderGroupFamily) {ι : Type u_1} [Fintype ι] [DecidableEq ι] (d : F.Desc) (αs xs ys : ι → ZMod (F.order d)) {j : ι} (hj : ys j ≠ xs j) (hcoll : F.multiGeneratorHash d (fun (i : ι) => αs i • F.generator d) xs = F.multiGeneratorHash d (fun (i : ι) => αs i • F.generator d) ys) :
αs j = (ys j - xs j)⁻¹ * ∑ i ∈ Finset.univ.erase j, (xs i - ys i) * αs i

Coordinate discrete-logarithm extraction from a multiGeneratorHash collision (ingredient of the proof of [KL20], Exercise 9.28(a), p. 363): if xs and ys collide under hs i = αs i • F.generator d and differ at coordinate j (ys j ≠ xs j), then the discrete logarithm αs j is given by (ys j - xs j)⁻¹ * ∑ i ∈ Finset.univ.erase j, (xs i - ys i) * αs i.