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
- Gadgets for allocating bits in the circuit and performing boolean logic.
- Gadgets representing numbers in the scalar field of the underlying curve.
Structs
- This represents a linear combination of some variables, with coefficients in the scalar field of a pairing-friendly elliptic curve group.
- This is a “namespaced” constraint system which borrows a constraint system (pushing a namespace context) and, when dropped, pops out of the namespace context.
- Represents a variable in our constraint system.
Enums
- Represents the index of either an input variable or auxiliary variable.
- This is an error that could occur during circuit synthesis contexts, such as CRS generation, proving or verification.
Constants
Traits
- 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. Thesynthesize
method is called during CRS generation and during proving. - Represents a constraint system which can have new variables allocated and constrains between them formed.