Skip to content

Commit

Permalink
update dependecies for snark-verifier with halo2-pse
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenfeizhang committed Oct 23, 2023
1 parent 7011e8c commit cde1814
Show file tree
Hide file tree
Showing 38 changed files with 2,314 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ testdata
Cargo.lock
params
agg.pk
break_points.json
break_points.json
*.srs
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ incremental = false
[profile.flamegraph]
inherits = "release"
debug = true

[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "sync-halo2-lib-0.4.0" }
14 changes: 7 additions & 7 deletions snark-verifier-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ serde_json = "1.0"
serde_with = { version = "2.2", optional = true }
bincode = "1.3.3"
ark-std = { version = "0.3.0", features = ["print-trace"], optional = true }
halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib.git", branch = "community-edition", default-features = false }
halo2-base = { git = "https://github.com/scroll-tech/halo2-lib.git", branch = "sync-halo2-lib-0.4.0", default-features = false }
snark-verifier = { path = "../snark-verifier", default-features = false }
getset = "0.1.2"

# loader_evm
ethereum-types = { version = "0.14.1", default-features = false, features = ["std"], optional = true }

# zkevm benchmarks
zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", features = ["test"], optional = true }
bus-mapping = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
eth-types = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
mock = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
# # zkevm benchmarks
# zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", features = ["test"], optional = true }
# bus-mapping = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
# eth-types = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
# mock = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }

[dev-dependencies]
ark-std = { version = "0.3.0", features = ["print-trace"] }
Expand All @@ -41,7 +41,7 @@ crossterm = { version = "0.25" }
tui = { version = "0.19", default-features = false, features = ["crossterm"] }

[features]
default = ["loader_halo2", "loader_evm", "halo2-axiom", "halo2-base/jemallocator", "display"]
default = ["loader_halo2", "loader_evm", "halo2-pse", "halo2-base/jemallocator", "display"]
display = ["snark-verifier/display", "dep:ark-std"]
loader_evm = ["snark-verifier/loader_evm", "dep:ethereum-types"]
loader_halo2 = ["snark-verifier/loader_halo2"]
Expand Down
29 changes: 20 additions & 9 deletions snark-verifier-sdk/examples/k_as_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ mod application {
impl Circuit<Fr> for StandardPlonk {
type Config = StandardPlonkConfig;
type FloorPlanner = SimpleFloorPlanner;
type Params = ();

fn without_witnesses(&self) -> Self {
Self(Fr::zero(), self.1)
Expand All @@ -105,35 +106,45 @@ mod application {
layouter.assign_region(
|| "",
|mut region| {
region.assign_advice(config.a, 0, Value::known(self.0));
region.assign_fixed(config.q_a, 0, -Fr::one());
region.assign_advice(config.a, 1, Value::known(-Fr::from(5u64)));
region.assign_advice(|| "", config.a, 0, || Value::known(self.0));
region.assign_fixed(|| "", config.q_a, 0, || Value::known(-Fr::one()));
region.assign_advice(|| "", config.a, 1, || Value::known(-Fr::from(5u64)));
for (idx, column) in (1..).zip([
config.q_a,
config.q_b,
config.q_c,
config.q_ab,
config.constant,
]) {
region.assign_fixed(column, 1, Fr::from(idx as u64));
region.assign_fixed(|| "", column, 1, ||Value::known(Fr::from(idx as u64)));
}
let a = region.assign_advice(config.a, 2, Value::known(Fr::one()));
a.copy_advice(&mut region, config.b, 3);
a.copy_advice(&mut region, config.c, 4);
let a = region.assign_advice(|| "", config.a, 2, || Value::known(Fr::one()))?;
a.copy_advice(|| "", &mut region, config.b, 3);
a.copy_advice(|| "", &mut region, config.c, 4);

// assuming <= 10 blinding factors
// fill in most of circuit with a computation
let n = self.1;
for offset in 5..n - 10 {
region.assign_advice(config.a, offset, Value::known(-Fr::from(5u64)));
region.assign_advice(
|| "",
config.a,
offset,
|| Value::known(-Fr::from(5u64)),
);
for (idx, column) in (1..).zip([
config.q_a,
config.q_b,
config.q_c,
config.q_ab,
config.constant,
]) {
region.assign_fixed(column, offset, Fr::from(idx as u64));
region.assign_fixed(
|| "",
column,
offset,
|| Value::known(Fr::from(idx as u64)),
);
}
}

Expand Down
1 change: 1 addition & 0 deletions snark-verifier-sdk/examples/standard_plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ mod application {
impl Circuit<Fr> for StandardPlonk {
type Config = StandardPlonkConfig;
type FloorPlanner = SimpleFloorPlanner;
type Params = ();

fn without_witnesses(&self) -> Self {
Self::default()
Expand Down
20 changes: 13 additions & 7 deletions snark-verifier-sdk/examples/vkey_as_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ mod application {
impl Circuit<Fr> for StandardPlonk {
type Config = StandardPlonkConfig;
type FloorPlanner = SimpleFloorPlanner;
type Params = ();

fn without_witnesses(&self) -> Self {
Self(Fr::zero(), self.1)
Expand All @@ -113,9 +114,9 @@ mod application {
layouter.assign_region(
|| "",
|mut region| {
region.assign_advice(config.a, 0, Value::known(self.0));
region.assign_fixed(config.q_a, 0, -Fr::one());
region.assign_advice(config.a, 1, Value::known(-Fr::from(5u64)));
region.assign_advice(|| "", config.a, 0, || Value::known(self.0));
region.assign_fixed(|| "", config.q_a, 0, || Value::known(-Fr::one()));
region.assign_advice(|| "", config.a, 1, || Value::known(-Fr::from(5u64)));
if self.1 != ComputeFlag::SkipFixed {
for (idx, column) in (1..).zip([
config.q_a,
Expand All @@ -124,13 +125,18 @@ mod application {
config.q_ab,
config.constant,
]) {
region.assign_fixed(column, 1, Fr::from(idx as u64));
region.assign_fixed(
|| "",
column,
1,
|| Value::known(Fr::from(idx as u64)),
);
}
}
let a = region.assign_advice(config.a, 2, Value::known(Fr::one()));
let a = region.assign_advice(|| "", config.a, 2, || Value::known(Fr::one()))?;
if self.1 != ComputeFlag::SkipCopy {
a.copy_advice(&mut region, config.b, 3);
a.copy_advice(&mut region, config.c, 4);
a.copy_advice(|| "", &mut region, config.b, 3);
a.copy_advice(|| "", &mut region, config.c, 4);
}

Ok(())
Expand Down
Loading

0 comments on commit cde1814

Please sign in to comment.