The small-prime-factor test for Decisional Diffie–Hellman #
In a cyclic group of order q whose order has a prime divisor l, whether a discrete logarithm is
divisible by l is visible from raising to the power q / l: (q / l) • (a • g) = 0 exactly when
l ∣ a.val (div_nsmul_smul_eq_zero_iff). Because l is prime, l divides (a * b).val in
ZMod q exactly when l divides a.val or b.val (dvd_val_mul_iff), so a Diffie–Hellman triple
(a • g, b • g, (a * b) • g) satisfies (q / l) • w = 0 ↔ (q / l) • u = 0 ∨ (q / l) • v = 0
with probability 1, whereas an independent uniform w = c • g matches with probability
1 - (3 * l - 2) * (l - 1) / l ^ 3. This generalizes the parity test (l = 2) of
[BS23], Section 16.1.3, to arbitrary prime factors l ∣ q (Exercise 16.2(a), p. 707).
The book writes that the test has advantage "about 1 / l": here the exact advantage is
((3 * l - 2) * (l - 1)) / l ^ 3 (ddhAdvantage_ddhSmallFactorDistinguisher), which equals
1 / 2 at l = 2, is at least 1 / l for every prime l
(inv_le_ddhAdvantage_ddhSmallFactorDistinguisher), and approaches 3 / l for large l.
The setting is that of CslibFrontier/Crypto/Computational/DiffieHellman/Finite.lean: an additive
commutative group G that is a ZMod q-module ([NeZero q]) with c ↦ c • g injective on
ZMod q. The fixed-group advantage places no bound on running time; polynomial-time efficiency over
CyclicGroupFamily and the asymptotic failure of DDH when the order has a polynomially bounded
prime factor are in CslibFrontier/Crypto/Computational/DiffieHellman/CyclicGroupFamily.lean. Not
covered: the O(log q) operation count as a count of group operations, Exercise 16.2(b), a family
of the groups (ZMod p)ˣ, and #5673's cleanup in
CslibFrontier/Crypto/Computational/DiffieHellman/CyclicGroupFamily.lean.
Main definitions #
Cslib.Crypto.ddhSmallFactorDistinguisher: the distinguisher of Exercise 16.2(a), which accepts(u, v, w)iff(q / l) • w = 0iff(q / l) • u = 0 ∨ (q / l) • v = 0.
Main results #
Cslib.Crypto.div_nsmul_smul_eq_zero_iff:(q / l) • (a • g) = 0 ↔ l ∣ a.valwheneverl ∣ qandc ↦ c • gis injective.Cslib.Crypto.dvd_val_mul_iff: for primel ∣ q,l ∣ (a * b).val ↔ (q / l) • (a • g) = 0 ∨ (q / l) • (b • g) = 0.Cslib.Crypto.eval_ddhRealExperiment_ddhSmallFactorDistinguisher: in the real DDH world,ddhSmallFactorDistinguisher q lreturnsPMF.pure true.Cslib.Crypto.probability_ddhRandomExperiment_ddhSmallFactorDistinguisher: in the random DDH world,ddhSmallFactorDistinguisher q laccepts with probability1 - (3 * l - 2) * (l - 1) / l ^ 3.Cslib.Crypto.ddhAdvantage_ddhSmallFactorDistinguisher: the exact fixed-group advantage is((3 * l - 2) * (l - 1)) / l ^ 3inℝ≥0.Cslib.Crypto.inv_le_ddhAdvantage_ddhSmallFactorDistinguisher: the fixed-group advantage is at least1 / l.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Exercise 16.2(a) (p. 707) and Section 16.1.3 (p. 687).
In a cyclic group of order q generated by g, if l ∣ q, raising a • g to q / l gives
0 iff l divides a.val
(generalization of [BS23], Lemma 16.1, p. 687; Exercise 16.2(a), p. 707).
For prime l ∣ q, l divides (a * b).val in ZMod q iff (q / l) • (a • g) = 0 or
(q / l) • (b • g) = 0
(generalization of [BS23], Lemma 16.2, p. 687; Exercise 16.2(a), p. 707).
The l-th-power DDH distinguisher of [BS23], Exercise 16.2(a) (p. 707):
accept (u, v, w) iff (q / l) • w = 0 iff (q / l) • u = 0 ∨ (q / l) • v = 0.
In the real DDH experiment, ddhSmallFactorDistinguisher q l returns PMF.pure true
when l is prime and divides q.
Acceptance probability of ddhSmallFactorDistinguisher q l in the random DDH experiment is
1 - (3 * l - 2) * (l - 1) / l ^ 3 ([BS23], Exercise 16.2(a), p. 707).
The exact fixed-group DDH advantage of ddhSmallFactorDistinguisher q l for prime l ∣ q
is (3 * l - 2) * (l - 1) / l ^ 3 ([BS23], Exercise 16.2(a), p. 707). Since l ≥ 1,
both subtractions in ℝ≥0 are exact (non-truncated). At l = 2 this equals 1 / 2, and for
every prime l it is at least 1 / l and close to 3 / l for large l (reading the book's
"advantage about 1 / l").
ddhSmallFactorDistinguisher q l achieves fixed-group advantage at least 1 / l
for every prime l ∣ q ([BS23], Exercise 16.2(a), p. 707).