halo2/halo2_gadgets
Jack Grigg 78de8a5c94 Add a `Constraints` helper
There are two existing patterns for constructing a gate from a set of
constraints with a common selector:

- Create an iterator of constraints, where each constraint includes the
  selector:
  ```
  vec![
      ("foo", selector.clone() * foo),
      ("bar", selector.clone() * bar),
      ("baz", selector * bar),
  ]
  ```
  This requires the user to write O(n) `selector.clone()` calls.

- Create an iterator of constraints, and then map the selector in:
  ```
  vec![
      ("foo", foo),
      ("bar", bar),
      ("baz", bar),
  ].into_iter().map(move |(name, poly)| (name, selector.clone() * poly))
  ```
  This looks cleaner overall, but the API is not as intuitive, and it
  is messier when the constraints are named.

The `Constraints` struct provides a third, clearer API:
```
Constraints::with_selector(
    selector,
    vec![
        ("foo", foo),
        ("bar", bar),
        ("baz", bar),
    ],
)
```
This focuses on the structure of the constraints, and handles the
selector application for the user.
2022-04-20 10:55:50 +00:00
..
benches Remove VerifyingKey serialization from sha256 gadget benchmark 2022-03-17 18:58:53 +00:00
proptest-regressions/constants Migrate to `halo2_gadgets` crate in subdir 2022-01-27 23:08:01 +00:00
src Add a `Constraints` helper 2022-04-20 10:55:50 +00:00
CHANGELOG.md halo2_gadgets 0.1.0-beta.3 2022-04-06 12:28:36 +08:00
Cargo.toml halo2_gadgets 0.1.0-beta.3 2022-04-06 12:28:36 +08:00
README.md halo2_gadgets 0.1.0-beta.1 2022-02-14 21:58:20 +00:00
katex-header.html Fix docs.rs build 2022-03-17 19:14:11 +00:00
rust-toolchain Migrate to `halo2_gadgets` crate in subdir 2022-01-27 23:08:01 +00:00

README.md

halo2_gadgets Crates.io

IMPORTANT: This library is in beta, and should not be used in production software.

Requires Rust 1.51+.

Documentation

License

Copyright 2020-2022 The Electric Coin Company.

You may use this package under the Bootstrap Open Source Licence, version 1.0, or at your option, any later version. See the file COPYING for more details, and LICENSE-BOSL for the terms of the Bootstrap Open Source Licence, version 1.0.

The purpose of the BOSL is to allow commercial improvements to the package while ensuring that all improvements are open source. See here for why the BOSL exists.