Documentation

CatCryptCore.Crypto.SecurityDefs

Standard Security Definitions #

This file provides abstract security definitions for the most common cryptographic security notions. These serve as a reference catalog and provide reusable building blocks for security proofs.

Main definitions #

Indistinguishability #

Pseudorandomness #

Authentication #

Concrete instantiations #

These abstract definitions are instantiated in the example files:

References #

IND-CPA: Indistinguishability under Chosen Plaintext Attack #

IND-CPA game for a symmetric encryption scheme.

The adversary chooses two messages and receives an encryption of one. The game returns the ciphertext; the adversary tries to guess which message was encrypted.

  • INDCPA_Game E m₀ m₁ true — encrypts m₀ (left/real)
  • INDCPA_Game E m₀ m₁ false — encrypts m₁ (right/ideal)
Equations
Instances For

    IND-CPA advantage: distinguishing probability between left and right.

    Equations
    Instances For

      IND-CCA: Indistinguishability under Chosen Ciphertext Attack #

      IND-CCA extends IND-CPA by handing the adversary a decryption oracle on ciphertexts other than the challenge. In this single-shot SPComp game framework a decryption oracle is faithfully modelled as an ordinary Lean function E.Ciphertext → SPComp (Option E.Plaintext) that closes over the game's secret key k; the CCA2 "may not query the challenge" restriction is enforced by the guard if c = cStar then none else E.decrypt k c. No oracle-state threading is needed because decryption is stateless — it only reads the key. The adversary takes the oracle as an explicit argument and may call it on any ciphertext, so the oracle is genuinely reachable (not a dead argument).

      The restricted (off-challenge) decryption oracle used by the IND-CCA game: decrypt with the real key k, except reject (none) the challenge ciphertext cStar itself. This is the CCA2 restriction.

      Equations
      Instances For

        The ideal always-reject decryption oracle: every ciphertext is rejected. This is the oracle of an ideal authenticated-encryption scheme, against which the real oracle is compared to measure ciphertext-integrity.

        Equations
        Instances For

          IND-CCA game (CCA2, find-then-guess with a fixed message pair). The adversary A receives the challenge ciphertext together with the off-challenge decryption oracle ccaDecOracle E k cStar, and outputs a guess bit.

          • INDCCA_Game E m₀ m₁ true A — encrypts m₀ (left/real)
          • INDCCA_Game E m₀ m₁ false A — encrypts m₁ (right/ideal)
          Equations
          Instances For

            IND-CCA advantage: distinguishing probability between the m₀- and m₁-worlds when the adversary has decryption-oracle access.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              The IND-CCA game with the real decryption oracle replaced by the ideal always-reject oracle. Since the reject oracle ignores the key, this game collapses to an IND-CPA game whose adversary ignores its (useless) oracle (see INDCCA_rejectGame_eq).

              Equations
              Instances For
                theorem CatCrypt.Crypto.SecurityDefs.INDCCA_rejectGame_eq (E : EncScheme) (m₀ m₁ : E.Plaintext) (b : Bool) (A : (E.CiphertextCore.SPComp (Option E.Plaintext))E.CiphertextCore.SPComp Bool) :
                INDCCA_rejectGame E m₀ m₁ b A = (INDCPA_Game E m₀ m₁ b).bind fun (c : E.Ciphertext) => A (rejectDecOracle E) c

                The always-reject IND-CCA game is exactly an IND-CPA game post-composed with the adversary reading its useless oracle: the reject oracle ignores the key, so the challenge production factors out by monad associativity.

                PRF: Pseudorandom Function #

                A pseudorandom function family.

                Instances For

                  PRF real game: evaluate PRF with random key.

                  Equations
                  Instances For

                    PRF ideal game: return a uniformly random value.

                    Equations
                    Instances For

                      PRF advantage: distinguishing PRF output from random.

                      Equations
                      Instances For

                        MAC: Message Authentication Code #

                        A message authentication code scheme.

                        Instances For
                          noncomputable def CatCrypt.Crypto.SecurityDefs.EUF_CMA_Real (M : MACScheme) (m m_star : M.Message) (t_star : M.Tag) :

                          EUF-CMA real game (simplified, single-query): adversary receives a tag on message m and tries to forge on m*.

                          Returns true if the adversary's forgery attempt verifies.

                          Equations
                          Instances For
                            noncomputable def CatCrypt.Crypto.SecurityDefs.EUF_CMA_Adv (M : MACScheme) (m m_star : M.Message) (t_star : M.Tag) (A : BoolCore.SPComp Bool) :

                            EUF-CMA advantage: probability of successful forgery.

                            Equations
                            Instances For

                              Advantage Bounds #

                              If a PRF is perfect (PRF output = random for all inputs), PRF advantage is 0.

                              If encryption is perfectly indistinguishable, IND-CPA advantage is 0.

                              If the two IND-CCA oracle-games are perfectly indistinguishable, the IND-CCA advantage is 0. Note the hypothesis quantifies over the whole oracle-game (adversary and decryption oracle included); for a genuinely confidential scheme with two distinct messages it is only met degenerately (e.g. m₀ = m₁), because the decryption oracle's answers depend on the secret key.

                              theorem CatCrypt.Crypto.SecurityDefs.INDCCA_reduces_to_INDCPA (E : EncScheme) (m₀ m₁ : E.Plaintext) (A : (E.CiphertextCore.SPComp (Option E.Plaintext))E.CiphertextCore.SPComp Bool) :
                              INDCCA_Adv E m₀ m₁ A (Advantage (INDCCA_Game E m₀ m₁ true A) (INDCCA_rejectGame E m₀ m₁ true A) + INDCPA_Adv E m₀ m₁ fun (c : E.Ciphertext) => A (rejectDecOracle E) c) + Advantage (INDCCA_rejectGame E m₀ m₁ false A) (INDCCA_Game E m₀ m₁ false A)

                              IND-CCA reduces to IND-CPA plus decryption-oracle integrity. For any encryption scheme, the IND-CCA advantage is bounded by

                              • the two authenticity gaps — the advantage of distinguishing the real decryption oracle from the always-reject oracle, in each world — plus
                              • the IND-CPA advantage of the adversary that ignores its (reject) oracle.

                              This is the standard "authenticated encryption = confidentiality + integrity" decomposition, proved here purely from the triangle inequality for advantage: routing through the two always-reject games, whose difference is an IND-CPA game (INDCCA_rejectGame_eq). The two authenticity gaps are exactly the ciphertext-integrity (MAC-unforgeability) terms.