Skip to main content

Crate binius_frontend

Crate binius_frontend 

Source
Expand description

Circuit construction frontend for Binius64.

This crate provides the CircuitBuilder API for constructing arithmetic circuits that compile to Binius64 constraint systems. You describe your computation as a graph of operations on 64-bit words, and the frontend compiles it to AND/IMUL/BMUL constraints.

§Usage Flow

Use CircuitBuilder to construct your circuit. Call methods like add_witness() and add_inout() to create Wires - handles to 64-bit values that will exist during proof generation. Use operations like band(), bxor(), and iadd_32() to transform these wires, building up your computation graph.

When you call build(), the builder compiles your graph into a Circuit. This circuit contains the optimized constraint system and everything needed for proof generation.

To generate a witness, create a WitnessFiller from the circuit. Assign concrete values to your input wires, then call populate_wire_witness() to compute all intermediate values through circuit evaluation.

Use CircuitStat to inspect metrics like constraint counts and wire usage, helpful for optimization and debugging.

§Layout

  • builder — the vocabulary a circuit author writes.
  • ir — the gate graph those calls build, held as dense index maps.
  • gates — the shape, the constraints and the instruction of each gate kind.
  • pass — transformations over the graph, and the pipeline that runs them.
  • lower — the constraints a graph emits, over wires rather than value indices.
  • eval_form — the bytecode that fills a witness, and the interpreters that run it.
  • artifact — what a build hands back: the circuit, its witnesses, its statistics.

Every module reads ir, and nothing reads builder.

Modules§

chip
Circuits composed out of chips, each generating the witness of one M4 chip.
hints
Hint system.
stat
Circuit statistics module for analyzing constraint counts and circuit complexity.

Structs§

AssertionFailure
A single assertion that did not hold while populating the witness.
BatchPopulateError
The failure of batch witness population, attributed to a single instance.
BatchWitnessFiller
Assigns witness input wires of one instance into a ValueTable working buffer.
ChipRef
A chip of the system a CircuitBuilder is building.
Circuit
An artifact that represents a built circuit.
CircuitBuilder
Circuit builder for constructing zero-knowledge proof circuits.
CircuitM4
A circuit composed of chips, as the circuits that generate their witnesses.
CircuitStat
Various stats of a circuit that affect the prover performance.
EmbeddedCircuit
One chip of a CircuitM4, as the circuit that generates its witness.
Options
Which compiler passes run.
PopulateError
Witness population failed because the circuit is not satisfied.
Wire
A wire through which a value flows in and out of gates.
WitnessFiller
A helper struct for filling witness values in a circuit.

Enums§

CircuitM4Error
Reason an M4 circuit cannot be populated as it stands.
PopulateM4Error
Reason the witness of an M4 circuit could not be generated.

Constants§

MAX_ASSERTION_FAILURES
The cap on how many assertion failures an execution context retains.

Traits§

ChipGadget
A gadget the builder emits either as inline gates or as a call to a chip.
Hint
Hint handler trait for extensible operations.