diff --git a/masp_proofs/Cargo.toml b/masp_proofs/Cargo.toml index 1fdac5ba..e1006bf8 100644 --- a/masp_proofs/Cargo.toml +++ b/masp_proofs/Cargo.toml @@ -52,6 +52,7 @@ download-params = ["minreq", "directories"] local-prover = ["directories"] multicore = ["bellman/multicore"] embed-verifying-key = [] +benchmarks = [] [lib] bench = false diff --git a/masp_proofs/src/sapling/verifier/batch.rs b/masp_proofs/src/sapling/verifier/batch.rs index bfd22b32..b94319f6 100644 --- a/masp_proofs/src/sapling/verifier/batch.rs +++ b/masp_proofs/src/sapling/verifier/batch.rs @@ -209,3 +209,47 @@ impl BatchValidator { true } } + +#[cfg(feature = "benchmarks")] +impl BatchValidator { + /// Verify the signatures. Intended for testing purposes only. + pub fn verify_signatures( + self, + mut rng: R, + ) -> Result<(), redjubjub::Error> { + self.signatures.verify(&mut rng) + } + + /// Verify the spend proofs Intended for testing purposes only. + pub fn verify_spend_proofs( + self, + spend_vk: &groth16::VerifyingKey, + ) -> Result<(), bellman::VerificationError> { + #[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. Intended for testing purposes only. + pub fn verify_convert_proofs( + self, + convert_vk: &groth16::VerifyingKey, + ) -> Result<(), bellman::VerificationError> { + #[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. Intended for testing purposes only. + pub fn verify_output_proofs( + self, + output_vk: &groth16::VerifyingKey, + ) -> Result<(), bellman::VerificationError> { + #[cfg(feature = "multicore")] + return self.output_proofs.verify_multicore(output_vk); + #[cfg(not(feature = "multicore"))] + return self.output_proofs.verify(output_vk); + } +}