Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid cloning range proofs during verification #6166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions base_layer/common_types/src/types/bullet_rangeproofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ impl BulletRangeProof {
.expect("This should be 32 bytes for a Blake 256 hash")
.into()
}

/// Get the range proof as a vector reference, which is useful to satisfy the verification API without cloning
pub fn as_vec(&self) -> &Vec<u8> {
&self.0
}
}

impl ByteArray for BulletRangeProof {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use tari_crypto::{
extended_range_proof::{ExtendedRangeProofService, Statement},
keys::SecretKey,
ristretto::bulletproofs_plus::RistrettoAggregatedPublicStatement,
tari_utilities::{hex::Hex, ByteArray},
tari_utilities::hex::Hex,
};
use tari_script::TariScript;

Expand Down Expand Up @@ -545,9 +545,9 @@ pub fn batch_verify_range_proofs(
minimum_value_promise: output.minimum_value_promise.into(),
}],
});
proofs.push(output.proof_result()?.to_vec().clone());
proofs.push(output.proof_result()?.as_vec());
}
if let Err(err_1) = prover.verify_batch(proofs.iter().collect(), statements.iter().collect()) {
if let Err(err_1) = prover.verify_batch(proofs, statements.iter().collect()) {
for output in &bulletproof_plus_proofs {
if let Err(err_2) = output.verify_range_proof(prover) {
return Err(RangeProofError::InvalidRangeProof {
Expand Down
Loading