Skip to content

Commit

Permalink
Merge pull request #82 from anoma/grarco/batch-benchmarking
Browse files Browse the repository at this point in the history
Expose batch functions
  • Loading branch information
grarco authored May 22, 2024
2 parents 3aacc70 + d3cb964 commit 3689da5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions masp_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ download-params = ["minreq", "directories"]
local-prover = ["directories"]
multicore = ["bellman/multicore"]
embed-verifying-key = []
benchmarks = []

[lib]
bench = false
Expand Down
44 changes: 44 additions & 0 deletions masp_proofs/src/sapling/verifier/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,47 @@ impl BatchValidator {
true
}
}

#[cfg(feature = "benchmarks")]
impl BatchValidator {
/// Verify the signatures. Intended for testing purposes only.
pub fn verify_signatures<R: RngCore + CryptoRng>(
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<Bls12>,
) -> 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<Bls12>,
) -> 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<Bls12>,
) -> 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);
}
}

0 comments on commit 3689da5

Please sign in to comment.