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
5cb838f1a2
circuit: Remove `Copy` impl from `poseidon::pow5::StateWord`
...
We will be making it a newtype around `halo2::circuit::AssignedCell`,
which does not impl `Copy`.
2021-12-08 01:44:09 +00:00
Jack Grigg
e99fc92e4b
circuit: Use `Field::is_zero_vartime`
2021-12-08 01:44:08 +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
55567f31ed
Merge pull request #248 from zcash/ecc-config-refactor
...
circuit: Refactor `EccConfig` away from `impl From<EccConfig>`.
2021-12-08 01:40:14 +00:00
str4d
a38e2ff728
Ensure lo and hi incomplete ranges line up
...
The previous code assumed that `pallas::Scalar::NUM_BITS` was odd, which is true, but might not remain so after a future generalisation refactor.
2021-12-08 01:00:18 +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
therealyingtong
a09173a331
ecc::chip: Remove chip-level permutation.
...
We have now refactored away from the impl From<EccConfig> pattern
so that each sub-config can equality-enable the columns they need.
2021-12-04 04:45:06 +00:00
therealyingtong
c00ee1707e
mul_fixed::base_field_elem: Refactor base_field_elem::Config.
...
This commit does not result in circuit changes.
2021-12-04 04:45:06 +00:00
therealyingtong
687e220c36
mul_fixed::short: Refactor short::Config.
...
This commit does not result in circuit changes.
2021-12-04 04:45:06 +00:00
therealyingtong
165c9b6941
mul_fixed::full_width: Refactor full_width::Config.
...
This commit does not result in circuit changes.
2021-12-04 04:45:06 +00:00
therealyingtong
f472a16b32
chip::mul_fixed: Move running_sum_config into mul_fixed::Config.
2021-12-04 04:45:06 +00:00
therealyingtong
1a7e832ed4
chip::mul_fixed: Refactor mul_fixed::Config.
...
This commit does not introduce circuit changes.
2021-12-04 04:45:06 +00:00
therealyingtong
a7dad1d611
chip::mul: Refactor mul::Config.
...
This commit does not introduce additional circuit changes.
2021-12-04 04:45:05 +00:00
therealyingtong
440cd14dbb
mul::overflow: Refactor overflow::Config.
...
This is only used in chip::mul::Config. In a subsequent commit,
this will be configured from mul::Config instead of from
ecc::chip::Config.
This commit does not result in circuit changes.
2021-12-04 04:44:41 +00:00
therealyingtong
931d61a863
mul::complete: Refactor complete::Config.
...
This is only used in chip::mul::Config. In a subsequent commit,
this will be configured from mul::Config instead of from
ecc::chip::Config.
This commit does not result in circuit changes.
2021-12-04 04:41:52 +00:00
therealyingtong
22f57005a9
mul::incomplete: Refactor incomplete::Config.
...
This is only used in chip::mul::Config. In a subsequent commit,
this will be configured from mul::Config instead of from
ecc::chip::Config.
This commit does not result in circuit changes.
2021-12-04 04:39:41 +00:00
Jack Grigg
0ede6b2301
mul::Config: Reorder gate definitions
...
We are about to extract the sub-configs from mul::Config and refactor
them. Doing so would have moved their gate definitions past the one gate
that isn't created in a sub-config. Reordering the definitions here will
make the subsequent refactor diffs simpler to review.
2021-12-04 04:38:08 +00:00
therealyingtong
2ec480ef6b
utilities::lookup_range_check: Derive Copy for LookupRangeCheckConfig.
2021-12-02 14:55:37 -05:00
therealyingtong
4fe6fb8bf2
chip::add: Refactor add::Config.
...
This is also used in mul and mul_fixed.
2021-12-02 14:55:36 -05:00
therealyingtong
13faedc7cc
chip::add_incomplete: Refactor add_incomplete::Config.
...
This is also used in mul_fixed.
2021-12-02 14:54:13 -05:00
therealyingtong
9d8fee29c7
chip::witness_point: Refactor witness_point::Config.
2021-12-02 14:51:33 -05: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
ying tong
b02628d263
Apply suggestions from code review
...
Co-authored-by: str4d <jack@electriccoin.co>
2021-12-01 09:31:53 -05:00
therealyingtong
76c8bb9711
utilities::cond_swap: Use ternary helper in cond_swap.
...
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-11-30 20:36:13 -05:00
therealyingtong
1a7a1255c8
mul::complete.rs: Use ternary helper in complete addition part of variable-base scalar mul.
2021-11-30 13:02:25 -05:00
therealyingtong
9513efd6f3
ecc::chip::mul.rs: Use ternary helper in variable-base scalar mul.
2021-11-30 12:52:15 -05: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
9b76556503
poseidon: Make gadget tests generic over WIDTH, RATE
2021-11-30 10:03:49 -05:00
therealyingtong
b63c868591
poseidon: Make Spec trait methods not take (&self) parameter.
2021-11-30 10:02:16 -05:00
therealyingtong
409bbf36a0
mul::complete: Replace k_minus_one with one_minus_k.
2021-11-29 21:45:49 -05:00
therealyingtong
303bdc3f65
Replace local bool_check expressions with utilities::bool_check().
2021-11-29 21:45:48 -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
9bb29018ac
poseidon::pow5: Undo circuit change.
...
Co-authored-by: str4d <jack@electriccoin.co>
2021-11-23 15:38:55 -05:00
ying tong
79123629da
Docfixes and minor refactors.
...
Co-authored-by: str4d <jack@electriccoin.co>
2021-11-23 15:29:56 -05:00
therealyingtong
fe1bc97ab4
Generalise Pow5T3 chip to be generic over WIDTH, RATE.
2021-11-19 00:50:04 -05:00
therealyingtong
0417e233c3
poseidon: Return CellValue from squeeze()
2021-11-19 00:04:27 -05:00
therealyingtong
de37248749
Allow passing CellValue as input word to Poseidon gadget.
...
Update circuit description.
2021-11-18 23:47:57 -05:00
therealyingtong
2c97e56da7
Add hash() and permute() test vectors for Poseidon over Fq.
2021-10-12 11:58:27 +02:00
therealyingtong
764c445a81
Rename poseidon::nullifier -> poseidon::p128pow5t3.
2021-10-12 11:58:27 +02:00
Jack Grigg
631182fb77
Update selector columns in expected-failure tests
...
The addition of the non-identity selector caused the layouter to reorder
some of the selectors in the ECC gadget test circuit.
2021-09-28 21:49:06 +01:00
Daira Hopwood
d77cb82c8d
Apply suggestions from code review
...
Co-authored-by: str4d <jack@electriccoin.co>
2021-09-28 21:09:39 +01:00
Jack Grigg
d0056d9050
Test that we can't witness the identity as a NonIdentityPoint
2021-09-28 21:00:29 +01:00
str4d
aec3b1d52d
Remove unnecessary clones in closure
2021-09-28 20:31:32 +01:00
therealyingtong
52f53f3425
Remove IsIdentity trait from public EccInstructions.
...
We only need is_identity() in tests and can implement it on the
concrete EccPoint type. This method is flagged off by #[cfg(test)].
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-09-28 20:31:32 +01:00
therealyingtong
b0de6afd7c
Reintroduce Point::new() API and constraints.
...
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-09-28 20:31:32 +01:00
Jack Grigg
751277cdb2
Remove `EccInstructions::NonIdentityPoint: TryFrom<Self::Point>` bound
...
After the previous commit, this is no longer used anywhere. Additionally
it was not enforcing the conversion in the circuit, which could lead to
circuit implementation mistakes.
2021-09-28 13:13:25 -06:00