Commit Graph

21 Commits

Author SHA1 Message Date
Constance Beguier f51eebeb4e Add multiplexer chip (#23)
It is now possible to perform a mux between two points or between two non-identity points.
`mux(choice, left, right)` will return `left` when `choice=0` and `right` when `choice=1`.
`choice` must be constrained to `{0, 1}` outside the gate.

It is no longer needed to expose `from_coordinates_unchecked`.
2023-12-07 16:10:35 +01:00
Constance Beguier 475f54daa4 Add Point::new_from_constant method (#17)
It is now possible to create a Point from a constant.
This functionality is required to evaluate the old nullifier.
- for non split_notes, nf_old = Extract_P([PRF^{nfOrchard}_{nk}(rho_old) + psi_nf) mod q_P] NullifierK + cm_old)
- for split notes, nf_old = Extract_P([PRF^{nfOrchard}_{nk}(rho_old) + psi_nf) mod q_P] NullifierK + cm_old + NullifierL)
2023-12-07 16:10:35 +01:00
Constance 4ce262d8e7 Add some functionalities for MuxChip 2023-12-07 16:10:35 +01:00
Constance 35c815d36e Add variable-base sign-scalar multiplication 2023-12-07 16:10:35 +01: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 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 4b802a7d07 halo2_gadgets: Documentation fixes 2022-05-10 20:31:35 +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 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 342ebdd15e halo2_gadgets: Fix return type of `ecc::chip::FixedPoint::u`
This trait method was previously preventing the trait to working with
fields that encode to more than 256 bits.
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 1c877f3caf ecc::chip: Introduce ScalarVar enum. 2022-05-05 21:14:21 +02:00
therealyingtong 6f2fc57b3c Rename FixedPoint::ScalarKind -> FixedPoint::FixedScalarKind. 2022-05-05 21:14:21 +02:00
therealyingtong 5ebfe91eee Introduce ecc::BaseFitsInScalarInstructions trait. 2022-05-05 21:14:20 +02:00
therealyingtong cbf3d6a7f6 EccInstructions: introduce witness_scalar_var() instruction. 2022-05-05 21:14:20 +02:00
therealyingtong 6d83db719e EccInstructions::mul: take Self::ScalarVar instead of Chip::Var. 2022-05-05 21:14:20 +02: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 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