Documentation

CslibFrontier.Crypto.Computational.DiffieHellman.Equivalents

Deterministic oracle reductions among Diffie–Hellman problems in a fixed group #

[BS23], Exercise 10.17 (p. 429), asks for deterministic polynomial-time equivalences among four computational Diffie–Hellman problems in a cyclic group of prime order. This module formalizes explicit deterministic OracleComp programs in a fixed ZMod q-module G, proofs of correctness under OracleComp.evalPure against every solver that is correct on its domain, and solver call counts under OracleComp.IsQueryBounded (and OracleComp.QueriesSatisfy where a solver's domain excludes 0); group operations, scalar multiplications, and running time are not counted. The correctness theorems are therefore steps toward Exercise 10.17, not the cited result: the exercise's reductions are deterministic algorithms whose running time, apart from the solver calls, is polynomial in the input length, and no such bound is proved here (#5293).

For a modulus q : ℕ and element g : G, written additively (α • g for g ^ α):

Main definitions #

Main results #

References #

def Cslib.Crypto.SolvesCDH {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) (cdh : G × G → G) :

A deterministic solver solves (a) CDH with respect to g when on (α • g, β • g) it returns (α * β) • g.

def Cslib.Crypto.SolvesSqDH {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) (sq : G → G) :

A deterministic solver solves (b) Square-DH with respect to g when on α • g it returns (α ^ 2) • g.

def Cslib.Crypto.SolvesInvDH {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) (inv : G → G) :

A deterministic solver solves (c) Inverse-DH with respect to g when on α • g with α ≠ 0 it returns α⁻¹ • g.

def Cslib.Crypto.SolvesDivDH {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) (div : G × G → G) :

A deterministic solver solves (d) Divisible-DH with respect to g when on (α • g, β • g) with β ≠ 0 it returns (α * β⁻¹) • g.

def Cslib.Crypto.cdhFromSqProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] [DecidableEq G] (u v : G) :
OracleComp (fun (x : G) => G) G

Deterministic oracle reduction (a) CDH ≤ (b) Square-DH: for q = 2, returns 0 if u = 0 and v otherwise (since α, β ∈ {0, 1} gives α * β = β if α = 1, 0 if α = 0); for odd prime q, evaluates (4 : ZMod q)⁻¹ • (sq (u + v) - sq (u - v)) in 2 queries.

cdhFromSqProg makes at most 2 oracle calls on every execution path.

theorem Cslib.Crypto.solvesCDH_evalPure_cdhFromSqProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) [DecidableEq G] [Fact (Nat.Prime q)] {sq : G → G} (hsq : SolvesSqDH q g sq) :
SolvesCDH q g fun (p : G × G) => OracleComp.evalPure sq (cdhFromSqProg q p.1 p.2)

Correctness of (a) CDH ≤ (b) Square-DH, a step toward [BS23], Exercise 10.17 (p. 429), not the cited result, which also bounds the reduction's running time (only solver calls are counted, #5293): for prime q, any Square-DH solver sq turns cdhFromSqProg into a CDH solver.

def Cslib.Crypto.sqFromCDHProg {G : Type} (u : G) :
OracleComp (fun (x : G × G) => G) G

Deterministic oracle reduction (b) Square-DH ≤ (a) CDH: queries cdh (u, u) in 1 call.

sqFromCDHProg makes at most 1 oracle call.

theorem Cslib.Crypto.solvesSqDH_evalPure_sqFromCDHProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) {cdh : G × G → G} (hcdh : SolvesCDH q g cdh) :
SolvesSqDH q g fun (u : G) => OracleComp.evalPure cdh (sqFromCDHProg u)

Correctness of (b) Square-DH ≤ (a) CDH, a step toward [BS23], Exercise 10.17 (p. 429), not the cited result, which also bounds the reduction's running time (only solver calls are counted, #5293): any CDH solver turns sqFromCDHProg into a Square-DH solver.

def Cslib.Crypto.sqFromInvProg {G : Type} [AddCommGroup G] (g : G) [DecidableEq G] (u : G) :
OracleComp (fun (x : G) => G) G

Deterministic oracle reduction (b) Square-DH ≤ (c) Inverse-DH: checks u ∈ {0, g, -g}, otherwise queries inv (u - g), inv (u + g), and inv (inv (u - g) - inv (u + g)) to compute 2 • ((α - 1)⁻¹ - (α + 1)⁻¹)⁻¹ • g + g = α^2 • g. Guards r₁ = r₂ so every query is nonzero on every execution path against arbitrary oracle responses.

sqFromInvProg makes at most 3 oracle calls on every execution path.

theorem Cslib.Crypto.queriesSatisfy_sqFromInvProg {G : Type} [AddCommGroup G] (g : G) [DecidableEq G] (u : G) :
OracleComp.QueriesSatisfy (fun (qx : G) => qx ≠ 0) (sqFromInvProg g u)

