From 75126acfe9417f5a31e40529bf4af9e714acbc82 Mon Sep 17 00:00:00 2001 From: guorong009 Date: Fri, 5 Jul 2024 20:37:35 +0800 Subject: [PATCH 1/6] feat: refactor the verification api --- halo2_backend/src/plonk/verifier.rs | 38 ++++++++++++++++++----- halo2_backend/src/plonk/verifier/batch.rs | 18 ++++++----- halo2_backend/src/poly/ipa/strategy.rs | 15 ++++----- halo2_backend/src/poly/kzg/strategy.rs | 17 +++++----- 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/halo2_backend/src/plonk/verifier.rs b/halo2_backend/src/plonk/verifier.rs index 53d9da4181..afba1f9f5a 100644 --- a/halo2_backend/src/plonk/verifier.rs +++ b/halo2_backend/src/plonk/verifier.rs @@ -33,29 +33,28 @@ pub use batch::BatchVerifier; pub fn verify_proof_single<'params, Scheme, V, E, T, Strategy>( params: &'params Scheme::ParamsVerifier, vk: &VerifyingKey, - strategy: Strategy, instance: Vec>, transcript: &mut T, -) -> Result +) -> bool where Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>, Scheme: CommitmentScheme, V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptRead, - Strategy: VerificationStrategy<'params, Scheme, V>, + Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, { - verify_proof(params, vk, strategy, &[instance], transcript) + verify_proof::(params, vk, &[instance], transcript) } -/// Returns a boolean indicating whether or not the proof is valid -pub fn verify_proof< +/// Process the proof, checks that the proof is valid and returns the `Strategy` output. +pub fn verify_proof_with_strategy< 'params, Scheme: CommitmentScheme, V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptRead, - Strategy: VerificationStrategy<'params, Scheme, V>, + Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, >( params: &'params Scheme::ParamsVerifier, vk: &VerifyingKey, @@ -519,3 +518,28 @@ where .map_err(|_| Error::Opening) }) } + +/// Returns a boolean indicating whether or not the proof is valid +pub fn verify_proof< + 'params, + Scheme: CommitmentScheme, + V: Verifier<'params, Scheme>, + E: EncodedChallenge, + T: TranscriptRead, + Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, +>( + params: &'params Scheme::ParamsVerifier, + vk: &VerifyingKey, + instances: &[Vec>], + transcript: &mut T, +) -> bool +where + Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>, +{ + let strategy = Strategy::new(params); + let strategy = match verify_proof_with_strategy(params, vk, strategy, instances, transcript) { + Ok(strategy) => strategy, + Err(_) => return false, + }; + strategy.finalize() +} diff --git a/halo2_backend/src/plonk/verifier/batch.rs b/halo2_backend/src/plonk/verifier/batch.rs index 54b06450d9..3a96bebbd4 100644 --- a/halo2_backend/src/plonk/verifier/batch.rs +++ b/halo2_backend/src/plonk/verifier/batch.rs @@ -5,7 +5,7 @@ use halo2_middleware::zal::impls::H2cEngine; use halo2curves::CurveAffine; use rand_core::OsRng; -use super::{verify_proof, VerificationStrategy}; +use super::{verify_proof_with_strategy, VerificationStrategy}; use crate::{ multicore::{ IndexedParallelIterator, IntoParallelIterator, ParallelIterator, TryFoldAndReduce, @@ -34,7 +34,7 @@ struct BatchStrategy<'params, C: CurveAffine> { impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme, VerifierIPA> for BatchStrategy<'params, C> { - type Output = MSMIPA<'params, C>; + type Output = Self; fn new(params: &'params ParamsVerifierIPA) -> Self { BatchStrategy { @@ -47,7 +47,9 @@ impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme< f: impl FnOnce(MSMIPA<'params, C>) -> Result, Error>, ) -> Result { let guard = f(self.msm)?; - Ok(guard.use_challenges()) + Ok(Self { + msm: guard.use_challenges(), + }) } fn finalize(self) -> bool { @@ -110,10 +112,12 @@ where .map(|(i, item)| { let strategy = BatchStrategy::new(params); let mut transcript = Blake2bRead::init(&item.proof[..]); - verify_proof(params, vk, strategy, &item.instances, &mut transcript).map_err(|e| { - tracing::debug!("Batch item {} failed verification: {}", i, e); - e - }) + verify_proof_with_strategy(params, vk, strategy, &item.instances, &mut transcript) + .map_err(|e| { + tracing::debug!("Batch item {} failed verification: {}", i, e); + e + }) + .map(|st| st.msm) }) .try_fold_and_reduce( || ParamsVerifier::<'_, C>::empty_msm(params), diff --git a/halo2_backend/src/poly/ipa/strategy.rs b/halo2_backend/src/poly/ipa/strategy.rs index 4fdc47523c..8d8b756e22 100644 --- a/halo2_backend/src/poly/ipa/strategy.rs +++ b/halo2_backend/src/poly/ipa/strategy.rs @@ -119,7 +119,7 @@ pub struct SingleStrategy<'params, C: CurveAffine> { impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme, VerifierIPA> for SingleStrategy<'params, C> { - type Output = (); + type Output = Self; fn new(params: &'params ParamsIPA) -> Self { SingleStrategy { @@ -132,13 +132,9 @@ impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme< f: impl FnOnce(MSMIPA<'params, C>) -> Result, Error>, ) -> Result { let guard = f(self.msm)?; - let msm = guard.use_challenges(); - // ZAL: Verification is (supposedly) cheap, hence we don't use an accelerator engine - if msm.check(&H2cEngine::new()) { - Ok(()) - } else { - Err(Error::ConstraintSystemFailure) - } + Ok(Self { + msm: guard.use_challenges(), + }) } /// Finalizes the batch and checks its validity. @@ -147,7 +143,8 @@ impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme< /// specific failing proofs, it must re-process the proofs separately. #[must_use] fn finalize(self) -> bool { - unreachable!() + // TODO: Verification is cheap, ZkAccel on verifier is not a priority. + self.msm.check(&H2cEngine::new()) } } diff --git a/halo2_backend/src/poly/kzg/strategy.rs b/halo2_backend/src/poly/kzg/strategy.rs index 93c6a96163..f254477b37 100644 --- a/halo2_backend/src/poly/kzg/strategy.rs +++ b/halo2_backend/src/poly/kzg/strategy.rs @@ -155,7 +155,7 @@ where E::G1: CurveExt, E::G2Affine: SerdeCurveAffine, { - type Output = (); + type Output = Self; fn new(params: &'params ParamsVerifierKZG) -> Self { Self::new(params) @@ -168,16 +168,15 @@ where // Guard is updated with new msm contributions let guard = f(self.msm)?; let msm = guard.msm_accumulator; - // Verification is (supposedly) cheap, hence we don't use an accelerator engine - let default_engine = H2cEngine::new(); - if msm.check(&default_engine, &self.params) { - Ok(()) - } else { - Err(Error::ConstraintSystemFailure) - } + Ok(Self { + msm, + params: self.params, + }) } fn finalize(self) -> bool { - unreachable!(); + // Verification is (supposedly) cheap, hence we don't use an accelerator engine + let default_engine = H2cEngine::new(); + self.msm.check(&default_engine, &self.params) } } From 4f68012d350a0ab2c3e289852f40407b284324f7 Mon Sep 17 00:00:00 2001 From: guorong009 Date: Fri, 5 Jul 2024 20:38:03 +0800 Subject: [PATCH 2/6] chore: update the verification api uses in tests --- halo2_proofs/benches/plonk.rs | 8 +++- halo2_proofs/tests/compress_selectors.rs | 18 ++++---- halo2_proofs/tests/frontend_backend_split.rs | 45 +++++++++++--------- halo2_proofs/tests/plonk_api.rs | 11 ++--- halo2_proofs/tests/serialization.rs | 30 ++++++------- halo2_proofs/tests/shuffle.rs | 6 +-- halo2_proofs/tests/shuffle_api.rs | 6 +-- halo2_proofs/tests/vector-ops-unblinded.rs | 6 +-- p3_frontend/tests/common/mod.rs | 24 +++++++---- 9 files changed, 79 insertions(+), 75 deletions(-) diff --git a/halo2_proofs/benches/plonk.rs b/halo2_proofs/benches/plonk.rs index 9827fc5aa4..513c8e5f8d 100644 --- a/halo2_proofs/benches/plonk.rs +++ b/halo2_proofs/benches/plonk.rs @@ -300,9 +300,13 @@ fn criterion_benchmark(c: &mut Criterion) { } fn verifier(params: &ParamsIPA, vk: &VerifyingKey, proof: &[u8]) { - let strategy = SingleStrategy::new(params); let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(proof); - assert!(verify_proof(params, vk, strategy, &[vec![vec![]]], &mut transcript).is_ok()); + assert!(verify_proof::<_, _, _, _, SingleStrategy<_>>( + params, + vk, + &[vec![vec![]]], + &mut transcript + )); } let k_range = 8..=16; diff --git a/halo2_proofs/tests/compress_selectors.rs b/halo2_proofs/tests/compress_selectors.rs index 99cacab9ac..7c9a66ff32 100644 --- a/halo2_proofs/tests/compress_selectors.rs +++ b/halo2_proofs/tests/compress_selectors.rs @@ -375,16 +375,14 @@ fn test_mycircuit( // Verify let mut verifier_transcript = Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); - let strategy = SingleStrategy::new(&verifier_params); - - verify_proof::, VerifierSHPLONK, _, _, _>( - &verifier_params, - &vk, - strategy, - instances.as_slice(), - &mut verifier_transcript, - ) - .map_err(halo2_proofs::plonk::Error::Backend)?; + if !verify_proof::, VerifierSHPLONK, _, _, SingleStrategy<_>>( + &verifier_params, + &vk, + instances.as_slice(), + &mut verifier_transcript, + ) { + return Err(halo2_proofs::plonk::Error::Backend(halo2_backend::plonk::Error::Opening)); + }; Ok(proof) } diff --git a/halo2_proofs/tests/frontend_backend_split.rs b/halo2_proofs/tests/frontend_backend_split.rs index 6238a13e33..0dea659679 100644 --- a/halo2_proofs/tests/frontend_backend_split.rs +++ b/halo2_proofs/tests/frontend_backend_split.rs @@ -525,16 +525,22 @@ fn test_mycircuit_full_legacy() { let mut verifier_transcript = Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); let verifier_params = params.verifier_params(); - let strategy = SingleStrategy::new(&verifier_params); - verify_proof::, VerifierSHPLONK, _, _, _>( - &verifier_params, - &vk, - strategy, - instances.as_slice(), - &mut verifier_transcript, - ) - .expect("verify succeeds"); + assert!( + verify_proof::< + KZGCommitmentScheme, + VerifierSHPLONK, + _, + _, + SingleStrategy<_>, + >( + &verifier_params, + &vk, + instances.as_slice(), + &mut verifier_transcript, + ), + "failed to verify proof" + ); println!("Verify: {:?}", start.elapsed()); proof @@ -605,16 +611,17 @@ fn test_mycircuit_full_split() { let mut verifier_transcript = Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); let verifier_params = params.verifier_params(); - let strategy = SingleStrategy::new(&verifier_params); - - verify_proof_single::, VerifierSHPLONK, _, _, _>( - &verifier_params, - &vk, - strategy, - instances, - &mut verifier_transcript, - ) - .expect("verify succeeds"); + + assert!( + verify_proof_single::< + KZGCommitmentScheme, + VerifierSHPLONK, + _, + _, + SingleStrategy<_>, + >(&verifier_params, &vk, instances, &mut verifier_transcript,), + "failed to verify proof" + ); println!("Verify: {:?}", start.elapsed()); proof diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index d454d0292b..b8160c5b88 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -560,11 +560,12 @@ fn plonk_api() { let mut transcript = T::init(proof); let instance = [vec![vec![instance_val]], vec![vec![instance_val]]]; - let strategy = Strategy::new(params_verifier); - let strategy = - verify_plonk_proof(params_verifier, vk, strategy, &instance, &mut transcript).unwrap(); - - assert!(strategy.finalize()); + assert!(verify_plonk_proof::<_, _, _, _, Strategy>( + params_verifier, + vk, + &instance, + &mut transcript + )); } fn test_plonk_api_gwc() { diff --git a/halo2_proofs/tests/serialization.rs b/halo2_proofs/tests/serialization.rs index 54e350d7d6..75150d686f 100644 --- a/halo2_proofs/tests/serialization.rs +++ b/halo2_proofs/tests/serialization.rs @@ -183,22 +183,22 @@ fn test_serialization() { let proof = transcript.finalize(); let verifier_params = params.verifier_params(); - let strategy = SingleStrategy::new(&verifier_params); let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - assert!(verify_proof::< - KZGCommitmentScheme, - VerifierGWC, - Challenge255, - Blake2bRead<&[u8], G1Affine, Challenge255>, - SingleStrategy, - >( - &verifier_params, - pk.get_vk(), - strategy, - instances.as_slice(), - &mut transcript - ) - .is_ok()); + assert!( + verify_proof::< + KZGCommitmentScheme, + VerifierGWC, + Challenge255, + Blake2bRead<&[u8], G1Affine, Challenge255>, + SingleStrategy, + >( + &verifier_params, + pk.get_vk(), + instances.as_slice(), + &mut transcript + ), + "failed to verify proof" + ); proof }, diff --git a/halo2_proofs/tests/shuffle.rs b/halo2_proofs/tests/shuffle.rs index f74958bee8..eb13ed8bfa 100644 --- a/halo2_proofs/tests/shuffle.rs +++ b/halo2_proofs/tests/shuffle.rs @@ -301,18 +301,14 @@ where }; let accepted = { - let strategy = AccumulatorStrategy::new(¶ms); let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - verify_proof::, VerifierIPA, _, _, _>( + verify_proof::, VerifierIPA, _, _, AccumulatorStrategy>( ¶ms, pk.get_vk(), - strategy, &[vec![]], &mut transcript, ) - .map(|strategy| strategy.finalize()) - .unwrap_or_default() }; assert_eq!(accepted, expected); diff --git a/halo2_proofs/tests/shuffle_api.rs b/halo2_proofs/tests/shuffle_api.rs index 7dc8d73bc5..cd5dce12e3 100644 --- a/halo2_proofs/tests/shuffle_api.rs +++ b/halo2_proofs/tests/shuffle_api.rs @@ -175,18 +175,14 @@ where }; let accepted = { - let strategy = AccumulatorStrategy::new(¶ms); let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - verify_proof::, VerifierIPA, _, _, _>( + verify_proof::, VerifierIPA, _, _, AccumulatorStrategy<_>>( ¶ms, pk.get_vk(), - strategy, &[vec![]], &mut transcript, ) - .map(|strategy| strategy.finalize()) - .unwrap_or_default() }; assert_eq!(accepted, expected); diff --git a/halo2_proofs/tests/vector-ops-unblinded.rs b/halo2_proofs/tests/vector-ops-unblinded.rs index 6a3f54a4a9..46139a71ce 100644 --- a/halo2_proofs/tests/vector-ops-unblinded.rs +++ b/halo2_proofs/tests/vector-ops-unblinded.rs @@ -499,18 +499,14 @@ where }; let accepted = { - let strategy = AccumulatorStrategy::new(¶ms); let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - verify_proof::, VerifierIPA, _, _, _>( + verify_proof::, VerifierIPA, _, _, AccumulatorStrategy<_>>( ¶ms, pk.get_vk(), - strategy, &instances, &mut transcript, ) - .map(|strategy| strategy.finalize()) - .unwrap_or_default() }; assert_eq!(accepted, expected); diff --git a/p3_frontend/tests/common/mod.rs b/p3_frontend/tests/common/mod.rs index d762b5f2d5..666f9e5d06 100644 --- a/p3_frontend/tests/common/mod.rs +++ b/p3_frontend/tests/common/mod.rs @@ -93,15 +93,21 @@ pub(crate) fn setup_prove_verify( println!("Verifying..."); let mut verifier_transcript = Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); - let strategy = SingleStrategy::new(&verifier_params); - verify_proof_single::, VerifierSHPLONK, _, _, _>( - &verifier_params, - &vk, - strategy, - pis.to_vec(), - &mut verifier_transcript, - ) - .expect("verify succeeds"); + assert!( + verify_proof_single::< + KZGCommitmentScheme, + VerifierSHPLONK, + _, + _, + SingleStrategy<_>, + >( + &verifier_params, + &vk, + pis.to_vec(), + &mut verifier_transcript, + ), + "failed to verify proof" + ); println!("Verify: {:?}", start.elapsed()); } From 735f1649758fd6fd83ed0e9e46178d4b06aed369 Mon Sep 17 00:00:00 2001 From: guorong009 Date: Fri, 5 Jul 2024 20:40:13 +0800 Subject: [PATCH 3/6] chore: fmt + clippy --- halo2_proofs/benches/plonk.rs | 11 ++++------- halo2_proofs/tests/compress_selectors.rs | 12 +++++++----- halo2_proofs/tests/shuffle.rs | 1 - halo2_proofs/tests/shuffle_api.rs | 13 +++++-------- halo2_proofs/tests/vector-ops-unblinded.rs | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/halo2_proofs/benches/plonk.rs b/halo2_proofs/benches/plonk.rs index 513c8e5f8d..dc5ceb19b9 100644 --- a/halo2_proofs/benches/plonk.rs +++ b/halo2_proofs/benches/plonk.rs @@ -10,13 +10,10 @@ use halo2curves::pasta::{EqAffine, Fp}; use rand_core::OsRng; use halo2_proofs::{ - poly::{ - ipa::{ - commitment::{IPACommitmentScheme, ParamsIPA}, - multiopen::ProverIPA, - strategy::SingleStrategy, - }, - VerificationStrategy, + poly::ipa::{ + commitment::{IPACommitmentScheme, ParamsIPA}, + multiopen::ProverIPA, + strategy::SingleStrategy, }, transcript::{TranscriptReadBuffer, TranscriptWriterBuffer}, }; diff --git a/halo2_proofs/tests/compress_selectors.rs b/halo2_proofs/tests/compress_selectors.rs index 7c9a66ff32..a11fb16e57 100644 --- a/halo2_proofs/tests/compress_selectors.rs +++ b/halo2_proofs/tests/compress_selectors.rs @@ -376,12 +376,14 @@ fn test_mycircuit( let mut verifier_transcript = Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); if !verify_proof::, VerifierSHPLONK, _, _, SingleStrategy<_>>( - &verifier_params, - &vk, - instances.as_slice(), - &mut verifier_transcript, + &verifier_params, + &vk, + instances.as_slice(), + &mut verifier_transcript, ) { - return Err(halo2_proofs::plonk::Error::Backend(halo2_backend::plonk::Error::Opening)); + return Err(halo2_proofs::plonk::Error::Backend( + halo2_backend::plonk::Error::Opening, + )); }; Ok(proof) diff --git a/halo2_proofs/tests/shuffle.rs b/halo2_proofs/tests/shuffle.rs index eb13ed8bfa..1fdeca261c 100644 --- a/halo2_proofs/tests/shuffle.rs +++ b/halo2_proofs/tests/shuffle.rs @@ -13,7 +13,6 @@ use halo2_proofs::{ multiopen::{ProverIPA, VerifierIPA}, strategy::AccumulatorStrategy, }, - VerificationStrategy, }, transcript::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, diff --git a/halo2_proofs/tests/shuffle_api.rs b/halo2_proofs/tests/shuffle_api.rs index cd5dce12e3..272e1ca851 100644 --- a/halo2_proofs/tests/shuffle_api.rs +++ b/halo2_proofs/tests/shuffle_api.rs @@ -10,15 +10,12 @@ use halo2_proofs::{ create_proof, keygen_pk, keygen_vk, verify_proof, Advice, Circuit, Column, ConstraintSystem, ErrorFront, Fixed, Selector, }, - poly::Rotation, - poly::{ - ipa::{ - commitment::{IPACommitmentScheme, ParamsIPA}, - multiopen::{ProverIPA, VerifierIPA}, - strategy::AccumulatorStrategy, - }, - VerificationStrategy, + poly::ipa::{ + commitment::{IPACommitmentScheme, ParamsIPA}, + multiopen::{ProverIPA, VerifierIPA}, + strategy::AccumulatorStrategy, }, + poly::Rotation, transcript::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, }, diff --git a/halo2_proofs/tests/vector-ops-unblinded.rs b/halo2_proofs/tests/vector-ops-unblinded.rs index 46139a71ce..b49240b0bb 100644 --- a/halo2_proofs/tests/vector-ops-unblinded.rs +++ b/halo2_proofs/tests/vector-ops-unblinded.rs @@ -16,7 +16,7 @@ use halo2_proofs::{ multiopen::{ProverIPA, VerifierIPA}, strategy::AccumulatorStrategy, }, - Rotation, VerificationStrategy, + Rotation, }, transcript::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, From bce0bebb934253392dffdf58c0caf64c17b04c8f Mon Sep 17 00:00:00 2001 From: guorong009 Date: Mon, 15 Jul 2024 11:14:47 +0800 Subject: [PATCH 4/6] feat: rename the "verify_*" apis --- halo2_backend/src/plonk/verifier.rs | 6 +++--- halo2_proofs/benches/plonk.rs | 2 +- halo2_proofs/src/plonk.rs | 4 ++-- halo2_proofs/tests/compress_selectors.rs | 12 +++++++++--- halo2_proofs/tests/frontend_backend_split.rs | 6 +++--- halo2_proofs/tests/plonk_api.rs | 6 +++--- halo2_proofs/tests/serialization.rs | 6 +++--- halo2_proofs/tests/shuffle.rs | 2 +- halo2_proofs/tests/shuffle_api.rs | 4 ++-- halo2_proofs/tests/vector-ops-unblinded.rs | 2 +- p3_frontend/tests/common/mod.rs | 10 ++-------- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/halo2_backend/src/plonk/verifier.rs b/halo2_backend/src/plonk/verifier.rs index afba1f9f5a..c0bd80b85f 100644 --- a/halo2_backend/src/plonk/verifier.rs +++ b/halo2_backend/src/plonk/verifier.rs @@ -30,7 +30,7 @@ pub use batch::BatchVerifier; /// Returns a boolean indicating whether or not the proof is valid. Verifies a single proof (not /// batched). -pub fn verify_proof_single<'params, Scheme, V, E, T, Strategy>( +pub fn verify_proof<'params, Scheme, V, E, T, Strategy>( params: &'params Scheme::ParamsVerifier, vk: &VerifyingKey, instance: Vec>, @@ -44,7 +44,7 @@ where T: TranscriptRead, Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, { - verify_proof::(params, vk, &[instance], transcript) + verify_proof_multi::(params, vk, &[instance], transcript) } /// Process the proof, checks that the proof is valid and returns the `Strategy` output. @@ -520,7 +520,7 @@ where } /// Returns a boolean indicating whether or not the proof is valid -pub fn verify_proof< +pub fn verify_proof_multi< 'params, Scheme: CommitmentScheme, V: Verifier<'params, Scheme>, diff --git a/halo2_proofs/benches/plonk.rs b/halo2_proofs/benches/plonk.rs index dc5ceb19b9..87d9bd76eb 100644 --- a/halo2_proofs/benches/plonk.rs +++ b/halo2_proofs/benches/plonk.rs @@ -298,7 +298,7 @@ fn criterion_benchmark(c: &mut Criterion) { fn verifier(params: &ParamsIPA, vk: &VerifyingKey, proof: &[u8]) { let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(proof); - assert!(verify_proof::<_, _, _, _, SingleStrategy<_>>( + assert!(verify_proof_multi::<_, _, _, _, SingleStrategy<_>>( params, vk, &[vec![vec![]]], diff --git a/halo2_proofs/src/plonk.rs b/halo2_proofs/src/plonk.rs index 41a2feb2d9..dee402f34f 100644 --- a/halo2_proofs/src/plonk.rs +++ b/halo2_proofs/src/plonk.rs @@ -9,14 +9,14 @@ mod error; mod keygen; mod prover; mod verifier { - pub use halo2_backend::plonk::verifier::verify_proof; + pub use halo2_backend::plonk::verifier::verify_proof_multi; } use halo2_frontend::circuit::compile_circuit; pub use keygen::{keygen_pk, keygen_pk_custom, keygen_vk, keygen_vk_custom}; pub use prover::{create_proof, create_proof_with_engine}; -pub use verifier::verify_proof; +pub use verifier::verify_proof_multi; pub use error::Error; pub use halo2_backend::plonk::{Error as ErrorBack, ProvingKey, VerifyingKey}; diff --git a/halo2_proofs/tests/compress_selectors.rs b/halo2_proofs/tests/compress_selectors.rs index a11fb16e57..436603b903 100644 --- a/halo2_proofs/tests/compress_selectors.rs +++ b/halo2_proofs/tests/compress_selectors.rs @@ -17,8 +17,8 @@ use halo2_middleware::circuit::{Any, ColumnMid}; use halo2_middleware::zal::impls::{H2cEngine, PlonkEngineConfig}; use halo2_proofs::arithmetic::Field; use halo2_proofs::plonk::{ - create_proof_with_engine, keygen_pk_custom, keygen_vk_custom, verify_proof, Advice, Assigned, - Circuit, Column, ConstraintSystem, Instance, Selector, + create_proof_with_engine, keygen_pk_custom, keygen_vk_custom, verify_proof_multi, Advice, + Assigned, Circuit, Column, ConstraintSystem, Instance, Selector, }; use halo2_proofs::poly::kzg::commitment::{KZGCommitmentScheme, ParamsKZG}; use halo2_proofs::poly::kzg::multiopen::{ProverSHPLONK, VerifierSHPLONK}; @@ -375,7 +375,13 @@ fn test_mycircuit( // Verify let mut verifier_transcript = Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); - if !verify_proof::, VerifierSHPLONK, _, _, SingleStrategy<_>>( + if !verify_proof_multi::< + KZGCommitmentScheme, + VerifierSHPLONK, + _, + _, + SingleStrategy<_>, + >( &verifier_params, &vk, instances.as_slice(), diff --git a/halo2_proofs/tests/frontend_backend_split.rs b/halo2_proofs/tests/frontend_backend_split.rs index 0dea659679..e701a297c3 100644 --- a/halo2_proofs/tests/frontend_backend_split.rs +++ b/halo2_proofs/tests/frontend_backend_split.rs @@ -5,7 +5,7 @@ use halo2_backend::{ plonk::{ keygen::{keygen_pk, keygen_vk}, prover::ProverSingle, - verifier::{verify_proof, verify_proof_single}, + verifier::{verify_proof, verify_proof_multi}, }, transcript::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, @@ -527,7 +527,7 @@ fn test_mycircuit_full_legacy() { let verifier_params = params.verifier_params(); assert!( - verify_proof::< + verify_proof_multi::< KZGCommitmentScheme, VerifierSHPLONK, _, @@ -613,7 +613,7 @@ fn test_mycircuit_full_split() { let verifier_params = params.verifier_params(); assert!( - verify_proof_single::< + verify_proof::< KZGCommitmentScheme, VerifierSHPLONK, _, diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index b8160c5b88..b525db666b 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -13,8 +13,8 @@ use halo2_proofs::circuit::{Cell, Layouter, SimpleFloorPlanner, Value}; use halo2_proofs::dev::MockProver; use halo2_proofs::plonk::{ create_proof_with_engine as create_plonk_proof_with_engine, keygen_pk, keygen_vk, - verify_proof as verify_plonk_proof, Advice, Assigned, Circuit, Column, ConstraintSystem, Error, - ErrorFront, Fixed, ProvingKey, TableColumn, VerifyingKey, + verify_proof_multi as verify_multi_plonk_proof, Advice, Assigned, Circuit, Column, + ConstraintSystem, Error, ErrorFront, Fixed, ProvingKey, TableColumn, VerifyingKey, }; use halo2_proofs::poly::commitment::{CommitmentScheme, ParamsProver, Prover, Verifier}; use halo2_proofs::poly::Rotation; @@ -560,7 +560,7 @@ fn plonk_api() { let mut transcript = T::init(proof); let instance = [vec![vec![instance_val]], vec![vec![instance_val]]]; - assert!(verify_plonk_proof::<_, _, _, _, Strategy>( + assert!(verify_multi_plonk_proof::<_, _, _, _, Strategy>( params_verifier, vk, &instance, diff --git a/halo2_proofs/tests/serialization.rs b/halo2_proofs/tests/serialization.rs index 75150d686f..17b9f09401 100644 --- a/halo2_proofs/tests/serialization.rs +++ b/halo2_proofs/tests/serialization.rs @@ -8,8 +8,8 @@ use halo2_debug::test_rng; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, plonk::{ - create_proof, keygen_pk, keygen_vk_custom, pk_read, verify_proof, Advice, Circuit, Column, - ConstraintSystem, ErrorFront, Fixed, Instance, + create_proof, keygen_pk, keygen_vk_custom, pk_read, verify_proof_multi, Advice, Circuit, + Column, ConstraintSystem, ErrorFront, Fixed, Instance, }, poly::{ kzg::{ @@ -185,7 +185,7 @@ fn test_serialization() { let verifier_params = params.verifier_params(); let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); assert!( - verify_proof::< + verify_proof_multi::< KZGCommitmentScheme, VerifierGWC, Challenge255, diff --git a/halo2_proofs/tests/shuffle.rs b/halo2_proofs/tests/shuffle.rs index 1fdeca261c..cbdb01c2e3 100644 --- a/halo2_proofs/tests/shuffle.rs +++ b/halo2_proofs/tests/shuffle.rs @@ -302,7 +302,7 @@ where let accepted = { let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - verify_proof::, VerifierIPA, _, _, AccumulatorStrategy>( + verify_proof_multi::, VerifierIPA, _, _, AccumulatorStrategy>( ¶ms, pk.get_vk(), &[vec![]], diff --git a/halo2_proofs/tests/shuffle_api.rs b/halo2_proofs/tests/shuffle_api.rs index 272e1ca851..e22fb68e21 100644 --- a/halo2_proofs/tests/shuffle_api.rs +++ b/halo2_proofs/tests/shuffle_api.rs @@ -7,7 +7,7 @@ use halo2_proofs::{ arithmetic::Field, circuit::{Layouter, SimpleFloorPlanner, Value}, plonk::{ - create_proof, keygen_pk, keygen_vk, verify_proof, Advice, Circuit, Column, + create_proof, keygen_pk, keygen_vk, verify_proof_multi, Advice, Circuit, Column, ConstraintSystem, ErrorFront, Fixed, Selector, }, poly::ipa::{ @@ -174,7 +174,7 @@ where let accepted = { let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - verify_proof::, VerifierIPA, _, _, AccumulatorStrategy<_>>( + verify_proof_multi::, VerifierIPA, _, _, AccumulatorStrategy<_>>( ¶ms, pk.get_vk(), &[vec![]], diff --git a/halo2_proofs/tests/vector-ops-unblinded.rs b/halo2_proofs/tests/vector-ops-unblinded.rs index b49240b0bb..19e90fd4e5 100644 --- a/halo2_proofs/tests/vector-ops-unblinded.rs +++ b/halo2_proofs/tests/vector-ops-unblinded.rs @@ -501,7 +501,7 @@ where let accepted = { let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); - verify_proof::, VerifierIPA, _, _, AccumulatorStrategy<_>>( + verify_proof_multi::, VerifierIPA, _, _, AccumulatorStrategy<_>>( ¶ms, pk.get_vk(), &instances, diff --git a/p3_frontend/tests/common/mod.rs b/p3_frontend/tests/common/mod.rs index 666f9e5d06..ba15a8314f 100644 --- a/p3_frontend/tests/common/mod.rs +++ b/p3_frontend/tests/common/mod.rs @@ -5,7 +5,7 @@ use halo2_backend::{ plonk::{ keygen::{keygen_pk, keygen_vk}, prover::ProverSingle, - verifier::verify_proof_single, + verifier::verify_proof, }, transcript::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, @@ -95,13 +95,7 @@ pub(crate) fn setup_prove_verify( Blake2bRead::<_, G1Affine, Challenge255<_>>::init(proof.as_slice()); assert!( - verify_proof_single::< - KZGCommitmentScheme, - VerifierSHPLONK, - _, - _, - SingleStrategy<_>, - >( + verify_proof::, VerifierSHPLONK, _, _, SingleStrategy<_>>( &verifier_params, &vk, pis.to_vec(), From e5153c4e57d76d9ace3fa951c185ff22b78dd672 Mon Sep 17 00:00:00 2001 From: guorong009 Date: Mon, 15 Jul 2024 15:46:57 +0800 Subject: [PATCH 5/6] feat: remove "Output" type from "VerificationStrategy" trait --- halo2_backend/src/plonk/verifier.rs | 8 ++++---- halo2_backend/src/plonk/verifier/batch.rs | 4 +--- halo2_backend/src/poly/ipa/strategy.rs | 8 ++------ halo2_backend/src/poly/kzg/strategy.rs | 8 ++------ halo2_backend/src/poly/multiopen_test.rs | 2 +- halo2_backend/src/poly/strategy.rs | 10 ++++------ halo2_proofs/tests/plonk_api.rs | 2 +- 7 files changed, 15 insertions(+), 27 deletions(-) diff --git a/halo2_backend/src/plonk/verifier.rs b/halo2_backend/src/plonk/verifier.rs index c0bd80b85f..6e4f63bfc8 100644 --- a/halo2_backend/src/plonk/verifier.rs +++ b/halo2_backend/src/plonk/verifier.rs @@ -42,7 +42,7 @@ where V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptRead, - Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, + Strategy: VerificationStrategy<'params, Scheme, V>, { verify_proof_multi::(params, vk, &[instance], transcript) } @@ -54,14 +54,14 @@ pub fn verify_proof_with_strategy< V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptRead, - Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, + Strategy: VerificationStrategy<'params, Scheme, V>, >( params: &'params Scheme::ParamsVerifier, vk: &VerifyingKey, strategy: Strategy, instances: &[Vec>], transcript: &mut T, -) -> Result +) -> Result where Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>, { @@ -526,7 +526,7 @@ pub fn verify_proof_multi< V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptRead, - Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, + Strategy: VerificationStrategy<'params, Scheme, V>, >( params: &'params Scheme::ParamsVerifier, vk: &VerifyingKey, diff --git a/halo2_backend/src/plonk/verifier/batch.rs b/halo2_backend/src/plonk/verifier/batch.rs index 3a96bebbd4..c849f2f23a 100644 --- a/halo2_backend/src/plonk/verifier/batch.rs +++ b/halo2_backend/src/plonk/verifier/batch.rs @@ -34,8 +34,6 @@ struct BatchStrategy<'params, C: CurveAffine> { impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme, VerifierIPA> for BatchStrategy<'params, C> { - type Output = Self; - fn new(params: &'params ParamsVerifierIPA) -> Self { BatchStrategy { msm: MSMIPA::new(params), @@ -45,7 +43,7 @@ impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme< fn process( self, f: impl FnOnce(MSMIPA<'params, C>) -> Result, Error>, - ) -> Result { + ) -> Result { let guard = f(self.msm)?; Ok(Self { msm: guard.use_challenges(), diff --git a/halo2_backend/src/poly/ipa/strategy.rs b/halo2_backend/src/poly/ipa/strategy.rs index 8d8b756e22..fd9031d3f4 100644 --- a/halo2_backend/src/poly/ipa/strategy.rs +++ b/halo2_backend/src/poly/ipa/strategy.rs @@ -79,8 +79,6 @@ pub struct AccumulatorStrategy<'params, C: CurveAffine> { impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme, VerifierIPA> for AccumulatorStrategy<'params, C> { - type Output = Self; - fn new(params: &'params ParamsIPA) -> Self { AccumulatorStrategy { msm: MSMIPA::new(params), @@ -90,7 +88,7 @@ impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme< fn process( mut self, f: impl FnOnce(MSMIPA<'params, C>) -> Result, Error>, - ) -> Result { + ) -> Result { self.msm.scale(C::Scalar::random(OsRng)); let guard = f(self.msm)?; @@ -119,8 +117,6 @@ pub struct SingleStrategy<'params, C: CurveAffine> { impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme, VerifierIPA> for SingleStrategy<'params, C> { - type Output = Self; - fn new(params: &'params ParamsIPA) -> Self { SingleStrategy { msm: MSMIPA::new(params), @@ -130,7 +126,7 @@ impl<'params, C: CurveAffine> VerificationStrategy<'params, IPACommitmentScheme< fn process( self, f: impl FnOnce(MSMIPA<'params, C>) -> Result, Error>, - ) -> Result { + ) -> Result { let guard = f(self.msm)?; Ok(Self { msm: guard.use_challenges(), diff --git a/halo2_backend/src/poly/kzg/strategy.rs b/halo2_backend/src/poly/kzg/strategy.rs index f254477b37..2428021f36 100644 --- a/halo2_backend/src/poly/kzg/strategy.rs +++ b/halo2_backend/src/poly/kzg/strategy.rs @@ -120,8 +120,6 @@ where E::G1: CurveExt, E::G2Affine: SerdeCurveAffine, { - type Output = Self; - fn new(params: &'params ParamsVerifierKZG) -> Self { AccumulatorStrategy::new(params) } @@ -129,7 +127,7 @@ where fn process( mut self, f: impl FnOnce(V::MSMAccumulator) -> Result, - ) -> Result { + ) -> Result { self.msm_accumulator.scale(E::Fr::random(OsRng)); // Guard is updated with new msm contributions @@ -155,8 +153,6 @@ where E::G1: CurveExt, E::G2Affine: SerdeCurveAffine, { - type Output = Self; - fn new(params: &'params ParamsVerifierKZG) -> Self { Self::new(params) } @@ -164,7 +160,7 @@ where fn process( self, f: impl FnOnce(V::MSMAccumulator) -> Result, - ) -> Result { + ) -> Result { // Guard is updated with new msm contributions let guard = f(self.msm)?; let msm = guard.msm_accumulator; diff --git a/halo2_backend/src/poly/multiopen_test.rs b/halo2_backend/src/poly/multiopen_test.rs index e907d0134c..e40d203a8a 100644 --- a/halo2_backend/src/poly/multiopen_test.rs +++ b/halo2_backend/src/poly/multiopen_test.rs @@ -173,7 +173,7 @@ mod test { V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptReadBuffer<&'a [u8], Scheme::Curve, E>, - Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, + Strategy: VerificationStrategy<'params, Scheme, V>, >( params: &'params Scheme::ParamsVerifier, proof: &'a [u8], diff --git a/halo2_backend/src/poly/strategy.rs b/halo2_backend/src/poly/strategy.rs index 850f95e6c9..5c6f646818 100644 --- a/halo2_backend/src/poly/strategy.rs +++ b/halo2_backend/src/poly/strategy.rs @@ -10,18 +10,16 @@ pub trait Guard { /// Trait representing a strategy for verifying Halo 2 proofs. pub trait VerificationStrategy<'params, Scheme: CommitmentScheme, V: Verifier<'params, Scheme>> { - /// The output type of this verification strategy after processing a proof. - type Output; - /// Creates new verification strategy instance fn new(params: &'params Scheme::ParamsVerifier) -> Self; - /// Obtains an MSM from the verifier strategy and yields back the strategy's - /// output. + /// Obtains an MSM from the verifier strategy and yields back the strategy fn process( self, f: impl FnOnce(V::MSMAccumulator) -> Result, - ) -> Result; + ) -> Result + where + Self: Sized; /// Finalizes the batch and checks its validity. /// diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index b525db666b..35b24431ff 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -547,7 +547,7 @@ fn plonk_api() { V: Verifier<'params, Scheme>, E: EncodedChallenge, T: TranscriptReadBuffer<&'a [u8], Scheme::Curve, E>, - Strategy: VerificationStrategy<'params, Scheme, V, Output = Strategy>, + Strategy: VerificationStrategy<'params, Scheme, V>, >( params_verifier: &'params Scheme::ParamsVerifier, vk: &VerifyingKey, From 9fc59c100ed3e65f58c174853f8bd4d6c2bc8231 Mon Sep 17 00:00:00 2001 From: guorong009 Date: Mon, 15 Jul 2024 15:57:41 +0800 Subject: [PATCH 6/6] feat: rename "ProverSingle" -> "Prover", "Prover" -> "ProverMulti" --- halo2_backend/src/plonk/prover.rs | 26 ++++++++++---------- halo2_proofs/src/plonk/prover.rs | 4 +-- halo2_proofs/tests/frontend_backend_split.rs | 4 +-- p3_frontend/tests/common/mod.rs | 4 +-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/halo2_backend/src/plonk/prover.rs b/halo2_backend/src/plonk/prover.rs index af72d863d8..33f5624e3f 100644 --- a/halo2_backend/src/plonk/prover.rs +++ b/halo2_backend/src/plonk/prover.rs @@ -39,9 +39,9 @@ struct AdviceSingle { } /// The prover object used to create proofs interactively by passing the witnesses to commit at -/// each phase. This works for a single proof. This is a wrapper over Prover. +/// each phase. This works for a single proof. This is a wrapper over ProverMulti. #[derive(Debug)] -pub struct ProverSingle< +pub struct Prover< 'a, 'params, Scheme: CommitmentScheme, @@ -50,7 +50,7 @@ pub struct ProverSingle< R: RngCore, T: TranscriptWrite, M: MsmAccel, ->(Prover<'a, 'params, Scheme, P, E, R, T, M>); +>(ProverMulti<'a, 'params, Scheme, P, E, R, T, M>); impl< 'a, @@ -61,9 +61,9 @@ impl< R: RngCore, T: TranscriptWrite, M: MsmAccel, - > ProverSingle<'a, 'params, Scheme, P, E, R, T, M> + > Prover<'a, 'params, Scheme, P, E, R, T, M> { - /// Create a new prover object + /// Create a new ProverMulti object pub fn new_with_engine( engine: PlonkEngine, params: &'params Scheme::ParamsProver, @@ -75,7 +75,7 @@ impl< where Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>, { - Ok(Self(Prover::new_with_engine( + Ok(Self(ProverMulti::new_with_engine( engine, params, pk, @@ -91,12 +91,12 @@ impl< instance: Vec>, rng: R, transcript: &'a mut T, - ) -> Result, Error> + ) -> Result, Error> where Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>, { let engine = PlonkEngineConfig::build_default(); - ProverSingle::new_with_engine(engine, params, pk, instance, rng, transcript) + Prover::new_with_engine(engine, params, pk, instance, rng, transcript) } /// Commit the `witness` at `phase` and return the challenges after `phase`. @@ -123,7 +123,7 @@ impl< /// The prover object used to create proofs interactively by passing the witnesses to commit at /// each phase. This supports batch proving. #[derive(Debug)] -pub struct Prover< +pub struct ProverMulti< 'a, 'params, Scheme: CommitmentScheme, @@ -164,7 +164,7 @@ impl< R: RngCore, T: TranscriptWrite, M: MsmAccel, - > Prover<'a, 'params, Scheme, P, E, R, T, M> + > ProverMulti<'a, 'params, Scheme, P, E, R, T, M> { /// Create a new prover object pub fn new_with_engine( @@ -283,7 +283,7 @@ impl< let challenges = HashMap::::with_capacity(meta.num_challenges); - Ok(Prover { + Ok(ProverMulti { engine, params, pk, @@ -902,11 +902,11 @@ impl< circuits_instances: &[Vec>], rng: R, transcript: &'a mut T, - ) -> Result, Error> + ) -> Result, Error> where Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>, { let engine = PlonkEngineConfig::build_default(); - Prover::new_with_engine(engine, params, pk, circuits_instances, rng, transcript) + ProverMulti::new_with_engine(engine, params, pk, circuits_instances, rng, transcript) } } diff --git a/halo2_proofs/src/plonk/prover.rs b/halo2_proofs/src/plonk/prover.rs index 1c6a3a7e0b..fe31bf5f01 100644 --- a/halo2_proofs/src/plonk/prover.rs +++ b/halo2_proofs/src/plonk/prover.rs @@ -1,7 +1,7 @@ use crate::plonk::{Error, ErrorBack}; use crate::poly::commitment::{self, CommitmentScheme, Params}; use crate::transcript::{EncodedChallenge, TranscriptWrite}; -use halo2_backend::plonk::{prover::Prover, ProvingKey}; +use halo2_backend::plonk::{prover::ProverMulti, ProvingKey}; use halo2_frontend::circuit::WitnessCalculator; use halo2_frontend::plonk::{Circuit, ConstraintSystem}; use halo2_middleware::ff::{FromUniformBytes, WithSmallOrderMulGroup}; @@ -55,7 +55,7 @@ where WitnessCalculator::new(params.k(), circuit, &config, &cs, instances[i].as_slice()) }) .collect(); - let mut prover = Prover::::new_with_engine( + let mut prover = ProverMulti::::new_with_engine( engine, params, pk, instances, rng, transcript, )?; let mut challenges = HashMap::new(); diff --git a/halo2_proofs/tests/frontend_backend_split.rs b/halo2_proofs/tests/frontend_backend_split.rs index e701a297c3..375fcdcc99 100644 --- a/halo2_proofs/tests/frontend_backend_split.rs +++ b/halo2_proofs/tests/frontend_backend_split.rs @@ -4,7 +4,7 @@ use halo2_backend::{ plonk::{ keygen::{keygen_pk, keygen_vk}, - prover::ProverSingle, + prover::Prover, verifier::{verify_proof, verify_proof_multi}, }, transcript::{ @@ -579,7 +579,7 @@ fn test_mycircuit_full_split() { let start = Instant::now(); let mut witness_calc = WitnessCalculator::new(k, &circuit, &config, &cs, &instances); let mut transcript = Blake2bWrite::<_, G1Affine, Challenge255<_>>::init(vec![]); - let mut prover = ProverSingle::< + let mut prover = Prover::< KZGCommitmentScheme, ProverSHPLONK<'_, Bn256>, _, diff --git a/p3_frontend/tests/common/mod.rs b/p3_frontend/tests/common/mod.rs index ba15a8314f..1c46aa0feb 100644 --- a/p3_frontend/tests/common/mod.rs +++ b/p3_frontend/tests/common/mod.rs @@ -4,7 +4,7 @@ use halo2_backend::poly::kzg::strategy::SingleStrategy; use halo2_backend::{ plonk::{ keygen::{keygen_pk, keygen_vk}, - prover::ProverSingle, + prover::Prover, verifier::verify_proof, }, transcript::{ @@ -73,7 +73,7 @@ pub(crate) fn setup_prove_verify( println!("Proving..."); let start = Instant::now(); let mut transcript = Blake2bWrite::<_, G1Affine, Challenge255<_>>::init(vec![]); - let mut prover = ProverSingle::< + let mut prover = Prover::< KZGCommitmentScheme, ProverSHPLONK<'_, Bn256>, _,