Documentation

CslibFrontier.Crypto.Computational.GoldwasserMicali

Goldwasser–Micali public-key encryption #

The Goldwasser–Micali probabilistic public-key encryption scheme ([KL20], Section 15.4.4, Construction 15.28, Theorem 15.29, and Exercises 15.11–15.12) over distinct odd primes p ≠ q with modulus N = p * q and public nonresidue z ∈ QNR_N^{+1}:

References #

Key parameters and Blum specialization #

Goldwasser–Micali key parameters: distinct odd primes p and q (ModulusDesc) together with the canonical residue z < p * q of an element of positiveNonresidues p q.

@[reducible, inline]

Composite modulus N = p * q.

Every valid Goldwasser–Micali modulus exceeds 1.

z is strictly smaller than N = p * q.

z viewed as a unit in (ZMod k.modulus)ˣ.

The canonical natural representative of k.zUnit is k.z.

k.zUnit lies in positiveNonresidues k.p k.q (QNR_N^{+1}).

k.zUnit is not a square in (ZMod k.modulus)ˣ.

Deterministic Blum-integer Goldwasser–Micali key description ([KL20], Exercise 15.12): for a Blum modulus N = p * q (p ≡ q ≡ 3 (mod 4)), N - 1 represents -1 in positiveNonresidues p q.

The parameters ((p, q), z) of a key; the proof fields are determined by them.

Encoding of KeyDesc as the binary triple ((p, q), z).

Arithmetic encryption, Euler-criterion decryption, and homomorphic multiplication #

Goldwasser–Micali ciphertext (if m then z else 1) * (r ^ 2 mod N) mod N ([KL20], Construction 15.28).

Quadratic-residuosity test modulo p * q via Euler's criterion modulo p and q.

Goldwasser–Micali decryption ([KL20], Construction 15.28): return false on quadratic residues and true otherwise.

Homomorphic multiplication of two ciphertexts modulo N ([KL20], Exercise 15.11).

theorem Cslib.Crypto.GoldwasserMicali.natCast_ciphertext {N : ℕ} (hN : N ≠ 0) (z : ℕ) (m : Bool) (r : ℕ) :
↑(ciphertext N z m r) = (if m = true then ↑z else 1) * ↑r ^ 2

Cast of ciphertext N z m r to ZMod N.

theorem Cslib.Crypto.GoldwasserMicali.ciphertext_eq_unit_val {N z r : ℕ} [NeZero N] (hz : z.Coprime N) (hr : r.Coprime N) (m : Bool) :

Canonical residue representation of ciphertext N z m r for coprime z and r.

Euler's criterion on (ZMod (d.p * d.q))ˣ: isQuadResidueNat d.p d.q decides IsSquare u.

decryptNat d.p d.q decides non-squareness on (ZMod (d.p * d.q))ˣ.

theorem Cslib.Crypto.GoldwasserMicali.decryptNat_ciphertext (d : ModulusDesc) {z r : ℕ} (hz : z.Coprime (d.p * d.q)) (hnotsq : ¬IsSquare (ZMod.unitOfCoprime z hz)) (hr : r.Coprime (d.p * d.q)) (m : Bool) :
decryptNat d.p d.q (ciphertext (d.p * d.q) z m r) = m

Arithmetic correctness of Goldwasser–Micali decryption ([KL20], Construction 15.28): for any non-square unit z and coprime r, decryptNat recovers m.

theorem Cslib.Crypto.GoldwasserMicali.mulCiphertextsNat_ciphertext {N : ℕ} (hN : N ≠ 0) (z : ℕ) (b₁ b₂ : Bool) (r₁ r₂ : ℕ) :
mulCiphertextsNat N (ciphertext N z b₁ r₁) (ciphertext N z b₂ r₂) = ciphertext N z (b₁ ^^ b₂) ((if (b₁ && b₂) = true then z else 1) * r₁ * r₂)

