Carter–Wegman message authentication codes from Δ-universal hashing #
Wegman and Carter [WC81] observed that an ε-almost-Δ-universal (ε-DUF / ε-AXU)
hash family hash : K → M → Y into a finite additive group Y
(Cslib.Probability.IsDeltaUniversalHash) yields an unconditional message authentication code when
each hash digest hash k m is masked by a uniform one-time pad r ∈ Y:
sign hash k r m = hash k m + r and verify hash k r m t = decide (hash k m + r = t).
For every fixed (k, m), left addition by hash k m is a bijection on Y, so t = hash k m + r
is uniform on Y and independent of k, with r = -hash k m + t. Under r = -hash k m + t, a
forgery (m', t') with m' ≠ m verifies iff hash k m' - hash k m = t' - t, which occurs with
probability at most ε over k ← seed ([BS23], Section 7.6, Lemma 7.11 and
Theorem 7.12). Because each (k, r, m) admits a unique valid tag, strong and ordinary
unforgeability coincide.
This module develops the core information-theoretic Carter–Wegman experiments (zero-query, one-time,
and adaptive multi-query issued-counter MACs with zero query degradation [WC81]), the
arbitrary-pad and single-query PRF-pad hybrid bounds, and the shared word-level stateful
prfLogDistinguisher reduction framework consumed by the stateful nonce-based
(CarterWegman.Nonce), randomized-nonce (CarterWegman.RandomNonce), and concrete hash
(CarterWegman.Instantiations) modules.
Main definitions #
Cslib.Crypto.Protocols.CarterWegman.sign,Cslib.Crypto.Protocols.CarterWegman.verify: Carter–Wegman tag generation and verification.Cslib.Crypto.Protocols.CarterWegman.zeroQueryGame,Cslib.Crypto.Protocols.CarterWegman.OneTimeForger,Cslib.Crypto.Protocols.CarterWegman.oneTimeGame,Cslib.Crypto.Protocols.CarterWegman.oneTimeStrongGame: zero-query and adaptive one-time EUF-CMA / SUF-CMA experiments.Cslib.Crypto.Protocols.CarterWegman.CounterForger,Cslib.Crypto.Protocols.CarterWegman.counterRealHandler,Cslib.Crypto.Protocols.CarterWegman.counterSimHandler,Cslib.Crypto.Protocols.CarterWegman.transcriptToPads,Cslib.Crypto.Protocols.CarterWegman.checkCounterSlot,Cslib.Crypto.Protocols.CarterWegman.checkCounterEUF,Cslib.Crypto.Protocols.CarterWegman.checkCounterSUF,Cslib.Crypto.Protocols.CarterWegman.counterSlotGame,Cslib.Crypto.Protocols.CarterWegman.counterGame,Cslib.Crypto.Protocols.CarterWegman.counterStrongGame: adaptive multi-query issued-counter handlers, verification predicates, and experiments.Cslib.Crypto.Protocols.CarterWegman.maskedOneTimeGame,Cslib.Crypto.Protocols.CarterWegman.maskedOneTimeStrongGame,Cslib.Crypto.Protocols.CarterWegman.padDistinguisher,Cslib.Crypto.Protocols.CarterWegman.probPadTest,Cslib.Crypto.Protocols.CarterWegman.encForgeInput,Cslib.Crypto.Protocols.CarterWegman.wordProbPadTest,Cslib.Crypto.Protocols.CarterWegman.prfPadDist,Cslib.Crypto.Protocols.CarterWegman.prfOneTimeGame,Cslib.Crypto.Protocols.CarterWegman.prfOneTimeStrongGame,Cslib.Crypto.Protocols.CarterWegman.prfPadDistinguisher: arbitrary-pad and single-query PRF-pad experiments and distinguishers.Cslib.Crypto.Protocols.CarterWegman.carterWegmanKeyGen,Cslib.Crypto.Protocols.CarterWegman.encLogCaller,Cslib.Crypto.Protocols.CarterWegman.prfLogDistinguisher: shared(k, prfKey)key generator, caller encoding, and generic stateful log-handlerOracleDistinguisherfor multi-query PRF-pad reductions.
Main results #
Cslib.Crypto.Protocols.CarterWegman.map_sign_eq_uniform,Cslib.Crypto.Protocols.CarterWegman.uniform_bind_verify_apply_true,Cslib.Crypto.Protocols.CarterWegman.zeroQueryGame_apply_true: uniform tag law and exact1 / |Y|zero-query verification probability.Cslib.Crypto.Protocols.CarterWegman.oneTimeStrongGame_eq_oneTimeGame,Cslib.Crypto.Protocols.CarterWegman.oneTimeGame_eq_bind_uniform,Cslib.Crypto.Protocols.CarterWegman.oneTimeGame_le,Cslib.Crypto.Protocols.CarterWegman.oneTimeStrongGame_le: the Carter–Wegman instance of Boneh–Shoup Theorem 7.12 (≤ ε).Cslib.Crypto.Protocols.CarterWegman.run_interpret_counterRealHandler,Cslib.Crypto.Protocols.CarterWegman.counterStrongGame_eq_counterSlotGame,Cslib.Crypto.Protocols.CarterWegman.counterSlotGame_le,Cslib.Crypto.Protocols.CarterWegman.counterGame_le,Cslib.Crypto.Protocols.CarterWegman.counterStrongGame_le: multi-query issued-counter simulation and≤ εsecurity.Cslib.Crypto.Protocols.CarterWegman.maskedOneTimeGame_toReal_le,Cslib.Crypto.Protocols.CarterWegman.maskedOneTimeGame_toReal_le_add_advantage,Cslib.Crypto.Protocols.CarterWegman.maskedOneTimeStrongGame_toReal_le_add_advantage,Cslib.Crypto.Protocols.CarterWegman.prfOneTimeGame_le,Cslib.Crypto.Protocols.CarterWegman.prfOneTimeGame_ofProbComp_le,Cslib.Crypto.Protocols.CarterWegman.prfOneTimeStrongGame_ofProbComp_le,Cslib.Crypto.Protocols.CarterWegman.isOraclePPT_prfPadDistinguisher,Cslib.Crypto.Protocols.CarterWegman.isPPTOn_wordProbPadTest,Cslib.Crypto.Protocols.CarterWegman.isOraclePPT_prfPadDistinguisher_wordProbPadTest: arbitrary-pad and single-query PRF-pad bounds andIsOraclePPTcertificates.Cslib.Crypto.Protocols.CarterWegman.isPPTOn_carterWegmanKeyGen,Cslib.Crypto.Protocols.CarterWegman.isOraclePPT_prfLogDistinguisher,Cslib.Crypto.Protocols.CarterWegman.eval_prfRealGame_prfLogDistinguisher,Cslib.Crypto.Protocols.CarterWegman.eval_prfIdealGame_prfLogDistinguisher_le: shared key-sampler PPT certificate,IsOraclePPTadmissibility, and real/ideal game simulation forprfLogDistinguisher.
References #
Core Carter–Wegman signing, verification, and pad resampling #
Carter–Wegman tag verification: check whether hash k m + r = t.
Every valid tag for (k, r, m) equals sign hash k r m.
Because (k, r, m) determines a unique valid tag sign hash k r m, pair freshness
(m', t') ≠ (m, sign hash k r m) and message freshness m' ≠ m agree on all verifying pairs.
For a uniform pad r ← PMF.uniformOfFintype Y, the tag sign hash k r m is uniformly
distributed on Y for every k and m.
Under a uniform pad r ← PMF.uniformOfFintype Y, any fixed (m, t) verifies with probability
(Fintype.card Y : ℝ≥0∞)⁻¹.
Zero-query forgery experiment #
The zero-query forgery experiment: sample k ← seed, r ← PMF.uniformOfFintype Y, and
(m', t') ← forger, and check whether verify hash k r m' t' = true.
Without any signing query, every forgery distribution forger : PMF (M × Y) succeeds with
probability exactly 1 / |Y|, regardless of the hash family hash or key distribution
seed.
Adaptive one-time Carter–Wegman EUF-CMA and SUF-CMA (Boneh–Shoup Section 7.6) #
An adaptive one-time forger against a Carter–Wegman MAC:
it chooses a signing query m ← query, receives its tag t = sign hash k r m, and outputs a
candidate forgery (m', t') ← forge m t.
- query : PMF M
Distribution of the single signing query
m. Forgery distribution given the queried message
mand its tagt.
The adaptive one-time EUF-CMA experiment for Carter–Wegman ([BS23],
Theorem 7.12): the forger wins if m' ≠ m and verify hash k r m' t' = true.
The adaptive one-time SUF-CMA (strong unforgeability) experiment:
the forger wins if (m', t') ≠ (m, sign hash k r m) and verify hash k r m' t' = true.
Strong unforgeability and ordinary unforgeability coincide for the one-time Carter–Wegman MAC,
because each (k, r, m) admits a unique valid tag.
The queried message m, uniform tag t, and candidate forgery p = (m', t') can be sampled
independently of the hash key k, which is drawn last to test
verify hash k (-hash k m + t) m' t'.
One-time Carter–Wegman EUF-CMA security (the Carter–Wegman instance of
[BS23], Theorem 7.12; [WC81]): if hash is ε-almost-Δ-universal under
seed (IsDeltaUniversalHash seed hash ε), then every adaptive one-time forger succeeds with
probability at most ε.
One-time Carter–Wegman SUF-CMA security: under IsDeltaUniversalHash seed hash ε, every
adaptive one-time forger has strong-forgery probability at most ε.
Adaptive multi-query issued-counter Carter–Wegman MAC #
An adaptive multi-query forger against an issued-counter Carter–Wegman MAC:
it draws private coins s ← coins, makes any number of adaptive signing queries m : M via
OracleComp (fun _ : M => Y) (receiving t_i = sign hash k r_i m_i under a fresh pad r_i for
the i-th query), and outputs a target issued counter index idx : ℕ, message m' : M, and tag
t' : Y.
- Coins : Type
Type of the forger's private coins.
Distribution of the forger's private coins.
Adaptive oracle program outputting
(idx, m', t').
Real counter Carter–Wegman signing handler: on query m, sample a fresh pad
r ← PMF.uniformOfFintype Y, append (m, r) to the pad log, and return sign hash k r m.
Simulated key-independent tag handler: on query m, sample a fresh uniform tag
t ← PMF.uniformOfFintype Y, append (m, t) to the message–tag transcript, and return t.
Running any adaptive OracleComp program against counterRealHandler hash k from
transcriptToPads hash k tr has the exact distribution of running it against the key-independent
counterSimHandler from tr and applying transcriptToPads hash k to the final transcript.
Issued-slot message-freshness verification predicate on a pad log pads: the target counter
idx was issued (pads[idx]? = some (m_idx, r_idx), returning false on unissued indices),
m' ≠ m_idx, and verify hash k r_idx m' t' = true.
Issued-counter global-message-freshness EUF-CMA verification predicate on a pad log pads:
the target counter idx was issued (pads[idx]? = some (_, r_idx), returning false on unissued
indices), m' was never queried in any issued slot (!(pads.map Prod.fst).contains m'), and
verify hash k r_idx m' t' = true.
Issued-slot strong SUF-CMA verification predicate on a pad log pads: the target counter idx
was issued (pads[idx]? = some (m_idx, r_idx), returning false on unissued indices), the pair
(m', t') differs from the pair (m_idx, sign hash k r_idx m_idx) issued at counter idx, and
verify hash k r_idx m' t' = true.
Issued-slot SUF-CMA and issued-slot EUF-CMA checks are identical on every pad log and output.
Issued-counter global message freshness implies issued-slot message freshness at the target
counter idx.
The issued-slot EUF-CMA experiment for the counter Carter–Wegman MAC (unissued indices idx
are rejected).
The issued-counter global-message-freshness EUF-CMA experiment for the counter Carter–Wegman
MAC (unissued indices idx are rejected).
The issued-slot strong SUF-CMA experiment for the counter Carter–Wegman MAC (unissued indices
idx are rejected).
Issued-slot strong unforgeability (counterStrongGame) and issued-slot EUF-CMA
(counterSlotGame) have identical outcome distributions.
Issued-counter global-message-freshness EUF-CMA success probability is at most issued-slot EUF-CMA success probability.
Multi-query issued-slot Carter–Wegman security ([WC81];
[BS23], Section 7.4): under IsDeltaUniversalHash seed hash ε, every adaptive
multi-query forger succeeds in counterSlotGame with probability at most ε, with zero
degradation in the number of signing queries.
Multi-query issued-counter Carter–Wegman EUF-CMA security: under
IsDeltaUniversalHash seed hash ε, every adaptive multi-query forger has issued-counter EUF-CMA
forgery probability at most ε.
Multi-query issued-slot Carter–Wegman SUF-CMA security: under
IsDeltaUniversalHash seed hash ε, every adaptive multi-query forger has issued-slot SUF-CMA
forgery probability at most ε.
Pseudorandom-pad hybrid decomposition (after Boneh–Shoup Section 7.4) #
The one-time Carter–Wegman experiment with an arbitrary pad distribution padDist : PMF Y
(such as a pseudorandom function output F(k₂, nonce)).
The strong one-time Carter–Wegman experiment with an arbitrary pad distribution
padDist : PMF Y.
The induced pad distinguisher Y → PMF Bool that samples k ← seed, simulates the one-time
Carter–Wegman experiment using the supplied pad r : Y, and outputs true iff the forger
produces a valid forgery.
maskedOneTimeGame is equivalent to sampling r ← padDist and running
padDistinguisher seed hash forger r.
Game.advantage form of the pseudorandom-pad Carter–Wegman bound (after [BS23],
Section 7.4): if hash is ε-almost-Δ-universal (ε ≠ ⊤), the real-valued forgery probability
under padDist is bounded by ε.toReal plus Game.advantage between
padDist.bind (padDistinguisher seed hash forger) and
(PMF.uniformOfFintype Y).bind (padDistinguisher seed hash forger).
Pseudorandom-pad Carter–Wegman bound (after [BS23], Section 7.4):
if hash is ε-almost-Δ-universal (ε ≠ ⊤), then the real-valued forgery probability under any
pad distribution padDist : PMF Y is bounded by ε.toReal plus the distinguishing gap of
padDistinguisher between padDist and PMF.uniformOfFintype Y.
Strong-unforgeability version of maskedOneTimeGame_toReal_le_add_advantage.
Construct a OneTimeForger from ProbComp query and forgery programs.
Executable ProbComp simulation of the one-time Carter–Wegman experiment with a supplied pad
r : Y, given ProbComp samplers for the hash key seed, signing query query, and forgery
attempt forge.
One-query, fixed-nonce PRF-pad reduction (after Boneh–Shoup Section 7.4) #
The one-query, fixed-nonce PRF-masked Carter–Wegman EUF-CMA experiment (after
[BS23], Section 7.4): the pad r : BitString n is generated by evaluating family on a
uniform n-bit PRF key at the fixed nonce List.replicate n false.
The one-query, fixed-nonce PRF-masked Carter–Wegman SUF-CMA experiment (after [BS23], Section 7.4).
Single-query PRF OracleDistinguisher induced by a family of ProbComp pad tests
test : (k : ℕ) → BitString k → ProbComp Bool: at security parameter n, query the oracle once at
the fixed nonce List.replicate n false and run test n on the n-bit view of the reply.
In prfRealGame, prfPadDistinguisher test evaluates test n on a pad drawn from
prfPadDist family n.
In prfIdealGame, prfPadDistinguisher test evaluates test n on a uniform pad
r ← PMF.uniformOfFintype (BitString n).
Exact single-query PRF-pad reduction for prfOneTimeGame in the one-query, fixed-nonce
case (after [BS23], Section 7.4): replacing the uniform pad
r ← PMF.uniformOfFintype (BitString n) with the fixed-nonce PRF pad prfPadDist family n bounds
the real-valued one-time forgery probability at parameter n by ε.toReal plus the concrete PRF
distinguishing advantage of prfPadDistinguisher test between prfRealGame and prfIdealGame.
This is a concrete lemma: the caller supplies the pad test together with the equation htest that
it realizes padDistinguisher seed hash forger.
Exact single-query PRF-pad reduction for ProbComp samplers and forgers in the one-query,
fixed-nonce case (after [BS23], Section 7.4): at parameter n, any ProbComp hash-key
sampler seed, query program query, and forgery program forge induce the single-query PRF
distinguisher via probPadTest, without asserting IsOraclePPT encBool admissibility or an
asymptotic PseudorandomFunction corollary.
Strong-unforgeability version of prfOneTimeGame_ofProbComp_le.
prfPadDistinguisher test is uniformly strict oracle-PPT (IsOraclePPT encBool) whenever
running test n on the n-bit view of a raw pad word is uniformly strict PPT in (n, word).
Input (1ⁿ, m, t) of the forgery program of wordProbPadTest: the security parameter n in
unary, then the queried message and its tag as bit words. The parameter and the message are
framed.
Executable ProbComp one-time pad test induced by a uniform word-level hash-key sampler seed,
hash evaluator hash, signing query query, and forgery program forge: at security parameter n
and pad r : BitString n, it runs probPadTest with digest BitString.ofList n (hash n k m) and
candidate tag BitString.ofList n p.2.
If seed, hash, query, and forge are uniformly polynomial-time / strict PPT in their
encoded inputs, then wordProbPadTest on the n-bit view of a raw pad word is uniformly strict
PPT.
prfPadDistinguisher (wordProbPadTest seed hash query forge) is uniformly strict oracle-PPT
(IsOraclePPT encBool) for any uniform polynomial-time / strict-PPT family (seed, hash, query, forge).
Shared stateful log-handler PRF reduction #
carterWegmanKeyGen seed is uniformly strict PPT whenever seed is uniformly strict PPT.
Generic stateful log-handler OracleDistinguisher for multi-query Carter–Wegman PRF reductions:
sample k ← seed n, run adversary n [] from the empty log [] under logHandler n k, query the
external PRF/RF oracle on candNonce out (reading n bits), and test accept n k out.
prfLogDistinguisher is uniformly strict oracle-PPT (IsOraclePPT encBool) whenever seed,
adversary, logHandler, candNonce, and accept satisfy the corresponding uniform polytime /
strict-PPT bounds with per-step reply/log growth allowance resources.
Real-game simulation for prfLogDistinguisher: when prfKey has length n, if interpreting
prfOracle family n prfKey into each logHandler n k step agrees in ProbComp.eval with
realOracle (encPair encBits encBits (k, prfKey)) and accept n k out on the n-bit PRF output at
candNonce out agrees with realCheck (encPair encBits encBits (k, prfKey)) out, then running
prfLogDistinguisher in prfRealGame id family matches running realOracle and realCheck under
k ← seed n, prfKey ← BitString.sampleList n.
Ideal-game simulation inequality for prfLogDistinguisher: bounds the acceptance probability of
prfLogDistinguisher in prfIdealGame id id by that of a typed stateful PMF handler
typedHandler composed with a word-to-typed step adapter adaptStep under step invariant R.