Documentation

CslibFrontier.Crypto.Computational.MAC.VerificationQueries

MAC security with verification queries #

This module formalizes [BS23], Section 6.2 (Attack Game 6.2 and Theorem 6.1, pp. 220–223) and Section 6.14 (Exercise 6.2, p. 246), in the computational word-level MACScheme model against uniform strict IsOraclePPT adversaries.

In Attack Game 6.2 (MACScheme.sufCmaVqGame), an adversary VqForger interacts over a Bool-tagged word channel:

Main definitions #

Main results #

References #

Word-level Attack Game 6.2 adversaries and query budgets #

@[reducible, inline]

Word-level adversary for Attack Game 6.2: given unary security parameter n and auxiliary input, interacts with a Bool-tagged word channel (false for signing, true for verification) and returns Unit.

@[reducible, inline]

Pathwise budget of at most Q_s signing queries ((false, msg)) on a Bool-tagged word channel.

@[reducible, inline]

Pathwise budget of at most Q_v verification queries ((true, raw)) on a Bool-tagged word channel.

One word-level signing query (false, msg) costs 1 signing query.

One word-level verification query (true, raw) costs 0 signing queries.

One word-level signing query (false, msg) costs 0 verification queries.

One word-level verification query (true, raw) costs 1 verification query.

A total external query budget bounds the number of signing queries.

A total external query budget bounds the number of verification queries.

Separate word signing and verification query budgets yield a total external query budget of Q_s + Q_v.

Adapt a word-level VqForger at (n, aux) into a typed Attack Game 6.2 program over forgeVqSpec (List Bool) (List Bool): (false, msg) becomes Sum.inl msg, and (true, raw) becomes Sum.inr (unframe raw, dropFrame raw) with its Bool verdict encoded as [ok].

theorem Cslib.Crypto.VqForger.isSigningQueryBounded_toTyped {adversary : VqForger} {n : ℕ} {aux : List Bool} {Q_s : ℕ} (h : IsWordSigningQueryBounded (adversary n aux) Q_s) :
IsSigningQueryBounded (adversary.toTyped n aux) Q_s

VqForger.toTyped preserves signing query budgets.

theorem Cslib.Crypto.VqForger.isVerificationQueryBounded_toTyped {adversary : VqForger} {n : ℕ} {aux : List Bool} {Q_v : ℕ} (h : IsWordVerificationQueryBounded (adversary n aux) Q_v) :
IsVerificationQueryBounded (adversary.toTyped n aux) Q_v

VqForger.toTyped preserves verification query budgets.

@[reducible, inline]

The tuple of the fields of encVqState.

Multi-tape encoding of VqOracleState (List Bool) (List Bool) as the framed pair encPair (encList (encPair encBits encBits)) encBool of the chronological (msg, tag) signing log and the won latch.

theorem Cslib.Crypto.encVqState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List (List Bool × List Bool)} {T0 S0 : γ → ℕ} {x1 : γ → Bool} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits)) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBool T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { log := x0 x, won := x1 x }) encIn encVqState (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.encVqState_won_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → VqOracleState (List Bool) (List Bool)} :

Attack Game 6.2 on MACScheme (sufCmaVqGame, SUFCMAVq) #

Stateful Attack Game 6.2 challenger oracle for M at security parameter n under secret key sk ([BS23], Section 6.2, p. 221):

  • (false, msg): if msg.length == M.msgLen n, signs msg under sk, prepends (msg, tag) to st.log, and returns tag; otherwise returns [] without signing or logging.
  • (true, raw): decodes (msg, tag) := (unframe raw, dropFrame raw), checks ok := (msg.length == M.msgLen n) && M.verify sk msg tag, latches st.won when ok && !st.log.contains (msg, tag) holds, and replies [ok].
noncomputable def Cslib.Crypto.MACScheme.sufCmaVqGame (M : MACScheme) (adversary : VqForger) (n : ℕ) :

The strong MAC experiment with verification queries ([BS23], Section 6.2, Attack Game 6.2, p. 221): draw sk ← M.keyGen n, run adversary n [] against M.sufCmaVqOracle n sk from ⟨[], false⟩, and accept iff won latched true on some fresh valid verification query.

