Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.ForkingReduction

The forking reduction for Fiat–Shamir in the random-oracle model #

Fiat–Shamir signatures and Fiat–Shamir non-interactive proofs are proved secure by the same reduction ([BS23], Theorems 19.16 and 20.3.4, with the general forking lemma of [BN06], Lemma 1). The adversary makes signing (or proving) calls and hash calls and outputs a candidate (m, (t, z)): a message or statement m and a transcript commitment t and response z. The reduction runs it as a program over its own hash oracle alone:

This module states the reduction once (ForkingReduction.program) and proves the facts every security proof needs: with its oracle answered uniformly, it has the winning law of the adversary against the presampled game signer (map_run_program); it names a valid query whenever it wins, so the forking lemma bounds the winning probability (toReal_le_add_sqrt_fork_of_le); and a successful fork yields two accepting candidates at the same point with different challenges (exists_of_mem_support_fork). The only assumption linking signer and check is RejectsProgrammed: a candidate at a programmed point whose log entry is logged is not fresh.

Main definitions #

Main results #

References #

The state of the reduction while it runs the adversary: the oracle table, each point with its challenge and, when the reduction asked its own oracle for the point, the position of that query; the entries logged by signing calls; the number of queries asked so far; and the presampled values not used yet.

  • table : List (Point × C × Option ℕ)

    The oracle table.

  • log : List Log

    The entries logged by signing calls.

  • count : ℕ

    The number of queries asked so far.

  • samples : List S

    The presampled values not used yet.

How the reduction answers a signing call q without a secret, from one presampled value s: it returns (step s q).1 and, when (step s q).2 = some (x, c, l), programs the oracle at x with c and logs l.

  • fallback : S

    The value used once the presampled values run out.

  • step : S → Req → Reply × Option (Point × C × Log)

    The reply to a call and what it programs and logs.

The final check on a candidate (m, (t, z)): its challenge is the oracle's value at point m t, and it wins when accepts m t c z and fresh m t log.

  • point : M → T → Point

    The oracle point of a candidate.

  • accepts : M → T → C → Z → Bool

    Whether the candidate's transcript is accepting.

  • fresh : M → T → List Log → Bool

    Whether the candidate was not produced by a logged signing call.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.State.record {C Point Log S : Type} (st : State Point C Log S) :
Option (Point × C × Log) → State Point C Log S

Program the table at x with c and log l, when a signing call asks to.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.recordGame {C Point Log : Type} (st : List (Point × C) × List Log) :
Option (Point × C × Log) → List (Point × C) × List Log

The game's version of State.record, on the lazy oracle's table and the log.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.RejectsProgrammed {Req Reply M T C Z Point Log S : Type} (σ : Signer Req Reply Point C Log S) (κ : Check M T C Z Point Log) :

No candidate at a point the signer programmed is fresh once that call's log entry is logged. This is what makes a winning candidate name its own hash query.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.handler {Req Reply C Point Log S : Type} [DecidableEq Point] (σ : Signer Req Reply Point C Log S) (q : Req ⊕ Point) :
StateT (State Point C Log S) (OracleComp fun (x : Point) => C) (ROMSignature.ForgerSpec Req Point Reply C q)

Answer the adversary's calls without a secret, consuming one presampled value per call. A signing call follows the signer. A hash call returns the table's challenge, or asks the reduction's own oracle and records the answer with the position of the query.

The outcome of the final check: whether the candidate won, the candidate and its challenge.

  • won : Bool

    Whether the candidate won.

  • message : M

    The candidate's message or statement.

  • commitment : T

    The candidate's commitment.

  • challenge : C

    The challenge at the candidate's point.

  • response : Z

    The candidate's response.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.verdict {M T C Z Point Log S : Type} (κ : Check M T C Z Point Log) (cand : (M × T × Z) × State Point C Log S) (c : C) (position : Option ℕ) :

