Commit Graph

98 Commits

Author SHA1 Message Date
shuoer86 2ddacfb15e
chore: fix typos in comments 2023-10-30 20:33:52 +08:00
Thor 951abe619a
fix: clippy (#203)
* fix: clippy

* fmt

* fix: Final clippy complains & adjustments

---------

Co-authored-by: CPerezz <c.perezbaro@gmail.com>
2023-09-18 09:25:26 +02:00
Carlos Pérez 4cecd64a25
chore: Update rust-toolchain to 1.66 for testing (#208)
* chore: Update rust-toolchain to 1.66 for testing

Note that tests will not compile due to the silent MSRV bump in
`blake2b_simd`.

Hence, we need to use `1.66` as toolchain.

Resolves: #207

* change: UIpdate MSRVs in Cargo.toml
2023-09-18 08:54:15 +02:00
Han 7a21656171
Synchronize with upstream (#199)
* refactor: add default impl for `SyncDeps` for backward compatability

* feat: pick changes from https://github.com/zcash/halo2/pull/728 and changes of flag `test-dev-graph`

* feat: pick changes from https://github.com/zcash/halo2/pull/622

* feat: pick changes about mod `circuit` and mod `dev`

* feat: pick rest changes of `halo2_proofs`

* fix: when `--no-default-features`

* ci: sync from upstream, and deduplicate jobs when
push to `main`, and remove always failing job `codecov`.

* fix: make `commit_zk` runnable when `--no-default-features`
2023-09-06 14:59:44 +08:00
dante fe71cd4647
fix: explicitly define mds diff type (#196)
* fix: explicitly define mds diff type

* rm paren
2023-08-26 09:45:05 +08:00
dante 0f000478f4
feat: public cells to allow for implementations of custom `Layouter` (#192)
* feat: public cells

* Update mds.rs

* Update mds.rs

* Update single_pass.rs

Co-authored-by: Han <tinghan0110@gmail.com>

* bump toolchain to resolve errors

* fix clippy errors for CI run

* rustfmt post clippy

* plz let it be the last lint

* patch clippy lints in gadgets

* clippy lints for sha256 bench

* patch halo2proof benches

* Update assigned.rs

* Update halo2_gadgets/src/poseidon/primitives/mds.rs

Co-authored-by: Han <tinghan0110@gmail.com>

* Update halo2_gadgets/src/poseidon/primitives/mds.rs

Co-authored-by: Han <tinghan0110@gmail.com>

---------

Co-authored-by: Han <tinghan0110@gmail.com>
2023-08-25 22:39:50 +08:00
François Garillot f3487575f0
Updates halo2_curves dependency to released package (#190)
THe package release ressets the version from those inherited by the legacy
halo2curves repo's fork history.

The upstream diff is:
9f5c50810b..9a7f726fa7
2023-07-30 13:35:30 +02:00
Enrico Bottazzi 17e9765c19
Implement Clone trait for Hash, Absorbing, and Sponge structs (#171) 2023-04-27 09:02:08 +02:00
CeciliaZ030 b739b543d6
Allow halo2 constraint names to have non static names (#156)
* static ref to String type in Gates, Constraints, VirtualCell, Argument

* 'lookup'.to_string()

* return &str for gate name and constriant_name, also run fmt

* Update halo2_gadgets/Cargo.toml

Co-authored-by: Han <tinghan0110@gmail.com>

* upgrade rust-toochain

---------

Co-authored-by: Carlos Pérez <37264926+CPerezz@users.noreply.github.com>
Co-authored-by: Han <tinghan0110@gmail.com>
2023-04-20 22:26:34 +08:00
Eduard S 0d56c57a07
Extend Circuit trait to take parameters in config (#168)
* Extend Circuit trait to take parameters in config

The Circuit trait is extended with the following:
```
pub trait Circuit<F: Field> {
    /// [...]
    type Params: Default;

    fn params(&self) -> Self::Params {
        Self::Params::default()
    }

    fn configure_with_params(meta: &mut ConstraintSystem<F>, params: &Self::Params) -> Self::Config {
        Self::configure(meta)
    }

    fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config;
}
```

This allows runtime parametrization of the circuit configuration.  The extension to the Circuit trait has been designed to minimize the breaking change: existing circuits only need to define the associated `type Params`.

Unfortunately "Associated type defaults" are unstable in Rust, otherwise this would be a non-breaking change.  See https://github.com/rust-lang/rust/issues/29661

* Implement circuit params under feature flag

* Don't overwrite configure method

* Fix doc test
2023-04-20 21:20:09 +08:00
han0110 7d1814ce58 fix: pin `halo2curves` version to `0.3.2` 2023-04-13 16:23:55 +08:00
Carlos Pérez fcdd5b910d
change: Migrate workspace to pasta_curves-0.5 (#157)
* change: Migrate workspace to pasta_curves-0.5

This ports the majority of the workspace to the `pasta_curves-0.5.0`
leaving some tricky edge-cases that we need to handle carefully.

Resolves: #132

* fix: Complete latest trait bounds to compile halo2proofs

* change: Migrate examples & benches to pasta 0.5

* change: Migrate halo2_gadgets to pasta-0.5

* change: Update gadgets outdated code with latest upstream

* fix: Sha3 gadget circuit

* fix: doc tests

* chore: Update merged main

* fix: Apply review suggestions
2023-03-07 17:29:37 +01:00
dante 99795dd4df
fix: transcript instantiation in poseidon benchmark loop (#128) 2023-01-18 18:10:11 +01:00
dante 50ee8ad785
chore: instance columns for poseidon bench (#108) 2022-12-10 20:26:51 +01:00
han0110 8a82b7716e feat: use stable channel rust 2022-09-19 14:52:48 +08:00
Han a9e99a72a6
feat: implement multi-phase `ConstraintSystem` (#97) 2022-09-08 13:31:01 +02:00
Zhang Zhuo 31efabd369 Add name in `lookup::Argument` 2022-08-19 16:00:51 +08:00
kilic 51d523df60 Commitment scheme abstraction
Add SHPLONK and GWC varians of KZG
2022-08-19 16:00:51 +08:00
ChihChengLiang 25b47f23c8 add back diffs 2022-08-19 11:52:07 +08:00
ChihChengLiang 63b42c96cd Merge branch 'upstream' into purely-upstream 2022-08-19 11:47:43 +08:00
Jack Grigg 2c06d83ae9 halo2_gadgets 0.2.0 2022-06-23 17:41:52 +00:00
Jack Grigg 7a22f3c9b6 halo2_proofs 0.2.0 2022-06-23 17:40:23 +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
ying tong 34b2e77a57
Merge pull request #467 from zcash/sha256-tweaks
SHA-256 chip tweaks
2022-05-25 12:51:16 +08:00
Jack Grigg e36041d198 halo2_gadgets 0.1.0
Closes zcash/halo2#460.
2022-05-10 22:05:30 +00:00
Jack Grigg 3bc0c598ef halo2_proofs 0.1.0
Closes zcash/halo2#426.
2022-05-10 22:01:21 +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 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
Jack Grigg 96d4a31d39 halo2_gadgets: Batch inversions in `SinsemillaChip::hash_to_point`
This saves around 3.7% in proving time for a 2-action Orchard bundle on
a Ryzen 9 5950X.
2022-05-08 03:28:34 +00:00
Jack Grigg 03697e2a7d book: Rewrite Sinsemilla gadget page
The book now has enough detail for it to be obvious why there are
factors of 2 present in several equations.
2022-05-08 02:38:01 +00:00
Jack Grigg dc2ec0308d halo2_gadgets: Deduplicate some Sinsemilla chip expressions 2022-05-08 02:38:01 +00:00
Jack Grigg 6444ccc16f halo2_gadgets: Tidy up and document MerkleCRH implementation 2022-05-08 02:38:01 +00:00
Jack Grigg 3bed5725e5 Use `MessagePiece::from_subpieces` in `MerkleChip::hash_layer`
Several structs now impl `PartialEq, Eq` due to requirements of the
`MessagePiece::from_subpieces` impl.
2022-05-08 02:20:42 +00:00
Jack Grigg 0d978f0fc4 halo2_gadgets: Generalise `MerklePath` beyond two `MerkleChip`s 2022-05-07 23:03:30 +00:00
str4d 30f92f3f4b
Merge pull request #522 from zcash/full-width-var-base-mul
[ECC gadget] Distinguish base field element case in variable-base scalar mul.
2022-05-06 19:53:57 +01:00
str4d 5a543f9318
Move `EccInstructions::ScalarVar` changelog entry to "Changed" 2022-05-06 19:06:06 +01:00