zcash_proofs: Use threadpool for Sapling proof batch validation

This commit is contained in:
Jack Grigg 2022-07-04 18:44:51 +00:00
parent b52f3cc0fc
commit 6f0e26a504
2 changed files with 10 additions and 3 deletions

View File

@ -16,7 +16,7 @@ categories = ["cryptography::cryptocurrencies"]
all-features = true
[dependencies]
bellman = { version = "0.13", default-features = false, features = ["groth16"] }
bellman = { version = "0.13.1", default-features = false, features = ["groth16"] }
blake2b_simd = "1"
bls12_381 = "0.7"
byteorder = "1"

View File

@ -159,12 +159,19 @@ impl BatchValidator {
return false;
}
if self.spend_proofs.verify(&mut rng, spend_vk).is_err() {
#[cfg(feature = "multicore")]
let verify_proofs = |batch: groth16::batch::Verifier<Bls12>, vk| batch.verify_multicore(vk);
#[cfg(not(feature = "multicore"))]
let mut verify_proofs =
|batch: groth16::batch::Verifier<Bls12>, vk| batch.verify(&mut rng, vk);
if verify_proofs(self.spend_proofs, spend_vk).is_err() {
tracing::debug!("Spend proof batch validation failed");
return false;
}
if self.output_proofs.verify(&mut rng, output_vk).is_err() {
if verify_proofs(self.output_proofs, output_vk).is_err() {
tracing::debug!("Output proof batch validation failed");
return false;
}