The verdict on a candidate whose point has challenge c: when it wins, the reduction names position, the position of the query for its point.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.finish {M T C Z Point Log S : Type} [DecidableEq Point] (κ : Check M T C Z Point Log) (cand : (M × T × Z) × State Point C Log S) :
OracleComp (fun (x : Point) => C) (Option ℕ × Outcome M T C Z)

Check a candidate, querying its point when the table lacks it.

def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.program {Req Reply M T C Z Point Log S : Type} [DecidableEq Point] (σ : Signer Req Reply Point C Log S) (κ : Check M T C Z Point Log) (A : OracleComp (ROMSignature.ForgerSpec Req Point Reply C) (M × T × Z)) (samples : List S) :
OracleComp (fun (x : Point) => C) (Option ℕ × Outcome M T C Z)

The reduction. The adversary A, with signing calls answered by σ from samples, as a program over the hash oracle alone. It names the query of the candidate's point when the candidate wins.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.gameHandler {Req Reply C Point Log S : Type} [DecidableEq Point] [Fintype C] [Nonempty C] (σ : Signer Req Reply Point C Log S) (s : S) (q : Req ⊕ Point) :
StateT (List (Point × C) × List Log) PMF (ROMSignature.ForgerSpec Req Point Reply C q)

The game's signer from one value s: signing calls follow the signer, programming the lazy oracle's table, and hash calls are answered by the lazy random oracle.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.finishGame {M T C Z Point Log : Type} [DecidableEq Point] [Fintype C] [Nonempty C] (κ : Check M T C Z Point Log) (cand : (M × T × Z) × List (Point × C) × List Log) :

The game's final check: query the candidate's point on the lazy oracle and test it.

The reduction simulates the game #

theorem Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.map_run_program {Req Reply M T C Z Point Log S : Type} [DecidableEq Point] [Fintype C] [Nonempty C] (σ : Signer Req Reply Point C Log S) (κ : Check M T C Z Point Log) (A : OracleComp (ROMSignature.ForgerSpec Req Point Reply C) (M × T × Z)) (samples : List S) :
PMF.map (fun (x : (Option ℕ × Outcome M T C Z) × ℕ) => match x with | ((fst, outcome), snd) => outcome.won) ((OracleComp.interpret OracleComp.countingUniform (program σ κ A samples)).run 0) = ((OracleComp.interpret (OracleComp.withSampleList σ.fallback (gameHandler σ)) A).run (([], []), samples)).bind fun (x : (M × T × Z) × (List (Point × C) × List Log) × List S) => match x with | (cand, game, snd) => finishGame κ (cand, game)

The reduction simulates the game. With its oracle answered uniformly, the reduction wins exactly when the adversary wins against the game's signer with the same presampled values.

The reduction's runs on fixed answers #

theorem Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.runWithAnswers_program {Req Reply M T C Z Point Log S : Type} [DecidableEq Point] (default : C) (σ : Signer Req Reply Point C Log S) (κ : Check M T C Z Point Log) (hκ : RejectsProgrammed σ κ) (A : OracleComp (ROMSignature.ForgerSpec Req Point Reply C) (M × T × Z)) (samples : List S) (answers : List C) {position : Option ℕ} {outcome : Outcome M T C Z} {queries : List Point} (hout : OracleComp.runWithAnswers default (program σ κ A samples) answers = ((position, outcome), queries)) :
(outcome.won = true → position.isSome = true) ∧ ∀ (j : ℕ), position = some j → queries[j]? = some (κ.point outcome.message outcome.commitment) ∧ answers.getD j default = outcome.challenge ∧ κ.accepts outcome.message outcome.commitment outcome.challenge outcome.response = true

The reduction's runs on fixed answers. On any list of answers, a winning candidate names a position, and a named position is that of the query for the candidate's point, answered there with the candidate's challenge, and the candidate's transcript is accepting.

