Documentation

CslibFrontier.Crypto.Computational.Encryption.ParityPrediction

Parity-prediction security from semantic security (Boneh–Shoup §2.2.3.2) #

A semantically secure cipher over non-empty bit strings is secure against parity prediction ([BS23], Section 2.2.3.2, Attack Game 2.3, Definition 2.4, and Theorem 2.8, pp. 20–22). We formalize both the concrete exact advantage identity for a typed symmetric cipher Cipher K (BitString L) C and the asymptotic theorem for a cipher with message space {0, 1}^{msgLen n}, whose semantic security admits exactly the challenge pairs of two msgLen n-bit messages, together with the uniform strict PPT certificate of the reduction.

Relative to [BS23], §2.2.3.2, pp. 20–22, this formalization makes two hypotheses explicit:

Main definitions #

Main results #

References #

Flip the last bit of an L-bit string (m ↦ m ⊕ (0^{L-1} ‖ 1)), requiring 1 ≤ L.

noncomputable def Cslib.Crypto.Encryption.parityExperiment {K C : Type} {L : ℕ} (E : Cipher K (BitString L) C) (sampleKey : ProbComp K) (A : C → ProbComp Bool) :

Parity-prediction attack game ([BS23], Attack Game 2.3, p. 21).

noncomputable def Cslib.Crypto.Encryption.parityAdvantage {K C : Type} {L : ℕ} (E : Cipher K (BitString L) C) (sampleKey : ProbComp K) (A : C → ProbComp Bool) :

Parity-prediction advantage Parityadv[A, E] := |Pr[W] - 1 / 2| ([BS23], Attack Game 2.3, p. 21).

noncomputable def Cslib.Crypto.Encryption.parityReduction {M C : Type} (sampleMessage : ProbComp M) (flip : M → M) (par : M → Bool) (A : C → ProbComp Bool) :

Explicit semantic-security reduction B from a parity-prediction adversary A ([BS23], Theorem 2.8, p. 21), parameterized by message sampler, bit-flip map, and parity predicate so the typed and word-level theorems share one reduction program.

theorem Cslib.Crypto.Encryption.parityAdvantage_eq_half_mul_advantage_parityReduction {K C : Type} {L : ℕ} (E : Cipher K (BitString L) C) (sampleKey : ProbComp K) (hL : 1 ≤ L) {valid : BitString L → BitString L → Bool} (hvalid : ∀ (m₀ : BitString L), valid m₀ (flipLastBitString hL m₀) = true) (A : C → ProbComp Bool) :

Concrete advantage relation for Theorem 2.8 ([BS23], p. 21): Parityadv[A, E] = (1 / 2) * SSadv[B, E] with B := parityReduction (ProbComp.uniform (BitString L)) (flipLastBitString hL) (parity L) A.

Flip the last bit of a word of length L via XOR with 0^{L-1} ‖ 1 ([BS23], p. 21: m₀ ⊕ (0^{L-1} ‖ 1)).

noncomputable def Cslib.Crypto.Encryption.parityWordExperiment (msgLen keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp Bool) (n : ℕ) :

Word-level parity-prediction experiment over {0, 1}^{msgLen n}.

noncomputable def Cslib.Crypto.Encryption.parityWordAdvantage (msgLen keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp Bool) (n : ℕ) :

Word-level parity-prediction advantage Parityadv[A, E](n) = |Pr[W] - 1 / 2|.

Explicit WordAdversary reduction for parity prediction on {0, 1}^{msgLen n}, running parityReduction.

theorem Cslib.Crypto.Encryption.parityWordAdvantage_eq_half_mul_demKeyGameOn (msgLen keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp Bool) {n : ℕ} (hn : 1 ≤ msgLen n) :
↑(parityWordAdvantage msgLen keyLen encryptSym A n) = 1 / 2 * ↑(Game.advantage (demKeyGameOn (fun (n : ℕ) (x m₀ m₁ : List Bool) => m₀.length == msgLen n && m₁.length == msgLen n) keyLen encryptSym (parityWordToDEMAdversary msgLen A) false n).eval (demKeyGameOn (fun (n : ℕ) (x m₀ m₁ : List Bool) => m₀.length == msgLen n && m₁.length == msgLen n) keyLen encryptSym (parityWordToDEMAdversary msgLen A) true n).eval)

Exact word-level advantage identity of the proof of Theorem 2.8 ([BS23], p. 21) at each n with 1 ≤ msgLen n: Parityadv[A, E](n) = (1 / 2) · SSadv[B, E](n) for B := parityWordToDEMAdversary msgLen A, in Attack Game 2.1 with challenge pairs of two msgLen n-bit messages. Derived from parityReduction_advantage_eq.

theorem Cslib.Crypto.Encryption.DEMOneTimeKeyINDCPAOn.negligible_parityWordAdvantage {msgLen keyLen : ℕ → ℕ} {encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)} (hsec : DEMOneTimeKeyINDCPAOn (fun (n : ℕ) (x m₀ m₁ : List Bool) => m₀.length == msgLen n && m₁.length == msgLen n) Turing.MultiTapeTM.encBits keyLen encryptSym) (hmsgLen : Turing.MultiTapeTM.ComputableInPolyTime msgLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hpos : ∀ (n : ℕ), 1 ≤ msgLen n) {A : ℕ → List Bool → ProbComp Bool} (hA : Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool fun (x : ℕ × List Bool) => match x with | (n, ct) => A n ct) :
Negligible (parityWordAdvantage msgLen keyLen encryptSym A)

Theorem 2.8 ([BS23], Section 2.2.3.2, p. 21): a semantically secure cipher with message space {0, 1}^L is secure against parity prediction. Here L = msgLen n at security parameter n, with 1 ≤ msgLen n (the book leaves 1 ≤ L implicit: at L = 0 the parity is constant and the conclusion fails) and msgLen computable in polynomial time in unary. The premise is semantic security in Attack Game 2.1 (Definition 2.2, p. 16) with a uniform keyLen n-bit key, against uniform strict PPT two-stage adversaries, for exactly the challenge pairs of the message space: two msgLen n-bit messages. The conclusion: every uniform strict PPT predictor A, given 1ⁿ and the ciphertext of a uniform msgLen n-bit message, has negligible advantage |Pr[W] - 1 / 2| in Attack Game 2.3 (parityWordAdvantage). The reduction parityWordToDEMAdversary is certified by isPPT_parityWordToDEMAdversary, and parityWordAdvantage_eq_half_mul_demKeyGameOn is the proof's exact equation.