batch verify proofs during validation (#1412)

* batch verify proofs during validation

* don't attempt to batch verify proofs with empty vec
This commit is contained in:
Yeastplume 2018-08-23 18:53:42 +01:00 committed by GitHub
parent 7dd2888b71
commit 2251a82404
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -457,9 +457,18 @@ impl TransactionBody {
/// Verify all the output rangeproofs. /// Verify all the output rangeproofs.
/// Note: this is expensive. /// Note: this is expensive.
fn verify_rangeproofs(&self) -> Result<(), Error> { fn verify_rangeproofs(&self) -> Result<(), Error> {
for x in &self.outputs { let mut commits: Vec<Commitment> = vec![];
x.verify_proof()?; let mut proofs: Vec<RangeProof> = vec![];
if self.outputs.len() == 0 {
return Ok(());
} }
// unfortunately these have to be aligned in memory for the underlying
// libsecp call
for x in &self.outputs {
commits.push(x.commit.clone());
proofs.push(x.proof.clone());
}
Output::batch_verify_proofs(&commits, &proofs)?;
Ok(()) Ok(())
} }