theorem Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.isQueryBounded_program {Req Reply M T C Z Point Log S : Type} [DecidableEq Point] (σ : Signer Req Reply Point C Log S) (κ : Check M T C Z Point Log) {A : OracleComp (ROMSignature.ForgerSpec Req Point Reply C) (M × T × Z)} {Qro : ℕ} (hA : OracleComp.IsCostBounded ROMSignature.hashCost A Qro) (samples : List S) :
(program σ κ A samples).IsQueryBounded (Qro + 1)

The reduction asks at most one query per hash call of the adversary, and one more to check the candidate.

Forking the reduction #

theorem Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.toReal_le_add_sqrt_fork_of_le {Req Reply M T C Z Point Log S : Type} [DecidableEq Point] [Fintype C] [Nonempty C] [DecidableEq C] {Coins : Type} (first : PMF Coins) (σ : Signer Req Reply Point C Log S) (κ : Coins → Check M T C Z Point Log) (hκ : ∀ (s : Coins), RejectsProgrammed σ (κ s)) (A : Coins → OracleComp (ROMSignature.ForgerSpec Req Point Reply C) (M × T × Z)) (samples : Coins → List S) {Qro : ℕ} (hA : ∀ (s : Coins), OracleComp.IsCostBounded ROMSignature.hashCost (A s) Qro) {p ε succ : ENNReal} (hε : ε ≠ ⊤) (hp : p ≤ (first.bind fun (s : Coins) => PMF.map (fun (x : (Option ℕ × Outcome M T C Z) × ℕ) => match x with | ((fst, outcome), snd) => outcome.won) ((OracleComp.interpret OracleComp.countingUniform (program σ (κ s) (A s) (samples s))).run 0)) true + ε) {fallback : C} (hfork : (PMF.map Option.isSome (Probability.Forking.fork first (OracleComp.forkingAlgorithm fallback (Qro + 1) fun (s : Coins) => program σ (κ s) (A s) (samples s)))) true ≤ succ) (hsucc : succ ≠ ⊤) :
p.toReal ≤ ↑(Qro + 1) / ↑(Fintype.card C) + √(↑(Qro + 1) * succ.toReal) + ε.toReal

The forking lemma for the reduction ([BN06], Lemma 1). If an event has probability at most ε more than the reduction's winning probability, over coins first that fix the check, the adversary and the presampled values, and the adversary makes at most Qro hash calls, then the event has real probability at most (Qro + 1) / |C| + √((Qro + 1) · succ) + ε, where forking the reduction succeeds with probability at most succ.

theorem Cslib.Crypto.Protocols.SigmaProtocol.ForkingReduction.exists_of_mem_support_fork {Req Reply M T C Z Point Log S : Type} [DecidableEq Point] [Fintype C] [Nonempty C] [DecidableEq C] {Coins : Type} {first : PMF Coins} (σ : Signer Req Reply Point C Log S) (κ : Coins → Check M T C Z Point Log) (hκ : ∀ (s : Coins), RejectsProgrammed σ (κ s)) (A : Coins → OracleComp (ROMSignature.ForgerSpec Req Point Reply C) (M × T × Z)) (samples : Coins → List S) {default : C} {q : ℕ} {j : Fin q} {position position' : Option ℕ} {outcome outcome' : Outcome M T C Z} {queries queries' : List Point} (hfork : some (j, ((position, outcome), queries), (position', outcome'), queries') ∈ (Probability.Forking.fork first (OracleComp.forkingAlgorithm default q fun (s : Coins) => program σ (κ s) (A s) (samples s))).support) :
∃ s ∈ first.support, (κ s).point outcome.message outcome.commitment = (κ s).point outcome'.message outcome'.commitment ∧ outcome.challenge ≠ outcome'.challenge ∧ (κ s).accepts outcome.message outcome.commitment outcome.challenge outcome.response = true ∧ (κ s).accepts outcome'.message outcome'.commitment outcome'.challenge outcome'.response = true

Extraction data from a successful fork. Both runs of a successful fork of the reduction start from the same coins s and name the same query: their candidates outcome and outcome' have the same point, different challenges, and accepting transcripts.