Skip to content

Circuits

In this section, we explain how to build real circuits.

Before we can do this, we need to elaborate a few concepts that only exist in ZK. We need to explain what wires are, for example, as well as the distinction between public and witness wires. Having done that, we turn to practical matters. We go through various motifs that arise repeatedly in practical circuit design.

Here are the pages in this section:

  • Introduction. Here, we set up basic notions, like wires, and explain the distinction between witness and public wires. We also talk about gates and gadgets.
  • Gadgets. Gadgets are reusable components designed to achieve common operations (like byte-manipulation and hashing). By composing these and wiring them together, we can quickly build complex cryptographic circuits.
  • Control Flow. Circuits can't run if-statements and loops, like classic imperative programs can. Here, we explain how to port these patterns into the language of circuits. Multiplexers will prove to be a key tool.
  • Composition. Composition is a key idea that lets us build large, complex circuits out of smaller ones by using smaller circuits as reusable components.
  • Performance. Here, we sketch how to understand the costs of the circuits you build. We explain the various cost metrics that circuits have, like number of witness values and number of constraints.