Documentation

CslibFrontier.Crypto.Computational.RabinFactoring

Equivalence of Rabin inversion and integer factoring for Blum moduli #

The Rabin squaring function x ↦ x ^ 2 % N over Blum moduli N = p * q (p ≠ q primes with p ≡ q ≡ 3 [MOD 4]), the integer factoring assumption FactoringHard, the Rabin one-wayness assumption RabinOneWay, the polynomial-time equivalence RabinOneWay gen ↔ FactoringHard gen, and the Blum-modulus transfer FactoringHard.of_modulusFactoringHard and QuadraticResiduosityHard.factoringHard.

Main definitions #

Main results #

Implementation notes #

To execute natively inside ProbComp without an exact uniform sampler over (ZMod N)ˣ or modular rejection-sampling error, rabinInversionGame and rabinToFactor use an original dyadic all-residue sampling variant: they draw a uniform 2 * N.bits.length-bit word r (x = ofBits r < 2^(2 * bits(N)) with N^2 ≤ 2^(2 * bits(N))) and evaluate rabinEval N x = x^2 % N. In rabinToFactor, if 1 < gcd(x, N) < N the reduction factors N immediately; otherwise it queries the Rabin inverter A on (N, x^2 % N) and returns (gcd(x + x', N), N / gcd(x + x', N)). Partitioning Fin (2^L) into nontrivial-gcd draws, multiples of N, and 4-to-1 unit fibers (where at least 2k of the at most 4(k + 1) preimages in Fin (2^L) fall in the two mixed-sign CRT classes, equal to x' modulo one prime and -x' modulo the other, for k = 2^L / N ≥ N ≥ 21) yields the concrete factor-3 reduction bound succProbability_rabinInversionGame_le: Game.succProbability (rabinInversionGame gen A n) ≤ 3 * Game.succProbability (factoringGame gen (rabinToFactor A) n). Both FactoringHard and RabinOneWay are parameterized by an arbitrary generator family gen : BlumGen := ℕ → PMF BlumDesc (without bundling efficient Blum-modulus sampling or bit-length bounds in n) and quantify over uniform native strict-PPT algorithms (IsPPTOn) charging the full binary-encoded inputs and sampled/callback outputs uniformly before n.

References #

Blum modulus parameters (p, q) with distinct primes p ≠ q satisfying p ≡ q ≡ 3 [MOD 4].

  • p : ℕ

    First Blum prime factor.

  • q : ℕ

    Second Blum prime factor.

  • hp : Nat.Prime self.p

    Primality of p.

  • hq : Nat.Prime self.q

    Primality of q.

  • hpq : self.p ≠ self.q

    Distinctness of p and q.

  • hp3 : self.p % 4 = 3

    p ≡ 3 [MOD 4].

  • hq3 : self.q % 4 = 3

    q ≡ 3 [MOD 4].

theorem Cslib.Crypto.BlumDesc.ext_iff {x y : BlumDesc} :
x = y ↔ x.p = y.p ∧ x.q = y.q
theorem Cslib.Crypto.BlumDesc.ext {x y : BlumDesc} (p : x.p = y.p) (q : x.q = y.q) :
x = y
@[reducible, inline]

The Blum modulus N = p * q.

The Blum modulus is positive.

Every Blum prime is at least 3.

Every Blum prime is at least 3.

Every Blum modulus is at least 21.

View a Blum modulus descriptor as a ModulusDesc.

@[reducible, inline]

A Blum modulus generator indexed by the security parameter n.

Rabin squaring function: x ^ 2 % N.

Rabin squaring (N, x) ↦ x ^ 2 % N is computable in polynomial time whenever N and x are computable in polynomial time and 0 < N a.

noncomputable def Cslib.Crypto.factoringGame (gen : BlumGen) (A : ℕ → ℕ → ProbComp (ℕ × ℕ)) (n : ℕ) :

The integer factoring experiment: sample desc ← gen n, run A n N, and accept when A returns a nontrivial factorization 1 < a, 1 < b, a * b = N.

The integer factoring assumption for gen ([KL20], Section 9.2.3, Definition 9.45): every uniform PPT factoring algorithm succeeds with negligible probability.

@[simp]

factoringGame gen A n is modulusFactoringGame on the pushed-forward Blum modulus distribution (gen n).map BlumDesc.modulus.

FactoringHard gen is equivalent to ModulusFactoringHard on the pushed-forward Blum modulus distribution.

theorem Cslib.Crypto.FactoringHard.of_modulusFactoringHard {modGen : ℕ → PMF ℕ} {gen : BlumGen} (h : ModulusFactoringHard modGen) (hmod : ∀ (n : ℕ), modGen n = PMF.map BlumDesc.modulus (gen n)) :

Transfer ModulusFactoringHard on a modulus distribution to FactoringHard on a Blum generator with the same modulus distribution.

noncomputable def Cslib.Crypto.rabinInversionGame (gen : BlumGen) (A : ℕ → ℕ × ℕ → ProbComp ℕ) (n : ℕ) :

The Rabin inversion experiment: sample desc ← gen n and a uniform bitstring r of length 2 * N.bits.length, set y = (ofBits r) ^ 2 % N, and accept when A n (N, y) outputs x' with x' ^ 2 % N = y.

The Rabin one-wayness assumption for gen ([KL20], Section 15.5.2; locator not independently inspected in the 3rd-edition PDF): every uniform strict PPT inverter has negligible probability of finding a modular square root of x ^ 2 % N on Blum moduli drawn from gen, with the preimage x drawn from a uniform bit string of length 2 * N.bits.length reduced modulo N rather than a uniform unit in ℤ_N^*.

Split N at g = Nat.gcd u N, returning (g, N / g).

noncomputable def Cslib.Crypto.rabinToFactor (A : ℕ → ℕ × ℕ → ProbComp ℕ) (n N : ℕ) :

Explicit PPT reduction from factoring to Rabin inversion: sample x uniformly, check gcd x N, and otherwise query the Rabin inverter A on (N, x^2 mod N) to recover gcd (x + x') N.

Recombine square roots modulo Blum primes a and b via Fermat's little theorem CRT.

Explicit PPT reduction from Rabin inversion to factoring: given (n, (N, y)), run the factoring algorithm F n N; if it returns (a, b) with 1 < a, 1 < b, a * b = N, extract square roots modulo a and b via y ^ ((p + 1) / 4) % p and combine them via Fermat's little theorem CRT.

Success probability of factoringGame gen F n is at most that of rabinInversionGame gen (factorToRabin F) n.

If Rabin squaring is one-way for gen, then factoring is hard for gen.

Counting Rabin preimages #

Success probability of rabinInversionGame gen A n is at most 3 times that of factoringGame gen (rabinToFactor A) n.

If factoring is hard for gen, then Rabin squaring is one-way for gen.

Equivalence of Rabin one-wayness and integer factoring hardness for Blum modulus generators.

Quadratic residuosity hardness implies FactoringHard for any Blum modulus generator gen whose modulus distribution matches setup.