Every query emitted by sqFromInvProg is nonzero, on every execution path against any oracle responses.

theorem Cslib.Crypto.solvesSqDH_evalPure_sqFromInvProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) [DecidableEq G] [Fact (Nat.Prime q)] {inv : G → G} (hinv : SolvesInvDH q g inv) :
SolvesSqDH q g fun (u : G) => OracleComp.evalPure inv (sqFromInvProg g u)

Correctness of (b) Square-DH ≤ (c) Inverse-DH, a step toward [BS23], Exercise 10.17 (p. 429), not the cited result, which also bounds the reduction's running time (only solver calls are counted, #5293): for prime q, any Inverse-DH solver turns sqFromInvProg into a Square-DH solver.

def Cslib.Crypto.invFromDivProg {G : Type} [AddCommGroup G] (g : G) [DecidableEq G] (u : G) :
OracleComp (fun (x : G × G) => G) G

Deterministic oracle reduction (c) Inverse-DH ≤ (d) Divisible-DH: queries div (g, u) when u ≠ 0 and returns 0 otherwise.

invFromDivProg makes at most 1 oracle call on every execution path.

theorem Cslib.Crypto.queriesSatisfy_invFromDivProg {G : Type} [AddCommGroup G] (g : G) [DecidableEq G] (u : G) :
OracleComp.QueriesSatisfy (fun (qp : G × G) => qp.2 ≠ 0) (invFromDivProg g u)

Every query emitted by invFromDivProg has nonzero second coordinate.

theorem Cslib.Crypto.solvesInvDH_evalPure_invFromDivProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) [DecidableEq G] [Fact (Nat.Prime q)] {div : G × G → G} (hdiv : SolvesDivDH q g div) :
SolvesInvDH q g fun (u : G) => OracleComp.evalPure div (invFromDivProg g u)

Correctness of (c) Inverse-DH ≤ (d) Divisible-DH, a step toward [BS23], Exercise 10.17 (p. 429), not the cited result, which also bounds the reduction's running time (only solver calls are counted, #5293): for prime q, any Divisible-DH solver turns invFromDivProg into an Inverse-DH solver.

def Cslib.Crypto.invFromCDHStep {G : Type} (u acc : G) (bit : Bool) :
OracleComp (fun (x : G × G) => G) G

One step of square-and-multiply in the exponent using a CDH oracle: squares acc, and if bit = true multiplies by u.

def Cslib.Crypto.invFromCDHProg {G : Type} (q : ℕ) (g u : G) :
OracleComp (fun (x : G × G) => G) G

Deterministic oracle reduction (c) Inverse-DH ≤ (a) CDH: computes α ^ (q - 2) • g by square-and-multiply along (q - 2).bits.reverse using at most 2 * (q - 2).bits.length CDH queries.

invFromCDHProg makes at most 2 * (q - 2).bits.length oracle calls.

theorem Cslib.Crypto.solvesInvDH_evalPure_invFromCDHProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) [Fact (Nat.Prime q)] {cdh : G × G → G} (hcdh : SolvesCDH q g cdh) :
SolvesInvDH q g fun (u : G) => OracleComp.evalPure cdh (invFromCDHProg q g u)

Correctness of (c) Inverse-DH ≤ (a) CDH, a step toward [BS23], Exercise 10.17 (p. 429), not the cited result, which also bounds the reduction's running time (only solver calls are counted, #5293): for prime q, any CDH solver turns invFromCDHProg into an Inverse-DH solver.

def Cslib.Crypto.divFromCDHProg {G : Type} (q : ℕ) (g u v : G) :
OracleComp (fun (x : G × G) => G) G

Deterministic oracle reduction (d) Divisible-DH ≤ (a) CDH: inverts v with invFromCDHProg and calls cdh (u, v⁻¹) in at most 2 * (q - 2).bits.length + 1 queries.

theorem Cslib.Crypto.isQueryBounded_divFromCDHProg {G : Type} (q : ℕ) (g u v : G) :
(divFromCDHProg q g u v).IsQueryBounded (2 * (q - 2).bits.length + 1)

divFromCDHProg makes at most 2 * (q - 2).bits.length + 1 oracle calls.

theorem Cslib.Crypto.solvesDivDH_evalPure_divFromCDHProg {G : Type} [AddCommGroup G] (q : ℕ) [Module (ZMod q) G] (g : G) [Fact (Nat.Prime q)] {cdh : G × G → G} (hcdh : SolvesCDH q g cdh) :
SolvesDivDH q g fun (p : G × G) => OracleComp.evalPure cdh (divFromCDHProg q g p.1 p.2)

Correctness of (d) Divisible-DH ≤ (a) CDH, a step toward [BS23], Exercise 10.17 (p. 429), not the cited result, which also bounds the reduction's running time (only solver calls are counted, #5293): for prime q, any CDH solver turns divFromCDHProg into a Divisible-DH solver.