Commit Graph

2569 Commits

Author SHA1 Message Date
Carlos Pérez 5c3ea1a696
chore: Move Codecov, wasm-build, Bitrot & doc-tests to push (#125)
* chore: Move Codecov, wasm-build, Bitrot & doc-tests to push

This should cut down significantly the CI times on every push done to a
branch for a PR.
Resolves: #124

* chore: Add back `push` on CI checks
2023-01-17 12:15:10 +01:00
Carlos Pérez 54e4c57d05
Add support for Column annotations for MockProver debugging (#109)
* feat: Add `name_column` to `Layouter` & `RegionLayouter`

This adds the trait-associated function `name_column` in order to enable
the possibility of the Layouter to store annotations aobut the colums.

This function does nothing for all the trait implementors (V1,
SimpleFloor, Assembly....) except for the `MockProver`. Which is
responsible of storing a map that links within a `Region` index, the
`column::Metadata` to the annotation `String`.

* feta: Update metadata/dbg structs to hold Col->Ann mapping

* feat: Update emitter module to print Column annotations

* feat: Add lookup column annotations

This adds the fn `annotate_lookup_column` for `ConstraintSystem` which
allows to carry annotations for the lookup columns declared for a
circuit within a CS.

* feat: Add Lookup TableColumn annotations

This allows to annotate lookup `TableColumn`s and print it's annotation
within the `assert_satisfied` fn.

This has required to change the `ConstraintSystem::lookup_annotations`
to have keys as `metadata::Column` rather than `usize` as otherwise it's
impossible within the `emitter` scope to distinguish between regular
advice columns (local to the Region) and fixed columns which come from
`TableColumn`s.

* fix: Customly derive PartialEq for metadata::Region

This allows to ignore the annotation map of the metadata::Region so that
is easier to match against `VerifyFailure` errors in tests.

* fix: Update ConstraintNotSatisfied testcase

* fix: Update Debug & Display for VerifyFailure

It was necessary to improve the `prover.verify` output also. To do so,
this required auxiliary types which are obfuscated to any other part of the lib
but that are necessary in order to be able to inject the Column names inside of
the `Column` section itself.
This also required to re-implement manually `Debug` and `Display` for this enum.

This closes #705

* fix: Address clippy & warnings

* fix: Add final comments & polish

* fix: Resolve cherry-pick merge conflics & errors

* chore: Change DebugColumn visibility

* chore: Allow to fetch annotations from metadata

* chore: Fix clippy lints

* chore: Remove comments from code for testing

* feat: Add support for Advice and Instance anns in lookups

* feat: Allow `V1` layouter to annotate columns too

* fix: Support `Constant` & `Selector` for lookup exprs

* chore: Address review comments

* chore: Propagete write! result in `VerifyFailure::Display`

* chore: Address clippy lints
2023-01-17 00:39:10 +01:00
Jonathan Wang 4ad07d424e
Feature to serialize/deserialize KZG params, verifying key, and proving key into uncompressed Montgomery form (#111)
* feat: read `VerifyingKey` and `ProvingKey` does not require `params` as
long as we serialize `params.k()`

* feat: add features "serde-raw" and "raw-unchecked" to
serialize/deserialize KZG params, verifying key, and proving key
directly into raw bytes in internal memory format.
So field elements are stored in Montgomery form `a * R (mod p)` and
curve points are stored without compression.

* chore: switch to halo2curves 0.3.1 tag

* feat: add enum `SerdeFormat` for user to select
serialization/deserialization format of curve and field elements

Co-authored-by: Jonathan Wang <jonathanpwang@users.noreply.github.com>
2023-01-16 14:42:13 +01:00
Carlos Pérez 789790ffa7
Feature: Expose Fixed columns & Assembly permutation structs in MockProver instance (#123)
* feat: Expose fixed columns in MockProver

* change: Make `Assembly` object public & add getters

* chore: Address leftover TODOs
2023-01-16 14:02:08 +01:00
Carlos Pérez 7aa1009786
fix: FailureLocation::find empty-region handling (#121)
After working on fixing
privacy-scaling-explorations/zkevm-circuits#1024, a bug was found in the
verification fn of the MockProver which implies that while finding a
FailureLocation, if a Region doesn't contain any rows.

This is fixed by introducing a 2-line solution suggested by @lispc.

Resolves: #117
2023-01-11 13:11:59 +01:00
Jonathan Wang b8e458e8af
Parallelize SHPLONK multi-open prover (#114)
* feat: parallelize (cpu) shplonk prover

* shplonk: improve `construct_intermediate_sets` using `BTreeSet` and
`BTreeMap` more aggressively

* shplonk: add `Send` and `Sync` to `Query` trait for more parallelization

* fix: ensure the order of the collection of rotation sets is independent
of the values of the opening points

Co-authored-by: Jonathan Wang <jonathanpwang@users.noreply.github.com>
2023-01-10 12:03:47 +01:00
adria0.eth 0af4611d1a
Merge pull request #115 from privacy-scaling-explorations/feat/challenge-evm-helpers
perf: improve memory allocation in `Expression::identifier()`
2023-01-09 16:56:42 +01:00
adria0 8c26a8309f Remove transpose 2023-01-09 16:49:38 +01:00
adria0 e56a4a4f1e Remove partial ordering for value 2023-01-09 15:06:45 +01:00
Carlos Pérez be10b68d4b
Fix MockProver `assert_verify` panic errors (#118)
* fix: Support dynamic lookups in `MockProver::assert_verify`

Since lookups can only be `Fixed` in Halo2-upstream, we need to add
custom suport for the error rendering of dynamic lookups which doesn't
come by default when we rebase to upstream.

This means that now we have to print not only `AdviceQuery` results to
render the `Expression` that is being looked up. But also support
`Instance`, `Advice`, `Challenge` or any other expression types that are
avaliable.

This addresses the rendering issue, renaming also the `table_columns`
variable for `lookup_columns` as the columns do not have the type
`TableColumn` by default as opposite to what happens upstream.

* fix: Don't error and emit empty String for Empty queries

* feat: Add `assert_sarisfied_par` fn to `MockProver`

* fix: Address clippy errors

* chore: Address review comments

* chore: Fix clippy lints

Resolves: #116
2023-01-09 12:15:51 +01:00
adria0 551c782b1b - Implements `PartialOrd` for `Value<F>`
- Adds a `transpose` method to turn `Value<Result<_>>` into
  `Result<Value<_>>`
- `Expression::identifier()` remove string memory reallocation
2023-01-02 18:37:53 +01:00
dante 50ee8ad785
chore: instance columns for poseidon bench (#108) 2022-12-10 20:26:51 +01:00
Jonathan Wang 246ce4e8e3
Add verifying key and proving key serialization (#103)
* VerifyingKey Serialization: merge Nalin's PR
https://github.com/zcash/halo2/pull/661 that allows for vkey
serialization/deserialization and fixes the previous selector
optimization issue

* feat: add serialization & deserialization of pkey and vkey using serde
derive

* fix: add `num_fixed_commitments` to vkey serialization so correct number
of fixed columns, post selector compression, are read

* fix: serialize/deserialize pkey directly to/from file

* Update: implement suggestions for PR

* add `plonk::Error::Serde` to pass through serialization errors

* update: remove serialization from evaluation as we now recalculate directly

* fix: clippy warnings

* feat: implement `ProvingKey` serialization without using external crates
`serde` or `bincode`

* examples: add `serialization` example to test `ProvingKey` read and
write on "simple-example"

* feat: added `to/from_bytes` for `ProvingKey` and `VerifyingKey`

* add `pack`/`unpack` helper functions between `&[bool]` and `u8`
* made serialization example use smaller example of standard plonk for
  less code bloat

Co-authored-by: Nalin Bhardwaj <nalinbhardwaj@nibnalin.me>
2022-12-02 11:43:38 +01:00
Han 5fc8ce89ef
Merge pull request #96 from han0110/feature/configurable-instance-query
Configurable instance query
2022-10-21 22:34:04 -07:00
Han adefd9a4a0
Merge pull request #99 from han0110/feature/stable-channel
Use stable channel rust
2022-10-21 22:33:48 -07:00
han0110 432d72f462 fix: iterate on `instance_queries` to calculate correct `instance_evals` 2022-09-20 01:30:20 +08:00
han0110 8a82b7716e feat: use stable channel rust 2022-09-19 14:52:48 +08:00
han0110 090c4d727b tmp: add associated const bool `QUERY_INSTANCE` in `Prover` and `Verifier` 2022-09-12 16:09:30 +08:00
han0110 e54dedbe3f tmp: don't query instance but build the evaluation directly 2022-09-11 14:10:24 +08:00
Han a9e99a72a6
feat: implement multi-phase `ConstraintSystem` (#97) 2022-09-08 13:31:01 +02:00
Han 0cccba00d1
Merge pull request #84 from han0110/feature/abstraction-squashed 2022-08-19 18:21:00 +08:00
han0110 3e4b27fc6c feat: expose necessary structure of ConstraintSystem 2022-08-19 16:00:51 +08:00
han0110 6e564cfd23 feat: Add `MockProver::verify_{par,at_rows_par}` 2022-08-19 16:00:51 +08:00
han0110 984105592c feat: Cache table when same identifier and improve permutation checks in `MockProver` 2022-08-19 16:00:51 +08:00
han0110 f08632016f feat: use nightly rust and fix warnings 2022-08-19 16:00:51 +08:00
Brechtpd 182ec2dd99 Reduce lifetime of advice polys 2022-08-19 16:00:51 +08:00
Brechtpd 70cfe70a01 Add `plonk::evaluation` for prover optimization 2022-08-19 16:00:51 +08:00
NoCtrlZ 5b3bf56ca6 Add `ConstraintSystem::lookup_any` 2022-08-19 16:00:51 +08:00
Zhang Zhuo 31efabd369 Add name in `lookup::Argument` 2022-08-19 16:00:51 +08:00
Zhang Zhuo 1e967eb35f Add `MockProver::verify_at_rows` 2022-08-19 16:00:51 +08:00
Brechtpd 8e87a74180 Parallelized `eval_polynomial` 2022-08-19 16:00:51 +08:00
Brechtpd 8916c60b1a Add `Expression::evaluate_lazy` and `Expression::identifier` 2022-08-19 16:00:51 +08:00
Brechtpd f9923c8dd6 Use `HashMap` to count cell assignment in `dev::Region` 2022-08-19 16:00:51 +08:00
testuser-at-490752553772 5eac2ad543 Removed bench.yml, added trigger_proverbench_dispatch.yml to allign halo2 benches with main 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
Chih Cheng Liang 2a19e441b1
Merge pull request #94 from privacy-scaling-explorations/purely-upstream
Purely upstream
2022-08-19 15:55:25 +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
Han ad425ed3d1
Merge pull request #78 from Brechtpd/eval-mem
Reduce memory use in h evaluation
2022-08-09 00:40:06 +08:00
Brechtpd 9015e5432b Reduce memory use in h evaluation 2022-08-08 18:20:26 +02:00
Han 6ec2f49ee3
Merge pull request #85 from scroll-tech/parallel-mockprover-verify
Add Mockprover::verify_par()
2022-08-08 13:31:43 +08:00
Han 763335c95e
Merge pull request #86 from pinkiebell/params_pub
Params,ParamsVerifier: make k & n public
2022-08-08 11:32:28 +08:00
spherel 55bae7c687 Fix parallel function signature. 2022-08-07 20:44:36 +00:00
han0110 8ff5b1e3af feat: make `Expression::{Fixed,Advice,Instance}` to wrap their own `Query` struct 2022-07-15 10:33:47 -04:00
pinkiebell f12f082b71 add doc strings 2022-07-12 07:35:42 +00:00
pinkiebell 2b625a2802 Params,ParamsVerifier: make k & n public
Used for decision making in downstream projects that want to infer
certain bounds given a `Params{Verifier}` structure.
2022-07-12 06:53:28 +00:00
spherel 0b83e58b30 Add Mockprover::verify_par() 2022-07-09 03:23:44 +00:00
Daira Hopwood 5af2bd3bd7 [Book] Rename "polynomial degree bound" to "maximum constraint degree".
This is because "degree bound" is often defined to be exclusive.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-07-07 18:13:14 -04:00
Daira Hopwood 104101d0eb [Book] Make the permutation diagram stand out against dark backgrounds.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-07-07 18:13:14 -04:00
str4d 96d9bde905
Merge pull request #612 from zcash/batch-crate-feature
Place `halo2_proofs::plonk::BatchVerifier` behind a (default enabled) crate feature called `batch`.
2022-06-23 20:16:37 +01:00