Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.Computational

Computational special honest-verifier zero knowledge #

Boneh and Shoup's computational relaxation of special HVZK ([BS23], Section 20.4.2, Attack Game 20.4 and Definition 20.6, p. 840) for an indexed family of Sigma protocols P i over a parameter distribution setup : ℕ → PMF I ([BS23], Section 2.3.4).

Attack Game 20.4 is first stated at one index. chvzkExperiment R conv A runs a two-stage adversary A : TwoStage Unit (X × Y) (T × C × Z) Bool σ: it chooses a witness-statement pair (x, y) and a saved state; if R x y fails the experiment outputs false, and otherwise it samples a conversation from conv x y and outputs A's guess on it.

The games chvzkRealGame and chvzkSimGame draw i ← setup n and run the experiment at i with the adversary A n i of a family A : CHVZKAdversary I X Y T C Z σ. Adversaries receive and return typed values; their efficiency is stated on encodings by CHVZKAdversary.IsPPT. The choice stage writes ((encW i x, enc.statement i y), state), the layout of the word-level adversaries when σ := List Bool. The guessing stage reads the record CHVZKGuessInput, encoded by encCHVZKGuessInput as the unary security parameter, the state, the index and the encoded commitment, challenge and response.

ComputationalSpecialHVZK P R enc encW setup sim δ bundles, for a typed simulator family sim : Simulator I Y T C Z:

  1. Uniform strict PPT admissibility of sim (Simulator.IsPPT), the only place where its encodings appear.
  2. Acceptance on every (i, y, c) with probability at least 1 - δ i (exact Definition 20.6 acceptance when δ = 0; relaxed by δ when a strict PPT fair-coin simulator approximates a non-dyadic distribution).
  3. Negligible distinguishing advantage between chvzkRealGame and chvzkSimGame for every state type, state encoding and uniform strict PPT CHVZKAdversary.

