Documentation

CslibFrontier.Crypto.Computational.Encryption.RealIdealAE

Real/Ideal Authenticated Encryption #

For encryption queries on n-bit messages, real/ideal authenticated encryption is equivalent to adaptive left-or-right CCA security together with fresh-plaintext unforgeability. This is a fixed-length variant of Katz and Lindell, Theorem 5.5.

A uniform strict oracle-PPT adversary has encryption and decryption channels. A real encryption query returns a fresh encryption of the message. The real decryption channel rejects ciphertexts returned by earlier encryptions and otherwise returns the encoded result of E.decrypt. The ideal encryption channel encrypts the all-zero message, and ideal decryption always rejects.

Main definitions #

Main results #

Relation to Katz and Lindell #

References #

The real and ideal worlds #

Real-world oracle of the authenticated-encryption experiment (Katz and Lindell, Definition 5.4). Its state is the list of ciphertexts returned so far.

  • On an encryption query (false, msg) with msg.length = n, encrypt msg under k, record the ciphertext and return it; on other lengths return [].
  • On a decryption query (true, ct), return [] if ct was returned by an earlier encryption query, and encOption encBits (E.decrypt n k ct) otherwise.

Ideal-world oracle of the authenticated-encryption experiment (Katz and Lindell, Definition 5.4): an encryption query (false, msg) with msg.length = n returns an encryption of the all-zero message List.replicate n false, other encryption queries return [], and every decryption query (true, _) returns [], the encoding of rejection.

The real-world authenticated-encryption experiment: sample k ← E.keyGen n and run adversary n [] against E.aeRealOracle n k, starting with no recorded ciphertexts.

The ideal-world authenticated-encryption experiment: sample k ← E.keyGen n and run adversary n [] against E.aeIdealOracle n k.

Real/ideal authenticated encryption for n-bit encryption queries, following Katz and Lindell, §5.2.1, Definition 5.4, pp. 152–153. Every uniform strict oracle-PPT adversary has negligible two-world advantage. Both worlds reject decryption of earlier encryption replies, which the source forbids querying, and the advantage is twice the absolute deviation of the source's hidden-bit guessing probability from 1/2.

Real/ideal security implies CPA security #

Stateful handler for cpaToAEAdversary: a left-or-right request req whose two messages unframe req and dropFrame req both have length n is sent to the encryption channel as (false, if bit then dropFrame req else unframe req), with the reply truncated to ctBound; other requests return [].

noncomputable def Cslib.Crypto.SymmetricCipher.cpaToAEAdversary (ctBound : ℕ → ℕ) (bit : Bool) (adversary : OracleDistinguisher) :

Reduction from cpaGame to the real/ideal experiment: run the CPA distinguisher against cpaToAEHandler n (ctBound n) bit, which answers each left-or-right request by encrypting the message chosen by the fixed bit.

theorem Cslib.Crypto.SymmetricCipher.eval_aeRealGame_cpaToAEAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : OracleDistinguisher) (bit : Bool) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.aeRealGame (cpaToAEAdversary ctBound bit adversary) n).eval = (E.cpaGame adversary bit n).eval

When ctBound n bounds the ciphertext lengths of n-bit messages, running cpaToAEAdversary ctBound bit adversary in the real world has the same output distribution as running adversary in cpaGame with challenge bit bit.

theorem Cslib.Crypto.SymmetricCipher.advantage_cpaGame_le_aeRealGame_aeIdealGame (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : OracleDistinguisher) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
Game.advantage (E.cpaGame adversary false n).eval (E.cpaGame adversary true n).eval ≤ Game.advantage (E.aeRealGame (cpaToAEAdversary ctBound false adversary) n).eval (E.aeIdealGame (cpaToAEAdversary ctBound false adversary) n).eval + Game.advantage (E.aeRealGame (cpaToAEAdversary ctBound true adversary) n).eval (E.aeIdealGame (cpaToAEAdversary ctBound true adversary) n).eval

The CPA advantage of adversary is at most the sum of the real/ideal advantages of cpaToAEAdversary ctBound false adversary and cpaToAEAdversary ctBound true adversary, when ctBound n bounds the ciphertext lengths of n-bit messages.

Real/ideal authenticated encryption implies adaptive CPA security (INDCPA).

Real/ideal security implies ciphertext integrity #

Stateful handler for ciToAEAdversary: send each encryption request of the CI adversary to the encryption channel, truncating the reply to ctBound.

noncomputable def Cslib.Crypto.SymmetricCipher.ciToAEAdversary (ctBound : ℕ → ℕ) (adversary : CIAdversary) :

Reduction from ciGame to the real/ideal experiment: run the CI adversary with its encryption requests sent to the encryption channel, submit its candidate ciphertext to the decryption channel, and output true exactly when the reply encodes an accepted decryption.

theorem Cslib.Crypto.SymmetricCipher.eval_aeRealGame_ciToAEAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : CIAdversary) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.aeRealGame (ciToAEAdversary ctBound adversary) n).eval = (E.ciGame adversary n).eval

