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:
Perfect authentication. For a bijection family hash — one where
k ↦ H(k, n)is a bijection for each fixed noncen— the authentication advantage of every adversary is exactly0. The XOR hash is such a family (k ↦ k ⊕ nis a bijection), so it authenticates perfectly. The argument is the bijection-coupling technique shared withCatCrypt.Examples.OTPandCatCrypt.Examples.PRF: over a uniform key,H(k, n)is uniform and independent ofn, coupling the real game with a fresh uniform sample.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 #
HashFunc— a keyed hash functionWord → Word → Word.xorHash— the XOR hashH(k, n) = k ⊕ n.auth_real/auth_ideal— the authentication real/ideal games.PerfectAuth— perfect authentication as anrHoarecoupling.unlink_real/unlink_ideal— the two-session unlinkability games.unlink_distinguisher— the correlation-testing distinguisher.
Main results #
auth_perfect_bij— any bijection-family hash authenticates perfectly.auth_perfect_xor— the XOR hash authenticates perfectly.auth_zero_advantage_xor— zero authentication advantage for the XOR hash.xorHash_correlated—H(k,n₁) ⊕ H(k,n₂) = n₁ ⊕ n₂(the structural leak).unlink_real_always_true— the distinguisher always accepts the real game.unlink_ideal_not_always_true— the distinguisher can reject the ideal game.
References #
- proof-ladders protocol-ladder benchmark
- [Vaudenay, On Privacy Models for RFID]
- [Rosulek, The Joy of Cryptography, §6 (pseudorandom functions)]
Type Definitions #
Word type (base type for keys, nonces, responses).
Equations
Instances For
Hash Function #
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
- CatCrypt.Examples.BasicHash.reader_verify H k n r = decide (H.h k n = r)
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
- CatCrypt.Examples.BasicHash.xorHash = { h := fun (k n : CatCrypt.Examples.BasicHash.Word) => k ^^ n }
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 #
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.
Unlinkability real game: one shared key for both sessions.
Equations
- CatCrypt.Examples.BasicHash.unlink_real H n1 n2 = do let k ← CatCrypt.Core.SPComp.sample CatCrypt.Examples.BasicHash.Word CatCrypt.Core.SPComp.pure (H.h k n1, H.h k n2)
Instances For
Unlinkability ideal game: independent keys per session.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Unlinkability advantage.
Equations
Instances For
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.
Correlation-testing distinguisher: accept iff the XOR of the two responses equals the XOR of the two nonces (which holds exactly when the key is shared).
Equations
- CatCrypt.Examples.BasicHash.unlink_distinguisher n1 n2 (r1, r2) = CatCrypt.Core.SPComp.pure ((r1 ^^ r2) == (n1 ^^ n2))
Instances For
Against the real game the distinguisher always accepts: with a shared
key the XOR of the outputs deterministically equals the XOR of the nonces, so
the run reduces to sampling the (discarded) key and returning true.
Against the ideal game the distinguisher can reject: for distinct nonces there are independent keys making the correlation check fail, so the real and ideal unlinkability games genuinely differ.