Documentation

CatCryptCore.Examples.MAC

Bijection-Family MAC: Optimal Information-Theoretic Unforgeability #

A message-authentication code built from a bijection family achieves the information-theoretically optimal forgery probability 1 / |Tag|. Following Rosulek, The Joy of Cryptography, §9 (MACs).

For each message m, if the map k ↦ mac k m is a bijection from keys to tags, then over a uniform key the tag mac k m is uniform on the tag space. A fixed forgery attempt (m*, t*) therefore verifies for exactly one key, so the single-query EUF-CMA game accepts the forgery with probability exactly 1 / |Tag| — the smallest a forger can be forced below by an honest random tag, and the best any |Tag|-tag MAC can achieve against a blind guess.

Overview #

This mirrors the bijection-coupling examples (CatCrypt.Examples.OTP, CatCrypt.Examples.PRF). Where those collapse a distinguishing advantage to 0, a MAC's forgery probability is not 0 (a forger may always guess a tag); the sharp statement is that it equals 1 / |Tag|. The forgery probability is a prTrue of the real game, computed by prTrue_sample_pure_bool: it counts the keys under which the forgery verifies, divided by |Key|. The bijection makes that count exactly 1, and |Key| = |Tag| since bij m* is an equivalence.

Main definitions #

Main results #

References #

Bijection-Family MAC #

A MAC given by a family of bijections bij m : KeyTag, one per message.

For a uniform key, bij m maps the uniform key distribution onto the uniform tag distribution, which forces the forgery probability down to 1 / |Tag|.

Instances For

    The core MACScheme induced by a bijection family: mac k m = bij m k, verification recomputing and comparing (the MACScheme default).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem CatCrypt.Examples.MAC.toMACScheme_mac (B : BijMACFamily) (k : B.Key) (m : B.Message) :
      B.toMACScheme.mac k m = (B.bij m) k
      @[simp]
      theorem CatCrypt.Examples.MAC.toMACScheme_verify (B : BijMACFamily) (k : B.Key) (m : B.Message) (t : B.Tag) :
      B.toMACScheme.verify k m t = (t == (B.bij m) k)

      Forgery Probability #

      theorem CatCrypt.Examples.MAC.bijMAC_forgery_filter (B : BijMACFamily) (m_star : B.Message) (t_star : B.Tag) :
      {k : B.Key | B.toMACScheme.verify k m_star t_star = true}.card = 1

      A fixed forgery attempt (m*, t*) verifies under exactly one key: the map k ↦ bij m* k is a bijection, so bij m* k = t* pins k = (bij m*).symm t*.

      Optimal forgery probability. For a bijection-family MAC the single-query EUF-CMA game accepts a fixed forgery (m*, t*) with probability exactly 1 / |Tag|.

      The real game samples a key k and returns verify k m* t* = (t* == bij m* k); prTrue_sample_pure_bool turns this into #{k | forgery verifies} / |Key|. The forgery verifies for exactly one k (bijMAC_forgery_filter), and |Key| = |Tag| because bij m* is an equivalence.

      Forgery probability through the core EUF_CMA_Adv game. With the identity forger (no post-processing of the verification bit), the bijection-family MAC's EUF-CMA advantage is exactly 1 / |Tag|.

      Example: the XOR MAC over Bool #

      mac k m = k ⊕ m is the bijection family m ↦ boolXorBij m; it is the MAC counterpart of the one-time pad and the XOR PRF, and attains the optimal 1-bit forgery probability 1 / 2.

      The XOR MAC over Bool as a bijection family: bij m = boolXorBij m.

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

        The Bool XOR MAC has forgery probability exactly 1 / 2.