The parity test for Decisional Diffie–Hellman in groups of even order #
In a group of even order q the parity of a discrete logarithm is visible: raising an element to
the power q / 2 gives the identity exactly when its discrete logarithm is even. A Diffie–Hellman
triple (g^α, g^β, g^(αβ)) therefore satisfies a parity relation that a random triple satisfies
only half of the time. This module proves Lemmas 16.1 and 16.2 of [BS23], Section
16.1.3, and the section's sentence that the resulting three-step parity test has advantage 1 / 2
in breaking DDH, on the fixed-group experiments of
CslibFrontier/Crypto/Computational/DiffieHellman/Finite.lean.
The fixed-group advantage ddhAdvantage places no bound on the distinguisher: in this model a
brute-force discrete-logarithm distinguisher already has advantage at least 1 - 1 / q. What
makes the book's attack meaningful is that the test is efficient. That is stated over cyclic group
families in CslibFrontier/Crypto/Computational/DiffieHellman/CyclicGroupFamily.lean: the
certificate CyclicGroupFamily.isPPT_ddhParityDistinguisher gives one uniform strict PPT machine
that computes the test on encoded inputs, and CyclicGroupFamily.not_ddh_of_even_order concludes
that DDH does not hold in a family of even order, which is Exercise 10.24 (p. 431). The book's
conclusion that DDH does not hold in Z_p^* (p. 687, and the remark after Exercise 10.24) needs a
family of the groups (ZMod p)ˣ, which is not constructed; here it is proved in the fixed-group
form ddhAdvantage_units_ddhParityDistinguisher.
The setting is that of Finite.lean: an additive commutative group G that is a ZMod q-module
and an element g : G, with the textbook g^α written α • g. The book's cyclic group of order
n generated by g enters as injectivity of c ↦ c • g on ZMod q, that is, g has order q;
G itself need not be generated by g, and the random world samples w uniformly from the
multiples of g (the book's "w uniform in G" when g generates G). The results also assume
Even q. The book's u^(n/2) = 1 is (q / 2) • u = 0, and its parity of α ∈ Z_n is the parity
of the natural representative α.val.
Main definitions #
Cslib.Crypto.ddhParityDistinguisher: the distinguisher of Section 16.1.3, which accepts(u, v, w)whenwhas an even discrete logarithm exactly whenuorvhas one.Cslib.Crypto.zmodUnitsModule: the multiplicative group(ZMod p)ˣ, written additively, as aZMod (p - 1)-module. It is a definition, not a global instance.
Main results #
Cslib.Crypto.div_two_nsmul_smul_eq_zero_iff: Lemma 16.1,(q / 2) • (a • g) = 0exactly whena.valis even.Cslib.Crypto.even_val_mul_iff: Lemma 16.2,(a * b).valis even exactly when(q / 2) • (a • g) = 0or(q / 2) • (b • g) = 0.Cslib.Crypto.probability_ddhRealExperiment_ddhParityDistinguisher,Cslib.Crypto.probability_ddhRandomExperiment_ddhParityDistinguisher: the distinguisher accepts with probability1in the real world and1 / 2in the random world. The exact output laws areeval_ddhRealExperiment_ddhParityDistinguisherandeval_ddhRandomExperiment_ddhParityDistinguisher.Cslib.Crypto.ddhAdvantage_ddhParityDistinguisher: the test has fixed-group DDH advantage exactly1 / 2.Cslib.Crypto.injective_smul_ofMul_units: a generator of(ZMod p)ˣhas orderp - 1.Cslib.Crypto.ddhAdvantage_units_ddhParityDistinguisher: in(ZMod p)ˣ,pan odd prime, with any generator, the test has fixed-group DDH advantage exactly1 / 2.
The efficiency certificate and Exercise 10.24 are in
CslibFrontier/Crypto/Computational/DiffieHellman/CyclicGroupFamily.lean, and the generalization
to an arbitrary prime factor l ∣ q (Exercise 16.2(a), p. 707) is in
CslibFrontier/Crypto/Computational/DiffieHellman/SmallFactor.lean (from which the fixed-group
results below specialize at l = 2). Not proved: the asymptotic statement that DDH does not hold
in Z_p^* (which needs a family of the groups (ZMod p)ˣ) and Exercise 16.2(b).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 16.1.3, Lemmas 16.1 and 16.2 and the advantage of the parity test (p. 687).
Parity of discrete logarithms #
Lemma 16.1 ([BS23], Section 16.1.3, p. 687): for g of even order q, the
element a • g (the textbook u = g^α) satisfies (q / 2) • (a • g) = 0 (the textbook
u^(n/2) = 1) exactly when a.val is even. The book's cyclic group of order n generated by g
is here injectivity of c ↦ c • g on ZMod q; G need not be generated by g.
Lemma 16.2 ([BS23], Section 16.1.3, p. 687): for g of even order q, the
exponent a * b of the Diffie–Hellman element is even exactly when (q / 2) • (a • g) = 0 or
(q / 2) • (b • g) = 0. So the parity of the Diffie–Hellman exponent is computable from a • g
and b • g.
The distinguisher #
The distinguisher of [BS23], Section 16.1.3 (p. 687), for a group of even order
q: on (u, v, w) it computes the parity of the discrete logarithm of w by Lemma 16.1 and that
of the Diffie–Hellman exponent by Lemma 16.2, and accepts when they agree, that is, when
(q / 2) • w = 0 exactly when (q / 2) • u = 0 or (q / 2) • v = 0. It is deterministic.
In the real DDH world, ddhParityDistinguisher always accepts: by Lemmas 16.1 and 16.2,
both parities it compares are the parity of a * b.
In the random DDH world, ddhParityDistinguisher outputs a fair coin: for every a and b,
the parity of the independent uniform c agrees with that of a * b with probability 1 / 2.
The distinguisher of Section 16.1.3 accepts every real DDH triple: its acceptance
probability in ddhRealExperiment is 1.
The distinguisher of Section 16.1.3 accepts a random triple with probability 1 / 2.
The parity test has advantage 1 / 2 ([BS23], Section 16.1.3, p. 687): when
q is even and g has order q, the three-step parity test of Section 16.1.3 has fixed-group
DDH advantage exactly 1 / 2, the book's "this algorithm has advantage 1/2 in breaking DDH in the
group G". The fixed-group advantage does not bound the distinguisher's running time. Exercise
10.24 (p. 431), which asks for an efficient adversary, is
CyclicGroupFamily.not_ddh_of_even_order over cyclic group families, with the efficiency
certificate CyclicGroupFamily.isPPT_ddhParityDistinguisher.
The group (ZMod p)ˣ #
The unit group (ZMod p)ˣ of a prime p, written additively, as a ZMod (p - 1)-module:
every unit satisfies x ^ (p - 1) = 1 (Fermat's little theorem). This is a definition, not a
global instance; clients enable it with attribute [local instance] zmodUnitsModule (together
with neZero_sub_one_of_prime) or with letI.
A generator g of (ZMod p)ˣ has order p - 1: c ↦ c • g is injective on ZMod (p - 1)
in the module structure zmodUnitsModule p.
The parity test in (ZMod p)ˣ ([BS23], Section 16.1.3, p. 687): for an odd
prime p and any generator g of (ZMod p)ˣ, a cyclic group of even order p - 1, the parity
test of Section 16.1.3 has fixed-group DDH advantage exactly 1 / 2. The group is written
additively, with the module structure zmodUnitsModule p. Generators exist: (ZMod p)ˣ is cyclic
(IsCyclic.exists_generator). This fixed-group statement does not bound running time, so it
does not prove the book's conclusion that DDH does not hold in Z_p^* (p. 687, and the remark
after Exercise 10.24, p. 431), which concerns efficient adversaries. That would follow from
CyclicGroupFamily.not_ddh_of_even_order for a family of these groups, which is not constructed
here.