Documentation

Complexity.Crypto.Computational.ZeroKnowledge

Computational zero-knowledge interactive proofs for NP #

Goldreich, Micali, and Wigderson [GMW91] proved that if one-way functions exist, then every language in NP has a computational zero-knowledge interactive proof system. This module defines computational zero-knowledge interactive proofs (ZeroKnowledgeProof) together with explicit public API predicates distinguishing restricted polynomial-time-generable zero-knowledge (GenerableZeroKnowledge) from general auxiliary-input zero-knowledge over arbitrary polynomially bounded valid families (AuxiliaryInputZeroKnowledge), and constructs a proof system for ThreeSAT and hence for every language in NP via ThreeSAT_npHard and Naor's bit commitment scheme [Nao91] (Complexity.Crypto.Computational.Commitment).

Protocol design and source credit #

While the theorem that every language in NP has a computational zero-knowledge interactive proof system from one-way functions is due to Goldreich, Micali, and Wigderson [GMW91] using Naor's commitment scheme [Nao91], the concrete underlying ThreeSAT protocol formalized in Complexity.Crypto.Computational.GMW is a direct 3-copy masked-3SAT truth-table commitment protocol rather than GMW's original 3-coloring protocol: each of 3 parallel copies commits to a random variable mask, the XOR-masked assignment, and the 8-entry masked truth table of each clause, and a random 3-bit challenge selects for each copy whether to open the mask and full truth tables or the masked assignment and the active truth-table entries.

Restricted versus general auxiliary-input zero-knowledge and witness conventions #

Main definitions #

Main results #

References #

Restricted versus general auxiliary-input zero-knowledge predicates #

def Cslib.Crypto.GenerableZeroKnowledge {α : Type} (enc : α ↪ List Bool) (prover : ℕ → α → List Bool → Complexity.Prover Unit) (isWitness : α → List Bool → Bool) :

Uniform computational zero-knowledge with polynomial-time-generable families. For every uniform strict oracle PPT malicious verifier Vstar (taking security parameter n, instance a, and auxiliary input z, charged for the complete encoded input (1^n, (a, z))), there exists a single uniform strict PPT witness-free simulator S (chosen before the families and charged for (1^n, (a, z))) whose output ensemble is computationally indistinguishable from the real interaction output across all deterministic polynomial-time-generable families of instances a : ℕ → α, valid witnesses w : ℕ → List Bool (∀ n, isWitness (a n) (w n) = true), and auxiliary inputs z : ℕ → List Bool (ComputableInPolyTime · encUnary _).

