Commit Graph

87 Commits

Author SHA1 Message Date
therealyingtong 3d22943ebe dev::bad_lookup test: Do not assign zero in lookup table.
We now expect the lookup to fail when q = 0, but it still passes,
revealing a bug in the MockProver.
2022-01-04 14:23:08 +08:00
Jack Grigg 28489d03ad Rename `VerifyFailure::Cell` to `VerifyFailure::CellNotAssigned`
Closes zcash/halo2#381.
2021-12-20 14:45:56 +00:00
Jack Grigg cbe4d05002 dev: Match lookup failures to regions
This currently matches the first region on the row that matches any
input column, which will result in some mismatches. To fix this, we will
need to track the columns of complex selectors.
2021-12-20 13:16:55 +00:00
Jack Grigg 3843c11e82 dev: Enable `VerifyFailure::Lookup` to point to region offsets 2021-12-20 13:16:55 +00:00
str4d 069aa1dd17
Merge pull request #376 from zcash/364-mockprover-constraint-values
dev: Collect values of queried cells for unsatisfied constraints
2021-11-18 19:23:42 +00:00
Jack Grigg 72a731cba1 Remove `minimum_k` from `Error::NotEnoughRowsAvailable`
Due to this error being detected and returned early, in practice
`minimum_k` would always be `current_k + 1`, and the error would be
returned repeatedly (as more of the circuit could be processed) until
`k` was set large enough. We now simply suggest that the user try a
larger value of `k`.
2021-11-17 08:07:42 +00:00
Jack Grigg eb88a2ebef Replace `Error::BoundsFailure` uses with `Error::NotEnoughRowsAvailable`
The remaining uses of `Error::BoundsFailure` that are exposed to the
user, are for invalid column indices.
2021-11-15 22:50:35 +00:00
Jack Grigg d055acda31 Augment `Error::NotEnoughRowsAvailable` with current and min-required k
This makes the error message more useful, by informing the user of a
possible solution.
2021-11-15 21:44:51 +00:00
Jack Grigg 7da5605f51 Remove redundant Error suffix from Error cases 2021-11-10 16:19:36 +00:00
Jack Grigg b091757668 Rename Error::IncompatibleParams to Error::InvalidInstances
This was leftover from when proofs were structured in memory.
2021-11-10 14:49:35 +00:00
Jack Grigg 9c226d33b9 dev: Collect values of queried cells for unsatisfied constraints
Co-authored-by: ying tong <yingtong@z.cash>

Closes zcash/halo2#364.
2021-11-04 14:03:47 +00:00
therealyingtong b94aab76a3 dev: Remove O(n^2) loop in lookup checks.
Co-authored-by: Kris Nuttycombe<kris@nutty.land>
2021-10-22 19:33:30 +02:00
Jack Grigg a5a3c8ca63 Use `From<u64>` instead of `FieldExt::from_u64` 2021-09-30 22:53:00 +01:00
Jack Grigg 81622bf847 ff 0.11, group 0.11, pasta_curves 0.2 2021-09-02 23:05:18 +01:00
str4d 27c4187673
Merge pull request #354 from daira/table-refactoring
Add a `Layouter::assign_table` API
2021-07-27 20:52:36 +01:00
Daira Hopwood e3e39455be Table refactoring.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-07-27 01:34:51 +01:00
Jack Grigg 334036b942 dev: Add `halo2::dev::CircuitGates` developer tool 2021-07-26 02:53:13 +01:00
Jack Grigg 7355462a9f Add `Expression::Negated` enum case
We were previously representing this as `Expression::Scaled(poly, -1)`
which was less efficient.
2021-07-26 01:59:06 +01:00
Sean Bowe 382cd5a7ea
Create actual selector columns only during an optimization pass. 2021-07-21 12:55:19 -06:00
str4d 4283713ec7
Merge pull request #340 from zcash/339-dev-proof-cost
dev: Add CircuitCost tool with proof size measurement
2021-07-21 16:45:03 +01:00
Jack Grigg ed2295b077 Add trait methods and general APIs for defining circuit constants
During circuit configuration, fixed columns can be marked as suitable
for containing arbitrary constant values (i.e. the columns aren't
encumbered by constraints that preclude arbitrary values).

During synthesis, circuits can now request that the layouter assign
an advice cell within a region, to some specified constant value. It
is the layouter's responsibility to find space within the previously
marked fixed columns, in which to assign the constant.

This commit intentionally does not compile.
2021-07-21 09:31:27 +08:00
therealyingtong 958cc7ee4b Introduce metadata::Column struct. 2021-07-20 20:55:11 +01:00
Jack Grigg 87beee32f4 dev: Add CircuitCost tool with proof size measurement 2021-07-20 03:17:56 +01:00
Jack Grigg 1e33570c7a cargo fmt 2021-07-19 14:46:02 +01:00
str4d c0d2aa1286
Merge branch 'main' into coset-optimization 2021-07-19 14:43:37 +01:00
Jack Grigg 8e71415933 MockProver: Limit table expression evaluations to usable rows
Also refactors the lookup argument to only compute table expressions
once per lookup argument.
2021-07-16 00:26:16 +01:00
Jack Grigg 7dae8698b6 MockProver: Poison unusable advice cells
Circuit developers need to use selectors (or equivalent) to prevent their
custom gates from being active on unusable rows. By marking the advice
cells in these rows as "poisoned" and tracking this through expressions,
we can provide a better error message to developers that indicates the
missing selector issue.