Multiplying two ciphertexts modulo N encrypts b₁ ^^ b₂ with explicit combined randomness.

Word-level 1-bit scheme and efficiency certificates #

Goldwasser–Micali key generation ([KL20], Construction 15.28): draw k ← gen n and output pk = ⟨N, z⟩ and sk = ⟨p, q⟩.

noncomputable def Cslib.Crypto.GoldwasserMicali.encrypt (n : ℕ) (pk : List Bool) (m : Bool) :

Goldwasser–Micali 1-bit encryption ([KL20], Construction 15.28) under pk = ⟨N, z⟩.

Goldwasser–Micali decryption ([KL20], Construction 15.28) under sk = ⟨p, q⟩.

Homomorphic XOR combiner ([KL20], Exercise 15.11): multiply ciphertexts modulo N.

Support-level correctness and XOR homomorphism #

Supported ciphertexts under pk = ⟨N, z⟩ have the form encNat (ciphertext N z m r) with r.Coprime N.

theorem Cslib.Crypto.GoldwasserMicali.decrypt_encrypt {gen : ℕ → ProbComp KeyDesc} {n : ℕ} {keys : List Bool × List Bool} (hkeys : keys ∈ (keyGen gen n).eval.support) (m : Bool) {ct : List Bool} (hct : ct ∈ (encrypt n keys.1 m).eval.support) :
decrypt keys.2 ct = m

Perfect correctness of Goldwasser–Micali encryption ([KL20], Construction 15.28).

theorem Cslib.Crypto.GoldwasserMicali.decrypt_mulCiphertexts {gen : ℕ → ProbComp KeyDesc} {n : ℕ} {keys : List Bool × List Bool} (hkeys : keys ∈ (keyGen gen n).eval.support) {b₁ b₂ : Bool} {ct₁ ct₂ : List Bool} (hct₁ : ct₁ ∈ (encrypt n keys.1 b₁).eval.support) (hct₂ : ct₂ ∈ (encrypt n keys.1 b₂).eval.support) :
decrypt keys.2 (mulCiphertexts keys.1 ct₁ ct₂) = (b₁ ^^ b₂)

Preservation of plaintext XOR under ciphertext multiplication ([KL20], Definition 15.14 and Exercise 15.11, first clause).

Ideal unit-sampling encryption, re-randomization, and distributional XOR homomorphism #

noncomputable def Cslib.Crypto.GoldwasserMicali.idealEncryptUnit (N : ℕ) [NeZero N] (z : (ZMod N)ˣ) (m : Bool) :

Ideal Goldwasser–Micali unit-level encryption law: sample r uniformly from (ZMod N)ˣ and output (if m then z else 1) * r ^ 2.

noncomputable def Cslib.Crypto.GoldwasserMicali.idealEncrypt (N : ℕ) [NeZero N] (z : (ZMod N)ˣ) (m : Bool) :

Ideal Goldwasser–Micali word-level encryption law: encode the canonical residue of idealEncryptUnit N z m via encNat.

Ciphertext re-randomization ([KL20], Exercise 15.11): multiplying any fixed ciphertext (if m then z else 1) * r₀ ^ 2 by r ^ 2 for a uniform unit r yields idealEncryptUnit N z m.

Word-level ciphertext re-randomization via mulCiphertexts with a fresh draw from idealEncrypt N z false.

theorem Cslib.Crypto.GoldwasserMicali.idealEncryptUnit_mul_eq (N : ℕ) [NeZero N] (z : (ZMod N)ˣ) (b₁ b₂ : Bool) :
(do let c₁ ← idealEncryptUnit N z b₁ let c₂ ← idealEncryptUnit N z b₂ pure (c₁ * c₂)) = idealEncryptUnit N z (b₁ ^^ b₂)

Distributional XOR homomorphism on (ZMod N)ˣ ([KL20], Exercise 15.11).