Running an oracle-PPT VqForger against sufCmaVqOracle is uniformly strict PPT in the unary security parameter and secret key.

Run the complete MAC Attack Game 6.2 experiment on its unary security parameter for any oracle-PPT adversary.

The MAC Attack Game 6.2 experiment is uniformly strict PPT, independently of unused auxiliary input.

Strong MAC unforgeability under adaptive chosen-message and verification-query attack (SUFCMAVq) against uniform strict oracle-PPT adversaries ([BS23], Section 6.2, Attack Game 6.2, p. 221), on M.msgLen n-bit messages:

  • signing queries (false, msg) with msg.length ≠ M.msgLen n return [] without signing or recording msg in log;
  • verification queries (true, raw) decode (msg, tag) := (unframe raw, dropFrame raw), return [false] without latching won when msg.length ≠ M.msgLen n, and return [true] (by M.verify_sign) without latching won when (msg, tag) ∈ log.

SUFCMAVq security gives negligible sufCmaVqGame winning probability for every oracle-PPT VqForger.

Establish SUFCMAVq security by bounding every oracle-PPT VqForger's winning probability.

theorem Cslib.Crypto.MACScheme.sufCmaVqGame_eq_vqForgeExperiment (M : MACScheme) (adversary : VqForger) (n : ℕ) :
(M.sufCmaVqGame adversary n).eval = ProbComp.eval (vqForgeExperiment ((fun (x : List Bool) => ((), x)) <$> M.keyGen n) ((Signer.ofSign M.sign).restrict fun (x : List Bool) => x.length == M.msgLen n) (fun (x : Unit) (sk msg tag : List Bool) => msg.length == M.msgLen n && M.verify sk msg tag) fun (x : Unit) => adversary.toTyped n [])

At each security parameter n, M.sufCmaVqGame adversary n has the exact Boolean law of vqForgeExperiment with PK = Unit, policy (Signer.ofSign M.sign).restrict (·.length == M.msgLen n), and verifier fun () sk msg tag => (msg.length == M.msgLen n) && M.verify sk msg tag.

An adversary making 0 verification queries at security parameter n wins sufCmaVqGame with probability 0.

Direction 1: SUFCMAVq implies SUFCMA (sufToVqForger) #

def Cslib.Crypto.sufToVqForger (tagBound : ℕ → ℕ) (adversary : Forger) :

Embed a standard Attack Game 6.1 Forger into Attack Game 6.2 (VqForger): forward every signing query ((), msg) to (false, msg) (truncating the reply to tagBound n bits) and submit the final candidate (msg, tag) as a single verification query (true, encPair encBits encBits (msg, tag)).

sufToVqForger tagBound adversary is uniformly strict oracle-PPT whenever tagBound is polynomial-time computable in unary and adversary is oracle-PPT.

