Skip to content

Commit

Permalink
Update halo2-lib and add SDK (privacy-scaling-explorations#3)
Browse files Browse the repository at this point in the history
* chore: add display feature to Cargo.toml

* fix: change test data directory to ./data and give error message

* feat: add succinct_verify_or_dummy to allow flag to turn off verification in aggregation snark

* Rollback to pse halo2 and halo2wrong for first release (privacy-scaling-explorations#5)

* feat: move `Accumulator` to `accumulator.rs`

* feat: update due to halo2

* feat: upgrade to use branch `feature/generic-instructions` of `halo2wrong`

* refactor: rollback to `{halo2,halo2_wrong}` without challenge API and cleanup dependencies

* chore: rename statement to instance and auxliary to witness

* chore: use `finalize` instead of `code`

* feat: add `Code::deployment` and `EvmLoader::deployment_code`; add example `evm-verifier-codegen`

* fix: typo

* feat: reduce generated evm verifier size; rename to `evm-verifier` and add another example `evm-verifier-with-accumulator`

* fix: due to `halo2wrong`

* feat: reorganize mods and traits

* fix: allow empty `values` in `sum_*` and move them under `ScalarLoader`

* ci: use `--all-features` for `cargo test`

* fix: use same strategy for aggregation testing

* fix: simplify trait `PlonkVerifier` again

* fix: move system specified transcript under mod `system`

* feat: add `quotient_poly` info in `Protocol`

* feat: implement linearization for circom integration

* feat: re-export loader's dependency for consumer

* refactor: for circom's integration

* tmp: pin `revm` to rev

* fix: remove parentheses

* fix: upgrade for multi-phase halo2

* feat: improve error reporting

* chore: rename crate to snake case

* feat: add `Domain` as an input of `PolynomialCommitmentScheme::read_proof`

* refactor: for further integration

* feat: generalize to suppoer also ipa and add builder fns to `system::halo2::Config`

* feat: add `KzgDecider` for simple evm verifier

* refactor: split `AccumulationScheme` and `AccumulatorEncoding`

* refactor: split `PolynomialCommitmentScheme` and `MultiOpenScheme`

* fix: not need sealed actually

* fix: `chunk_size` should be `LIMBS` when recovering accumulator

* feat: add `Expression::DistributePowers` to avoid stack overflow

* fix: update and pin foundry

* fix: move testing circuits under `system/halo2`

* fix: allow accumulate single accumulator

* feat: remove all patch and make less depending `halo2wrong`

* chore: update dependencies with latest halo2_proofs

* add `serialize` feature to turn on/off vkey/pkey write

* feat: change `name` to function instead of const in `TargetCircuit`

* fix: `load_verify_circuit_degree` now takes in environmental variable
`VERIFY_CONFIG`

* Generalized `Halo2Loader` (privacy-scaling-explorations#12)

* feat: generalize `Protocol` for further usage

* feat: add `EccInstruction::{fixed_base_msm,variable_base_msm,sum_with_const}`

* chore: move `rand_chacha` as dev dependency

* feat: implement `IntegerInstructions` and `EccInstructions` traits for
`halo2-lib`

* feat: implement `EncodeNative` and working example
`evm-verifier-with-accumulator` using `halo2-lib`
* Does not yet use custom `fixed_base_msm`

* feat: add example `recursion`

* chore: update for compatibility with halo2-lib

* poseidon: switch to rate = 2, `t = 3` for faster proving time

* update: remove unnecessary trait `where` clause

* feat: add example `recursion`

* General refactor for further integration (privacy-scaling-explorations#13)

* feat: remove dev-dependency `foundry` and vendor necessary part of it

* refactor: simplify traits and remove unused stuff

* refactor: much less clone

* feat: generalized `AccumulatorEncoding` for `EccInstructions`

* feat: implement ipa pcs and accumulation (privacy-scaling-explorations#14)

* feat: add example `recursion`

* wip: update to halo2-lib v0.2.0

* wip: recursion example currently works if circuit does not use simple
selectors

* Simple selector compression is not correctly handled by `CsProxy` at
  the moment

* fix: got recursion example working with halo2-lib

* where halo2-lib uses simple selectors
* only works if all selector columns are in active use and can't be
  optimized away
* tricks `CsProxy` by turning all selectors on in row `0`

* feat: add `sdk` module for snark aggregation toolkit

* chore: move `aggregation` under `halo2` inside `sdk`

* Update `EvmLoader` to generate Yul code instead of bytecode (privacy-scaling-explorations#15)

* Update `EvmLoader` to generate Yul instead of bytecode

* feat: simplify

* feat: Add missing end_gas_metering impl

Co-authored-by: Han <[email protected]>

Co-authored-by: Han <[email protected]>

* feat: add `evm` module to `sdk` with evm proof and verifier functions

* add bench for zkevm EVM circuit, currently uses my local repo because
  official repo does not compile... use scroll-dev-1115 circuit
implementation where power of randomness is generated internally and not
from public inputs (far too many public inputs for aggregation)

* chore: update Cargo.toml

* reorg: rename repo to snark-verifier

* split into two crates: snark-verifier and snark-verifier-sdk
* previous module sdk moved to snark-verifier-sdk

Co-authored-by: Han <[email protected]>
Co-authored-by: DoHoon Kim <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2022
1 parent db4994a commit 68f7d1e
Show file tree
Hide file tree
Showing 91 changed files with 10,752 additions and 4,489 deletions.
113 changes: 52 additions & 61 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,61 +1,52 @@
[package]
name = "plonk_verifier"
version = "0.1.0"
edition = "2021"

[dependencies]
itertools = "0.10.3"
lazy_static = "1.4.0"
num-bigint = "0.4"
num-traits = "0.2"

rand = "0.8"
rand_chacha = "0.3.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
hex = "0.4.3"
ark-std = { version = "0.3", features = ["print-trace"] }

halo2_curves = { git = "https://github.com/privacy-scaling-explorations/halo2curves", tag = "0.2.1", package = "halo2curves" }

# system_halo2
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2", tag = "v2022_09_10", optional = true }

# loader_evm
ethereum_types = { package = "ethereum-types", version = "0.13.1", default-features = false, features = ["std"], optional = true }
sha3 = { version = "0.10.1", optional = true }
foundry_evm = { git = "https://github.com/jonathanpwang/foundry", package = "foundry-evm", branch = "fix/pin-revm-to-rev", optional = true }

# loader_halo2
halo2_base = { git = "ssh://github.com/axiom-crypto/halo2-lib-working.git", package = "halo2_base", default-features = false, optional = true }
halo2_ecc = { git = "ssh://github.com/axiom-crypto/halo2-lib-working.git", package = "halo2_ecc", default-features = false, optional = true }
poseidon = { git = "https://github.com/privacy-scaling-explorations/poseidon", branch = "padding", optional = true }

[dev-dependencies]
paste = "1.0.7"

# loader_evm
crossterm = { version = "0.22.1" }
tui = { version = "0.16.0", default-features = false, features = ["crossterm"] }

# zkevm
zkevm_circuit_benchmarks = {git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", package = "circuit-benchmarks", features = ["benches"] }
zkevm_circuits = {git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", package = "zkevm-circuits" }

[features]
default = ["loader_evm", "loader_halo2", "system_halo2"]
loader_evm = ["dep:ethereum_types", "dep:sha3", "dep:foundry_evm"]
loader_halo2 = ["dep:halo2_proofs", "dep:halo2_base", "halo2_ecc", "dep:poseidon"]
system_halo2 = ["dep:halo2_proofs"]
sanity_check = []

[patch."https://github.com/privacy-scaling-explorations/halo2"]
halo2_proofs = { git = "https://github.com/axiom-crypto/halo2.git", branch = "axiom/add-serialization", package = "halo2_proofs" }

[[example]]
name = "evm-verifier"
required-features = ["loader_evm", "system_halo2"]

[[example]]
name = "evm-verifier-with-accumulator"
required-features = ["loader_halo2", "loader_evm", "system_halo2"]
[workspace]
members = [
"snark-verifier",
"snark-verifier-sdk",
]

[profile.dev]
opt-level = 3

# Local "release" mode, more optimized than dev but faster to compile than release
[profile.local]
inherits = "dev"
opt-level = 3
# Set this to 1 or 2 to get more useful backtraces
debug = true
debug-assertions = false
panic = 'unwind'
# better recompile times
incremental = true
lto = "thin"
codegen-units = 16

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = "fat"
# codegen-units = 1
panic = "abort"
incremental = false

# For performance profiling
[profile.flamegraph]
inherits = "release"
debug = true

[patch."ssh://github.com/axiom-crypto/axiom-core-working.git"]
halo2-base = { path = "../axiom-core-working/halo2-lib/halo2-base" }
halo2-ecc = { path = "../axiom-core-working/halo2-lib/halo2-ecc" }

[patch."https://github.com/axiom-crypto/halo2.git"]
halo2_proofs = { path = "../halo2/halo2_proofs" }
halo2curves = { path = "../halo2/arithmetic/curves" }
poseidon = { path = "../halo2/primitives/poseidon" }

# patch for now because PSE/halo2 has not yet updated halo2curves version, unnecessary if halo2_proofs is using latest halo2curves with Fq12 public
[patch."https://github.com/privacy-scaling-explorations/halo2curves.git"]
halo2curves = { path = "../halo2/arithmetic/curves" }

# patch just because we cannot patch the same repo with different tag: serialization is already in latest PSE/halo2 but not in v2022_10_22
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/axiom-crypto/halo2.git", branch = "axiom/add-serialization" }
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# PLONK Verifier

Generic PLONK verifier.

## SRS

Note that if aggregating snarks with different `K` params size, you should generate the largest srs necessarily and then `downgrade` to the smaller param sizes so that the first two points are the same for all srs files.
Loading

0 comments on commit 68f7d1e

Please sign in to comment.