Skip to content

Commit

Permalink
upgrade halo2curves to 0.6.0 + changes to tests and benches (#297)
Browse files Browse the repository at this point in the history
* upgrade halo2curves to 0.6.0

* use expect-test

* update verifier circuit size in benches
  • Loading branch information
srinathsetty authored Jan 24, 2024
1 parent 499ba16 commit 27c5ad1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rand_core = { version = "0.6", default-features = false }
rand_chacha = "0.3"
subtle = "2.5"
pasta_curves = { version = "0.5", features = ["repr-c", "serde"] }
halo2curves = { version = "0.6.0", features = ["bits", "derive_serde"] }
neptune = { version = "13.0.0", default-features = false }
generic-array = "0.14"
num-bigint = { version = "0.4", features = ["serde", "rand"] }
Expand All @@ -39,13 +40,9 @@ itertools = "0.12.0"
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
pasta-msm = { version = "0.1.4" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
halo2curves = { version = "0.5.0", features = ["bits", "derive_serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# see https://github.com/rust-random/rand/pull/948
getrandom = { version = "0.2.0", default-features = false, features = ["js"] }
halo2curves = { version = "0.5.0", default-features = false, features = ["bits", "derive_serde"] }

[dev-dependencies]
criterion = { version = "0.4", features = ["html_reports"] }
Expand All @@ -56,6 +53,7 @@ cfg-if = "1.0.0"
sha2 = "0.10.7"
proptest = "1.2.0"
rand = "0.8.5"
expect-test = "1.4.1"

[[bench]]
name = "recursive-snark"
Expand Down
2 changes: 1 addition & 1 deletion benches/compressed-snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ cfg_if::cfg_if! {
criterion_main!(compressed_snark);

// This should match the value for the primary in test_recursive_circuit_pasta
const NUM_CONS_VERIFIER_CIRCUIT_PRIMARY: usize = 9825;
const NUM_CONS_VERIFIER_CIRCUIT_PRIMARY: usize = 9817;
const NUM_SAMPLES: usize = 10;

/// Benchmarks the compressed SNARK at a provided number of constraints
Expand Down
2 changes: 1 addition & 1 deletion benches/recursive-snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cfg_if::cfg_if! {
criterion_main!(recursive_snark);

// This should match the value for the primary in test_recursive_circuit_pasta
const NUM_CONS_VERIFIER_CIRCUIT_PRIMARY: usize = 9825;
const NUM_CONS_VERIFIER_CIRCUIT_PRIMARY: usize = 9817;
const NUM_SAMPLES: usize = 10;

fn bench_recursive_snark(c: &mut Criterion) {
Expand Down
20 changes: 10 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,12 @@ mod tests {
mlkzg::Bn256EngineKZG, pedersen::CommitmentKeyExtTrait, traits::DlogGroup, Bn256Engine,
GrumpkinEngine, PallasEngine, Secp256k1Engine, Secq256k1Engine, VestaEngine,
},
traits::{evaluation::EvaluationEngineTrait, snark::default_ck_hint},
traits::{circuit::TrivialCircuit, evaluation::EvaluationEngineTrait, snark::default_ck_hint},
};
use ::bellpepper_core::{num::AllocatedNum, ConstraintSystem, SynthesisError};
use core::{fmt::Write, marker::PhantomData};
use expect_test::{expect, Expect};
use ff::PrimeField;
use traits::circuit::TrivialCircuit;

type EE<E> = provider::ipa_pc::EvaluationEngine<E>;
type S<E, EE> = spartan::snark::RelaxedR1CSSNARK<E, EE>;
Expand Down Expand Up @@ -908,7 +908,7 @@ mod tests {
}
}

fn test_pp_digest_with<E1, E2, T1, T2>(circuit1: &T1, circuit2: &T2, expected: &str)
fn test_pp_digest_with<E1, E2, T1, T2>(circuit1: &T1, circuit2: &T2, expected: &Expect)
where
E1: Engine<Base = <E2 as Engine>::Scalar>,
E2: Engine<Base = <E1 as Engine>::Scalar>,
Expand All @@ -934,7 +934,7 @@ mod tests {
let _ = write!(output, "{b:02x}");
output
});
assert_eq!(digest_str, expected);
expected.assert_eq(&digest_str);
}

#[test]
Expand All @@ -946,13 +946,13 @@ mod tests {
test_pp_digest_with::<PallasEngine, VestaEngine, _, _>(
&trivial_circuit1,
&trivial_circuit2,
"9bc7ad2ab3f2a12455fdd21527598e365a14619c7f1e09f5cc3c78caa2fdd602",
&expect!["9bc7ad2ab3f2a12455fdd21527598e365a14619c7f1e09f5cc3c78caa2fdd602"],
);

test_pp_digest_with::<PallasEngine, VestaEngine, _, _>(
&cubic_circuit1,
&trivial_circuit2,
"8dea023ed642fd2d1a7bedb536cd96d22c0d25ea40961a4fe4a865169bf6ee01",
&expect!["8dea023ed642fd2d1a7bedb536cd96d22c0d25ea40961a4fe4a865169bf6ee01"],
);

let trivial_circuit1_grumpkin = TrivialCircuit::<<Bn256Engine as Engine>::Scalar>::default();
Expand All @@ -962,13 +962,13 @@ mod tests {
test_pp_digest_with::<Bn256Engine, GrumpkinEngine, _, _>(
&trivial_circuit1_grumpkin,
&trivial_circuit2_grumpkin,
"89e746ed5055445a4aceb2b6fb0413fe0bf4d2efec387dee85613922a972a701",
&expect!["89e746ed5055445a4aceb2b6fb0413fe0bf4d2efec387dee85613922a972a701"],
);

test_pp_digest_with::<Bn256Engine, GrumpkinEngine, _, _>(
&cubic_circuit1_grumpkin,
&trivial_circuit2_grumpkin,
"941f55146ac21a3b4ff9863546bea95df48cb0069d2fa9e8249f8d0a00560401",
&expect!["941f55146ac21a3b4ff9863546bea95df48cb0069d2fa9e8249f8d0a00560401"],
);

let trivial_circuit1_secp = TrivialCircuit::<<Secp256k1Engine as Engine>::Scalar>::default();
Expand All @@ -978,12 +978,12 @@ mod tests {
test_pp_digest_with::<Secp256k1Engine, Secq256k1Engine, _, _>(
&trivial_circuit1_secp,
&trivial_circuit2_secp,
"4320b4f18ac17958f77db04e78c2d9d6064810f44441e0681f44e977d0fddf03",
&expect!["c70782c49d3de831b3822081655cf61c7d53533f0effcd5c4166cd4fbe651e00"],
);
test_pp_digest_with::<Secp256k1Engine, Secq256k1Engine, _, _>(
&cubic_circuit1_secp,
&trivial_circuit2_secp,
"ac86337a156c328c400a6c38ce4f65dc29dcca7317b1f5da45599e4031d1a302",
&expect!["148c5994c443174b67699cb6169aa4489babebb360ae5145bb4b09d77a3a9a01"],
);
}

Expand Down

0 comments on commit 27c5ad1

Please sign in to comment.