Documentation

CslibFrontier.Crypto.Computational.Paillier.Security

Paillier encryption is IND-CPA secure under DCR #

[KL20], Theorem 15.13: if the decisional composite residuosity problem is hard relative to the modulus generator, Paillier encryption is CPA-secure. We prove this for Paillier.keyGen and Paillier.encrypt with the strict-PPT game Encryption.INDCPAOn.

For a chosen-message adversary A and a challenge bit b, the distinguisher dcrDistinguisher A b on input (N, y) runs A on the public key N and, for an admissible pair, answers with (1 + N) ^ m_b * y mod N ^ 2, as in the book's proof. The proof has four hops:

  1. The real IND-CPA experiment for bit b is within 5 / 2 ^ n of the DCR real game of dcrDistinguisher A b. In the DCR real game y = s ^ N for s uniform in (ZMod (N ^ 2))ˣ, and s ^ N depends only on s mod N; reduction modulo N pushes the uniform law on (ZMod (N ^ 2))ˣ to the uniform law on (ZMod N)ˣ. The encryption randomness is unitOrOne N r for r from ProbComp.sampleModNat, which is within N / 2 ^ (n + |N|) + (N - φ(N)) / N of uniform on the units.
  2. The DCR real and random games of dcrDistinguisher A b differ by its DCR advantage.
  3. The DCR random games for b = false and b = true are equal: multiplying a uniform unit by the unit (1 + N) ^ m gives a uniform unit, whatever m is.
  4. Hops 1 and 2 again, for the other bit.

On every input that the DCR games give it, the modulus N and the least representative of a unit y modulo N ^ 2, dcrDistinguisher A b is the typed reduction paillierToDCR of CslibFrontier.Crypto.Computational.Paillier.Finite for bit b on y, played by A read at modulus N, with an inadmissible pair answered by false. Hop 3 is that reduction's eval_dcrRandomExperiment_paillierToDCR.

The book's encryption samples r uniformly from ℤ*_N. Our encryption samples from ProbComp.sampleModNat and replaces a non-unit by 1; the extra statistical distance (N - φ(N)) / N ≤ 1 / p + 1 / q is negligible only when the primes grow with n. This is the hypothesis hsize of DCR.indcpaOn_paillier: every modulus the generator outputs at parameter n has primes of at least n bits, as in the book's GenModulus.

Main results #

References #

def Cslib.Crypto.Paillier.validMessages (_n : ℕ) (pk : List Bool) (m₀ m₁ : ℕ) :

Admissible challenge pairs: both messages are below the modulus N of the public key.

noncomputable def Cslib.Crypto.Paillier.dcrDistinguisher (adversary : Encryption.AdversaryOf ℕ) (bit : Bool) (n : ℕ) (input : ℕ × ℕ) :

The DCR distinguisher built from a chosen-message adversary and a challenge bit: on (N, y), it runs the adversary on the public key N and answers its challenge with (1 + N) ^ m * y mod N ^ 2 ([KL20], proof of Theorem 15.13).

Algebra of the reduction #

The typed reduction #

The hops #

theorem Cslib.Crypto.Paillier.DCR.indcpaOn_paillier {gen : ℕ → ProbComp BalancedModulus.Desc} (hsize : ∀ (n : ℕ), ∀ d ∈ (gen n).eval.support, n ≤ d.p.size ∧ n ≤ d.q.size) (hDCR : DCR fun (n : ℕ) => (gen n).eval) :

Paillier encryption is IND-CPA secure under DCR ([KL20], Theorem 15.13): if the decisional composite residuosity problem is hard relative to the generator's law, then (keyGen gen, encrypt) satisfies Encryption.INDCPAOn validMessages encNat. The hypothesis hsize (primes of at least n bits) makes the statistical distance between our encryption randomness and a uniform unit of ZMod N negligible; the book's encryption samples a uniform unit directly and needs no such hypothesis.