midnight-circuits

Crates.iomidnight-circuits
lib.rsmidnight-circuits
version6.0.0
created_at2025-10-28 16:29:28.812376+00
updated_at2025-12-19 16:15:02.633173+00
descriptionCircuit and gadget implementations for Midnight zero-knowledge proofs
homepage
repository
max_upload_size
id1905138
size1,992,999
(MidnightCI)

documentation

README

Midnight Circuits

CI checks Examples

Midnight Circuits is a library designed for implementing circuits with Halo2. It is built on the PSE v0.4.0 release of Halo2, incorporating a few minor additions required to support Midnight Circuits.

Disclaimer: This library has not been audited. Use it at your own risk.

Features

Midnight Circuits provides several tools to facilitate circuit development with Halo2. These include:

  1. Native and non-native field operations.
  2. Native and non-native elliptic-curve operations.
  3. Native and non-native hash-to-curve functionality.
  4. Bit/Byte decomposition tools and range-checks.
  5. SHA-256.
  6. SHA-512.
  7. Set (non-)membership.
  8. BigUInt.
  9. Variable length vectors (see explanation below).
  10. Finite-state automata parsing.
  11. In-circuit verification of PLONK proofs (a.k.a. recursion).

We aim to expose these functionalities via traits, which can be found in [src/instructions].

Variable length vectors

We provide support for variable-length vectors in-circuit, even when the exact size of the vector is unknown at compilation time. Each variable-length vector is parameterized with a MAX_LENGTH attribute, which specifies the maximum allowed size.

The cost of using these structures in-circuit is proportional to the MAX_LENGTH, while the computed result is guaranteed to correspond to the operation applied to the actual vector values. For example, operations such as hashing or parsing are performed over the full vector of length MAX_LENGTH, and the final result is conditionally selected to reflect the operation applied only to the actual elements of the vector.

Usage

Midnight Circuits provides low-level building blocks for constructing zero-knowledge circuits. For a higher-level abstraction that simplifies circuit development, see the midnight-zk-stdlib crate.

Versioning

We use Semantic Versioning. To capture the changes that do not affect the API, do not add any new functionality, but are breaking changes, we increment the MAJOR version. This happens when the circuit is modified for performance or bug fixes; the modification of the verification keys break backwards compatibility.

  • MAJOR: Incremented when you make incompatible API or VK changes
  • MINOR: Incremented when you add functionality in a backward-compatible manner
  • PATCH: Incremented when you make backward-compatible bug fixes
Commit count: 0

cargo fmt