Decisional Diffie–Hellman over cyclic group families, and small prime factors of the order #
This module states the Decisional Diffie–Hellman assumption over a CyclicGroupFamily: Attack
Game 10.6 of [BS23] (p. 410) without the restriction that the order is prime, as in
Exercise 10.24 (p. 431). Its declarations have the shapes of the prime-order ones in
CslibFrontier/Crypto/Computational/DiffieHellman.lean, and on a prime-order family the two
assumptions agree (PrimeOrderGroupFamily.ddh_toCyclicGroupFamily_iff).
The small-prime-factor test of [BS23], Exercise 16.2(a) (p. 707)
(Cslib.Crypto.ddhSmallFactorDistinguisher in
CslibFrontier/Crypto/Computational/DiffieHellman/SmallFactor.lean), generalizes the parity test
of Section 16.1.3 (Cslib.Crypto.ddhParityDistinguisher in
CslibFrontier/Crypto/Computational/DiffieHellman/EvenOrder.lean) from l = 2 to any prime
factor l ∣ F.order d. Parameterized by a factor selector
factor : ℕ → F.Desc → ℕ, CyclicGroupFamily.ddhSmallFactorDistinguisher F factor is computed by
one uniform strict PPT machine on encDDHInput whenever factor is polynomial time
(CyclicGroupFamily.isPPT_ddhSmallFactorDistinguisher). Whenever factor n d is a prime divisor
of F.order d at most bound n, its distinguishing advantage is at least (bound n)⁻¹
(CyclicGroupFamily.inv_le_advantage_ddhSmallFactorDistinguisher), so DDH fails whenever a
polynomial-time selector finds a polynomially bounded prime factor infinitely often
(CyclicGroupFamily.not_ddh_of_prime_factor). In particular:
- Exercise 16.2(a) (
CyclicGroupFamily.not_ddh_of_polynomiallyBounded_minFac): DDH fails whenever1 < F.order dand(F.order d).minFacis polynomially bounded across(setup n).supportinfinitely often. The internal distinguisher usesNat.findGreatestto test the greatest prime factor up to the polynomial boundC * (n + 1) ^ Dwhere the exercise names the smallest factor, yielding the same conclusion without extra machinery. - Section 16.1.3 and Exercise 10.24 (
CyclicGroupFamily.ddhParityDistinguisher,l = 2):CyclicGroupFamily.isPPT_ddhParityDistinguisherandCyclicGroupFamily.not_ddh_of_even_orderspecialize the small-factor results tofactor _ _ := 2.
Main definitions #
Cslib.Crypto.CyclicGroupFamily.DDHInput,Cslib.Crypto.CyclicGroupFamily.encDDHInput: the input of a DDH distinguisher and its encoding.Cslib.Crypto.CyclicGroupFamily.DDHDistinguisher,Cslib.Crypto.CyclicGroupFamily.DDHDistinguisher.IsPPT: DDH distinguishers and their efficiency on encodings.Cslib.Crypto.CyclicGroupFamily.ddhRealGame,Cslib.Crypto.CyclicGroupFamily.ddhRandomGame,Cslib.Crypto.CyclicGroupFamily.DDH: the two DDH games and the DDH assumption.Cslib.Crypto.CyclicGroupFamily.ddhSmallFactorDistinguisher: the small-prime-factor test parameterized by a factor selectorfactor : ℕ → F.Desc → ℕ.Cslib.Crypto.CyclicGroupFamily.ddhParityDistinguisher: the parity test (l = 2) as a distinguisher over the family.
Main results #
Cslib.Crypto.PrimeOrderGroupFamily.isPPT_toCyclicGroupFamily_iff,Cslib.Crypto.PrimeOrderGroupFamily.ddh_toCyclicGroupFamily_iff: on a prime-order family, PPT distinguishers and the DDH assumption are those ofPrimeOrderGroupFamily.Cslib.Crypto.CyclicGroupFamily.isPPT_ddhSmallFactorDistinguisher: the small-factor test is PPT whenfactoris polynomial time.Cslib.Crypto.CyclicGroupFamily.inv_le_advantage_ddhSmallFactorDistinguisher: per-parameter advantage lower bound(B : ℝ≥0)⁻¹.Cslib.Crypto.CyclicGroupFamily.not_ddh_of_prime_factor: general DDH failure criterion for any polynomially bounded polynomial-time prime factor selector.Cslib.Crypto.CyclicGroupFamily.not_ddh_of_polynomiallyBounded_minFac: DDH fails when the smallest prime factor ofF.order dis polynomially bounded infinitely often (Exercise 16.2(a)).Cslib.Crypto.CyclicGroupFamily.isPPT_ddhParityDistinguisher: the parity test is PPT.Cslib.Crypto.CyclicGroupFamily.not_ddh_of_even_order: DDH does not hold when every group the setup law can produce has even order.
Implementation notes #
DDHInput, encDDHInput, DDHDistinguisher, DDHDistinguisher.IsPPT, ddhRealGame,
ddhRandomGame and DDH repeat the prime-order declarations over CyclicGroupFamily, with the
same games Cslib.Crypto.ddhRealExperiment and Cslib.Crypto.ddhRandomExperiment.
ddh_toCyclicGroupFamily_iff ties the two assumptions together. Removing this repeated boilerplate
after PrimeOrderGroupFamily settles is tracked separately in #5673.
Not covered: the O(log q) operation count of Exercise 16.2(a) as a count of group operations (only
polynomial time on encDDHInput is proved), Exercise 16.2(b), and a family of the groups
(ZMod p)ˣ. For such a family with odd primes p, not_ddh_of_even_order applies, since the order
p - 1 is even; without it, the book's conclusion that DDH does not hold in Z_p^* (p. 687, and
the remark after Exercise 10.24) is proved here only in the fixed-group form
ddhAdvantage_units_ddhParityDistinguisher.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Attack Game 10.6 (p. 410), Exercise 10.24 (p. 431), Section 16.1.3 (p. 687) and Exercise 16.2(a) (p. 707).
Distinguisher inputs and the DDH assumption #
The input of a DDH distinguisher: the security parameter, public group parameters d and
three elements of F.Carrier d, which are a • g, b • g and the candidate shared element.
- secParam : ℕ
The security parameter, given to machines in unary.
- groupParameters : F.Desc
Public parameters selecting the group, its order and generator within the family.
- leftPublic : F.Carrier self.groupParameters
The first public element,
a • gin the experiment. - rightPublic : F.Carrier self.groupParameters
The second public element,
b • gin the experiment.
The encoding of a DDH input: the unary security parameter, the group parameters and the words
of the three elements, each framed except the last (encDDHInput_apply). It has the layout of
PrimeOrderGroupFamily.encDDHInput.
A DDH distinguisher over the family: given the security parameter, public group parameters
d and three elements of F.Carrier d, it outputs a bit.
A DDH distinguisher is PPT when one uniform strict PPT machine reads encDDHInput and writes
the distinguisher's output bit.
The real DDH game ([BS23], Attack Game 10.6, Experiment 0, with the order not
required to be prime as in Exercise 10.24): choose group parameters d using the arbitrary setup
law, then run Cslib.Crypto.ddhRealExperiment in F.Carrier d.
The random DDH game ([BS23], Attack Game 10.6, Experiment 1, with the order not
required to be prime as in Exercise 10.24): choose group parameters d using the arbitrary setup
law, then run Cslib.Crypto.ddhRandomExperiment in F.Carrier d.
The Decisional Diffie–Hellman assumption for a cyclic group family and a setup law
([BS23], Attack Game 10.6, printed p. 410, with the order not required to be prime, as
in Exercise 10.24, printed p. 431): every PPT DDH distinguisher has negligible advantage between
ddhRealGame and ddhRandomGame. This is a hypothesis, not a theorem; on a prime-order family it
is PrimeOrderGroupFamily.DDH (PrimeOrderGroupFamily.ddh_toCyclicGroupFamily_iff).
Agreement with the prime-order assumption #
A distinguisher over F is PPT for F.toCyclicGroupFamily exactly when it is PPT for F:
the two input encodings agree.
On a prime-order family the DDH assumption over cyclic group families is the prime-order one.
Small prime factors and the parity test in families #
The small-prime-factor DDH distinguisher of [BS23], Exercise 16.2(a) (p. 707),
parameterized by a factor selector factor : ℕ → F.Desc → ℕ: in the group selected by d it runs
Cslib.Crypto.ddhSmallFactorDistinguisher (F.order d) (factor n d). When used inside
not_ddh_of_polynomiallyBounded_minFac, factor selects the greatest prime factor of F.order d
up to the polynomial bound C * (n + 1) ^ D where the exercise names the smallest prime factor;
both yield the same failure theorem.
The small-factor test is efficient: whenever factor is computable in polynomial time on
encPair encUnary F.encDesc → encNat, one uniform strict PPT machine computes
ddhSmallFactorDistinguisher F factor on encDDHInput. It divides F.order d by factor n d
and multiplies each encoded element by the quotient using F.smul.
If every d ∈ (setup n).support has order divisible by a prime factor n d ≤ B, then
ddhSmallFactorDistinguisher F factor achieves distinguishing advantage at least (B : ℝ≥0)⁻¹ at
security parameter n.
General prime-factor DDH failure criterion (underlying [BS23], Exercise 10.24 and
Exercise 16.2(a)): whenever a polynomial-time factor selector factor outputs, for infinitely
many security parameters n, a prime divisor of F.order d at most bound n across
(setup n).support for a polynomially bounded bound, F.DDH setup fails.
DDH fails when a small prime factor is polynomially bounded ([BS23], Exercise
16.2(a), p. 707): if for infinitely many security parameters n, every group d in the support
of setup n has 1 < F.order d and smallest prime factor (F.order d).minFac ≤ bound n for a
polynomially bounded bound, then DDH does not hold.
The distinguisher instantiated in the proof (ddhSmallFactorDistinguisher F fun n d => Nat.findGreatest (fun i => i.Prime ∧ F.order d % i = 0) (C * (n + 1) ^ D)) tests the greatest
prime factor up to C * (n + 1) ^ D where the exercise names the smallest prime factor; the theorem
is the same, since any prime divisor up to bound n gives advantage at least (bound n)⁻¹. The
proof establishes polynomial time on encDDHInput, not the O(log q) operation count.
The parity test of [BS23], Section 16.1.3 (p. 687), as a distinguisher over the
family: in the group selected by d it runs Cslib.Crypto.ddhParityDistinguisher (F.order d).
The parity test is efficient: one uniform strict PPT machine computes
ddhParityDistinguisher on encDDHInput. It computes F.order d / 2, multiplies each encoded
element by it with F.smul and compares the results with the encoded identity.
DDH fails in families of even order ([BS23], Exercise 10.24, p. 431): when every
group the setup law can produce has even order, the parity test, which is PPT
(isPPT_ddhParityDistinguisher), has advantage 1 / 2 for every security parameter, so the
DDH assumption does not hold.