Documentation

CslibFrontier.Crypto.Protocols.BCS.ROM.Protocol

Two-channel BCS random-oracle protocol, completeness, and RBR knowledge soundness #

Defines the two-channel random-oracle interface BCSROMSpec Stmt Chal := MerkleHashSpec ⊕ₒ BCSFSSpec Stmt Chal, the transcript-chained Fiat–Shamir bridge chainedFS, the oracle-program BCS prover and verifier (bcsProveROM, bcsVerifyROM), perfect completeness in the lazy two-channel random-oracle model (bcsHonestROMGame_eq_pure_true), per-channel query cost functions (bcsMTCost, bcsFSCost), and the round-by-round IOP knowledge-soundness predicate IOPRoundByRoundKnowledgeSoundness ([BSCS16]; compare [CY24], Construction 25.1.1, Remark 25.1.3, Chapter 26, and Chapter 31, Definition 31.1.6 and Theorem 31.3.1).

Main definitions #

Main results #

References #

@[reducible, inline]

Query input to the transcript-chained BCS Fiat–Shamir oracle: statement x, root prefix rts through the current round, and challenges prevChals from earlier rounds.

@[reducible, inline]

Oracle specification for the transcript-chained BCS Fiat–Shamir challenge oracle.

@[reducible, inline]

Combined two-channel random-oracle specification for the BCS transform: a Merkle hash oracle on the left (Sum.inl) and a transcript-chained Fiat–Shamir challenge oracle on the right (Sum.inr).

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.BCS.bcsOracle {Stmt Chal : Type} (hTree : List Bool → List Bool) (f : BCSFSQuery Stmt Chal → Chal) (q : List Bool ⊕ BCSFSQuery Stmt Chal) :
BCSROMSpec Stmt Chal q

Combine a deterministic Merkle hash hTree and a deterministic transcript-chained Fiat–Shamir function f into a deterministic oracle for BCSROMSpec Stmt Chal.

def Cslib.Crypto.Protocols.BCS.chainedFSChallenges {Stmt Chal : Type} (f : BCSFSQuery Stmt Chal → Chal) (x : Stmt) (rts : List (List Bool)) :
List Chal

Sequentially compute the transcript-chained Fiat–Shamir challenge list [c_0, ..., c_{k-1}] associated with a Merkle root list rts = [rt_0, ..., rt_{k-1}] under f.

def Cslib.Crypto.Protocols.BCS.chainedFS {Stmt Chal : Type} (f : BCSFSQuery Stmt Chal → Chal) (x : Stmt) (rts : List (List Bool)) :
Chal

Deterministic bridge turning a transcript-chained Fiat–Shamir function f : Stmt × List (List Bool) × List Chal → Chal into the root-prefix Fiat–Shamir interface Stmt → List (List Bool) → Chal of CslibFrontier/Crypto/Protocols/BCS/Basic.lean.

@[simp]
theorem Cslib.Crypto.Protocols.BCS.chainedFSChallenges_nil {Stmt Chal : Type} (f : BCSFSQuery Stmt Chal → Chal) (x : Stmt) :
theorem Cslib.Crypto.Protocols.BCS.chainedFSChallenges_concat {Stmt Chal : Type} (f : BCSFSQuery Stmt Chal → Chal) (x : Stmt) (rts : List (List Bool)) (rt : List Bool) :
chainedFSChallenges f x (rts ++ [rt]) = chainedFSChallenges f x rts ++ [chainedFS f x (rts ++ [rt])]
def Cslib.Crypto.Protocols.BCS.bcsChallengesProg {r : ℕ} {Stmt Chal : Type} (x : Stmt) (roots : Fin r → List Bool) :
OracleComp (BCSFSSpec Stmt Chal) (Fin r → Chal)

Sequentially query the transcript-chained Fiat–Shamir oracle to derive all r round challenges (c_0, ..., c_{r-1}) from (x, roots).

