Commit Graph

101 Commits

Author SHA1 Message Date
Jack Grigg e65974eb2d halo2_proofs: Remove lint overrides now that MSRV is above 1.51 2022-09-09 17:45:00 +00:00
Jack Grigg f852be62a8 halo2_proofs: Remove unused imports 2022-09-09 17:43:43 +00:00
Jack Grigg 60696a7cfa halo2_proofs: Proxy all `rayon` usage through `halo2_proofs::multicore`
Part of zcash/halo2#648.
2022-09-09 17:36:05 +00:00
Jack Grigg df61767e02 halo2_proofs: Reduce memory usage of `poly::Evaluator`
`poly::Evaluator` stores all of the polynomials registered with it in
memory for the duration of its existence. When evaluating an AST, it
additionally caches the rotated polynomials in memory, and then chunks
all of the rotated polynomials for parallel evaluation.

Previously, it stored a polynomial for every unique AST leaf, regardless
of whether that leaf required a rotation or not. This resulted in the
unrotated polynomials being stored twice in memory. However, the chunks
simply refer to slices over cached polynomials, so we can reference the
unrotated polynomials stored in `poly::Evaluator` instead of copies of
them stored in the rotated polynomial `HashMap`. This strictly reduces
memory usage during proving with no effect on correctness.
2022-08-23 18:25:39 +00:00
han0110 8ff5b1e3af feat: make `Expression::{Fixed,Advice,Instance}` to wrap their own `Query` struct 2022-07-15 10:33:47 -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 5641a64d3c halo2_proofs: Fix clippy lints 2022-06-23 17:38:11 +00:00
str4d dac6cfb5d7
Merge pull request #610 from zcash/rework-batch-verifier
Rework `halo2_proofs::plonk::BatchVerifier`
2022-06-23 18:15:24 +01: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
ebfull 7087c33658
Merge pull request #608 from ebfull/msm-optimization
MSM optimizations
2022-06-23 10:49:22 -06:00
Daira Hopwood 2ed70a3f08 Reduce memory overhead of MSM by 64 bytes per "other" base, and add tests.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-06-23 14:15:37 +01:00
Sean Bowe 6b4af24a5f
Deduplicate the extra (scalar, base) pairs in MSMs. 2022-06-22 14:31:00 -06:00
Sean Bowe 6939ac47ab
Remove parallelism from within MSM scalar operations. 2022-06-22 13:41:45 -06:00
Jack Grigg 05f37ee8a6 Cache the constraint system degree in `VerifyingKey`
This means we only compute the degree in a verification context during
construction, instead of twice per proof in the permutation argument.
2022-06-22 19:33:36 +00:00
Jack Grigg 4802936c56 Cache the representative of `VerifyingKey` used in transcripts
This means we only need to `Debug`-format the `PinnedVerificationKey`
once on construction, instead of once per proof.
2022-06-22 19:25:32 +00:00
Jack Grigg 22ec36979c Add `BatchVerifier::finalize_and_return_rng` 2022-06-21 15:04:08 +00:00
str4d 7cb71b4814
Update halo2_proofs/src/circuit/value.rs
Co-authored-by: ying tong <yingtong@z.cash>
2022-06-13 16:41:05 +01:00
Jack Grigg 5752adf0e5 halo2_proofs: `impl {Add, Sub, Mul} for &Value<V>` 2022-06-09 22:44:25 +00:00
Jack Grigg 521d6edd1c halo2_proofs: Make `Value::{known, unknown}` const 2022-06-09 22:40:11 +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 515f97769f halo2_gadgets: Enable more inversions to be batched during synthesis 2022-06-08 00:50:16 +00:00
Jack Grigg 3bc0c598ef halo2_proofs 0.1.0
Closes zcash/halo2#426.
2022-05-10 22:01:21 +00:00
Jack Grigg 96d4a31d39 halo2_gadgets: Batch inversions in `SinsemillaChip::hash_to_point`
This saves around 3.7% in proving time for a 2-action Orchard bundle on
a Ryzen 9 5950X.
2022-05-08 03:28:34 +00:00
ebfull 6fb622a1fc
Merge pull request #543 from NoCtrlZ/feat/fft-optimization
Optimize Fft
2022-05-05 14:05:13 -06:00
ebfull a1d1371ce3
Merge pull request #563 from parazyd/clone-impls-keys
plonk: Derive Clone for VerifyingKey and ProvingKey.
2022-05-05 13:59:44 -06:00
Taylor Hornby 64e7efb0d4
Merge pull request #542 from zcash/relicense-mit-or-apache-2.0
Relicense Halo 2 crates as MIT OR Apache 2.0
2022-05-05 13:50:45 -06:00
Jack Grigg e04c8bfb4b Migrate to `ff 0.12` 2022-05-04 23:36:18 +00:00
NoCtrlZ 32ed927579 Apply @daira's review suggestion 2022-04-28 09:47:22 +09:00
NoCtrlZ 9a9873a2c5 optimize fft 2022-04-28 09:44:54 +09:00
Jack Grigg f4675997bc Fix some clippy lints 2022-04-27 12:58:16 +00:00
Jack Grigg f830c6f7fb Remove pins for dependencies with MSRV-incompatible point releases 2022-04-27 12:28:19 +00:00
Jack Grigg bb1ed8288a Set edition to 2021
We also set `resolver = "2"` on the workspace; this is the default for
the root package in Rust 2021, but as we use a virtual workspace we need
to explicitly set it instead.
2022-04-27 12:28:19 +00:00
Jack Grigg 7688c371f6 Bump MSRV to 1.56.1
Closes zcash/halo2#482.
2022-04-27 12:24:57 +00:00
parazyd a6d7785ddc
plonk: Derive Clone for VerifyingKey and ProvingKey.
Signed-off-by: parazyd <parazyd@dyne.org>
2022-04-26 14:08:11 +02:00
str4d 66b2b3ba7e
Merge pull request #414 from zcash/constraints-helper
Add a `Constraints` helper
2022-04-22 11:52:06 +02:00
Sean Bowe a02b9e2e7e
Add benchmark for various FFT sizes. 2022-04-20 13:09:58 -06:00
Jack Grigg d93846f8fd Note that `Constraints::with_selector` accepts arrays from 1.53 2022-04-20 10:55:55 +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
str4d 69c138c25c
Clarify some comments and messages
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-04-19 16:04:19 +02:00
str4d 606afb8349
Merge pull request #445 from daira/mockprover-regression
Fix mock prover performance regression for lookup arguments
2022-04-19 14:17:17 +02:00
Daira Hopwood 424a2748d1
Clarify a comment 2022-04-19 12:36:02 +01:00
str4d 221766986b
Merge pull request #532 from zcash/bench-lookup-mockprover
Bench heavily padded lookup in MockProver.
2022-04-18 12:45:30 +02:00
str4d 19b2b3b7e2
Fix clippy lints 2022-04-18 12:25:58 +02:00
ying tong 066bd15d7e
cost-model.rs: Correct lookup required degree calculation. 2022-04-14 16:25:52 +02:00
Jack Grigg 90e671e77c Relicense Halo 2 crates as MIT OR Apache 2.0
See this blog post for details:
    https://electriccoin.co/blog/zero-knowledge-proving-system-halo-now-licensed-under-mit-making-it-available-for-anyone-to-use/
2022-04-07 14:22:49 +00:00
therealyingtong a11cb9796e halo2_proofs 0.1.0-beta.4 2022-04-06 12:24:28 +08:00
Sean Bowe 6a31a0e6a1
Apply @str4d's review suggestions. 2022-04-04 14:07:31 -06:00