Every EfficientSpecialHVZK protocol whose realization error δ is bounded along setup by a negligible function satisfies ComputationalSpecialHVZK, in fact against arbitrary, even computationally unbounded adversaries at each index (SimulatorRealizedBy.advantage_chvzkExperiment_le, EfficientSpecialHVZK.exists_computationalSpecialHVZK). As in EfficientSpecialHVZK, δ is an explicit parameter of ComputationalSpecialHVZK rather than a bundled Negligible condition on the acceptance error alone; exact Definition 20.6 acceptance corresponds to δ = fun _ => 0 (which Schnorr's simulator achieves in PrimeOrderGroupFamily.computationalSpecialHVZK_schnorr).

When an ideal-sampling PMF prover P is replaced by a fair-coin prover P' whose honest transcripts are within statistical distance ε of P's on valid pairs, pointwise transcript closeness (SimulatorRealizedBy.closeTo_transcript_of_closeTo), Attack Game 20.4 advantage bounds (advantage_chvzkRealGame_le_of_closeTo_transcript, SimulatorRealizedBy.advantage_chvzkGame_le_of_closeTo_transcript), and ComputationalSpecialHVZK (ComputationalSpecialHVZK.of_closeTo_transcript) transfer without requiring P and P' to share a private-state type.

Main definitions #

Main results #

References #

Attack Game 20.4 at one index #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.chvzkExperiment {X Y T C Z σ : Type} (R : X → Y → Prop) (conv : X → Y → PMF (T × C × Z)) (A : TwoStage Unit (X × Y) (T × C × Z) Bool σ) :

Attack Game 20.4 ([BS23], Section 20.4.2, p. 840) at one index, with conversation law conv. The adversary chooses a witness-statement pair (x, y) and a state. If R x y holds, the challenger samples a conversation from conv x y and the experiment outputs the adversary's guess on it; it outputs false when R x y fails.

theorem Cslib.Crypto.Protocols.SigmaProtocol.advantage_chvzkExperiment_le {X Y T C Z σ : Type} {R : X → Y → Prop} {conv₀ conv₁ : X → Y → PMF (T × C × Z)} {ε : NNReal} (h : ∀ (x : X) (y : Y), R x y → Probability.CloseTo (conv₀ x y) (conv₁ x y) ↑ε) (A : TwoStage Unit (X × Y) (T × C × Z) Bool σ) :
(chvzkExperiment R conv₀ A).advantage (chvzkExperiment R conv₁ A) ≤ ε

Conversation laws that are ε-close on every valid pair give Attack Game 20.4 advantage at most ε against every adversary, including computationally unbounded ones.

Adversary families and their efficiency #

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.SigmaProtocol.CHVZKAdversary (I : Type) (X Y T C Z : I → Type) (σ : Type) :

A family of Attack Game 20.4 adversaries: at security parameter n and index i, a two-stage adversary that chooses a pair in X i × Y i with a state of type σ, then guesses from the state and a conversation in T i × C i × Z i. CHVZKAdversary.IsPPT states its efficiency on encodings.

The input of the guessing stage: the security parameter, the saved state, the index and a conversation at that index.

  • secParam : ℕ

    The security parameter.

  • state : σ

    The state saved by the choice stage.

  • index : I

    The index.

  • commitment : T self.index

    The commitment.

  • challenge : C self.index

    The challenge.

  • response : Z self.index

    The response.

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_apply {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_commitment_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encCHVZKGuessInput enc encσ) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (enc.commitment (g✝ c).index) (g✝ c).commitment) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_index_length_le {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
(enc.index ((fun (a : CHVZKGuessInput I T C Z σ) => a.index) a)).length ≤ ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_secParam_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO (fun (a : CHVZKGuessInput I T C Z σ) => a.secParam) (encCHVZKGuessInput enc encσ) Turing.MultiTapeTM.encUnary (fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length) fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_index_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO (fun (a : CHVZKGuessInput I T C Z σ) => a.index) (encCHVZKGuessInput enc encσ) enc.index (fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length) fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_secParam_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_response_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encCHVZKGuessInput enc encσ) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (enc.response (g✝ c).index) (g✝ c).response) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_state_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO (fun (a : CHVZKGuessInput I T C Z σ) => a.state) (encCHVZKGuessInput enc encσ) encσ (fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length) fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_secParam_length_le {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
(Turing.MultiTapeTM.encUnary ((fun (a : CHVZKGuessInput I T C Z σ) => a.secParam) a)).length ≤ ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_commitment_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO (fun (a : CHVZKGuessInput I T C Z σ) => (enc.commitment a.index) a.commitment) (encCHVZKGuessInput enc encσ) Turing.MultiTapeTM.encBits (fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length) fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_state_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encCHVZKGuessInput enc encσ) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).state) encIn✝ encσ
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_state_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encCHVZKGuessInput enc encσ) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).state) encIn✝ encσ S✝
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_commitment_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_challenge_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_response_length_le {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
(Turing.MultiTapeTM.encBits ((fun (a : CHVZKGuessInput I T C Z σ) => (enc.response a.index) a.response) a)).length ≤ ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_mk_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → σ} {T1 S1 : γ → ℕ} {x2 : γ → I} {T2 S2 : γ → ℕ} {x3 : (c : γ) → T (x2 c)} {T3 S3 : γ → ℕ} {x4 : (c : γ) → C (x2 c)} {T4 S4 : γ → ℕ} {x5 : (c : γ) → Z (x2 c)} {T5 S5 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encσ T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn enc.index T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (enc.commitment (x2 c)) (x3 c)) encIn Turing.MultiTapeTM.encBits T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (enc.challenge (x2 c)) (x4 c)) encIn Turing.MultiTapeTM.encBits T4 S4) (h5 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (enc.response (x2 c)) (x5 c)) encIn Turing.MultiTapeTM.encBits T5 S5) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { secParam := x0 x, state := x1 x, index := x2 x, commitment := x3 x, challenge := x4 x, response := x5 x }) encIn (encCHVZKGuessInput enc encσ) (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + (T4 x + T5 x))))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + (S4 x + S5 x))))
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_index_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encCHVZKGuessInput enc encσ) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).index) encIn✝ enc.index
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_response_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_secParam_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_state_length_le {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
(encσ ((fun (a : CHVZKGuessInput I T C Z σ) => a.state) a)).length ≤ ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_index_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encCHVZKGuessInput enc encσ) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).index) encIn✝ enc.index S✝
@[reducible, inline]
abbrev Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInputFields {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :

The tuple of the fields of encCHVZKGuessInput.

theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_commitment_length_le {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
(Turing.MultiTapeTM.encBits ((fun (a : CHVZKGuessInput I T C Z σ) => (enc.commitment a.index) a.commitment) a)).length ≤ ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_response_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO (fun (a : CHVZKGuessInput I T C Z σ) => (enc.response a.index) a.response) (encCHVZKGuessInput enc encσ) Turing.MultiTapeTM.encBits (fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length) fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_mk_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → σ} {x2 : γ → I} {x3 : (c : γ) → T (x2 c)} {x4 : (c : γ) → C (x2 c)} {x5 : (c : γ) → Z (x2 c)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encσ budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn enc.index budget) (h3 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (enc.commitment (x2 c)) (x3 c)) encIn Turing.MultiTapeTM.encBits budget) (h4 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (enc.challenge (x2 c)) (x4 c)) encIn Turing.MultiTapeTM.encBits budget) (h5 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (enc.response (x2 c)) (x5 c)) encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { secParam := x0 x, state := x1 x, index := x2 x, commitment := x3 x, challenge := x4 x, response := x5 x }) encIn (encCHVZKGuessInput enc encσ) budget
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_mk_polyTime {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ℕ} {x1 : γ → σ} {x2 : γ → I} {x3 : (c : γ) → T (x2 c)} {x4 : (c : γ) → C (x2 c)} {x5 : (c : γ) → Z (x2 c)} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn Turing.MultiTapeTM.encUnary) (h1 : Turing.MultiTapeTM.ComputableInPolyTime x1 encIn encσ) (h2 : Turing.MultiTapeTM.ComputableInPolyTime x2 encIn enc.index) (h3 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (enc.commitment (x2 c)) (x3 c)) encIn Turing.MultiTapeTM.encBits) (h4 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (enc.challenge (x2 c)) (x4 c)) encIn Turing.MultiTapeTM.encBits) (h5 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (enc.response (x2 c)) (x5 c)) encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { secParam := x0 x, state := x1 x, index := x2 x, commitment := x3 x, challenge := x4 x, response := x5 x }) encIn (encCHVZKGuessInput enc encσ)
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_index_deg {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_challenge_length_le {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) (a : CHVZKGuessInput I T C Z σ) :
(Turing.MultiTapeTM.encBits ((fun (a : CHVZKGuessInput I T C Z σ) => (enc.challenge a.index) a.challenge) a)).length ≤ ((encCHVZKGuessInput enc encσ) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_state_deg {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInDegree (fun (a : CHVZKGuessInput I T C Z σ) => a.state) (encCHVZKGuessInput enc encσ) encσ 1 1
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_challenge_budget {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → CHVZKGuessInput I T C Z σ} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encCHVZKGuessInput enc encσ) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (enc.challenge (g✝ c).index) (g✝ c).challenge) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput_challenge_inO {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO (fun (a : CHVZKGuessInput I T C Z σ) => (enc.challenge a.index) a.challenge) (encCHVZKGuessInput enc encσ) Turing.MultiTapeTM.encBits (fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length) fun (a : CHVZKGuessInput I T C Z σ) => ((encCHVZKGuessInput enc encσ) a).length
def Cslib.Crypto.Protocols.SigmaProtocol.encCHVZKGuessInput {I : Type} {Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encσ : σ ↪ List Bool) :

The encoding of a guessing-stage input: the unary security parameter, the state encoded by encσ, the index and the words of the commitment, challenge and response under enc at that index, each framed except the last (encCHVZKGuessInput_apply).

structure Cslib.Crypto.Protocols.SigmaProtocol.CHVZKAdversary.IsPPT {I : Type} {X Y T C Z : I → Type} {σ : Type} (enc : Encoding I Y T C Z) (encW : (i : I) → X i ↪ List Bool) (encσ : σ ↪ List Bool) (A : CHVZKAdversary I X Y T C Z σ) :

A family of Attack Game 20.4 adversaries is uniform strict PPT: one machine runs each stage at every security parameter and index. The choice stage reads the unary security parameter and the encoded index and writes the encoded witness, statement and state; the guessing stage reads encCHVZKGuessInput and writes the guess. Each clock charges the complete encoded input, including the saved state.

The real and simulated games #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.simulatedConversation {I : Type} {Y T C Z : I → Type} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (sim : Simulator I Y T C Z) (i : I) (y : Y i) :
PMF (T i × C i × Z i)

The simulated conversation on (i, y) ([BS23], Section 20.4.2, Attack Game 20.4, Experiment 1, p. 840): sample a uniform challenge c : C i and run sim i y c.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.chvzkRealGame {I : Type} {X Y T C Z : I → Type} {σ : Type} (P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)) [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (R : (i : I) → X i → Y i → Prop) (setup : ℕ → PMF I) (A : CHVZKAdversary I X Y T C Z σ) (n : ℕ) :

Experiment 0 of Attack Game 20.4 ([BS23], Section 20.4.2, p. 840): draw i ← setup n and give the adversary an honest conversation of P i on its valid pair.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.chvzkSimGame {I : Type} {X Y T C Z : I → Type} {σ : Type} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (R : (i : I) → X i → Y i → Prop) (setup : ℕ → PMF I) (sim : Simulator I Y T C Z) (A : CHVZKAdversary I X Y T C Z σ) (n : ℕ) :

Experiment 1 of Attack Game 20.4 ([BS23], Section 20.4.2, p. 840): draw i ← setup n and give the adversary a conversation simulated from the statement of its valid pair, without the witness.

structure Cslib.Crypto.Protocols.SigmaProtocol.ComputationalSpecialHVZK {I : Type} {X Y T C Z : I → Type} (P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)) [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (R : (i : I) → X i → Y i → Prop) (enc : Encoding I Y T C Z) (encW : (i : I) → X i ↪ List Bool) (setup : ℕ → PMF I) (sim : Simulator I Y T C Z) (δ : I → ENNReal) :

Computational special honest-verifier zero knowledge ([BS23], Section 20.4.2, Definition 20.6, p. 840), for a family P of Sigma protocols over setup with explicit typed simulator sim and acceptance error δ: sim is uniform strict PPT, outputs an accepting conversation on every (i, y, c) with probability at least 1 - δ i (exact Definition 20.6 acceptance when δ = fun _ => 0), and for every state type and state encoding, every uniform strict PPT CHVZKAdversary has negligible distinguishing advantage between chvzkRealGame and chvzkSimGame.

theorem Cslib.Crypto.Protocols.SigmaProtocol.ComputationalSpecialHVZK.mono_error {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → X i ↪ List Bool} {setup : ℕ → PMF I} {sim : Simulator I Y T C Z} {δ δ' : I → ENNReal} (h : ComputationalSpecialHVZK P R enc encW setup sim δ) (hle : ∀ (i : I), δ i ≤ δ' i) :
ComputationalSpecialHVZK P R enc encW setup sim δ'

Relaxing the acceptance-error bound preserves ComputationalSpecialHVZK.

Bridging statistical EfficientSpecialHVZK to ComputationalSpecialHVZK #

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.closeTo_simulatedConversation {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (h : SimulatorRealizedBy simulate sim δ) {i : I} {x : X i} {y : Y i} (hxy : R i x y) :

A simulator realizing a perfect special HVZK simulator up to δ i gives simulated conversations within statistical distance δ i of honest conversations, for every valid witness-statement pair.

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.advantage_chvzkExperiment_le {I : Type} {X Y T C Z : I → Type} {σ : Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (h : SimulatorRealizedBy simulate sim δ) (i : I) {ε : NNReal} (hδ : δ i ≤ ↑ε) (A : TwoStage Unit (X i × Y i) (T i × C i × Z i) Bool σ) :
(chvzkExperiment (R i) (P i).conversation A).advantage (chvzkExperiment (R i) (fun (x : X i) (y : Y i) => simulatedConversation sim i y) A) ≤ ε

When δ i ≤ ε, a simulator realizing a perfect special HVZK simulator has Attack Game 20.4 advantage at most ε at index i against every adversary (including computationally unbounded adversaries).

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.advantage_chvzkGame_le {I : Type} {X Y T C Z : I → Type} {σ : Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {setup : ℕ → PMF I} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (h : SimulatorRealizedBy simulate sim δ) {n : ℕ} {ε : NNReal} (hδ : ∀ i ∈ (setup n).support, δ i ≤ ↑ε) (A : CHVZKAdversary I X Y T C Z σ) :
(chvzkRealGame P R setup A n).advantage (chvzkSimGame R setup sim A n) ≤ ε

When δ i ≤ ε on (setup n).support, a simulator realizing a perfect special HVZK simulator has Attack Game 20.4 advantage at most ε against every adversary family (including computationally unbounded adversaries).

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.computationalSpecialHVZK_of_accepts {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → X i ↪ List Bool} {setup : ℕ → PMF I} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ δ' : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (hppt : Simulator.IsPPT enc sim) (hreal : SimulatorRealizedBy simulate sim δ) (hacc : ∀ (i : I) (y : Y i) (c : C i), 1 - δ' i ≤ (sim i y c).eval.toOuterMeasure {tz : T i × Z i | (P i).Accepts y tz.1 c tz.2}) (hnegl : ∃ (ε : ℕ → NNReal), Negligible ε ∧ ∀ (n : ℕ), ∀ i ∈ (setup n).support, δ i ≤ ↑(ε n)) :
ComputationalSpecialHVZK P R enc encW setup sim δ'

A strict PPT simulator realizing a perfect special HVZK simulator with negligible statistical error along setup gives ComputationalSpecialHVZK, retaining any independently proved acceptance error δ'.

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.computationalSpecialHVZK {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → X i ↪ List Bool} {setup : ℕ → PMF I} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (hppt : Simulator.IsPPT enc sim) (hreal : SimulatorRealizedBy simulate sim δ) (hnegl : ∃ (ε : ℕ → NNReal), Negligible ε ∧ ∀ (n : ℕ), ∀ i ∈ (setup n).support, δ i ≤ ↑(ε n)) :
ComputationalSpecialHVZK P R enc encW setup sim δ

A strict PPT simulator realizing a perfect special HVZK simulator with negligible statistical error along setup satisfies ComputationalSpecialHVZK with acceptance error δ.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialHVZK.exists_computationalSpecialHVZK {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {enc : Encoding I Y T C Z} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {δ : I → ENNReal} (h : EfficientSpecialHVZK P R enc simulate δ) (encW : (i : I) → X i ↪ List Bool) (setup : ℕ → PMF I) (hnegl : ∃ (ε : ℕ → NNReal), Negligible ε ∧ ∀ (n : ℕ), ∀ i ∈ (setup n).support, δ i ≤ ↑(ε n)) :
∃ (sim : Simulator I Y T C Z), ComputationalSpecialHVZK P R enc encW setup sim δ

Efficient statistical special HVZK implies computational special HVZK whenever the realization error δ is bounded along setup by a negligible function.

Transfer across protocols with close honest transcripts #

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialSoundness.of_verify_eq {I : Type} {X Y T C Z : I → Type} {P P' : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {W : I → Type} {R : (i : I) → W i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → W i ↪ List Bool} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} (h : EfficientSpecialSoundness P R enc encW extract) (hver : ∀ (i : I), (P' i).verify = (P i).verify) :
EfficientSpecialSoundness P' R enc encW extract

Efficient special soundness depends only on verify and transfers across protocol families with the same verifier.

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.closeTo_transcript_of_closeTo {I : Type} {X Y T C Z : I → Type} {P P' : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {R : (i : I) → X i → Y i → Prop} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δP δS : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (hreal : SimulatorRealizedBy simulate sim δS) {i : I} {x : X i} {y : Y i} (hxy : R i x y) {c : C i} (htrans : Probability.CloseTo ((P i).transcript x y c) ((P' i).transcript x y c) (δP i)) :
Probability.CloseTo ((P' i).transcript x y c) (sim i y c).eval (δP i + δS i)

Combining a perfect special HVZK simulator for P, a typed simulator realizing it up to δS i, and a second protocol family P' whose honest transcript is within δP i of (P i)'s yields δP i + δS i pointwise transcript closeness for P'.

theorem Cslib.Crypto.Protocols.SigmaProtocol.advantage_chvzkRealGame_le_of_closeTo_transcript {I : Type} {X Y T C Z : I → Type} {σ : Type} {P P' : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {setup : ℕ → PMF I} {n : ℕ} {ε : NNReal} (htrans : ∀ i ∈ (setup n).support, ∀ (x : X i) (y : Y i), R i x y → ∀ (c : C i), Probability.CloseTo ((P i).transcript x y c) ((P' i).transcript x y c) ↑ε) (A : CHVZKAdversary I X Y T C Z σ) :
(chvzkRealGame P' R setup A n).advantage (chvzkRealGame P R setup A n) ≤ ε

Replacing P by a protocol family P' whose honest transcripts are within ε on valid pairs over (setup n).support changes Experiment 0 of Attack Game 20.4 (chvzkRealGame) by at most ε in Game.advantage, against every adversary (including computationally unbounded ones).

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.advantage_chvzkGame_le_of_closeTo_transcript {I : Type} {X Y T C Z : I → Type} {σ : Type} {P P' : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {setup : ℕ → PMF I} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} {n : ℕ} {εP εS : NNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (hreal : SimulatorRealizedBy simulate sim δ) (htrans : ∀ i ∈ (setup n).support, ∀ (x : X i) (y : Y i), R i x y → ∀ (c : C i), Probability.CloseTo ((P i).transcript x y c) ((P' i).transcript x y c) ↑εP) (hδ : ∀ i ∈ (setup n).support, δ i ≤ ↑εS) (A : CHVZKAdversary I X Y T C Z σ) :
(chvzkRealGame P' R setup A n).advantage (chvzkSimGame R setup sim A n) ≤ εP + εS

Combining advantage_chvzkRealGame_le_of_closeTo_transcript and SimulatorRealizedBy.advantage_chvzkGame_le bounds Attack Game 20.4 distinguishing advantage for P' by εP + εS against every adversary (including computationally unbounded ones).

theorem Cslib.Crypto.Protocols.SigmaProtocol.ComputationalSpecialHVZK.of_closeTo_transcript {I : Type} {X Y T C Z : I → Type} {P P' : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] {R : (i : I) → X i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → X i ↪ List Bool} {setup : ℕ → PMF I} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (h : ComputationalSpecialHVZK P R enc encW setup sim δ) (hacc : ∀ (i : I) (y : Y i) (t : T i) (c : C i) (z : Z i), (P i).Accepts y t c z → (P' i).Accepts y t c z) (hnegl : ∃ (ε : ℕ → NNReal), Negligible ε ∧ ∀ (n : ℕ), ∀ i ∈ (setup n).support, ∀ (x : X i) (y : Y i), R i x y → ∀ (c : C i), Probability.CloseTo ((P i).transcript x y c) ((P' i).transcript x y c) ↑(ε n)) :
ComputationalSpecialHVZK P' R enc encW setup sim δ

ComputationalSpecialHVZK transfers from P to P' with the same simulator sim and acceptance error δ whenever P' accepts every conversation P accepts and their honest transcripts are within a negligible statistical distance along setup on valid pairs.

theorem Cslib.Crypto.Protocols.SigmaProtocol.closeTo_andProof_transcript {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type} {P₀ P₀' : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ P₁' : SigmaProtocol X₁ Y₁ T₁ C Z₁} {x : X₀ × X₁} {y : Y₀ × Y₁} {c : C} {δ₀ δ₁ : ENNReal} (h₀ : Probability.CloseTo (P₀.transcript x.1 y.1 c) (P₀'.transcript x.1 y.1 c) δ₀) (h₁ : Probability.CloseTo (P₁.transcript x.2 y.2 c) (P₁'.transcript x.2 y.2 c) δ₁) :
Probability.CloseTo ((P₀.andProof P₁).transcript x y c) ((P₀'.andProof P₁').transcript x y c) (δ₀ + δ₁)

Honest transcripts of andProof add their component transcript distances (δ₀ + δ₁).

theorem Cslib.Crypto.Protocols.SigmaProtocol.closeTo_orProofWith_transcript {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type} [AddCommGroup C] {sampleChallenge sampleChallenge' : PMF C} {P₀ P₀' : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ P₁' : SigmaProtocol X₁ Y₁ T₁ C Z₁} {R₀ : X₀ → Y₀ → Prop} {R₁ : X₁ → Y₁ → Prop} {simulate₀ simulate₀' : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ simulate₁' : Y₁ → C → PMF (T₁ × Z₁)} {x : X₀ ⊕ X₁} {y : Y₀ × Y₁} (hxy : orRelation R₀ R₁ x y) (c : C) {δC δS δP : ENNReal} (hc : Probability.CloseTo sampleChallenge sampleChallenge' δC) (hs₀ : ∀ (c₀ : C), Probability.CloseTo (simulate₀ y.1 c₀) (simulate₀' y.1 c₀) δS) (hs₁ : ∀ (c₁ : C), Probability.CloseTo (simulate₁ y.2 c₁) (simulate₁' y.2 c₁) δS) (hp₀ : ∀ (x₀ : X₀), R₀ x₀ y.1 → ∀ (c₀ : C), Probability.CloseTo (P₀.transcript x₀ y.1 c₀) (P₀'.transcript x₀ y.1 c₀) δP) (hp₁ : ∀ (x₁ : X₁), R₁ x₁ y.2 → ∀ (c₁ : C), Probability.CloseTo (P₁.transcript x₁ y.2 c₁) (P₁'.transcript x₁ y.2 c₁) δP) :
Probability.CloseTo ((orProofWith sampleChallenge P₀ P₁ simulate₀ simulate₁).transcript x y c) ((orProofWith sampleChallenge' P₀' P₁' simulate₀' simulate₁').transcript x y c) (δC + (δS + δP))

Honest transcripts of orProofWith on any valid witness-statement pair (orRelation R₀ R₁) add the challenge-sampling error δC, the simulated-side error δS, and the witness-side honest transcript error δP.

theorem Cslib.Crypto.Protocols.SigmaProtocol.closeTo_parallelRepetition_transcript {X Y T C Z : Type} {P P' : SigmaProtocol X Y T C Z} {k : ℕ} {x : X} {y : Y} {c : Fin k → C} {δ : ENNReal} (h : ∀ (j : Fin k), Probability.CloseTo (P.transcript x y (c j)) (P'.transcript x y (c j)) δ) :

Honest transcripts of k-fold parallelRepetition multiply a uniform coordinate transcript distance δ by k.

theorem Cslib.Crypto.Protocols.SigmaProtocol.exists_negligible_inv_two_pow_map {D : Type} (setup : ℕ → PMF D) :
∃ (ε : ℕ → NNReal), Negligible ε ∧ ∀ (n : ℕ), ∀ i ∈ (PMF.map (fun (x : D) => (n, x)) (setup n)).support, 1 / 2 ^ i.1 ≤ ↑(ε n)

1 / 2 ^ n is bounded along any distribution paired with the security parameter by a negligible geometric sequence.