Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.FiatShamir

Fiat–Shamir signatures #

The Fiat–Shamir transform ([BS23], Section 19.6.1) turns a Sigma protocol into a signature scheme in the random-oracle model: to sign m, the prover commits to t, takes the challenge c := H(m, t) and responds with z; the signature (t, z) verifies when (t, H(m, t), z) is an accepting conversation.

The implementation permits an injective representation hashPoint : (M × T) ↪ Query and hashes hashPoint (m, t). Every Query, including points outside this image, is retained in the same oracle table and charged to the hash-call budget. There is no image-membership test or decoder. This representation generalization is original; the identity embedding recovers the typed model.

Honest signatures verify (fiatShamir_correct). With special soundness, special HVZK and δ-unpredictable commitments ([BS23], Definition 19.7), a forger making at most Qs signing calls and Qro hash calls wins the random-oracle EUF-CMA experiment with probability ε bounded by

ε ≤ Qs · (Qs + Qro) · δ + (Qro + 1) / N + √((Qro + 1) · ε'),

where N is the number of challenges and ε' the success probability of an explicit adversary in the one-way game for the key generator (succProbability_eufCmaGame_le). This is the bound (19.21) stated after [BS23], Theorem 19.16, with Qs · (Qs + Qro) · δ in place of the slightly larger Qs · (Qs + Qro + 1) · δ, for one instance. It is a step toward Theorem 19.16, not the cited result: the book's adversary in (19.21) is efficient, running in about twice the forger's time, while nothing here certifies the reduction as efficient. The asymptotic theorem for a generic Sigma protocol is open (#5293). For Schnorr signatures it is PrimeOrderGroupFamily.DiscreteLog.eufCma_schnorrNativeROMScheme, which reaches this bound through a word instance and the certified forking adversary schnorrForkingAdversary.

The proof follows [BS23], Theorems 19.7 and 19.16, with the general forking lemma of [BN06] in place of the reduction through impersonation:

  1. The signer is replaced by one that programs the oracle at hashPoint (m, t) with a fresh challenge. The two agree until the signer's commitment hits a point already in the oracle's table, which has probability at most Qs · (Qs + Qro) · δ (RandomOracle.closeTo_run_lazyProgramHandler_overwriteProgramHandler_of_isQueryBounded).
  2. Special HVZK replaces the programming signer by the simulator, which needs no witness.
  3. The simulated transcripts are drawn in advance, one per call (OracleComp.IsQueryBounded.run_interpret_presample).
  4. The result is a program over the hash oracle alone, with explicit coins (FiatShamir.forkingProgram), that names the hash query of the forgery whenever the forger wins. It is the shared forking reduction ForkingReduction.program for the signer FiatShamir.signer and the final check FiatShamir.check. The forking lemma (ForkingReduction.toReal_le_add_sqrt_fork_of_le) and special soundness turn it into the one-way adversary FiatShamir.reduction.

These are exact probability laws for one Sigma protocol, key generator and forger; there is no efficiency claim (#5293). The forger has explicit coins, so the reduction can rerun it.

Main definitions #

Main results #

Step toward Theorem 19.16 #

References #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamir {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) (P : SigmaProtocol X Y T C Z) (keyGen : PMF (X × Y)) :
ROMSignature.Scheme Y (X × Y) M (T × Z) Query C

The Fiat–Shamir signature scheme ([BS23], Section 19.6.1): the public key is the statement and the secret key the witness-statement pair. To sign m, commit to t, query the oracle at hashPoint (m, t) for the challenge and respond; a signature (t, z) verifies when (t, H(hashPoint (m, t)), z) is accepting. Arbitrary other Query points remain available to the forger in the same random oracle.

theorem Cslib.Crypto.Protocols.SigmaProtocol.fiatShamir_correct {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) [DecidableEq Query] [Fintype C] [Nonempty C] {P : SigmaProtocol X Y T C Z} {keyGen : PMF (X × Y)} {R : X → Y → Prop} (hP : P.Complete R) (hkey : ∀ key ∈ keyGen.support, R key.1 key.2) :
(fiatShamir hashPoint P keyGen).Correct

Correctness of Fiat–Shamir signatures: with a complete Sigma protocol and keys in the relation, every honest signature verifies.

The reduction #

def Cslib.Crypto.Protocols.SigmaProtocol.FiatShamir.check {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) [DecidableEq M] (P : SigmaProtocol X Y T C Z) (y : Y) :
ForkingReduction.Check M T C Z Query M

The final check on a forgery (m, (t, z)) against the statement y: its point is hashPoint (m, t), and it wins when (t, c, z) is accepting and m was never signed.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.FiatShamir.signer {T C Z M Query : Type} (hashPoint : M × T ↪ Query) [Nonempty C] [Nonempty T] [Nonempty Z] :
ForkingReduction.Signer M (T × Z) Query C M (T × C × Z)

Signing without the witness, from one simulated transcript (t, c, z) per call: a signing call on m returns (t, z), programs the oracle at hashPoint (m, t) with c and logs m.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.FiatShamir.forkingProgram {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) [DecidableEq M] [DecidableEq Query] [Nonempty C] [Nonempty T] [Nonempty Z] (P : SigmaProtocol X Y T C Z) (A : ROMSignature.Forger Y M (T × Z) Query C) (s : Y × A.Coins × List (T × C × Z)) :
OracleComp (fun (x : Query) => C) (Option ℕ × ForkingReduction.Outcome M T C Z)

The forger, with simulated signing, as a program over the hash oracle with explicit coins: the statement, the forger's coins and the simulated transcripts. It names the query of the forgery's point when the forger wins.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.FiatShamir.coins {Y T C Z M Query : Type} [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) (A : ROMSignature.Forger Y M (T × Z) Query C) (Q : ℕ) (y : Y) :
PMF (Y × A.Coins × List (T × C × Z))

The coins of the forking program for the statement y: the forger's coins and Q simulated transcripts.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.FiatShamir.reduction {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) [DecidableEq M] [DecidableEq Query] [Fintype C] [Nonempty C] [Nonempty T] [Nonempty Z] [DecidableEq C] (P : SigmaProtocol X Y T C Z) (simulate : Y → C → PMF (T × Z)) (extract : Y → T → C → Z → C → Z → X) (fallback : X) (A : ROMSignature.Forger Y M (T × Z) Query C) (Qs Qro : ℕ) (y : Y) :
PMF X

The one-way adversary built from a forger making at most Qs signing and Qro hash calls: draw one simulated transcript per call, fork the forking program with the Qro + 1 answers of its hash oracle, and extract a witness from the two forgeries. A failed fork returns the supplied fallback; this value need not satisfy the witness relation.

Game hops #

The reduction simulates the game #

theorem Cslib.Crypto.Protocols.SigmaProtocol.FiatShamir.rejectsProgrammed {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) [DecidableEq M] [Nonempty C] [Nonempty T] [Nonempty Z] (P : SigmaProtocol X Y T C Z) (y : Y) :
ForkingReduction.RejectsProgrammed (signer hashPoint) (check hashPoint P y)

A forgery at a point programmed by a signing call on m is a forgery on m, which is then signed, so it does not win.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_eufCmaGame_le {X Y T C Z M Query : Type} (hashPoint : M × T ↪ Query) [DecidableEq M] [DecidableEq Query] [Fintype C] [Nonempty C] [Nonempty T] [Nonempty Z] [DecidableEq C] {P : SigmaProtocol X Y T C Z} {keyGen : PMF (X × Y)} {R : X → Y → Prop} [(x : X) → (y : Y) → Decidable (R x y)] {extract : Y → T → C → Z → C → Z → X} {simulate : Y → C → PMF (T × Z)} {δ : NNReal} (hkey : ∀ key ∈ keyGen.support, R key.1 key.2) (hsound : P.SpecialSoundOn keyGen R extract) (hzk : P.SpecialHVZK R simulate) (hcommit : ∀ key ∈ keyGen.support, ∀ (t : T), (PMF.map Prod.fst (P.commit key.1 key.2)) t ≤ ↑δ) (fallback : X) (A : ROMSignature.Forger Y M (T × Z) Query C) {Qs Qro : ℕ} (hA : A.CallBounded Qs Qro) :
↑(Game.succProbability (ROMSignature.eufCmaGame (fiatShamir hashPoint P keyGen) A)) ≤ ↑Qs * (↑Qs + ↑Qro) * ↑δ + (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(oneWayGame keyGen R (FiatShamir.reduction hashPoint P simulate extract fallback A Qs Qro)).succProbability)

Concrete bound (19.21) for one Sigma protocol, key generator and forger, a step toward [BS23], Theorem 19.16, not the cited result (proved via [BN06], Lemma 1). Let the Sigma protocol be special sound on the generated keys with extractor extract, special HVZK with simulator simulate, and have δ-unpredictable commitments, and let the key generator produce pairs in the relation. A forger making at most Qs signing calls and Qro hash calls wins the random-oracle EUF-CMA experiment with probability at most Qs · (Qs + Qro) · δ + (Qro + 1) / N + √((Qro + 1) · ε'), where N is the number of challenges and ε' is the probability that the reduction outputs a witness for a generated statement. The signer and final verifier use hashPoint (m, t), while Qro counts all adversary hash calls, including queries outside the embedding's image. The bound holds for every supplied failure output fallback; no correctness assumption is made about that output.

The book's (19.21) has an efficient one-way adversary, running in about twice the forger's time, and Theorem 19.16 concludes that the Fiat–Shamir scheme is secure. This lemma has no efficiency claim for reduction and fixes one instance; the generic asymptotic theorem is open (#5293). For Schnorr signatures it is PrimeOrderGroupFamily.DiscreteLog.eufCma_schnorrNativeROMScheme.