theorem Cslib.Crypto.GoldwasserMicali.idealEncrypt_mulCiphertexts_eq (N : ℕ) [NeZero N] (z : (ZMod N)ˣ) (b₁ b₂ : Bool) :
(do let ct₁ ← idealEncrypt N z b₁ let ct₂ ← idealEncrypt N z b₂ pure (mulCiphertexts ((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encNat Turing.MultiTapeTM.encNat) (N, (↑z).val)) ct₁ ct₂)) = idealEncrypt N z (b₁ ^^ b₂)

Exercise 15.11 ([KL20], p. 568, and Definition 15.14, second clause): multiplying two independent ideal ciphertexts of b₁ and b₂ with mulCiphertexts produces the exact fresh ciphertext distribution idealEncrypt N z (b₁ ^^ b₂).

Word-level lossiness on quadratic-residue keys: when IsSquare y, idealEncrypt N y m is independent of m.

theorem Cslib.Crypto.GoldwasserMicali.idealEncryptUnit_map_mul (N : ℕ) [NeZero N] (z s : (ZMod N)ˣ) (m b : Bool) :
PMF.map (fun (x : (ZMod N)ˣ) => x * ((if b = true then z else 1) * s ^ 2)) (idealEncryptUnit N z m) = idealEncryptUnit N z (m ^^ b)

Multiplying an ideal ciphertext by z ^ b * s ^ 2 adds b to its plaintext: re-randomization absorbs the square s ^ 2, and z ^ 2 when both m and b are set.

Word-level idealEncryptUnit_map_mul: multiplying an ideal ciphertext by the residue of z ^ b * s ^ 2 with mulCiphertexts adds b to its plaintext. Only the modulus N of the public key is read.

Sampling statistical distance between encrypt and idealEncrypt #

theorem Cslib.Crypto.GoldwasserMicali.advantage_sampleModNat_unitOrOne_le (d : ModulusDesc) (n : ℕ) (hsize : n ≤ d.p.size ∧ n ≤ d.q.size) (k : ℕ → Game) :
Game.advantage ((ProbComp.sampleModNat (n + (Turing.MultiTapeTM.encNat (d.p * d.q)).length) (d.p * d.q)).eval.bind fun (r : ℕ) => k (unitOrOne (d.p * d.q) r)) ((Probability.PMF.uniformOfFintype (ZMod (d.p * d.q))ˣ).bind fun (u : (ZMod (d.p * d.q))ˣ) => k (↑u).val) ≤ 5 / 2 ^ n

For d : ModulusDesc with n-bit primes (n ≤ d.p.size ∧ n ≤ d.q.size), sampling r ← ProbComp.sampleModNat (n + |N|) N and applying unitOrOne N is within 5 / 2 ^ n statistical distance of a uniform unit u ← PMF.uniformOfFintype (ZMod N)ˣ.

Replacing encrypt by idealEncrypt inside any continuation k changes game advantage by at most 5 / 2 ^ n when n ≤ d.p.size ∧ n ≤ d.q.size.

Ideal-key-law single-bit QR reduction step #

Ideal Goldwasser–Micali public-key distribution ([KL20], Construction 15.28): sample d ← setup n and z uniformly from positiveNonresidues d.p d.q.

Lossy quadratic-residue public-key distribution ([KL20], proof of Theorem 15.29): sample d ← setup n and y uniformly from quadResidueSet d.p d.q.

Single-bit QR reduction distinguisher ([KL20], proof of Theorem 15.29).

qrDistinguisher adversary is uniformly strict PPT whenever adversary is.

Under qrPublicKeyLaw, the chosen-message advantage is at most 10 / 2 ^ n.