@[simp]
theorem Cslib.Crypto.Protocols.BCS.evalPure_bcsChallengesProg {r : ℕ} {Stmt Chal : Type} (f : BCSFSQuery Stmt Chal → Chal) (x : Stmt) (roots : Fin r → List Bool) :
def Cslib.Crypto.Protocols.BCS.bcsProveROM {r d : ℕ} {Stmt Wit Sym Chal : Type} (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (w : Wit) :
OracleComp (BCSROMSpec Stmt Chal) (BCSProof r Sym)

The BCS prover in the two-channel random-oracle model (bcsProveROM): runs all r commit-and-challenge rounds via bcsProveRoundsProg and opens every queried entry under merklePathProg ([BSCS16]; compare [CY24], Construction 25.1.1, printed pp. 274–275).

def Cslib.Crypto.Protocols.BCS.bcsVerifyOpeningsProg {r d : ℕ} {Stmt Wit Sym Chal : Type} (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (prf : BCSProof r Sym) (chals : Fin r → Chal) :

Verify all Merkle openings and the IOP decision predicate for a BCSProof given already derived challenges chals.

def Cslib.Crypto.Protocols.BCS.bcsVerifyROM {r d : ℕ} {Stmt Wit Sym Chal : Type} (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (prf : BCSProof r Sym) :

The BCS verifier in the two-channel random-oracle model (bcsVerifyROM): re-derives all r round challenges on the Fiat–Shamir channel via bcsChallengesProg and checks all Merkle openings and iop.decide on the Merkle channel via bcsVerifyOpeningsProg ([BSCS16]; compare [CY24], Construction 25.1.1, printed pp. 274–275).

@[simp]
theorem Cslib.Crypto.Protocols.BCS.evalPure_bcsProveROM {r d : ℕ} {Stmt Wit Sym Chal : Type} (hTree : List Bool → List Bool) (f : BCSFSQuery Stmt Chal → Chal) (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (w : Wit) :
OracleComp.evalPure (bcsOracle hTree f) (bcsProveROM iop encSym x w) = bcsProve iop (fun (x : List Bool) => hTree) [] encSym (chainedFS f) x w
@[simp]
theorem Cslib.Crypto.Protocols.BCS.evalPure_bcsVerifyOpeningsProg {r d : ℕ} {Stmt Wit Sym Chal : Type} (hTree : List Bool → List Bool) (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (prf : BCSProof r Sym) (chals : Fin r → Chal) :
OracleComp.evalPure hTree (bcsVerifyOpeningsProg iop encSym x prf chals) = ((prf.openings.length == (iop.queries x chals).length && ((iop.queries x chals).zip prf.openings).all fun (x : (Fin r × Fin (2 ^ d)) × MerkleOpening Sym) => match x with | ((j, idx), o) => MerkleOpening.verify (fun (x : List Bool) => hTree) [] encSym d (prf.roots j) (↑idx) o) && iop.decide x chals (List.map MerkleOpening.leaf prf.openings))
@[simp]
theorem Cslib.Crypto.Protocols.BCS.evalPure_bcsVerifyROM {r d : ℕ} {Stmt Wit Sym Chal : Type} (hTree : List Bool → List Bool) (f : BCSFSQuery Stmt Chal → Chal) (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (prf : BCSProof r Sym) :
OracleComp.evalPure (bcsOracle hTree f) (bcsVerifyROM iop encSym x prf) = bcsVerify iop (fun (x : List Bool) => hTree) [] encSym (chainedFS f) x prf
theorem Cslib.Crypto.Protocols.BCS.bcsVerifyROM_bcsProveROM_eq_true {r d : ℕ} {Stmt Wit Sym Chal : Type} {iop : PublicCoinIOP r d Stmt Wit Sym Chal} {rel : Stmt → Wit → Prop} (hcomp : IOPCompleteness iop rel) (hTree : List Bool → List Bool) {ℓ : ℕ} (hlen : ∀ (y : List Bool), (hTree y).length = ℓ) (f : BCSFSQuery Stmt Chal → Chal) (encSym : Sym → List Bool) {x : Stmt} {w : Wit} (hrel : rel x w) :
(OracleComp.evalPure (bcsOracle hTree f) do let prf ← bcsProveROM iop encSym x w bcsVerifyROM iop encSym x prf) = true

Perfect completeness of the BCS ROM programs (OracleComp simulation form): under any deterministic Merkle hash hTree whose digests all have one length and any transcript-chained Fiat–Shamir function f, bcsVerifyROM accepts bcsProveROM on every (x, w) satisfying rel x w.

noncomputable def Cslib.Crypto.Protocols.BCS.bcsOracleDist (Stmt Chal : Type) [Fintype Chal] [Nonempty Chal] (σ : ℕ) (q : List Bool ⊕ BCSFSQuery Stmt Chal) :
PMF (BCSROMSpec Stmt Chal q)

Per-query distribution of the two-channel BCS random oracle with σ-bit Merkle digests and uniform challenges over Chal: Merkle hash queries (Sum.inl) sample BitString.uniformList σ, and Fiat–Shamir queries (Sum.inr) sample PMF.uniformOfFintype Chal.

def Cslib.Crypto.Protocols.BCS.bcsHonestROMProg {r d : ℕ} {Stmt Wit Sym Chal : Type} (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (w : Wit) :

The honest BCS execution as a two-channel OracleComp program: generate a proof via bcsProveROM and verify it via bcsVerifyROM against the same oracle.

noncomputable def Cslib.Crypto.Protocols.BCS.bcsHonestROMGame {r d : ℕ} {Stmt Wit Sym Chal : Type} [DecidableEq Stmt] [DecidableEq Chal] [Fintype Chal] [Nonempty Chal] (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (encSym : Sym → List Bool) (x : Stmt) (w : Wit) (σ : ℕ) :

The honest BCS random-oracle experiment with σ-bit Merkle digests: runs bcsHonestROMProg against the shared lazy random oracle RandomOracle.answer (bcsOracleDist Stmt Chal σ) from an empty cache.

theorem Cslib.Crypto.Protocols.BCS.bcsHonestROMGame_eq_pure_true {r d : ℕ} {Stmt Wit Sym Chal : Type} [DecidableEq Stmt] [DecidableEq Chal] [Fintype Chal] [Nonempty Chal] {iop : PublicCoinIOP r d Stmt Wit Sym Chal} {rel : Stmt → Wit → Prop} (hcomp : IOPCompleteness iop rel) (encSym : Sym → List Bool) {x : Stmt} {w : Wit} (hrel : rel x w) (σ : ℕ) :
bcsHonestROMGame iop encSym x w σ = PMF.pure true

Perfect completeness of the BCS transform in the lazy two-channel random-oracle model: if iop satisfies IOPCompleteness iop rel and rel x w holds, then for every digest length σ, bcsHonestROMGame outputs true with probability 1 ([BSCS16]; compare [CY24], Construction 25.1.1, printed pp. 274–275).

structure Cslib.Crypto.Protocols.BCS.IOPRoundByRoundKnowledgeSoundness {r d : ℕ} {Stmt Wit Sym Chal : Type} (iop : PublicCoinIOP r d Stmt Wit Sym Chal) (rel : Stmt → Wit → Prop) (iopExtract : Stmt → (Fin r → OracleTable d Sym) → Wit) (doomed : Stmt → List (OracleTable d Sym × Chal) → Prop) (goodStep : Stmt → List (OracleTable d Sym × Chal) → OracleTable d Sym → Chal → Prop) :

Round-by-round knowledge soundness of a PublicCoinIOP for relation rel with straight-line IOP extractor iopExtract, doomed-prefix predicate doomed, and non-escaping round transitions goodStep (compare IOPRoundByRoundSoundness and [CY24], Chapter 31, Definition 31.1.6 and Theorem 31.3.1, as well as state-restoration knowledge soundness in [BSCS16] and [CY24], Chapter 26, Theorem 26.1.1; note that extract_of_doomed here is deterministic on complete doomed transcripts):

  1. Every statement x starts in doomed x [] on the empty transcript prefix.
  2. Every non-escaping challenge goodStep x pref π c preserves doomed.
  3. On any complete transcript List.ofFn (fun j => (oracles j, chals j)) that remains doomed, if iopVerify accepts oracles at chals, then iopExtract x oracles satisfies rel x.
  • init_doomed (x : Stmt) : doomed x []

    Every statement starts in doomed on the empty transcript prefix.

  • step_doomed (x : Stmt) (pref : List (OracleTable d Sym × Chal)) (π : OracleTable d Sym) (c : Chal) : doomed x pref → goodStep x pref π c → doomed x (pref ++ [(π, c)])

    Every non-escaping challenge preserves doomed.

  • extract_of_doomed (x : Stmt) (oracles : Fin r → OracleTable d Sym) (chals : Fin r → Chal) : doomed x (List.ofFn fun (j : Fin r) => (oracles j, chals j)) → iopVerify iop x chals oracles = true → rel x (iopExtract x oracles)

    On any doomed complete transcript accepted by iopVerify, iopExtract recovers a valid witness for x.

theorem Cslib.Crypto.Protocols.BCS.IOPRoundByRoundKnowledgeSoundness.toRoundByRoundSoundness {r d : ℕ} {Stmt Wit Sym Chal : Type} {iop : PublicCoinIOP r d Stmt Wit Sym Chal} {rel : Stmt → Wit → Prop} {iopExtract : Stmt → (Fin r → OracleTable d Sym) → Wit} {doomed : Stmt → List (OracleTable d Sym × Chal) → Prop} {goodStep : Stmt → List (OracleTable d Sym × Chal) → OracleTable d Sym → Chal → Prop} (hks : IOPRoundByRoundKnowledgeSoundness iop rel iopExtract doomed goodStep) :
IOPRoundByRoundSoundness iop {x : Stmt | ∃ (w : Wit), rel x w} (fun (x : Stmt) (pref : List (OracleTable d Sym × Chal)) => x ∉ {x : Stmt | ∃ (w : Wit), rel x w} ∧ doomed x pref) goodStep

IOPRoundByRoundKnowledgeSoundness for rel implies IOPRoundByRoundSoundness for the associated language {x | ∃ w, rel x w} with the same goodStep relation.

theorem Cslib.Crypto.Protocols.BCS.IOPRoundByRoundKnowledgeSoundness.rel_iopExtract_of_goodSteps {r d : ℕ} {Stmt Wit Sym Chal : Type} {iop : PublicCoinIOP r d Stmt Wit Sym Chal} {rel : Stmt → Wit → Prop} {iopExtract : Stmt → (Fin r → OracleTable d Sym) → Wit} {doomed : Stmt → List (OracleTable d Sym × Chal) → Prop} {goodStep : Stmt → List (OracleTable d Sym × Chal) → OracleTable d Sym → Chal → Prop} (hks : IOPRoundByRoundKnowledgeSoundness iop rel iopExtract doomed goodStep) (x : Stmt) (oracles : Fin r → OracleTable d Sym) (chals : Fin r → Chal) (hsteps : ∀ (j : Fin r), goodStep x (List.take (↑j) (List.ofFn fun (i : Fin r) => (oracles i, chals i))) (oracles j) (chals j)) (hver : iopVerify iop x chals oracles = true) :
rel x (iopExtract x oracles)

If every round's challenge satisfies goodStep under IOPRoundByRoundKnowledgeSoundness and iopVerify accepts, then iopExtract recovers a valid witness for x.

Cost of a BCS oracle call on the Merkle hash channel (Sum.inl).

Cost of a BCS oracle call on the Fiat–Shamir challenge channel (Sum.inr).