Instances For
    def Cslib.Crypto.AuxiliaryInputZeroKnowledge {α : Type} (enc : α ↪ List Bool) (prover : ℕ → α → List Bool → Complexity.Prover Unit) (isWitness : α → List Bool → Bool) :

    General auxiliary-input computational zero-knowledge for arbitrary polynomially bounded valid families. For every uniform strict oracle PPT malicious verifier Vstar (charged for its complete encoded input (1^n, (a, z))), there exists a single uniform strict PPT witness-free simulator S (chosen before the families and distinguisher, and charged for (1^n, (a, z))) such that for all arbitrary polynomially bounded families of instances a : ℕ → α, valid witnesses w : ℕ → List Bool (∀ n, isWitness (a n) (w n) = true), and auxiliary inputs z : ℕ → List Bool, and for every uniform strict PPT distinguisher adversary (charged for its complete encoded input ((1^n, (a, z)), view)), the distinguishing advantage between the real interaction view and the simulated view is negligible.

    Instances For
      theorem Cslib.Crypto.AuxiliaryInputZeroKnowledge.generableZeroKnowledge {α : Type} {enc : α ↪ List Bool} {prover : ℕ → α → List Bool → Complexity.Prover Unit} {isWitness : α → List Bool → Bool} (h : AuxiliaryInputZeroKnowledge enc prover isWitness) :
      GenerableZeroKnowledge enc prover isWitness

      General auxiliary-input zero-knowledge implies poly-time-generable zero-knowledge. Every deterministic polynomial-time-generable family has polynomially bounded encoded output length, and every unary-indexed ComputationallyIndistinguishable distinguisher lifts to a full-input distinguisher by ignoring the extra (a, z) component.

      theorem Cslib.Crypto.GenerableZeroKnowledge.advantage_negligible {α : Type} {enc : α ↪ List Bool} {prover : ℕ → α → List Bool → Complexity.Prover Unit} {isWitness : α → List Bool → Bool} (h : GenerableZeroKnowledge enc prover isWitness) {Vstar : ℕ → α → List Bool → Probability.WordOracleComp Unit (List Bool)} (hV : Probability.IsOraclePPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair enc Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits fun (p : ℕ × α × List Bool) => Vstar p.1 p.2.1 p.2.2) :

      Under GenerableZeroKnowledge, any full-input uniform strict PPT distinguisher adversary n (a n) (z n) also has negligible distinguishing advantage on deterministic polynomial-time-generable families a, w, z, since (a n, z n) can be recomputed from 1^n.

      Bundled computational zero-knowledge proof systems #

      structure Cslib.Crypto.ZeroKnowledgeProof {α : Type} (enc : α ↪ List Bool) (A : Set α) :

      A computational zero-knowledge interactive proof system for a language A : Set α (with instance encoding enc : α ↪ List Bool), indexed by a security parameter n : ℕ Goldreich, Micali, and Wigderson.

      • verifier n a: the honest verifier's interactive program on security parameter n and instance a, certified uniform strict oracle PPT in (1^n, a) by isOraclePPT_verifier.
      • prover n a w: the honest prover strategy on security parameter n, instance a, and witness w, certified efficient by interact, eval_interact, and isPPT_interact.
      • isWitness a w: the bundled polynomial-time witness predicate characterizing membership in A (mem_iff_exists_witness). No witness-length bound is imposed, so isWitness by itself need not be an NP relation (in zero_knowledge, w is polynomial-time-generable in 1^n). When constructed via a Karp reduction f : α → CNF ℕ to ThreeSAT (PseudorandomGenerator.zeroKnowledgeProofOfReduction), isWitness a w is ThreeSAT.verifier (f a, w), checking a ThreeSAT witness for f a.
      • complete and sound: completeness 1 for valid witnesses and soundness error at most 1 / 3 against all computationally unbounded stateful provers P : Prover Unit.
      • zero_knowledge: uniform zero-knowledge with poly-time-generable families (GenerableZeroKnowledge enc prover isWitness). For every uniform strict oracle PPT malicious verifier Vstar (taking security parameter n, instance a, and auxiliary input z), there is a uniform strict PPT simulator S (taking (1^n, a, z) without any witness) whose output ensemble is computationally indistinguishable from the real interaction output across all deterministic polynomial-time-generable families of instances a : ℕ → α, valid witnesses w : ℕ → List Bool, and auxiliary inputs z : ℕ → List Bool (ComputableInPolyTime · encUnary _). The stronger general auxiliary-input property over arbitrary polynomially bounded valid families is stated separately as ZeroKnowledgeProof.AuxiliaryInputZeroKnowledge.
      Instances For

        Named projection for the restricted polynomial-time-generable zero-knowledge property bundled by ZeroKnowledgeProof.

        General auxiliary-input computational zero-knowledge for a bundled ZeroKnowledgeProof system, ranging over arbitrary polynomially bounded instance, valid-witness, and auxiliary-input families.

        Instances For

          General auxiliary-input zero-knowledge for zk implies the bundled restricted GenerableZeroKnowledge guarantee.

          theorem Cslib.Crypto.ZeroKnowledgeProof.AuxiliaryInputZeroKnowledge.zero_knowledge_const {α : Type} {enc : α ↪ List Bool} {A : Set α} {zk : ZeroKnowledgeProof enc A} (h : zk.AuxiliaryInputZeroKnowledge) {Vstar : ℕ → α → List Bool → Probability.WordOracleComp Unit (List Bool)} (hV : Probability.IsOraclePPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair enc Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits fun (p : ℕ × α × List Bool) => Vstar p.1 p.2.1 p.2.2) :
          ∃ (S : ℕ → α → List Bool → ProbComp (List Bool)), (Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair enc Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits fun (p : ℕ × α × List Bool) => S p.1 p.2.1 p.2.2) ∧ ∀ (a : α) (w : List Bool) (z : ℕ → List Bool), zk.isWitness a w = true → (PolynomiallyBounded fun (n : ℕ) => (z n).length) → ∀ (adversary : ℕ → α → List Bool → List Bool → ProbComp Bool), (Probability.IsPPTOn (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair enc Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool fun (p : (ℕ × α × List Bool) × List Bool) => adversary p.1.1 p.1.2.1 p.1.2.2 p.2) → Negligible fun (n : ℕ) => (distinguishingGame (PMF.map Prod.fst ((zk.prover n a w).run (Vstar n a (z n)) (zk.prover n a w).init)) (adversary n a (z n))).advantage (distinguishingGame (S n a (z n)).eval (adversary n a (z n)))

          Fixed-instance auxiliary-input zero-knowledge under zk.AuxiliaryInputZeroKnowledge: for any fixed instance a, valid witness w, and arbitrary polynomially bounded auxiliary-input family z : ℕ → List Bool, the real and simulated views have negligible distinguishing advantage against every full-input uniform strict PPT distinguisher.

          theorem Cslib.Crypto.ZeroKnowledgeProof.isInteractiveProof {α : Type} {enc : α ↪ List Bool} {A : Set α} (zk : ZeroKnowledgeProof enc A) (n : ℕ) :
          Complexity.IsInteractiveProof (zk.verifier n) A (2 / 3) (1 / 3)

          At every security parameter n, the honest verifier of a zero-knowledge proof system is an interactive proof for A with completeness 2 / 3 and soundness 1 / 3.

          theorem Cslib.Crypto.ZeroKnowledgeProof.mem_IP {α : Type} {enc : α ↪ List Bool} {A : Set α} (zk : ZeroKnowledgeProof enc A) :

          Every language with a zero-knowledge interactive proof system belongs to IP.

          Fixed-instance computational zero-knowledge: for every fixed instance a and valid witness w (zk.isWitness a w = true), and every polynomial-time auxiliary input family z : ℕ → List Bool, the real interaction output and simulator output are computationally indistinguishable.

          GMW zero-knowledge proof systems #

          noncomputable def Cslib.Crypto.PseudorandomGenerator.zeroKnowledgeProofOfReduction {α : Type} {enc : α ↪ List Bool} {A : Set α} {generator : List Bool → List Bool} {length : ℕ → ℕ} (hG : PseudorandomGenerator generator length) (hstretch : ∀ (k : ℕ), 3 * k + 1 ≤ length k) {f : α → Logic.PL.CNF ℕ} (hf : Turing.MultiTapeTM.ComputableInPolyTime f enc Complexity.encCNF) (hred : ∀ (a : α), a ∈ A ↔ f a ∈ Complexity.ThreeSAT) :

          Construct the Goldreich–Micali–Wigderson zero-knowledge proof system for any language A with a polynomial-time many-one reduction f : α → CNF ℕ to ThreeSAT, using a pseudorandom generator with stretch at least 3 * k + 1 and the 3-copy masked-3SAT commitment protocol in Cslib.Crypto.GMW. The bundled witness check isWitness a w is ThreeSAT.verifier (f a, w) on the reduced formula f a.

          Instances For
            theorem Cslib.Crypto.PseudorandomGenerator.auxiliaryInputZeroKnowledge_zeroKnowledgeProofOfReduction {α : Type} {enc : α ↪ List Bool} {A : Set α} {generator : List Bool → List Bool} {length : ℕ → ℕ} (hG : PseudorandomGenerator generator length) (hstretch : ∀ (k : ℕ), 3 * k + 1 ≤ length k) {f : α → Logic.PL.CNF ℕ} (hf : Turing.MultiTapeTM.ComputableInPolyTime f enc Complexity.encCNF) (hred : ∀ (a : α), a ∈ A ↔ f a ∈ Complexity.ThreeSAT) (hAdv : GMW.AdvicePRG enc generator length) :

            Under the explicit advice-PRG premise GMW.AdvicePRG enc generator length, the GMW proof system hG.zeroKnowledgeProofOfReduction hstretch hf hred satisfies general auxiliary-input zero-knowledge (ZeroKnowledgeProof.AuxiliaryInputZeroKnowledge) across all arbitrary polynomially bounded valid instance, witness, and auxiliary-input families.

            noncomputable def Cslib.Crypto.PseudorandomGenerator.zeroKnowledgeProofThreeSAT {generator : List Bool → List Bool} {length : ℕ → ℕ} (hG : PseudorandomGenerator generator length) (hstretch : ∀ (k : ℕ), 3 * k + 1 ≤ length k) :

            The Goldreich–Micali–Wigderson computational zero-knowledge proof system for ThreeSAT, built from any pseudorandom generator with stretch at least 3 * k + 1 via the 3-copy masked-3SAT commitment protocol in Cslib.Crypto.GMW.

            Instances For
              theorem Cslib.Crypto.PseudorandomGenerator.auxiliaryInputZeroKnowledge_zeroKnowledgeProofThreeSAT {generator : List Bool → List Bool} {length : ℕ → ℕ} (hG : PseudorandomGenerator generator length) (hstretch : ∀ (k : ℕ), 3 * k + 1 ≤ length k) (hAdv : GMW.AdvicePRG Complexity.encCNF generator length) :

              Under the explicit advice-PRG premise GMW.AdvicePRG encCNF generator length, the GMW proof system hG.zeroKnowledgeProofThreeSAT hstretch satisfies general auxiliary-input zero-knowledge (ZeroKnowledgeProof.AuxiliaryInputZeroKnowledge).

              theorem Cslib.Crypto.PseudorandomGenerator.exists_zeroKnowledgeProof_of_mem_NP {α : Type} {enc : α ↪ List Bool} {A : Set α} {generator : List Bool → List Bool} {length : ℕ → ℕ} (hG : PseudorandomGenerator generator length) (hstretch : ∀ (k : ℕ), 3 * k + 1 ≤ length k) (hA : A ∈ Complexity.NP enc) :

              Goldreich–Micali–Wigderson theorem (from a pseudorandom generator). Given a pseudorandom generator with stretch at least 3 * k + 1 (such as fun k => 3 * k + 1), every language A ∈ NP enc has a computational zero-knowledge interactive proof system Goldreich, Micali, and Wigderson in the uniform polynomial-time-generable sense (GenerableZeroKnowledge).

              theorem Cslib.Crypto.PseudorandomGenerator.exists_auxiliaryInputZeroKnowledge_of_mem_NP {α : Type} {enc : α ↪ List Bool} {A : Set α} {generator : List Bool → List Bool} {length : ℕ → ℕ} (hG : PseudorandomGenerator generator length) (hstretch : ∀ (k : ℕ), 3 * k + 1 ≤ length k) (hAdv : GMW.AdvicePRG enc generator length) (hA : A ∈ Complexity.NP enc) :

              Goldreich–Micali–Wigderson theorem under an explicit advice-PRG premise. Given a pseudorandom generator with stretch at least 3 * k + 1 that also satisfies the advice-supplied premise GMW.AdvicePRG enc generator length, every language A ∈ NP enc has a computational zero-knowledge interactive proof system satisfying general auxiliary-input zero-knowledge (ZeroKnowledgeProof.AuxiliaryInputZeroKnowledge) across all polynomially bounded valid families. This theorem takes GMW.AdvicePRG as an explicit hypothesis rather than deriving it from uniform PseudorandomGenerator or OneWay security.

              Goldreich–Micali–Wigderson theorem (from a one-way function). If a one-way function exists, then every language A ∈ NP enc has a computational zero-knowledge interactive proof system Goldreich, Micali, and Wigderson, in the uniform-family sense of GenerableZeroKnowledge (ZeroKnowledgeProof.zero_knowledge): instances, witnesses and auxiliary inputs range over polynomial-time-generable families rather than arbitrary ones.