Documentation

CatCryptCore.Examples.BasicHash

Basic Hash Protocol: Perfect Authentication and the Unlinkability Counterexample #

The Basic Hash RFID protocol from the proof-ladders benchmark. A tag holding a key k answers a reader challenge nonce n with the pair (n, H(k, n)); the reader recomputes H(k, n) and accepts iff it matches.

This file establishes the two distinctive facts of the challenge for the XOR hash H(k, n) = k ⊕ n:

  1. Perfect authentication. For a bijection family hash — one where k ↦ H(k, n) is a bijection for each fixed nonce n — the authentication advantage of every adversary is exactly 0. The XOR hash is such a family (k ↦ k ⊕ n is a bijection), so it authenticates perfectly. The argument is the bijection-coupling technique shared with CatCrypt.Examples.OTP and CatCrypt.Examples.PRF: over a uniform key, H(k, n) is uniform and independent of n, coupling the real game with a fresh uniform sample.

  2. The unlinkability counterexample. Perfect single-session authentication does not give multi-session unlinkability. The XOR outputs across two sessions are correlated: with a shared key, H(k, n₁) ⊕ H(k, n₂) = n₁ ⊕ n₂ deterministically. A distinguisher testing this fixed relation succeeds with certainty against the shared-key (real) game, whereas against independent keys the same relation can fail — so the two unlinkability games are distinguishable. This is why unlinkability needs a genuine PRF, not merely a bijection family.

Main definitions #

Main results #

References #

Type Definitions #

@[reducible, inline]

Word type (base type for keys, nonces, responses).

Equations
Instances For

    Hash Function #

    A keyed hash function for the Basic Hash protocol.

    • h : WordWordWord

      The hash function: key → nonce → response.

    Instances For

      Protocol Operations #

      Tag session: sample a fresh nonce and compute the hash response.

      Equations
      Instances For

        Reader verification: check that the response matches the expected hash.

        Equations
        Instances For

          XOR Hash #

          XOR-based hash: H(k, n) = k ⊕ n.

          This is a perfect single-query hash (a bijection family) but fails unlinkability across sessions.

          Equations
          Instances For

            XOR hash verification is correct: a tag's own response always verifies.

            Authentication Game #

            Authentication real game: sample a key and compute H(k, n) for the challenge nonce n.

            Equations
            Instances For

              Authentication ideal game: return a uniformly random response.

              Equations
              Instances For

                Authentication advantage: distinguishing a real response from random.

                Equations
                Instances For

                  Perfect authentication: the real and ideal games are perfectly indistinguishable (coupled by eqPost).

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

                    Authentication Security Proofs #

                    theorem CatCrypt.Examples.BasicHash.auth_perfect_bij (H : HashFunc) (hbij : ∀ (n : Word), Function.Bijective fun (x : Word) => H.h x n) :

                    Any hash whose per-nonce map k ↦ H(k, n) is a bijection achieves perfect authentication: the bijection carries the uniform key onto a uniform output, coupling the real game with the ideal uniform sample.

                    The XOR hash has perfect authentication: k ↦ k ⊕ n is a bijection for each nonce n.

                    Perfect authentication implies zero advantage for every adversary.

                    The XOR hash authenticates perfectly: zero authentication advantage for every nonce and every adversary.

                    Unlinkability Game (2 Sessions) #

                    Unlinkability asks whether an adversary can tell if two sessions share a key. The real game uses one key for both sessions; the ideal game uses independent keys. Perfect authentication constrains only a single session, and — as the counterexample below shows — says nothing about correlation across sessions.

                    XOR Hash Unlinkability Counterexample #

                    The XOR outputs of two sessions under a shared key satisfy the fixed relation H(k,n₁) ⊕ H(k,n₂) = n₁ ⊕ n₂, independent of the key. A distinguisher testing this relation accepts the real game with certainty; against independent keys it can reject. Hence the XOR hash — though a perfect authenticator — is not unlinkable, motivating a genuine PRF for multi-session privacy.

                    theorem CatCrypt.Examples.BasicHash.xorHash_correlated (k n1 n2 : Word) :
                    (k ^^ n1 ^^ (k ^^ n2)) = (n1 ^^ n2)

                    Key-correlation leak: with a shared key the XOR of the two responses is a fixed function of the nonces, independent of the key. This is the structural weakness that breaks unlinkability.