theorem Cslib.Crypto.GoldwasserMicali.advantage_idealPublicKeyGame_le_qr {setup : ℕ → PMF ModulusDesc} {n : ℕ} (hsize : ∀ d ∈ (setup n).support, n ≤ d.p.size ∧ n ≤ d.q.size) (adversary : Encryption.Adversary) :
(Encryption.publicKeyGame (publicKeyLaw setup n) encrypt adversary false n).advantage (Encryption.publicKeyGame (publicKeyLaw setup n) encrypt adversary true n) ≤ 2 * (qrRealGame setup (qrDistinguisher adversary) n).advantage (qrIdealGame setup (qrDistinguisher adversary) n) + 10 / 2 ^ n

Ideal-key-law step toward indcpa_textbookGoldwasserMicali and #5293 (after [KL20], Section 15.4.4, Theorem 15.29, locator not verified; not the cited result): when public keys are drawn from the exact uniform QNR_N^{+1} distribution publicKeyLaw setup n rather than a key-generation algorithm, single-bit chosen-plaintext advantage is at most twice qrDistinguisher adversary's QR advantage plus 10 / 2 ^ n.

Blum-modulus Goldwasser–Micali: IND-CPA from quadratic residuosity alone #

Blum-modulus Goldwasser–Micali public key ⟨N, N - 1⟩. Its public nonresidue N - 1 represents -1, which lies in QNR_N^{+1} for every Blum modulus (neg_one_mem_positiveNonresidues).

Blum-modulus Goldwasser–Micali key generation: draw d ← gen n and output pk = blumPublicKey N and sk = ⟨p, q⟩ for N = p * q; encryption and decryption are encrypt and decrypt. Unlike keyGen, nothing beyond the modulus is sampled: the public nonresidue -1 is computed from N, which is valid for Blum moduli (KeyDesc.ofBlum).

theorem Cslib.Crypto.GoldwasserMicali.decrypt_encrypt_blumKeyGen {gen : ℕ → ProbComp ModulusDesc} {n : ℕ} (hblum : ∀ d ∈ (gen n).eval.support, IsBlumModulus d.p d.q) {keys : List Bool × List Bool} (hkeys : keys ∈ (blumKeyGen gen n).eval.support) (m : Bool) {ct : List Bool} (hct : ct ∈ (encrypt n keys.1 m).eval.support) :
decrypt keys.2 ct = m

Perfect correctness of Blum-modulus Goldwasser–Micali encryption whenever gen n draws Blum moduli.

Blum QR reduction distinguisher. On a quadratic residuosity challenge input = (N, y), run message selection on blumPublicKey N, encrypt m₀ honestly, multiply the ciphertext by y when m₀ ≠ m₁, and return the adversary's guess. A quadratic residue y leaves a fresh encryption of m₀. For a Blum modulus, y ∈ QNR_N^{+1} is -1 times a square, so it turns the ciphertext into a fresh encryption of m₁ (advantage_blumGame_le_qr).

blumQRDistinguisher adversary is uniformly strict PPT whenever adversary is.

theorem Cslib.Crypto.GoldwasserMicali.advantage_blumGame_le_qr {gen : ℕ → ProbComp ModulusDesc} {n : ℕ} (hblum : ∀ d ∈ (gen n).eval.support, IsBlumModulus d.p d.q) (hsize : ∀ d ∈ (gen n).eval.support, n ≤ d.p.size ∧ n ≤ d.q.size) (adversary : Encryption.Adversary) :
Encryption.advantage (Encryption.game (blumKeyGen gen) encrypt adversary) n ≤ (qrRealGame (fun (n : ℕ) => (gen n).eval) (blumQRDistinguisher adversary) n).advantage (qrIdealGame (fun (n : ℕ) => (gen n).eval) (blumQRDistinguisher adversary) n) + 20 / 2 ^ n

Quantitative IND-CPA bound for Blum-modulus Goldwasser–Micali. When gen n draws Blum moduli with n-bit primes, every adversary's IND-CPA advantage against (blumKeyGen gen, encrypt) is at most the QR advantage of blumQRDistinguisher adversary relative to gen, plus 20 / 2 ^ n for approximate unit sampling.

