Documentation

CatCryptCore.Examples.EncryptThenMAC

Encrypt-then-MAC: a composed authenticated-encryption scheme #

Encrypt-then-MAC is the standard construction that turns a confidentiality-only encryption scheme into an authenticated one: encrypt the message, then MAC the resulting ciphertext, and transmit (ciphertext, tag). Decryption first checks the tag and only decrypts if it verifies. Following Rosulek, The Joy of Cryptography, §9-10 (MACs and authenticated encryption; Construction 10.9, Claim 10.10).

This file gives the construction as a combinator on core's EncScheme, proves its correctness generically, and then studies the XOR / one-time-pad instantiation, for which it achieves perfect IND-CPA security (advantage exactly 0).

The construction #

Given an encryption scheme E and a MAC macF : MacKey → E.Ciphertext → Tag, EtM E … macF is the scheme with

Main results #

On the Adv_CCA ≤ Adv_MAC + Adv_CPA + Adv_MAC bound #

The general Encrypt-then-MAC theorem bounds the authenticated (IND-CCA) advantage by the MAC's forging advantage plus the base scheme's IND-CPA advantage. Core currently exposes an IND-CPA game (INDCPA_Game) but no IND-CCA game, so the cleanest core-provable headline is the perfect IND-CPA security of the XOR instantiation, proved by the bijection-coupling technique of OneTimePad.lean.

References #

The Encrypt-then-MAC combinator #

noncomputable def CatCrypt.Examples.EncryptThenMAC.EtM (E : Crypto.EncScheme) (MacKey Tag : Type) [Fintype MacKey] [Nonempty MacKey] [Fintype Tag] [Nonempty Tag] [DecidableEq Tag] (macF : MacKeyE.CiphertextTag) :

Encrypt-then-MAC. Given an encryption scheme E and a deterministic MAC macF : MacKey → E.Ciphertext → Tag, produce the authenticated scheme that appends macF km c to each ciphertext c and refuses to decrypt a ciphertext whose tag does not verify.

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

    Correctness of the combinator #

    theorem CatCrypt.Examples.EncryptThenMAC.EtM_correct (E : Crypto.EncScheme) (MacKey Tag : Type) [Fintype MacKey] [Nonempty MacKey] [Fintype Tag] [Nonempty Tag] [DecidableEq Tag] (macF : MacKeyE.CiphertextTag) (hE : E.Correct) :
    (EtM E MacKey Tag macF).Correct

    Encrypt-then-MAC preserves correctness. An honestly generated ciphertext (c, macF km c) carries the matching tag, so decryption passes the tag check and falls through to E.decrypt, which recovers the message by hE.

    The XOR / one-time-pad instantiation #

    The XOR MAC over Bool: macF km c = km ⊕ c.

    Equations
    Instances For

      Encrypt-then-MAC over Bool: OTP encryption composed with the XOR MAC.

      Key = Bool × Bool (an encryption key and a MAC key), Plaintext = Bool, Ciphertext = Bool × Bool (the OTP ciphertext and its tag).

      Equations
      Instances For

        BoolEtM is correct, by EtM_correct and correctness of the one-time pad.

        Perfect IND-CPA security of the XOR instantiation #

        The BoolEtM ciphertext as a pure function of the (encryption, MAC) key pair and the message: k ↦ (k.1 ⊕ m, k.2 ⊕ (k.1 ⊕ m)).

        Equations
        Instances For

          Coupling: the two IND-CPA games for BoolEtM are equidistributed.

          The map (ke, km) ↦ (ke ⊕ (m₀ ⊕ m₁), km) is a bijection of the key space that carries the m₀-ciphertext onto the m₁-ciphertext: the OTP component becomes ke ⊕ (m₀ ⊕ m₁) ⊕ m₁ = ke ⊕ m₀, and the tag follows since it is a function of that component and the (unchanged) MAC key.

          BoolEtM has perfect IND-CPA security: every adversary has IND-CPA advantage exactly 0.