Documentation

CslibFrontier.Crypto.Computational.DiscreteLog.Extract

Discrete-logarithm extraction from two linear relations #

Several discrete-logarithm reductions end the same way: two answers give two linear relations z = w + c * x and z' = w + c' * x modulo the prime group order q with c ≠ c', and the reduction outputs the witness x = (c - c')⁻¹ (z - z'). Schnorr's extractor ([BS23], Example 19.2) reads c, c' as the two challenges and z, z' as the two responses. Two Pedersen openings (m₀, r₀) ≠ (m₁, r₁) of one commitment under h = α • g satisfy m₀ + r₀ * α = m₁ + r₁ * α, so α = extractNat q r₁ m₀ r₀ m₁ ([Ped92], Section 3, Theorem 3.1; [BS23], Section 10.6.1, Fact 10.3); the discrete-logarithm hash of [KL20], Theorem 9.79, reuses that extraction.

extractNat computes the witness on natural numbers, inverting by Fermat's little theorem as a (q - 2)nd power, so a polynomial-time machine can output it.

Main definitions #

Main results #

References #

The witness (c - c')⁻¹ (z - z') modulo q, computed on natural numbers with the inverse as a (q - 2)nd power.

theorem Cslib.Crypto.PrimeOrderGroupFamily.extractNat_cast {q : ℕ} [Fact (Nat.Prime q)] {c z c' z' : ℕ} (hc : ↑c ≠ ↑c') :
↑(extractNat q c z c' z') = (↑c - ↑c')⁻¹ * (↑z - ↑z')

Fermat's little theorem gives the inverse in extractNat: modulo a prime q, it is (c - c')⁻¹ (z - z') whenever c and c' are distinct modulo q.

theorem Cslib.Crypto.PrimeOrderGroupFamily.extractNat_zmod_val {q : ℕ} [Fact (Nat.Prime q)] {c z c' z' : ZMod q} (hc : c ≠ c') :
↑(extractNat q c.val z.val c'.val z'.val) = (c - c')⁻¹ * (z - z')

Modulo a prime q, extractNat on canonical ZMod q representatives computes (c - c')⁻¹ * (z - z') whenever c ≠ c'.