Documentation

CslibFrontier.Crypto.Computational.Encryption.Cipher

Symmetric ciphers and one-time security #

A symmetric cipher Cipher K M C has typed keys, messages and ciphertexts. Encryption under a key is a probabilistic program, and decryption is a function that returns none on a ciphertext it rejects. The cipher carries no key generation: the security game draws the key from a sampler, so one cipher serves as the data encapsulation mechanism (DEM) of a KEM–DEM hybrid, whose key comes from the KEM. Correctness is a separate property (Cipher.Correct).

Cipher.oneTimeExperiment is the one-time chosen-plaintext experiment of a fixed cipher ([BS23], Section 2.2, Attack Game 2.1, p. 16): draw a key from sampleKey and run the left-or-right experiment lrExperiment under it. The adversary is a TwoStage adversary whose first stage receives no public input; the admissibility predicate valid decides which challenge pairs are allowed, and an inadmissible pair outputs false on both sides. Semantic security (Definition 2.2) asks that the advantage between the two sides be negligible; the asymptotic statement and the efficiency of the adversary sit on top of this experiment.

Main definitions #

References #

structure Cslib.Crypto.Cipher (K M C : Type) :

A symmetric cipher with keys K, messages M and ciphertexts C: probabilistic encryption under a key and decryption that may reject. Keys are drawn by the game that uses the cipher.

  • encrypt : K → M → ProbComp C

    Encryption of a message under a key.

  • decrypt : K → C → Option M

    Decryption of a ciphertext with a key; none rejects the ciphertext.

def Cslib.Crypto.Cipher.Correct {K M C : Type} (E : Cipher K M C) :

A cipher is correct when decryption recovers every encrypted message: for every key, message and ciphertext that encryption of the message under the key can output, decryption with the same key returns the message.

def Cslib.Crypto.Cipher.oneTimeExperiment {K M C σ : Type} (E : Cipher K M C) (sampleKey : ProbComp K) (valid : M → M → Bool) (A : TwoStage Unit (MessagePair M) C Bool σ) (b : Bool) :

The one-time chosen-plaintext experiment of the cipher E with keys drawn from sampleKey and challenge-pair admissibility predicate valid ([BS23], Section 2.2, Attack Game 2.1, p. 16). Draw a key and run the left-or-right experiment under it: the adversary chooses two messages with no public input; if valid m₀ m₁ holds, the challenger encrypts the message selected by b and returns the adversary's guess, and otherwise it returns false. The key is never passed to the adversary.