Documentation

CslibFrontier.Crypto.Computational.Paillier.Finite

Fixed-modulus Paillier model and concrete CPA-to-DCR step #

Fix a positive modulus N. This module formalizes the fixed-modulus typed model of Paillier encryption (after [KL20], Construction 15.11), which encrypts a message m : ZMod N as the unit (1 + N) ^ m * r ^ N of ZMod (N ^ 2) for an exactly uniform unit r modulo N, together with its fixed-modulus concrete CPA-to-DCR advantage step. These are fixed-instance algebraic and distributional steps, not asymptotic scheme theorems: there are no word encodings, security parameter, key generation or running-time bounds here. The word-encoded strict-PPT scheme is in CslibFrontier.Crypto.Computational.Paillier and its asymptotic IND-CPA theorem under DCR ([KL20], Theorem 15.13, parameterized by a modulus generator; certified generator instantiation tracked in #5293) is Cslib.Crypto.Paillier.DCR.indcpaOn_paillier in CslibFrontier.Crypto.Computational.Paillier.Security.

Decryption raises the ciphertext to the power t = φ(N), reads off m * t with Paillier.logOneAdd, and multiplies by t⁻¹ modulo N. It is correct whenever gcd(N, φ(N)) = 1.

At a fixed modulus with exact uniform-unit randomness, both conditions of [KL20], Definition 15.14 hold: the product of ciphertexts decrypts to the sum of the messages, and multiplying a ciphertext of m₁ by a fresh encryption of m₂ has the exact distribution of a fresh encryption of m₁ + m₂. The word-level scheme in CslibFrontier.Crypto.Computational.Paillier satisfies only the first condition on the nose, because its randomness is dyadic; CslibFrontier.Crypto.Computational.Paillier.Statistical uses the exact fixed-modulus law here to bound that word scheme's statistical error.

For chosen-plaintext security, paillierCPAAdvantage_le_dcrAdvantage gives the fixed-modulus distributional step after the proof of [KL20], Theorem 15.13 (not the asymptotic IND-CPA theorem): the typed reduction paillierToDCR N A b runs the fixed-modulus CPA experiment for challenge bit b with the DCR challenge y in place of r ^ N. A real DCR challenge gives the CPA experiment, and a uniform challenge hides the message (eval_dcrRandomExperiment_paillierToDCR, reused in Paillier.Security), so the fixed-modulus CPA advantage is at most the sum of the two fixed-modulus DCR advantages, with no hardness assumption or PPT bound applied here.

Main definitions #

Main results #

References #

The fixed-modulus typed model #

noncomputable def Cslib.Crypto.paillierEncrypt (N : ℕ) [NeZero N] (m : ZMod N) :
ProbComp (ZMod (N ^ 2))ˣ

Typed Paillier encryption at a fixed modulus N (after [KL20], Construction 15.11): draw an exactly uniform unit r modulo N and output (1 + N) ^ m * r ^ N.

def Cslib.Crypto.paillierDecrypt (N t : ℕ) (c : (ZMod (N ^ 2))ˣ) :

Typed Paillier decryption at a fixed modulus N with secret exponent t (after [KL20], Construction 15.11): L(c ^ t) * t⁻¹ mod N, where L = logOneAdd N. The secret key is t = φ(N).

At a fixed modulus N, decryption with φ(N) inverts (a, r) ↦ (1 + N) ^ a * r ^ N in its first argument: raising to φ(N) removes r ^ N and multiplies the exponent by φ(N), which is invertible modulo N.

At a fixed modulus N, the encryptions of m under paillierEncrypt are the units (1 + N) ^ m * r ^ N for units r modulo N.

theorem Cslib.Crypto.paillierDecrypt_of_mem_support {N : ℕ} [NeZero N] (hcop : N.Coprime N.totient) {m : ZMod N} {c : (ZMod (N ^ 2))ˣ} (hc : c ∈ (paillierEncrypt N m).eval.support) :

Fixed-modulus correctness for the typed model (after [KL20], Construction 15.11; see Cslib.Crypto.Paillier.decrypt_encrypt in CslibFrontier.Crypto.Computational.Paillier for the word-encoded scheme): at a fixed modulus N, when gcd(N, φ(N)) = 1, every encryption of m in the support of paillierEncrypt N m decrypts to m with secret key φ(N).

theorem Cslib.Crypto.paillierDecrypt_mul {N : ℕ} [NeZero N] (hcop : N.Coprime N.totient) {m₁ m₂ : ZMod N} {c₁ c₂ : (ZMod (N ^ 2))ˣ} (hc₁ : c₁ ∈ (paillierEncrypt N m₁).eval.support) (hc₂ : c₂ ∈ (paillierEncrypt N m₂).eval.support) :
paillierDecrypt N N.totient (c₁ * c₂) = m₁ + m₂

Fixed-modulus additive homomorphism, first condition (after [KL20], Definition 15.14; see Cslib.Crypto.Paillier.decrypt_addCiphertexts in CslibFrontier.Crypto.Computational.Paillier for the word-encoded scheme): at a fixed modulus N, when gcd(N, φ(N)) = 1, the product of an encryption of m₁ and an encryption of m₂ decrypts to m₁ + m₂.

theorem Cslib.Crypto.eval_mul_paillierEncrypt {N : ℕ} [NeZero N] {m₁ : ZMod N} {c₁ : (ZMod (N ^ 2))ˣ} (hc₁ : c₁ ∈ (paillierEncrypt N m₁).eval.support) (m₂ : ZMod N) :
PMF.map (fun (x : (ZMod (N ^ 2))ˣ) => c₁ * x) (paillierEncrypt N m₂).eval = (paillierEncrypt N (m₁ + m₂)).eval

Fixed-modulus exact rerandomization (a fixed-instance ideal-randomness step after the second condition of [KL20], Definition 15.14, not a theorem for a PPT word-encoded scheme): at a fixed modulus N with exact uniform-unit randomness, multiplying any encryption c₁ of m₁ by a fresh encryption of m₂ has the exact distribution of a fresh encryption of m₁ + m₂, since if c₁ = (1 + N) ^ m₁ * r₁ ^ N then r₁ * r is again uniform. The word-encoded dyadic scheme in CslibFrontier.Crypto.Computational.Paillier satisfies this condition only statistically (see Cslib.Crypto.Paillier.closeTo_addCiphertexts_encrypt in CslibFrontier.Crypto.Computational.Paillier.Statistical).

theorem Cslib.Crypto.eval_paillierEncrypt_mul_paillierEncrypt {N : ℕ} [NeZero N] (m₁ m₂ : ZMod N) :
(do let c₁ ← paillierEncrypt N m₁ let c₂ ← paillierEncrypt N m₂ pure (c₁ * c₂)).eval = (paillierEncrypt N (m₁ + m₂)).eval

Fixed-modulus exact rerandomization for two independent encryptions (a fixed-instance ideal-randomness step after [KL20], Definition 15.14; see Cslib.Crypto.Paillier.closeTo_addCiphertexts in CslibFrontier.Crypto.Computational.Paillier.Statistical for the word-encoded scheme): at a fixed modulus N with exact uniform-unit randomness, the product of two independent encryptions of m₁ and m₂ has the exact distribution of an encryption of m₁ + m₂.

Fixed-modulus chosen-plaintext reduction step #

noncomputable def Cslib.Crypto.paillierCPAExperiment (N : ℕ) [NeZero N] {σ : Type} (A : TwoStage ℕ (MessagePair (ZMod N)) (ZMod (N ^ 2))ˣ Bool σ) (b : Bool) :

The fixed-modulus left-or-right chosen-plaintext experiment for the typed Paillier model at modulus N (a fixed-instance step toward [KL20], Theorem 15.13): the adversary receives N, chooses two messages in ZMod N, and guesses the challenge bit b from a typed encryption of the selected message. Every pair of messages is admissible, and running time is not tracked.

noncomputable def Cslib.Crypto.paillierCPAAdvantage (N : ℕ) [NeZero N] {σ : Type} (A : TwoStage ℕ (MessagePair (ZMod N)) (ZMod (N ^ 2))ˣ Bool σ) :

The fixed-modulus chosen-plaintext advantage of A against paillierCPAExperiment N (with running time untracked).

noncomputable def Cslib.Crypto.paillierToDCR (N : ℕ) [NeZero N] {σ : Type} (A : TwoStage ℕ (MessagePair (ZMod N)) (ZMod (N ^ 2))ˣ Bool σ) (b : Bool) (y : (ZMod (N ^ 2))ˣ) :

The fixed-modulus typed reduction from the Paillier CPA experiment to the DCR experiment (a step after the proof of [KL20], Theorem 15.13, with running time untracked here and certified at the word level via Cslib.Crypto.Paillier.dcrDistinguisher in CslibFrontier.Crypto.Computational.Paillier.Security): on challenge y, run the fixed-modulus chosen-plaintext experiment for bit b, encrypting m as (1 + N) ^ m * y.

Fixed-modulus real-world step (in the proof of [KL20], Theorem 15.13): at modulus N, a real DCR challenge gives paillierToDCR N A b the distribution of paillierCPAExperiment N A b.

Fixed-modulus random-world step (in the proof of [KL20], Theorem 15.13): at modulus N, a uniform DCR challenge hides the message—multiplying the uniform unit by (1 + N) ^ m leaves it uniform—so dcrRandomExperiment N (paillierToDCR N A b) does not depend on b.

Fixed-modulus concrete CPA-to-DCR advantage bound (a distributional step after the proof of [KL20], Theorem 15.13, not the asymptotic IND-CPA theorem; see Cslib.Crypto.Paillier.DCR.indcpaOn_paillier in CslibFrontier.Crypto.Computational.Paillier.Security for the asymptotic word-level theorem, with certified modulus generation tracked in #5293): at a fixed modulus N, with exact uniform-unit randomness, no DCR assumption applied, and running time untracked, the chosen-plaintext advantage of A is at most the sum of the fixed-modulus DCR advantages of paillierToDCR N A false and paillierToDCR N A true.