theorem Cslib.Crypto.GoldwasserMicali.indcpa_blumGoldwasserMicali {gen : ℕ → ProbComp ModulusDesc} (hblum : ∀ (n : ℕ), ∀ d ∈ (gen n).eval.support, IsBlumModulus d.p d.q) (hsize : ∀ (n : ℕ), ∀ d ∈ (gen n).eval.support, n ≤ d.p.size ∧ n ≤ d.q.size) (hQR : QuadraticResiduosityHard fun (n : ℕ) => (gen n).eval) :

IND-CPA security of Blum-modulus Goldwasser–Micali from quadratic residuosity. Let gen draw Blum moduli N = p * q (p ≡ q ≡ 3 (mod 4)) with n-bit primes. If quadratic residuosity is hard relative to gen, then Goldwasser–Micali with public nonresidue -1 (blumKeyGen gen, encrypt) is single-bit Encryption.INDCPA against uniform strict-PPT adversaries. These are the only premises; nothing is assumed about the key generator beyond its modulus law. The reduction blumQRDistinguisher is certified strict PPT (isPPTOn_blumQRDistinguisher), and the concrete bound is advantage_blumGame_le_qr.

This is the Blum-modulus variant of the Goldwasser–Micali security theorem of [KL20], Section 15.4.4 (locator not verified against the source). The textbook samples the public nonresidue uniformly from QNR_N^{+1}; here it is -1, which needs Blum moduli and makes key generation exactly the modulus draw. The modulus sampler gen is an arbitrary probabilistic program: the theorem does not use its efficiency, which isPPTOn_blumKeyGen transfers to key generation.

Multi-bit bitwise Goldwasser–Micali encryption and IND-CPA #

noncomputable def Cslib.Crypto.GoldwasserMicali.encryptBits (n : ℕ) (pk bits : List Bool) :

Encrypt each bit of bits independently with encrypt n pk.

Word-valued bitwise encryption for Encryption.gameOn: frame encryptBits via encList encBits (definitionally Encryption.bitwiseEncrypt encrypt).

Decrypt a list of Goldwasser–Micali ciphertexts bit-by-bit.

Word-valued bitwise decryption: split a framed ciphertext word via frames and decrypt each bit (Encryption.bitwiseDecrypt decrypt).

Componentwise homomorphic XOR of two ciphertext lists.

@[simp]

decryptWord sk on a framed list of bit ciphertexts evaluates decryptBits sk.

theorem Cslib.Crypto.GoldwasserMicali.decryptBits_encryptBits {gen : ℕ → ProbComp KeyDesc} {n : ℕ} {keys : List Bool × List Bool} (hkeys : keys ∈ (keyGen gen n).eval.support) (bits : List Bool) {cts : List (List Bool)} (hcts : cts ∈ (encryptBits n keys.1 bits).eval.support) :
decryptBits keys.2 cts = bits

Perfect correctness of bitwise Goldwasser–Micali encryption on ciphertext lists.

theorem Cslib.Crypto.GoldwasserMicali.decryptBits_xorCiphertexts {gen : ℕ → ProbComp KeyDesc} {n : ℕ} {keys : List Bool × List Bool} (hkeys : keys ∈ (keyGen gen n).eval.support) {bits₁ bits₂ : List Bool} {cts₁ cts₂ : List (List Bool)} (hcts₁ : cts₁ ∈ (encryptBits n keys.1 bits₁).eval.support) (hcts₂ : cts₂ ∈ (encryptBits n keys.1 bits₂).eval.support) :
decryptBits keys.2 (xorCiphertexts keys.1 cts₁ cts₂) = List.zipWith xor bits₁ bits₂

Componentwise XOR homomorphism of xorCiphertexts on supported encryptBits ciphertext lists: decrypting xorCiphertexts keys.1 cts₁ cts₂ recovers List.zipWith Bool.xor bits₁ bits₂.

