Commit Graph

29 Commits

Author SHA1 Message Date
therealyingtong 41c87eac0f Restrict query_fixed to current Rotation.
query_fixed no longer takes a Rotation argument and can only be
used to query the current rotation.
2022-12-09 16:47:19 +08:00
therealyingtong 153a08c755 query_any: panic if query_fixed is called with non-cur Rotation. 2022-12-09 16:47:14 +08:00
Jack Grigg 1d9790b2ce Migrate to published `ff 0.13` 2022-12-06 04:55:21 +00:00
Jack Grigg cb819e47e9 Migrate to `ff` revision without `FieldExt` 2022-11-30 19:35:26 +00:00
therealyingtong 966b5fc3b7 halo2_proofs/CHANGELOG: Document structs which now derive Eq 2022-11-30 15:13:55 +00:00
Jack Grigg 3e6df2b1de halo2_proofs: Replace `pasta_curves::arithmetic::Group` with new blanket trait 2022-11-30 03:41:45 +00:00
Jack Grigg 49b2324f0a Replace unnecessary dependencies on `FieldExt` trait 2022-11-30 03:41:19 +00:00
therealyingtong 6038b87a1d halo2_proofs: Introduce RegionLayouter::instance_value method.
This allows us to access instance column values within a region.
Previously, this was done only through assign_advice_from_instance.
2022-07-07 17:18:42 -04:00
Sean Bowe deef0e1416
Place `halo2_proofs::plonk::BatchVerifier` behind a (default enabled) crate feature called `batch`. 2022-06-23 12:51:47 -06:00
Jack Grigg 7a22f3c9b6 halo2_proofs 0.2.0 2022-06-23 17:40:23 +00:00
Jack Grigg dd94fb95a4 Rework `halo2_proofs::plonk::BatchVerifier`
`BatchVerifier` now manages the entire batch verification process.
Individual proofs are verified on a threadpool, and the resulting MSMs
are then batch-checked as before. The addition of parallelism here
couples with zcash/halo2#608 to make parallelism less fine-grained and
reduce the overhead of multi-threading.
2022-06-23 16:52:08 +00:00
Jack Grigg 22ec36979c Add `BatchVerifier::finalize_and_return_rng` 2022-06-21 15:04:08 +00:00
Jack Grigg 47f25ad632 halo2_proofs: Replace `Option<V>` with `Value<V>` 2022-06-08 23:03:16 +00:00
Jack Grigg c17d52e5bf halo2_proofs: Add `halo2_proofs::circuit::Value<V>`
This is a more usable and type-safe replacement for `Option<V>` in
circuit synthesis.
2022-06-08 22:29:14 +00:00
Jack Grigg 3bc0c598ef halo2_proofs 0.1.0
Closes zcash/halo2#426.
2022-05-10 22:01:21 +00:00
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
str4d 46ba444169
Merge pull request #480 from zcash/477-mockprover-pretty-failures
Add `MockProver::assert_satisfied` with pretty-printed failures
2022-04-20 12:53:16 +02:00
therealyingtong a11cb9796e halo2_proofs 0.1.0-beta.4 2022-04-06 12:24:28 +08:00
Sean Bowe 4163b8765a
Reduce depth of AST by special casing the application of Horner's rule.
The existing code will fold together a very deep AST that applies Horner's
rule to each gate in a proof -- which could include multiple circuits and
so for some applications will quickly grow such that when we recursively
descend later during evaluation the stack will easily overflow.

This change special cases the application of Horner's rule to a
"DistributePowers" AST node to keep the tree depth from exploding in size.
2022-04-02 13:13:46 -06:00
Jack Grigg 0946bdb455 dev: Enable `VerifyFailure::Permutation` to point to region offsets 2022-03-30 01:39:50 +00:00
Jack Grigg 8acd4abfb3 halo2_proofs 0.1.0-beta.3 2022-03-22 19:59:10 +00:00
Jack Grigg e39c8e94d2 Update changelogs 2022-03-22 19:55:53 +00:00
Jack Grigg 369ff521d3 dev: Store gate offset in `VerifyFailure::CellNotAssigned` 2022-02-16 13:57:53 +00:00
Jack Grigg 5cdc029bb4 dev: Add `MockProver::assert_satisfied`
This is equivalent to `assert_eq!(mock_prover.verify(), Ok(()))`, but
pretty-prints the verification failures instead of debug-printing them.
In its initial state, it just prints the `Display` impl.
2022-02-16 13:56:17 +00:00
Jack Grigg f642727e51 halo2_proofs 0.1.0-beta.2 2022-02-14 21:58:20 +00:00
Jack Grigg e0cc7b39d3 Update changelogs 2022-02-14 21:29:42 +00:00
Sean Bowe f2daf91315
halo2_proofs: change IPA check equation to match the book
The verifier's check in the inner product argument used to assume that the
G'_0 value had an additional (trivial) blinding factor term, which makes
it slightly easier to reason that it never is the point at infinity.
However, we never sample challenges that are zeroes (both for security
and completeness reasons) so this element would never be the point at
infinity anyway. Thus, we can simplify the check with the added benefit of
matching the book's description of the protocol.
2022-02-14 09:37:57 -07:00
Jack Grigg 4d336f2707 halo2_proofs: Improve `plonk::verify_proof` API
Previously `plonk::verify_proof` took an `MSM` as an argument, to enable
batch verification. However, this also required that it take a source of
randomness in order to enforce separation of proofs within a batch. This
made single-proof verification unnecessarily non-deterministic.

We now have a `VerificationStrategy` trait encapsulating the necessary
details, and separate `SingleVerifier` and `BatchVerifier` structs for
the specific variants. Proof verifiers no longer need to create and
manage the `MSM` themselves, and single-proof verifiers no longer need
to supply a source of randomness.

Co-authored-by: Sean Bowe <sean@electriccoin.co>
2022-01-27 00:20:56 +00:00
Jack Grigg 3c6558f049 Move `halo2` code into `halo2_proofs` crate 2022-01-20 18:50:43 +00:00