Commit Graph

34 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
Jack Grigg cb819e47e9 Migrate to `ff` revision without `FieldExt` 2022-11-30 19:35:26 +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
Jack Grigg 49b2324f0a Replace unnecessary dependencies on `FieldExt` trait 2022-11-30 03:41:19 +00:00
Jack Grigg 66242e0076 halo2_gadgets: Remove dead code
For the dead code we want to retain, we now allow it explicitly, so we
can remove the blanket lint override.
2022-09-09 17:57:37 +00:00
Jack Grigg 73282ba6b8 halo2_gadgets: Be explicit about `*EccPoint` construction without checks
These are all cases inside the ECC chip, where we are inherently
producing valid coordinate pairs as a result of the constraints being
implemented, but it is useful to be explicit about the contract being
asserted at each point we construct `EccPoint` or `NonIdentityEccPoint`.
2022-09-09 17:56:00 +00:00
Jack Grigg f0861db20b halo2_gadgets: Silence clippy lints
They are in code generated by macros from the `uint` crate, that we
can't do anything about from here.
2022-06-23 17:37:19 +00:00
Jack Grigg 5ed3d2501f halo2_gadgets: Replace `Option<V>` with `Value<V>` 2022-06-08 23:31:25 +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 5f1fb166d1 halo2_gadgets: Reduce allocations during var-mul synthesis 2022-06-08 00:50:16 +00:00
Jack Grigg c1007d8c23 halo2_gadgets: Add protocol rule links for the chip constraints
Part of zcash/zcash#3957.
2022-05-25 22:41:04 +00:00
Jack Grigg 91e1106a1e halo2_gadgets: Address review comments 2022-05-10 21:35:52 +00:00
Jack Grigg 4b802a7d07 halo2_gadgets: Documentation fixes 2022-05-10 20:31:35 +00:00
Jack Grigg a94a2bc552 halo2_gadgets: Various small code cleanups
Also documents a superfluous constraint, for removal in some future
breaking change.
2022-05-10 20:26:30 +00:00
Jack Grigg ff01e4a1f9 halo2_gadgets: Refactor `ScalarFixed::windows_usize`
It no longer relies on the `SqrtRatio::get_lower_32` method, which is
specific to that trait and not intended for external usage.
2022-05-10 20:26:30 +00:00
Jack Grigg 692fee099d halo2_gadgets: Clean up `ecc::chip::mul_fixed::Config` logic
- We were redundantly storing the `x_p` and `y_p` columns.
- `Config::add_incomplete` was redundantly copying.

Co-authored-by: therealyingtong <yingtong@z.cash>
2022-05-10 20:04:30 +00:00
Jack Grigg 85b0b7c065 halo2_gadgets: Refactor `ecc::chip::mul_fixed::Config` word assignment logic
Co-authored-by: therealyingtong <yingtong@z.cash>
2022-05-10 20:04:30 +00:00
Jack Grigg 18edad5df6 halo2_gadgets: Use separate field names for var-mul incomplete selectors
The previous tuple was confusing because tuple indices are zero-indexed,
while the selector names are one-indexed.
2022-05-10 20:04:30 +00:00
Jack Grigg 56fc8960c6 halo2_gadgets: Extract a common `DoubleAndAdd` helper struct
Both variable-base scalar mul and Sinsemilla use double-and-add with
incomplete addition on a single row, but they do so in slightly
different ways. Some of these are intentional (needing to look up the
y-coordinate vs constrain it), while others are accidental (different
concrete signs in otherwise-identical constraints that make their ASTs
incompatible).

The new `DoubleAndAdd` helper struct extracts the logic that is common
to both implementations, specifically the helper definitions of `x_r`
and `Y_A`. In a future breaking change, we can refactor both gadgets to
share more of this logic, so we are defining the incomplete addition
logic in fewer places.
2022-05-10 20:04:30 +00:00
Jack Grigg 144d082528 halo2_gadgets: Refactor complete addition constraints
We also fix several typos in the constraint analysis on the complete
addition book page, and adjust the constraints table for readability.
2022-05-10 00:20:00 +00:00
Jack Grigg 3486703bd2 halo2_gadgets: Refactor fixed-base scalar mul gadget APIs
The new `EccInstructions` instructions, and the corresponding changes to
existing instructions, enable chips to choose when to witness or constrain
the scalars, and simplify scalar reuse (though reuse is not implemented
for `EccChip` yet).

`FixedPoint::mul` and `FixedPointShort::mul` now has the same API style
as `NonIdentityPoint::mul`.
2022-05-09 15:48:55 +00:00
Jack Grigg 6145b1417c halo2_gadgets: Move `primitives::*` to `*::primitives` 2022-05-09 05:43:34 +00:00
therealyingtong 5fd0834503 Introduce ScalarVar::new and ScalarVar::from_base gadget APIs. 2022-05-05 21:33:43 +02:00
therealyingtong 1c877f3caf ecc::chip: Introduce ScalarVar enum. 2022-05-05 21:14:21 +02:00
Jack Grigg e3f1bf68db halo2_gadgets: Remove usage of `array::IntoIter::new`
Rust 2021 implements `IntoIterator` for arrays directly, instead of only
references to arrays.

    https://doc.rust-lang.org/edition-guide/rust-2021/IntoIterator-for-arrays.html
2022-04-27 12:56:54 +00:00
Jack Grigg b02800466a halo2_gadgets: Migrate chip gates to `Constraints::with_selector`
Only one gate couldn't be migrated without altering the Orchard circuit.
2022-04-24 22:13:38 +00:00
Jack Grigg 0946bdb455 dev: Enable `VerifyFailure::Permutation` to point to region offsets 2022-03-30 01:39:50 +00:00
Jack Grigg c6886600a9 halo2_gadgets: Migrate from bigint to uint
Closes zcash/halo2#457.
2022-02-01 16:19:53 +00:00
Jack Grigg 5312343e6d halo2_gadgets: Expose testing APIs required by `orchard` 2022-01-28 17:52:48 +00:00
therealyingtong 3547008d35 Clippy fixes. 2022-01-28 23:50:14 +08:00
therealyingtong 7c7c281000 Visibility fixes. 2022-01-28 23:38:22 +08:00
Jack Grigg 9a12beee73 halo2_gadgets: Rename `halo2` to `halo2_proofs`
The previous commit renamed `halo2_proofs` back to `halo2` temporarily
to keep the commit size down. This commit performs the rename in a
single pass.
2022-01-27 23:32:04 +00:00
Jack Grigg 5202ec6eda Integrate `halo2_gadgets` into the workspace
THe SHA-256 example gadget has been moved into the `halo2_gadgets` crate
behind an `unstable` feature flag.
2022-01-27 23:32:04 +00:00
Jack Grigg a2367abcaf Migrate to `halo2_gadgets` crate in subdir
- The crate module structure from `orchard` has been flattened.
- The book pages we want to include in `halo2` have been moved to their
  target location, to avoid any conflicts during the merge.
- Common files that already exist in zcash/halo2 have been removed.
2022-01-27 23:08:01 +00:00