Commit Graph

51 Commits

Author SHA1 Message Date
ying tong 83479fdadb
Merge 1ab16c319a into 7df93fd855 2024-03-01 11:27:10 -07:00
zhiqiangxu 2185856f26 fix typo 2023-05-05 15:51:10 +08:00
therealyingtong 1ab16c319a No-ops on best_multiexp and best_fft when #[cfg(feature=counter)]
Co-authored-by: Andrija <akinovak@gmail.com>
2023-04-05 03:32:58 +07:00
therealyingtong c3c57c6e07 circuit::table_layouter: Better table errors 2023-04-04 09:32:08 +07:00
therealyingtong 3f4710892a plonk::Error: Introduce TableError variant 2023-04-04 09:32:08 +07:00
therealyingtong 6a8f28ce31 plonk::prover: Introduce counter feature for FFTs and MSMs
Co-authored-by: Andrija <akinovak@gmail.com>
2023-04-03 23:23:49 +07:00
Sean Bowe 82dd2fb3f5 Make `Error` a non_exhaustive type. 2023-03-21 15:17:22 -06:00
str4d 5ff0e83616 Take accumulator as `T` in `halo2_proofs::multicore::TryFoldAndReduce`
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-02-14 18:53:36 +00:00
wangyao 6fbde15d11 Add `multicore` feature flag to allow `rayon` to be disabled
Closes zcash/halo2#648.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-02-14 18:53:36 +00:00
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 cb819e47e9 Migrate to `ff` revision without `FieldExt` 2022-11-30 19:35:26 +00:00
Daira Hopwood 23f63a8f50 Fix nightly clippy complaints.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-11-30 15:13:55 +00:00
Daira Hopwood c387aa7204 Fix additional beta clippy complaints.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-11-30 15:13:55 +00:00
Kris Nuttycombe b3f7db16f8 Fix beta clippy complaints. 2022-11-30 14:57:15 +00:00
Jack Grigg 49b2324f0a Replace unnecessary dependencies on `FieldExt` trait 2022-11-30 03:41:19 +00:00
therealyingtong c443665224 lookup::prover: Compress expressions and cosets in commit_permuted
The theta challenge is used in the lookup argument to compress the
input and table expressions. This can be done fully in the
commit_permuted step, after which the original uncompressed
expressions are no longer needed.

Author: Ying Tong Lai <yingtong@z.cash>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-10-08 12:07:54 +01:00
Daira Hopwood 6f692c0e53 There is no z' in the lookup argument, only z.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-26 20:14:08 +08:00
ebfull 61a1f63fcb
Merge pull request #623 from zcash/table-col-equality
Allow `enable_equality` on `TableColumn`
2022-09-13 08:03:20 -06:00
therealyingtong 7ed2a4d529 plonk::prover::create_proof: Return error if circuits and instances have different lengths. 2022-09-13 18:19:45 +08:00
therealyingtong d0bbcda590 plonk::prover: Test proof creation with wrong number of instances.
Currently, create_proof passes even if the number of circuits does
not equal the number of instances.
2022-09-13 18:19:45 +08:00
Jack Grigg 349908d539 halo2_proofs: Narrow `clippy::too_many_arguments` lint override
This enables the lint to show up on new PRs.
2022-09-09 18:15:10 +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
han0110 8ff5b1e3af feat: make `Expression::{Fixed,Advice,Instance}` to wrap their own `Query` struct 2022-07-15 10:33:47 -04:00
therealyingtong 28fbc5b4fe Allow enable_equality on TableColumn 2022-07-06 11:29:25 -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 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 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
Jack Grigg 47f25ad632 halo2_proofs: Replace `Option<V>` with `Value<V>` 2022-06-08 23:03:16 +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 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
parazyd a6d7785ddc
plonk: Derive Clone for VerifyingKey and ProvingKey.
Signed-off-by: parazyd <parazyd@dyne.org>
2022-04-26 14:08:11 +02: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
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
str4d 8abd7b74db
Merge pull request #417 from zcash/fix-assigned-usage
Expand `Assigned<F>` APIs
2022-03-22 19:46:51 +00:00
Sean Bowe f46d77763e
Remove logic for reading and writing VerificationKey to/from buffers. 2022-03-16 14:19:33 -06:00
Sean Bowe 819bc3c2f5
Stop placing the selector_map (which is an internal API detail) in the pinned verification key. 2022-03-16 14:19:13 -06:00
Dimitris Apostolou e2f88e450b
Fix typos 2022-02-03 18:01:22 +02: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 b7944e5c40 Make `Assigned::Zero` slightly less likely in `Assigned` proptest 2022-01-21 13:57:25 +00:00
Jack Grigg 05a4d26bea Add unary operators to `Assigned` proptest 2022-01-21 13:57:25 +00:00
Jack Grigg a7e45495cf Add `Assigned::{double, square, cube}` methods 2022-01-21 13:57:25 +00:00
Jack Grigg 50b8e05913 Add other `Add*, Sub*, Mul*` variant impls to `Assigned<F>` 2022-01-21 13:57:25 +00:00
Jack Grigg 8d00acace5 `impl<F: Field> Eq for Assigned<F>` 2022-01-21 13:57:24 +00:00
Jack Grigg 927463f76a Add `Assigned::is_zero_vartime` method 2022-01-21 13:57:24 +00:00
Jack Grigg 93ee7143fe `impl From<&Assigned<F>> for Assigned<F>`
In zcash/halo2#383 we altered the bounds on region assignment methods
like `Region::assign_advice` to constrain the value closure's result on
`for<'vr> Assigned<F>: From<&'vr VR>` instead of `VR: Into<Assigned<F>>`.
This had the unintended side-effect that `Assigned<F>` could no longer
be returned from the closure, because we were previously relying on the
implicit `impl From<T> for T` provided by Rust, which no longer fits the
bound. This commit adds the missing from-reference impl to restore
functionality, re-enabling inversion deferrment.
2022-01-21 13:57:24 +00:00