Commit Graph

34 Commits

Author SHA1 Message Date
Jack Grigg 65a89f099b Replace `gadget::utilities::copy` with `AssignedCell::copy_advice`
Also replaces other copy-advice implementations that weren't using
`copy`.
2021-12-08 01:50:02 +00:00
Jack Grigg 3079800f42 Remove `Var::new` trait method
As the underlying `Region` methods now return `AssignedCell` instead of
`Cell`, we can simplify all the places where we then constructed a
`CellValue` struct.
2021-12-08 01:48:17 +00:00
Jack Grigg 9b41a06363 Migrate to halo2 version with `AssignedCell`
We change `CellValue` into a typedef of `AssignedCell` to simplify the
migration in this commit.

The migration from `CellValue` to `AssignedCell` requires several other
changes:

- `<CellValue as Var>::value()` returned `Option<F>`, whereas
  `AssignedCell::<F, F>::value()` returns `Option<&F>`. This means we
  need to dereference, use `Option::cloned`, or alter functions to take
  `&F` arguments.
- `StateWord` in the Poseidon chip has been changed to a newtype around
  `AssignedCell` (the chip was written before `CellValue` existed).
2021-12-08 01:45:00 +00:00
Jack Grigg 50b4600a1a circuit: Remove `Copy` impl from `CellValue`
We will be replacing it with `halo2::circuit::AssignedCell`, which does
not impl `Copy`.
2021-12-08 01:43:00 +00:00
str4d 42ad193b58
Merge pull request #247 from zcash/ternary-expr
circuit: Introduce ternary expression helper.
2021-12-06 17:32:35 +00:00
str4d d8690b8985
Merge pull request #236 from zcash/bench-poseidon-2
Benchmark Poseidon gadget for rates {2, 8, 11}
2021-12-01 15:57:55 +00:00
therealyingtong ba75da27bb gadget::utilities: Introduce ternary expression helper. 2021-11-30 10:39:01 -05:00
therealyingtong 421891f065 Benchmark proof creation and verification for RATE = 2, 8, 11. 2021-11-30 10:03:49 -05:00
therealyingtong 4fb434f88d gadget::utilities: Use range_check in bool_check. 2021-11-29 20:50:31 -05:00
therealyingtong 36f1d18705 gadget::utilities: Use N - x in range_check. 2021-11-29 20:50:31 -05:00
Jack Grigg 99d03e0d25 Migrate to latest halo2 revision 2021-11-26 16:24:26 +00:00
therealyingtong cba0d8672b Remove standard PLONK helper.
The Action circuit only used standard PLONK in one place. Since it
used non-binary selectors, it cannot be optimised by the halo2
selector optimisations. We now replace it with a custom gate which
uses a binary selector.
2021-07-23 17:58:58 +08:00
therealyingtong a10aefc8c1 circuit.rs: Implement enable spends and enable outputs logic.
The utilities::enable_flag gadget has been deleted, since the
public inputs API makes it more convenient to inline the gate.
2021-07-21 20:35:43 +08:00
therealyingtong 7968c3b47e sinsemilla::commit_ivk.rs: Helper module for CommitIvk. 2021-07-21 20:35:43 +08:00
Jack Grigg 1dca72a1cc Migrate to latest `halo2` test API 2021-07-19 12:58:05 +01:00
Jack Grigg 15f9d254d9 Migrate to latest `halo2` API
- `halo2::plonk::{create_proof, verify_proof}` now take instance columns
  as slices of values.
- `halo2::plonk::Permutation` has been replaced by a global permutation,
  to which columns can be added with `ConstraintSystem::enable_equality`.
- The introduction of blinding rows means that various tests now require
  larger circuit parameters.
2021-07-19 12:53:38 +01:00
therealyingtong ee062bae3d gadget::utilities: Add decompose_running_sum helper.
This decomposes a field element into K-bit windows using a
running sum. Each step of the running sum is range-constrained.
In strict mode, the final output of the running sum is constrained
to be zero.

This helper asserts K <= 3.
2021-07-15 20:46:21 +08:00
Jack Grigg d47a7d2105 Migrate to latest halo2 Circuit APIs
- The `Circuit` trait now has a `FloorPlanner` associated type.
- `circuit_layout` has been replaced by `CircuitLayout`.
2021-07-15 11:22:25 +01:00
therealyingtong 425ee6e038 Docfixes and minor refactors.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-15 12:27:12 +08:00
therealyingtong 0ade539441 utilities::tests::test_range_check(): Test range_check() helper.
Verify that this constraint fails when the witnessed value is out
of range.
2021-07-09 23:17:42 +08:00
therealyingtong 6c41c72e66 utilities::range_check: Correct range_check expression
Previously, we were multiplying the expression by 0, which led it
to always evaluate to true.
2021-07-09 22:03:26 +08:00
therealyingtong ae4e54dce8 gadget::utilities: Add test cases for bitrange_subset() helper. 2021-07-08 16:29:07 +08:00
therealyingtong 22ec16f129 Minor refactors, cleanups, clippy fixes, docfixes.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-07-08 13:31:56 +08:00
therealyingtong 23f2ed5abe gadget::utilities.rs: Add bitrange_subset() helper. 2021-07-07 23:12:31 +08:00
str4d cbded2b821
Optimize transpose_option_array 2021-06-29 22:43:50 +01:00
therealyingtong d68eb6583d Docfixes, variable renames, cleanups
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-29 12:08:31 +08:00
therealyingtong c43c91b796 gadget::utilities: Adjustments to utilities gadgets and helpers. 2021-06-25 15:05:39 +08:00
therealyingtong cdab5bf8c4 gadget::utilities.rs: Remove Chip bound on UtilitiesInstructions. 2021-06-13 09:40:20 +08:00
therealyingtong e83880841a utilities::lookup_range_check: Add LookupRangeCheck chip
This decomposes a field element into K-bit words and constrains each
word's range by looking it up in a K-bit lookup table.

The field element is broken down using a running sum. All interstitial
values of the running sum are returned.
2021-06-12 22:46:31 +08:00
therealyingtong 54c8cfd1d0 Documentation improvements and minor refactors.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-06-08 00:28:32 +08:00
therealyingtong fea88c814c Add enable flag chip 2021-06-04 18:08:59 +08:00
therealyingtong 4b0ea0be15 Add conditional swap chip 2021-06-04 18:08:59 +08:00
therealyingtong 4f87815262 Add standard PLONK chip 2021-06-04 18:08:59 +08:00
therealyingtong 4d8ae89aa9 Add Utilities chip 2021-06-04 18:08:59 +08:00