theorem Cslib.Crypto.GoldwasserMicali.decryptWord_encryptWord {gen : ℕ → ProbComp KeyDesc} {n : ℕ} {keys : List Bool × List Bool} (hkeys : keys ∈ (keyGen gen n).eval.support) (bits : List Bool) {ct : List Bool} (hct : ct ∈ (encryptWord n keys.1 bits).eval.support) :
decryptWord keys.2 ct = bits

Perfect correctness of word-valued bitwise Goldwasser–Micali encryption (encryptWord / decryptWord).

theorem Cslib.Crypto.GoldwasserMicali.decryptBits_encryptBits_blumKeyGen {gen : ℕ → ProbComp ModulusDesc} {n : ℕ} (hblum : ∀ d ∈ (gen n).eval.support, IsBlumModulus d.p d.q) {keys : List Bool × List Bool} (hkeys : keys ∈ (blumKeyGen gen n).eval.support) (bits : List Bool) {cts : List (List Bool)} (hcts : cts ∈ (encryptBits n keys.1 bits).eval.support) :
decryptBits keys.2 cts = bits

Perfect correctness of Blum-modulus bitwise Goldwasser–Micali encryption on ciphertext lists.

theorem Cslib.Crypto.GoldwasserMicali.decryptWord_encryptWord_blumKeyGen {gen : ℕ → ProbComp ModulusDesc} {n : ℕ} (hblum : ∀ d ∈ (gen n).eval.support, IsBlumModulus d.p d.q) {keys : List Bool × List Bool} (hkeys : keys ∈ (blumKeyGen gen n).eval.support) (bits : List Bool) {ct : List Bool} (hct : ct ∈ (encryptWord n keys.1 bits).eval.support) :
decryptWord keys.2 ct = bits

Blum-modulus word-level round-trip correctness step (blumKeyGen gen, encryptWord, decryptWord) whenever gen n draws Blum moduli.

theorem Cslib.Crypto.GoldwasserMicali.length_blumPublicKey_le {p q B : ℕ} (hp : p.size ≤ B) (hq : q.size ≤ B) :
(blumPublicKey (p * q)).length ≤ 6 * B + 1

Encoded bit length of blumPublicKey (p * q) in terms of an upper bound B on p.size and q.size.

theorem Cslib.Crypto.GoldwasserMicali.wordINDCPA_blumGoldwasserMicali {gen : ℕ → ProbComp ModulusDesc} {sizeBound : ℕ → ℕ} (hbound : PolynomiallyBounded sizeBound) (hblum : ∀ (n : ℕ), ∀ d ∈ (gen n).eval.support, IsBlumModulus d.p d.q) (hsize : ∀ (n : ℕ), ∀ d ∈ (gen n).eval.support, n ≤ d.p.size ∧ n ≤ d.q.size) (hupper : ∀ (n : ℕ), ∀ d ∈ (gen n).eval.support, d.p.size ≤ sizeBound n ∧ d.q.size ≤ sizeBound n) (hQR : QuadraticResiduosityHard fun (n : ℕ) => (gen n).eval) :

Blum-modulus multi-bit IND-CPA step toward #5293 (after [KL20], Section 15.4.4 and Exercise 15.12, locator not verified; not the textbook QNR_N^{+1} key-generator endpoint). Let gen draw Blum moduli N = p * q (p ≡ q ≡ 3 (mod 4)) whose prime factors have bit-length at least n and at most sizeBound n for a polynomially bounded function sizeBound (for example fun n => n + c, max · 5 for exact n-bit Blum primes at n ≥ 5, or the length cap of any uniform strict-PPT modulus sampler gen). If quadratic residuosity is hard relative to gen, then bitwise Goldwasser–Micali encryption with public nonresidue -1 (blumKeyGen gen, encryptWord) satisfies Encryption.WordINDCPA against all uniform strict-PPT word adversaries.

