Encryption Scheme Definition #
This file defines the structure of symmetric encryption schemes for use in cryptographic security proofs.
Main definitions #
EncScheme- A symmetric encryption scheme with key generation, encryption, and decryptionEncScheme.Correct- Correctness property: decryption inverts encryptionEncScheme.IsDeterministic- Predicate for deterministic encryptionProbEncScheme- Probabilistic encryption with explicit randomnessDetEncScheme- Deterministic encryption scheme
References #
- [Bellare & Rogaway, Introduction to Modern Cryptography]
- [Katz & Lindell, Introduction to Modern Cryptography]
A symmetric encryption scheme.
An encryption scheme consists of:
- Key, Plaintext, and Ciphertext types
- A probabilistic key generation algorithm
- A probabilistic encryption algorithm
- A probabilistic decryption algorithm
The type requirements (Fintype, Nonempty) are needed for:
- Key: uniform sampling in key generation
- Ciphertext: supporting one-time pad style encryption where ciphertexts are sampled/XORed with keys
Note: Decryption returns Option Plaintext to handle decryption failures
(e.g., authenticated encryption modes).
- Key : Type
Key type
- Plaintext : Type
Plaintext type
- Ciphertext : Type
Ciphertext type
Keys form a finite type (for uniform sampling)
Keys are nonempty (for uniform sampling)
- finCt : Fintype self.Ciphertext
Ciphertexts form a finite type (for OTP-style constructions)
- neCt : Nonempty self.Ciphertext
Ciphertexts are nonempty (for OTP-style constructions)
- keyGen : Core.SPComp self.Key
Probabilistic key generation
- encrypt : self.Key → self.Plaintext → Core.SPComp self.Ciphertext
Probabilistic encryption
- decrypt : self.Key → self.Ciphertext → Core.SPComp (Option self.Plaintext)
Probabilistic decryption (may fail)
Instances For
Correctness Property #
Correctness: decryption of encryption returns the original message.
For a deterministic scheme, this means: ∀ k m, decrypt k (encrypt k m) = some m
For probabilistic schemes, we require that for any randomness used in encryption, decryption recovers the original message. We express this using support membership.
Note: This requires that for all ciphertexts c in the support of encrypt k m, decryption returns some m.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Strong correctness: decryption always succeeds and returns original message. This is expressed as equality of distributions after bind.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Determinism #
Deterministic encryption: encrypt is a pure function of key and message. The encryption produces a single deterministic ciphertext.
Equations
- E.IsDeterministic = ∃ (f : E.Key → E.Plaintext → E.Ciphertext), ∀ (k : E.Key) (m : E.Plaintext), E.encrypt k m = CatCrypt.Core.SPComp.pure (f k m)
Instances For
Deterministic decryption: decrypt is a pure function of key and ciphertext.
Equations
- E.HasDeterministicDecrypt = ∃ (f : E.Key → E.Ciphertext → Option E.Plaintext), ∀ (k : E.Key) (c : E.Ciphertext), E.decrypt k c = CatCrypt.Core.SPComp.pure (f k c)
Instances For
A fully deterministic scheme has both deterministic encryption and decryption.
Equations
Instances For
Simple Correctness for Deterministic Schemes #
Simple correctness condition for schemes with deterministic encrypt/decrypt. This is easier to prove and implies the general Correct property.
Equations
Instances For
If a scheme has deterministic encrypt/decrypt satisfying SimpleCorrect, then it satisfies the general Correct property.
Deterministic Encryption Scheme #
A deterministic encryption scheme where encryption and decryption are pure functions. This is a special case useful for schemes like OTP, block ciphers, etc.
- Key : Type
Key type
- Plaintext : Type
Plaintext type
- Ciphertext : Type
Ciphertext type
Keys form a finite type (for uniform sampling)
Keys are nonempty (for uniform sampling)
- finCt : Fintype self.Ciphertext
Ciphertexts form a finite type
- neCt : Nonempty self.Ciphertext
Ciphertexts are nonempty
- encryptF : self.Key → self.Plaintext → self.Ciphertext
Deterministic encryption function
- decryptF : self.Key → self.Ciphertext → Option self.Plaintext
Deterministic decryption function
Instances For
Convert a deterministic scheme to a general encryption scheme.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Encryption is injective in the message for each key.
Equations
Instances For
Correctness implies encryption is injective.
A correct deterministic scheme gives a correct general scheme.
Probabilistic Encryption Scheme with Explicit Randomness #
A probabilistic encryption scheme with explicit randomness. This models schemes like ElGamal, RSA-OAEP, etc. where encryption uses random coins that can be made explicit.
- finCt : Fintype self.Ciphertext
- neCt : Nonempty self.Ciphertext
- keyGen : Core.SPComp self.Key
- encrypt : self.Key → self.Plaintext → Core.SPComp self.Ciphertext
- decrypt : self.Key → self.Ciphertext → Core.SPComp (Option self.Plaintext)
- Randomness : Type
Randomness type used in encryption
- finRand : Fintype self.Randomness
Randomness is finite (for uniform sampling)
- neRand : Nonempty self.Randomness
Randomness is nonempty
- encryptR : self.Key → self.Plaintext → self.Randomness → self.Ciphertext
Deterministic encryption with explicit randomness
- encrypt_eq (k : self.Key) (m : self.Plaintext) : self.encrypt k m = do let r ← Core.SPComp.sample self.Randomness Core.SPComp.pure (self.encryptR k m r)
Probabilistic encryption samples randomness and applies encryptR
Instances For
Correctness for probabilistic schemes: for all randomness, decrypt recovers message. This uses the base scheme's Correct property specialized to the encrypted ciphertext.
Instances For
Simple correctness when decryption is also deterministic.
Equations
- P.SimpleCorrect decryptF = ∀ (k : P.Key) (m : P.Plaintext) (r : P.Randomness), decryptF k (P.encryptR k m r) = some m
Instances For
Basic Lemmas #
A deterministic scheme is IsDeterministic.
A deterministic scheme has deterministic decryption.
A deterministic scheme is fully deterministic.