Crate bellpepper_core

Crate bellpepper_core 

Source
Expand description

bellpepper is a crate for building zk-SNARK circuits. It provides circuit traits and and primitive structures, as well as basic gadget implementations such as booleans and number abstractions.

§Example circuit

Say we want to write a circuit that proves we know the preimage to some hash computed using SHA-256d (calling SHA-256 twice). The preimage must have a fixed length known in advance (because the circuit parameters will depend on it), but can otherwise have any value. We take the following strategy:

  • Witness each bit of the preimage.
  • Compute hash = SHA-256d(preimage) inside the circuit.
  • Expose hash as a public input using multiscalar packing.

Modules§

boolean
Gadgets for allocating bits in the circuit and performing boolean logic.
num
Gadgets representing numbers in the scalar field of the underlying curve.
test_cs

Structs§

LinearCombination
This represents a linear combination of some variables, with coefficients in the scalar field of a pairing-friendly elliptic curve group.
Namespace
This is a “namespaced” constraint system which borrows a constraint system (pushing a namespace context) and, when dropped, pops out of the namespace context.
Variable
Represents a variable in our constraint system.

Enums§

Delta
Index
Represents the index of either an input variable or auxiliary variable.
SynthesisError
This is an error that could occur during circuit synthesis contexts, such as CRS generation, proving or verification.

Constants§

BELLPEPPER_VERSION

Traits§

Circuit
Computations are expressed in terms of arithmetic circuits, in particular rank-1 quadratic constraint systems. The Circuit trait represents a circuit that can be synthesized. The synthesize method is called during CRS generation and during proving.
Comparable
ConstraintSystem
Represents a constraint system which can have new variables allocated and constrains between them formed.

Type Aliases§

Constraint