theorem Cslib.Crypto.MACScheme.eval_sufCmaVqGame_sufToVqForger (M : MACScheme) {tagBound : ℕ → ℕ} {n : ℕ} (htagBound : ∀ sk ∈ (M.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = M.msgLen n → ∀ tag ∈ (M.sign sk msg).eval.support, tag.length ≤ tagBound n) (adversary : Forger) :
(M.sufCmaVqGame (sufToVqForger tagBound adversary) n).eval = (M.sufCmaGame adversary n).eval

When tagBound n upper-bounds honest tag lengths on M.msgLen n-bit messages, running sufToVqForger tagBound adversary in M.sufCmaVqGame has the exact Boolean law of M.sufCmaGame adversary n (and of vqForgeExperiment ... (forgerToVq ...)).

Attack Game 6.2 security (SUFCMAVq) implies standard strong unforgeability (SUFCMA).

Direction 2: Theorem 6.1 (SUFCMA implies SUFCMAVq, vqToSufForger) #

noncomputable def Cslib.Crypto.MACScheme.vqToSufForger (M : MACScheme) (tagBound width Qv : ℕ → ℕ) (adversary : VqForger) :

Uniform Attack Game 6.2 to Attack Game 6.1 reduction ([BS23], Section 6.2, Theorem 6.1, pp. 221–223): sample a target verification-query index j via ProbComp.sampleModIndex (width n) (Qv n), simulate adversary n [], and output the captured (msg, tag) candidate.

M.vqToSufForger tagBound width Qv adversary preserves uniform strict oracle-PPT admissibility (IsOraclePPT) whenever tagBound, width, and Qv are computable in polynomial time in unary and adversary is oracle-PPT.

theorem Cslib.Crypto.MACScheme.isQueryBounded_vqToSufForger (M : MACScheme) (tagBound width Qv : ℕ → ℕ) {adversary : VqForger} {n Q_s : ℕ} (hs : IsWordSigningQueryBounded (adversary n []) Q_s) :
ProbOracleComp.IsQueryBounded (M.vqToSufForger tagBound width Qv adversary n []) Q_s

M.vqToSufForger makes at most Q_s signing queries whenever adversary n [] makes at most Q_s signing queries.

theorem Cslib.Crypto.MACScheme.eval_sufCmaGame_vqToSufForger_eq_forgeExperiment (M : MACScheme) {tagBound : ℕ → ℕ} (width Qv : ℕ → ℕ) {n : ℕ} (htagBound : ∀ sk ∈ (M.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = M.msgLen n → ∀ tag ∈ (M.sign sk msg).eval.support, tag.length ≤ tagBound n) (adversary : VqForger) :
(M.sufCmaGame (M.vqToSufForger tagBound width Qv adversary) n).eval = ProbComp.eval (forgeExperiment ((fun (x : List Bool) => ((), x)) <$> M.keyGen n) ((Signer.ofSign M.sign).restrict fun (x : List Bool) => x.length == M.msgLen n) (fun (x : Unit) (sk msg tag : List Bool) => msg.length == M.msgLen n && M.verify sk msg tag) freshPair (vqToForgerOn (fun (x : List (List Bool × List Bool)) (msg : List Bool) => msg.length == M.msgLen n) (ProbComp.sampleModIndex (width n) (Qv n)) fun (x : Unit) => adversary.toTyped n []))

Equality witness linking M.vqToSufForger in M.sufCmaGame to the finite planted-query reduction vqToForgerOn in forgeExperiment.

theorem Cslib.Crypto.MACScheme.succProbability_sufCmaVqGame_le_mul_add (M : MACScheme) {tagBound : ℕ → ℕ} (width Qv : ℕ → ℕ) {adversary : VqForger} {n : ℕ} (htagBound : ∀ sk ∈ (M.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = M.msgLen n → ∀ tag ∈ (M.sign sk msg).eval.support, tag.length ≤ tagBound n) (hQv : IsWordVerificationQueryBounded (adversary n []) (Qv n)) :
Game.succProbability (M.sufCmaVqGame adversary n).eval ≤ ↑(Qv n) * Game.succProbability (M.sufCmaGame (M.vqToSufForger tagBound width Qv adversary) n).eval + ↑(Qv n) / 2 ^ width n

Theorem 6.1, quantitative fair-coin loss bound ([BS23], Section 6.2, Theorem 6.1, pp. 221–223): when tagBound n bounds honest tag lengths on M.msgLen n-bit messages and adversary n [] makes at most Qv n verification queries, M.sufCmaVqGame adversary n succeeds with probability at most Qv n times the sufCmaGame success probability of M.vqToSufForger tagBound width Qv adversary, plus the fair-coin residue bias Qv n / 2 ^ width n.

theorem Cslib.Crypto.MACScheme.succProbability_sufCmaVqGame_le_mul (M : MACScheme) {tagBound : ℕ → ℕ} (width Qv : ℕ → ℕ) {adversary : VqForger} {n : ℕ} (htagBound : ∀ sk ∈ (M.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = M.msgLen n → ∀ tag ∈ (M.sign sk msg).eval.support, tag.length ≤ tagBound n) (hdvd : Qv n = 0 ∨ Qv n ∣ 2 ^ width n) (hQv : IsWordVerificationQueryBounded (adversary n []) (Qv n)) :
Game.succProbability (M.sufCmaVqGame adversary n).eval ≤ ↑(Qv n) * Game.succProbability (M.sufCmaGame (M.vqToSufForger tagBound width Qv adversary) n).eval

Theorem 6.1, exact dyadic loss bound ([BS23], Section 6.2, Theorem 6.1, pp. 221–223): proves the textbook bound ≤ Qv n * succProbability (M.sufCmaGame ...) with no additive error term when Qv n = 0 (where 0 verification queries give winning probability 0 via M.succProbability_sufCmaVqGame_zero) or when Qv n divides 2 ^ width n (for instance a power of two at most 2 ^ width n, where 0 < Qv n and ProbComp.sampleModIndex (width n) (Qv n) is uniform below Qv n).

Verification queries do not weaken a strong MAC ([BS23], Section 6.2, Theorem 6.1, pp. 221–223): every SUFCMA-secure MACScheme is SUFCMAVq-secure.

Equivalence of MAC security with and without verification queries ([BS23], Section 6.2, Theorem 6.1, pp. 221–223): for every MACScheme, strong unforgeability with verification queries (SUFCMAVq, Attack Game 6.2) is equivalent to strong unforgeability without verification queries (SUFCMA, Attack Game 6.1).

Exercise 6.2: prfMAC security with verification queries (vqMacToPrfDistinguisher) #

Direct oracle reduction turning a VqForger against prfMAC family into a PRF OracleDistinguisher ([BS23], Section 6.14, Exercise 6.2, p. 246): forwards n-bit signing queries (false, msg) and fresh (n, n)-bit verification queries (true, raw) directly to the PRF oracle (truncating replies to n bits), answers replayed (msg, tag) ∈ log pairs with [true] and wrong-length requests with [] / [false] locally, and outputs won.

vqMacToPrfDistinguisher queries the external PRF oracle only on n-bit signing messages and (n, n)-bit verification pairs, so its PRF query count is bounded by any budget Q on those well-formed requests.

theorem Cslib.Crypto.isQueryBounded_vqMacToPrfDistinguisher {adversary : VqForger} {n Q_s Q_v : ℕ} (hs : IsWordSigningQueryBounded (adversary n []) Q_s) (hv : IsWordVerificationQueryBounded (adversary n []) Q_v) :

vqMacToPrfDistinguisher makes at most Q_s + Q_v PRF queries when adversary n [] makes at most Q_s signing queries and at most Q_v verification queries.

theorem Cslib.Crypto.eval_prfRealGame_vqMacToPrfDistinguisher {family : List Bool → List Bool → List Bool} (hpoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => family pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) (adversary : VqForger) (n : ℕ) :
(prfRealGame id family (vqMacToPrfDistinguisher adversary) n).eval = ((prfMAC family hpoly).sufCmaVqGame adversary n).eval

Running vqMacToPrfDistinguisher adversary in prfRealGame id family produces the exact same Boolean law as (prfMAC family hpoly).sufCmaVqGame adversary n.

theorem Cslib.Crypto.succProbability_sufCmaVqGame_prfMAC_le {family : List Bool → List Bool → List Bool} (hpoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => family pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) {adversary : VqForger} {n Q_v : ℕ} (hQv : IsWordVerificationQueryBounded (adversary n []) Q_v) :

Quantitative PRF-to-SUFCMAVq bound for prfMAC ([BS23], Section 6.14, Exercise 6.2, p. 246): for every length-preserving keyed function family and every VqForger making at most Q_v verification queries at security parameter n, the sufCmaVqGame winning probability against prfMAC family is at most the PRF distinguishing advantage of vqMacToPrfDistinguisher adversary plus Q_v / 2 ^ n (without a Q_v factor on the PRF advantage).

Every pseudorandom function yields an SUFCMAVq-secure MAC via Exercise 6.2 ([BS23], Section 6.14, Exercise 6.2, p. 246): proved directly via vqMacToPrfDistinguisher and succProbability_sufCmaVqGame_prfMAC_le without incurring a Q_v factor on the PRF advantage.