[][src]Module zkp::toolbox

Contains lower-level tools that allow programmable specification of proof statements.

The higher-level define_proof macro allows declarative specification of static proof statements, and expands into code that uses this lower-level API. This lower-level API can also be used directly to perform imperative specification of proof statements, allowing proof statements with runtime parameters (e.g., an anonymous credential with a variable number of attributes).

The SchnorrCS trait defines the common constraint system API used for specifying proof statements; it is implemented by the Prover, Verifier, and BatchVerifier structs.

Roughly speaking, the tools fit together in the following way:

  • Statements are defined as generic functions which take a SchnorrCS implementation and some variables, and add the proof statements to the constraint system;

  • To create a proof, construct a Prover, allocate and assign variables, pass the prover and the variables to the generic statement function, then consume the prover to obtain a proof.

  • To verify a proof, construct a Verifier, allocate and assign variables, pass the verifier and the variables to the generic statement function, then consume the verifier to obtain a verification result.

Note that the expansion of the define_proof macro contains a public internal module with the generated proof statement function, making it possible to combine generated and hand-crafted proof statements into the same constraint system.

Modules

batch_verifier

Implements batch verification of batchable proofs.

prover

Implements proof creation.

verifier

Implements proof verification of compact and batchable proofs.

Traits

SchnorrCS

An interface for specifying proof statements, common between provers and verifiers.

TranscriptProtocol

This trait defines the wire format for how the constraint system interacts with the proof transcript.