When ctBound n bounds the ciphertext lengths of n-bit messages, ciToAEAdversary ctBound adversary outputs true in the real world exactly as often as adversary wins ciGame.

In the ideal world, ciToAEAdversary ctBound adversary always outputs false.

theorem Cslib.Crypto.SymmetricCipher.succProbability_ciGame_eq_advantage_aeRealGame_aeIdealGame (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : CIAdversary) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
Game.succProbability (E.ciGame adversary n).eval = Game.advantage (E.aeRealGame (ciToAEAdversary ctBound adversary) n).eval (E.aeIdealGame (ciToAEAdversary ctBound adversary) n).eval

The CI winning probability of adversary equals the real/ideal advantage of ciToAEAdversary ctBound adversary, when ctBound n bounds the ciphertext lengths of n-bit messages.

Real/ideal authenticated encryption implies ciphertext integrity (CiphertextIntegrity).

CCA security and ciphertext integrity imply real/ideal security #

noncomputable def Cslib.Crypto.SymmetricCipher.aeToCCAHandler (n ctBound : ℕ) (decBound : ℕ → List Bool → ℕ) (request : Bool × List Bool) :

Stateful handler for aeToCCAAdversary. A decryption request (true, ct) is sent to the CCA decryption channel, with the reply truncated to decBound n ct. An encryption request (false, msg) is sent to the CCA encryption channel as the left-or-right request frame msg ++ List.replicate n false, whose left message is msg and whose right message is the all-zero message, with the reply truncated to ctBound.

noncomputable def Cslib.Crypto.SymmetricCipher.aeToCCAAdversary (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : CCAAdversary) :

Reduction from the real/ideal experiment to ccaGame: run the real/ideal adversary against aeToCCAHandler, which turns each encryption request into a left-or-right request between the message and the all-zero message. With challenge bit false the adversary sees the real world; with challenge bit true and every decryption rejected (ccaRejectGame) it sees the ideal world.

theorem Cslib.Crypto.SymmetricCipher.eval_ccaGame_aeToCCAAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : CCAAdversary) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) (hdecBound : ∀ k ∈ (E.keyGen n).eval.support, ∀ (ct : List Bool), ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (E.decrypt n k ct)).length ≤ decBound n ct) :
(E.ccaGame (aeToCCAAdversary ctBound decBound adversary) false n).eval = (E.aeRealGame adversary n).eval

When ctBound n and decBound n bound the ciphertext and decryption-reply lengths, running aeToCCAAdversary ctBound decBound adversary in ccaGame with challenge bit false has the same output distribution as running adversary in the real world.

theorem Cslib.Crypto.SymmetricCipher.eval_ccaRejectGame_aeToCCAAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : CCAAdversary) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.ccaRejectGame (aeToCCAAdversary ctBound decBound adversary) true n).eval = (E.aeIdealGame adversary n).eval

When ctBound n bounds the ciphertext lengths of n-bit messages, running aeToCCAAdversary ctBound decBound adversary in ccaRejectGame with challenge bit true has the same output distribution as running adversary in the ideal world.

theorem Cslib.Crypto.SymmetricCipher.advantage_aeRealGame_aeIdealGame_le (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (aeToCCAAdversary ctBound decBound adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) (hdecBound : ∀ k ∈ (E.keyGen n).eval.support, ∀ (ct : List Bool), ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (E.decrypt n k ct)).length ≤ decBound n ct) :
↑(Game.advantage (E.aeRealGame adversary n).eval (E.aeIdealGame adversary n).eval) ≤ ↑(Game.advantage (E.ccaGame (aeToCCAAdversary ctBound decBound adversary) false n).eval (E.ccaGame (aeToCCAAdversary ctBound decBound adversary) true n).eval) + ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciGame (ccaToCIAdversary ctBound Qd true (aeToCCAAdversary ctBound decBound adversary)) n).eval)

Real/ideal advantage bound. If aeToCCAAdversary ctBound decBound adversary makes at most Qd n decryption queries, and ctBound n and decBound n bound the ciphertext and decryption-reply lengths, then the real/ideal advantage of adversary is at most the CCA advantage of that reduction plus dyadicSize (Qd n - 1) times the CI winning probability of ccaToCIAdversary built from it.

CCA security and ciphertext integrity imply real/ideal security.

The equivalences #

Real/ideal security implies the library's AuthenticatedEncryption (INDCPA ∧ CiphertextIntegrity).

Real/ideal security implies adaptive left-or-right CCA security.

The library's AuthenticatedEncryption implies real/ideal security.

Real/ideal security is equivalent to CCA security and integrity against fresh ciphertexts.

Fixed-length variant of Katz and Lindell, §5.2.1, Theorem 5.5, p. 153. Real/ideal security on n-bit encryption queries is equivalent to adaptive left-or-right CCA security and unforgeability for a fresh plaintext. Definition 5.1 uses a single challenge pair with ordinary encryption and decryption oracles.

Real/ideal security is equivalent to the library's AuthenticatedEncryption.