Documentation

CslibFrontier.Crypto.Computational.Encryption.SymmetricCPA

Symmetric chosen-plaintext security on a message space #

A symmetric cipher in [BS23] is defined over a message space M. Its CPA attack game (Section 5.3, Attack Game 5.2, printed pp. 181–182) lets the adversary submit any number of pairs m₀, m₁ ∈ M of the same length, and the challenger answers all of them under one key. SymmetricCipher.cpaGame fixes M to the n-bit words at security parameter n. Block-cipher modes need longer messages; randomized counter mode (Section 5.4.2, printed p. 189), for example, encrypts sequences of blocks.

This module states the attack game for raw key-generation and encryption algorithms with an admissibility predicate valid n m₀ m₁ on challenge pairs, as Encryption.INDCPAOn does for public-key encryption. A request whose pair is inadmissible is answered with the empty word and does not invoke encrypt. SymmetricINDCPAOn asks that every uniform strict oracle-PPT distinguisher have negligible advantage between the two challenge bits. Correctness and efficiency of the honest algorithms are separate properties.

SymmetricCipher.cpaGame and SymmetricCipher.INDCPA in Authenticated.lean are defined as the special case of n-bit pairs. blockPairValid admits equal-length pairs made of whole n-bit blocks: the message space Y^{≤ℓ} of Section 5.4.2 without the cap ℓ on the number of blocks.

Main definitions #

References #

noncomputable def Cslib.Crypto.symmetricCPAReplyOn (valid : ℕ → List Bool → List Bool → Bool) (encrypt : ℕ → List Bool → List Bool → ProbComp (List Bool)) (n : ℕ) (k : List Bool) (bit : Bool) (request : Unit × List Bool) :

The left-or-right encryption oracle with challenge-pair predicate valid ([BS23], Section 5.3, Attack Game 5.2): decode m₀ = unframe request.2 and m₁ = dropFrame request.2; if valid n m₀ m₁ holds, encrypt if bit then m₁ else m₀ under k, and otherwise answer [] without encrypting.

noncomputable def Cslib.Crypto.symmetricCPAGameOn (valid : ℕ → List Bool → List Bool → Bool) (keyGen : ℕ → ProbComp (List Bool)) (encrypt : ℕ → List Bool → List Bool → ProbComp (List Bool)) (adversary : OracleDistinguisher) (bit : Bool) (n : ℕ) :

The many-query left-or-right CPA experiment with challenge-pair predicate valid ([BS23], Section 5.3, Attack Game 5.2): sample k ← keyGen n and run adversary n [] with oracle symmetricCPAReplyOn valid encrypt n k bit.

def Cslib.Crypto.SymmetricINDCPAOn (valid : ℕ → List Bool → List Bool → Bool) (keyGen : ℕ → ProbComp (List Bool)) (encrypt : ℕ → List Bool → List Bool → ProbComp (List Bool)) :

Adaptive chosen-plaintext security on the challenge pairs admitted by valid ([BS23], Section 5.3, Definition 5.2): every uniform strict IsOraclePPT encBool distinguisher has negligible advantage between the experiments with challenge bits false and true. The negligible bound may depend on the distinguisher, which is fixed before the parameter.

def Cslib.Crypto.blockPairValid (n : ℕ) (m₀ m₁ : List Bool) :

Equal-length challenge pairs made of whole n-bit blocks. At n = 0 only the pair of empty messages is admitted.