Documentation

CslibFrontier.Crypto.Computational.CompositeResiduosity

The decisional composite residuosity assumption #

A balanced modulus is a product N = p * q of distinct odd primes of the same bit length. An element of (ZMod (N ^ 2))ˣ is an N-th residue when it equals r ^ N for some unit r. The decisional composite residuosity (DCR) problem asks to distinguish a uniform N-th residue modulo N ^ 2 from a uniform unit modulo N ^ 2, given only N. The DCR assumption relative to a law on moduli says that every uniform strict PPT distinguisher has negligible advantage.

A description of a balanced modulus is its pair of prime factors (p, q), with validity part of the type, as for Schnorr groups. Nothing here claims that valid descriptions can be generated efficiently; the assumption is stated relative to an arbitrary law on descriptions. The two worlds at one fixed modulus are dcrRealExperiment and dcrRandomExperiment in CslibFrontier/Crypto/Computational/CompositeResiduosity/Finite.lean; the games here draw a modulus and run them.

Main definitions #

Main results #

References #

A valid pair (p, q) of prime factors of a balanced modulus N = p * q: distinct odd primes of the same bit length.

  • prime_fst : Nat.Prime d.1

    The first factor is prime.

  • prime_snd : Nat.Prime d.2

    The second factor is prime.

  • fst_ne_snd : d.1 ≠ d.2

    The factors are distinct.

  • two_lt_fst : 2 < d.1

    The first factor is odd.

  • two_lt_snd : 2 < d.2

    The second factor is odd.

  • size_eq : d.1.size = d.2.size

    The factors have the same bit length.

@[reducible, inline]

Valid factor pairs (p, q) of balanced moduli.

@[reducible, inline]

The first prime factor p of a valid description (p, q).

@[reducible, inline]

The second prime factor q of a valid description (p, q).

@[reducible, inline]

The modulus N = p * q of a valid description (p, q).

Instances For
    @[reducible, inline]

    The totient φ(N) = (p - 1) * (q - 1), computed from the factors.

    The modulus is greater than 1.

    The computed totient (p - 1) * (q - 1) is Euler's totient of N = p * q.

    Claim 15.7 ([KL20]) for a valid description: gcd(N, φ(N)) = 1.

    Descriptions are encoded as the binary pair (p, q).

    noncomputable def Cslib.Crypto.dcrRealGame (setup : ℕ → PMF BalancedModulus.Desc) (distinguisher : ℕ → ℕ × ℕ → ProbComp Bool) (n : ℕ) :

    The real game of the decisional composite residuosity problem ([KL20], Definition 15.10): draw (p, q) ← setup n and run dcrRealExperiment at N = p * q, giving the distinguisher N and the least representative of the uniform N-th residue modulo N ^ 2.

    noncomputable def Cslib.Crypto.dcrRandomGame (setup : ℕ → PMF BalancedModulus.Desc) (distinguisher : ℕ → ℕ × ℕ → ProbComp Bool) (n : ℕ) :

    The random game of the decisional composite residuosity problem ([KL20], Definition 15.10): draw (p, q) ← setup n and run dcrRandomExperiment at N = p * q, giving the distinguisher N and the least representative of a uniform unit modulo N ^ 2.

    The decisional composite residuosity assumption relative to a law setup on balanced moduli ([KL20], Definition 15.10): every uniform strict PPT distinguisher, given N, has negligible advantage in telling a uniform N-th residue modulo N ^ 2 from a uniform unit modulo N ^ 2.

    Decisional composite residuosity hardness implies integer factoring hardness #

    Totient-exponentiation test for composite residuosity modulo N ^ 2 from candidate factors (a, b) of N: returns true when 1 < a, 1 < b, a * b = N, and y ^ ((a - 1) * (b - 1)) % (N ^ 2) = 1.

    def Cslib.Crypto.factorToDCR (F : ℕ → ℕ → ProbComp (ℕ × ℕ)) (n : ℕ) (Ny : ℕ × ℕ) :

    Explicit PPT reduction from decisional composite residuosity distinguishing to integer factoring ([KL20], Section 15.3.1): given (N, y), run the factoring algorithm F n N to obtain (a, b) and test whether y ^ ((a - 1) * (b - 1)) ≡ 1 [MOD N ^ 2].

    In dcrRealGame, factorToDCR F succeeds with the exact distribution of modulusFactoringGame on the pushed-forward modulus distribution.

    Twice the success probability of factorToDCR F in dcrRandomGame is at most the factoring success probability of F.

    The factoring success probability of F is at most twice the DCR distinguishing advantage of factorToDCR F.

    Decisional composite residuosity hardness implies integer factoring hardness: if setup satisfies DCR, then factoring N = d.modulus is hard for (setup n).map BalancedModulus.Desc.modulus.