This combines indcpa_blumGoldwasserMicali with the certified single-bit-to-multi-bit hybrid reduction step Encryption.INDCPA.wordINDCPA_bitwiseEncrypt_of_publicKey_length_le (Encryption.bitwiseToSingle, Encryption.isPPT_bitwiseToSingle). The upper bound hupper keeps public keys polynomially long in n (length_blumPublicKey_le), bounding the length of any strict-PPT adversary's challenge words; sizeBound and gen need not be computable.

noncomputable def Cslib.Crypto.GoldwasserMicali.idealEncryptBits (N : ℕ) [NeZero N] (z : (ZMod N)ˣ) (bits : List Bool) :

Ideal bitwise encryption law on a bit list bits.

theorem Cslib.Crypto.GoldwasserMicali.idealEncryptBits_eq_of_isSquare_of_length_eq (N : ℕ) [NeZero N] {y : (ZMod N)ˣ} (hy : IsSquare y) {m₀ m₁ : List Bool} (hlen : m₀.length = m₁.length) :

When IsSquare y, idealEncryptBits N y agrees on any two equal-length bit lists.

Statistical distance between encryptBits and idealEncryptBits is at most bits.length * (5 / 2 ^ n) for a modulus with n-bit primes.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.GoldwasserMicali.publicKeyWordGame (maxLen : ℕ → ℕ) (keys : PMF (List Bool)) (adversary : Encryption.WordAdversary) (bit : Bool) (n : ℕ) :

Chosen-message experiment for encryptWord under a given public-key PMF law and Encryption.validBoundedWords maxLen.

noncomputable def Cslib.Crypto.GoldwasserMicali.qrWordDistinguisher (maxLen : ℕ → ℕ) (adversary : Encryption.WordAdversary) (n : ℕ) (input : ℕ × ℕ) :

Multi-bit QR reduction distinguisher via Goldwasser–Micali lossy public keys: the public-key replacement distinguisher for encryptWord and validBoundedWords maxLen.

qrWordDistinguisher maxLen adversary is uniformly strict PPT whenever maxLen is unary polynomial-time computable and adversary is strict PPT.

theorem Cslib.Crypto.GoldwasserMicali.advantage_idealPublicKeyWordGame_le_qr (maxLen : ℕ → ℕ) {setup : ℕ → PMF ModulusDesc} {n : ℕ} (hsize : ∀ d ∈ (setup n).support, n ≤ d.p.size ∧ n ≤ d.q.size) (adversary : Encryption.WordAdversary) :
(publicKeyWordGame maxLen (publicKeyLaw setup n) adversary false n).advantage (publicKeyWordGame maxLen (publicKeyLaw setup n) adversary true n) ≤ 2 * (qrRealGame setup (qrWordDistinguisher maxLen adversary) n).advantage (qrIdealGame setup (qrWordDistinguisher maxLen adversary) n) + 10 * ↑(maxLen n) / 2 ^ n

Ideal-key-law step toward wordINDCPA_textbookGoldwasserMicali and #5293 (after [KL20], Section 15.4.4, Theorem 15.29, locator not verified; not the cited result): when public keys are drawn from the exact uniform QNR_N^{+1} distribution publicKeyLaw setup n rather than a key-generation algorithm, chosen-plaintext advantage against encryptWord on equal-length words of length at most maxLen n is at most twice qrWordDistinguisher maxLen adversary's QR advantage (independent of maxLen n) plus (10 * maxLen n) / 2 ^ n.

Necessity of J_N(z) = +1: polynomial-time Jacobi-symbol attack on jacobiNegSet #

Chosen-message adversary exploiting a public parameter z with Jacobi symbol -1: challenge on (false, true), save unframe pk, and test jacobiSym (ofBits ct) N = -1.

Necessity of z ∈ QNR_N^{+1} ([KL20], Section 15.4.4): if z ∈ jacobiNegSet p q (J_N(z) = -1), jacobiAttackAdversary distinguishes encrypt of false from true with exact IND-CPA advantage 1 at every n without factoring N.