Closes zcash/halo2#329.
2021-07-15 22:12:50 +01:00
Sean Bowe 0dc4447ad8
Change verification API to allow the caller to supply instances as slices of scalars rather than commitments. 2021-07-13 12:08:16 -06:00
Sean Bowe a091795aca
Switch to computing only Rotation::cur() cosets until rotation is needed. 2021-07-12 12:53:12 -06:00
Sean Bowe cc84e9bf52
Additional documentation suggestions from @str4d. 2021-07-10 08:47:57 -06:00
Sean Bowe 9023161988
Add bounds check to Assignment::query_instance impls. 2021-07-10 08:25:00 -06:00
Sean Bowe c4e2554654
Incorporate documentation improvements suggested by @str4d. 2021-07-10 08:20:34 -06:00
Sean Bowe bd29ebdb05
Use ranges to clarify bounds on cell assignment. 2021-07-09 12:38:38 -06:00
Sean Bowe f89e27ad10
Address some comments from @daira. 2021-07-09 09:22:20 -06:00
Sean Bowe 26739bbffe
Improvement to error messages for permutation argument failures in the mock prover. 2021-07-08 15:32:56 -06:00
Sean Bowe b246897a8d
Add `constrain_instance` and `assign_advice_from_instance` APIs. 2021-07-08 15:32:56 -06:00
Sean Bowe 32df26d881
Make permutation argument perfectly complete and zero-knowledge. 2021-07-02 16:20:36 -06:00
str4d 62414a92b6
Merge pull request #309 from zcash/dev-metadata
dev: Refactor VerifyFailure to extract metadata structs
2021-06-23 16:28:25 +01:00
str4d 305ca89bab
Merge pull request #302 from daira/clippy-nightly-clean
Make this crate clippy clean for warnings on nightly
2021-06-23 13:30:07 +01:00
Jack Grigg 32edf65efa dev: Refactor VerifyFailure to extract metadata structs 2021-06-23 13:16:20 +01:00
Jack Grigg 6d0017f47c Introduce a FloorPlanner trait and integrate it into the Circuit trait
This is the beginning of the process to enable full floor planning
capabilities in `halo2`. For now, all that a floor planner can do is
synthesize a circuit, which makes it no more powerful than a layouter,
but easier to use (as moving to a multi-pass layouter no longer requires
changes to `Circuit::synthesize`).
2021-06-22 23:47:17 +01:00
Daira Hopwood 209144981a Remove needless borrows that are immediately dereferenced:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-06-21 18:19:15 +01:00
ebfull ffe87e1fef
Merge pull request #293 from zcash/assigned-batch-inversions
Add support for batched inversion of cell assignments
2021-06-19 09:05:21 -06:00
Jack Grigg 5f8a61cb24 MockProver: Switch VerifyFailure::Cell to report offset within region
This is more useful for developers, as the absolute cell row may be
obfuscated by the layouter, whereas the offset within a row is controlled
by the developer.
2021-06-18 17:52:53 +01:00
Jack Grigg 181ade5e29 MockProver: Check cell assignment per-region instead of globally
Current layouters measure the shape of regions by looking at the cells
they assign. If a chip developer forgets to assign a cell in a region,
it is possible for active gates to "stick out" past the edge of a
measured region shape.

`MockProver` checks that all active gates have their cells assigned,
but this was previously checked globally. If a layouter happened to
position the buggy region such that the dangling gate overlapped an
assigned cell in in adjacent region, this check would pass.

In this commit, we extend the check to be per-region. We map enabled
selectors and assigned cells to a specific region, and then if a gate
is active within a region, we require that its cells be assigned within
that same region.

Closes zcash/halo2#297.
2021-06-18 17:51:44 +01:00
Jack Grigg 251bc68c05 Introduce an Assigned struct into the Assignment trait APIs
Value closures can now return a `(numerator, denominator)` tuple, in
order to defer inversions until after assignment.
2021-06-12 19:34:13 +01:00
Jack Grigg 3e82c7b232 dev: Move halo2::dev::circuit_layout to halo2::dev::CircuitLayout::render
This makes it easier to add configuration to the renderer.
2021-06-08 12:13:18 +01:00
str4d d8e4f24df4
Merge pull request #287 from zcash/remove-selector-rotations
Remove rotations from Selectors
2021-06-05 23:36:37 +01:00
str4d 879509491f
Merge pull request #286 from zcash/constraint-annotations
Enable annotating individual constraints within gates
2021-06-05 23:36:28 +01:00
str4d 1dff93a8ad
dev: Update documentation for constraint_name
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-04 23:12:55 +01:00