Documentation

CatCryptCore.Crypto.Encryption

Encryption Scheme Definition #

This file defines the structure of symmetric encryption schemes for use in cryptographic security proofs.

Main definitions #

References #

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).

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
        Instances For

          Deterministic decryption: decrypt is a pure function of key and ciphertext.

          Equations
          Instances For

            A fully deterministic scheme has both deterministic encryption and decryption.

            Equations
            Instances For

              Simple Correctness for Deterministic Schemes #

              def CatCrypt.Crypto.EncScheme.SimpleCorrect (E : EncScheme) (encryptF : E.KeyE.PlaintextE.Ciphertext) (decryptF : E.KeyE.CiphertextOption E.Plaintext) :

              Simple correctness condition for schemes with deterministic encrypt/decrypt. This is easier to prove and implies the general Correct property.

              Equations
              Instances For
                theorem CatCrypt.Crypto.EncScheme.correct_of_simple_correct (E : EncScheme) (encryptF : E.KeyE.PlaintextE.Ciphertext) (decryptF : E.KeyE.CiphertextOption E.Plaintext) (hEnc : ∀ (k : E.Key) (m : E.Plaintext), E.encrypt k m = Core.SPComp.pure (encryptF k m)) (hDec : ∀ (k : E.Key) (c : E.Ciphertext), E.decrypt k c = Core.SPComp.pure (decryptF k c)) (hSimple : E.SimpleCorrect encryptF decryptF) :

                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.

                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

                    Correctness for deterministic schemes: decrypt inverts encrypt.

                    Equations
                    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.

                        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.

                          Equations
                          Instances For

                            Simple correctness when decryption is also deterministic.

                            Equations
                            Instances For

                              Basic Lemmas #

                              A deterministic scheme has deterministic decryption.