From d3cb964043c820d4a4af60374adedee9bbe004df Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Thu, 16 May 2024 16:42:55 +0200 Subject: [PATCH] Simplifies batch validation test/benchmark functions --- masp_proofs/src/sapling/verifier/batch.rs | 57 +++++++---------------- 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/masp_proofs/src/sapling/verifier/batch.rs b/masp_proofs/src/sapling/verifier/batch.rs index 3638e7b3..b94319f6 100644 --- a/masp_proofs/src/sapling/verifier/batch.rs +++ b/masp_proofs/src/sapling/verifier/batch.rs @@ -212,7 +212,7 @@ impl BatchValidator { #[cfg(feature = "benchmarks")] impl BatchValidator { - /// Verify the signatures + /// Verify the signatures. Intended for testing purposes only. pub fn verify_signatures( self, mut rng: R, @@ -220,61 +220,36 @@ impl BatchValidator { self.signatures.verify(&mut rng) } - /// Get the proof verifier - #[cfg(feature = "multicore")] - pub fn get_proof_verifier() -> Box< - dyn Fn( - groth16::batch::Verifier, - &bellman::groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError>, - > { - Box::new(|batch: groth16::batch::Verifier, vk| batch.verify_multicore(vk)) - } - - /// Get the proof verifier - #[cfg(not(feature = "multicore"))] - pub fn get_proof_verifier() -> Box< - dyn Fn( - groth16::batch::Verifier, - &bellman::groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError>, - > { - Box::new(|batch: groth16::batch::Verifier, vk| batch.verify(&mut rng, vk)) - } - - /// Verify the spend proofs + /// Verify the spend proofs Intended for testing purposes only. pub fn verify_spend_proofs( self, - verify_proofs: &dyn Fn( - groth16::batch::Verifier, - &bellman::groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError>, spend_vk: &groth16::VerifyingKey, ) -> Result<(), bellman::VerificationError> { - verify_proofs(self.spend_proofs, spend_vk) + #[cfg(feature = "multicore")] + return self.spend_proofs.verify_multicore(spend_vk); + #[cfg(not(feature = "multicore"))] + return self.spend_proofs.verify(spend_vk); } - /// Verify the convert proofs + /// Verify the convert proofs. Intended for testing purposes only. pub fn verify_convert_proofs( self, - verify_proofs: &dyn Fn( - groth16::batch::Verifier, - &bellman::groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError>, convert_vk: &groth16::VerifyingKey, ) -> Result<(), bellman::VerificationError> { - verify_proofs(self.convert_proofs, convert_vk) + #[cfg(feature = "multicore")] + return self.convert_proofs.verify_multicore(convert_vk); + #[cfg(not(feature = "multicore"))] + return self.convert_proofs.verify(convert_vk); } - /// Verify the output proofs + /// Verify the output proofs. Intended for testing purposes only. pub fn verify_output_proofs( self, - verify_proofs: &dyn Fn( - groth16::batch::Verifier, - &bellman::groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError>, output_vk: &groth16::VerifyingKey, ) -> Result<(), bellman::VerificationError> { - verify_proofs(self.output_proofs, output_vk) + #[cfg(feature = "multicore")] + return self.output_proofs.verify_multicore(output_vk); + #[cfg(not(feature = "multicore"))] + return self.output_proofs.verify(output_vk); } }