From 085a9c6374d12992bf371d3011b40c5d2a818cc1 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Wed, 18 Jan 2023 09:39:28 +0100 Subject: [PATCH 1/2] chore: Update halo2_proofs to `v2023_01_17` --- halo2wrong/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halo2wrong/Cargo.toml b/halo2wrong/Cargo.toml index 9176a248..46323b17 100644 --- a/halo2wrong/Cargo.toml +++ b/halo2wrong/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" num-bigint = { version = "0.4", features = ["rand"] } num-integer = "0.1" num-traits = "0.2" -halo2 = { package = "halo2_proofs", git = "https://github.com/privacy-scaling-explorations/halo2", tag = "v2022_10_22" } +halo2 = { package = "halo2_proofs", git = "https://github.com/privacy-scaling-explorations/halo2", tag = "v2023_01_17" } group = "0.12" [dev-dependencies] From 35879e8f2d6dc2d5f5ea93f3cd0f1220a7e5a8c5 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Wed, 18 Jan 2023 09:46:14 +0100 Subject: [PATCH 2/2] chore: Accomodate `mock_prover_verify` to not return Since the new release of halo2_2023_10_17, `VerifyFailure` now has a reference to the prover itself. That means that we can't return the failures if we are out of the prover scope. To adapt to the situation, the fn `mock_prover_verify` has been changed so that does the assertion inside. Resolves: #60 --- ecc/src/base_field_ecc.rs | 8 ++++---- ecc/src/general_ecc.rs | 8 ++++---- ecdsa/src/ecdsa.rs | 2 +- halo2wrong/src/utils.rs | 20 ++++++++++++++------ integer/src/chip.rs | 2 +- transcript/src/transcript.rs | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ecc/src/base_field_ecc.rs b/ecc/src/base_field_ecc.rs index 9269c0ad..a79ac760 100644 --- a/ecc/src/base_field_ecc.rs +++ b/ecc/src/base_field_ecc.rs @@ -508,7 +508,7 @@ mod tests { fn run() { let circuit = TestEccAddition::::default(); let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } run::(); run::(); @@ -599,7 +599,7 @@ mod tests { b: Value::known(b), }; let instance = vec![public_data]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } run::(); @@ -686,7 +686,7 @@ mod tests { window_size, }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } } run::(); @@ -788,7 +788,7 @@ mod tests { number_of_pairs, }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } } } diff --git a/ecc/src/general_ecc.rs b/ecc/src/general_ecc.rs index 39f3ba87..49e08cca 100644 --- a/ecc/src/general_ecc.rs +++ b/ecc/src/general_ecc.rs @@ -591,7 +591,7 @@ mod tests { >() { let circuit = TestEccAddition::::default(); let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } run::(); @@ -708,7 +708,7 @@ mod tests { ..Default::default() }; let instance = vec![public_data]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } run::(); @@ -827,7 +827,7 @@ mod tests { ..Default::default() }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } } @@ -957,7 +957,7 @@ mod tests { ..Default::default() }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } } } diff --git a/ecdsa/src/ecdsa.rs b/ecdsa/src/ecdsa.rs index d0deeef9..4d1f7b85 100644 --- a/ecdsa/src/ecdsa.rs +++ b/ecdsa/src/ecdsa.rs @@ -343,7 +343,7 @@ mod tests { ..Default::default() }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } use crate::curves::bn256::Fr as BnScalar; diff --git a/halo2wrong/src/utils.rs b/halo2wrong/src/utils.rs index 4bba03f8..d0401ffe 100644 --- a/halo2wrong/src/utils.rs +++ b/halo2wrong/src/utils.rs @@ -1,7 +1,7 @@ use crate::halo2::{ arithmetic::FieldExt, circuit::Value, - dev::{MockProver, VerifyFailure}, + dev::MockProver, plonk::{ Advice, Any, Assigned, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed, FloorPlanner, Instance, Selector, @@ -63,14 +63,14 @@ pub fn compose(input: Vec, bit_len: usize) -> big_uint { .fold(big_uint::zero(), |acc, val| (acc << bit_len) + val) } -pub fn mock_prover_verify>( - circuit: &C, - instance: Vec>, -) -> Result<(), Vec> { +pub fn mock_prover_verify>(circuit: &C, instance: Vec>) { let dimension = DimensionMeasurement::measure(circuit).unwrap(); let prover = MockProver::run(dimension.k(), circuit, instance) .unwrap_or_else(|err| panic!("{:#?}", err)); - prover.verify_at_rows_par(dimension.advice_range(), dimension.advice_range()) + assert_eq!( + prover.verify_at_rows_par(dimension.advice_range(), dimension.advice_range()), + Ok(()) + ) } #[derive(Clone, Debug, PartialEq, Eq)] @@ -160,6 +160,14 @@ impl Assignment for DimensionMeasurement { Ok(Value::unknown()) } + fn annotate_column(&mut self, _annotation: A, _column: Column) + where + A: FnOnce() -> AR, + AR: Into, + { + // Do nothing. + } + fn assign_advice( &mut self, _: A, diff --git a/integer/src/chip.rs b/integer/src/chip.rs index ac732fb7..666bfa7e 100644 --- a/integer/src/chip.rs +++ b/integer/src/chip.rs @@ -1518,7 +1518,7 @@ mod tests { let circuit = $circuit::<$wrong_field, $native_field, $bit_len_limb> { rns: Rc::new(rns) }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); )* }; } diff --git a/transcript/src/transcript.rs b/transcript/src/transcript.rs index d8cd7b62..90b61bad 100644 --- a/transcript/src/transcript.rs +++ b/transcript/src/transcript.rs @@ -322,7 +322,7 @@ mod tests { expected: Value::known(expected), }; let instance = vec![vec![]]; - assert_eq!(mock_prover_verify(&circuit, instance), Ok(())); + mock_prover_verify(&circuit, instance); } } }