-
Notifications
You must be signed in to change notification settings - Fork 220
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
feat: add range proof batch verification to validators #4260
feat: add range proof batch verification to validators #4260
Conversation
Added batch verification of range proofs where ever more than one range proof needed to be verified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
I would just prefer adding docs to the two new functions.
Especially the power_of_two_chunk_sizes
one.
} | ||
Ok(()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pub function. Does this need to be public?
Either way, this function can benefit from docs. To understand what this function does, you need to read the comment on the function batch_verify_range_proofs
and the tests for this function, this is not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, fixed
a8531a3
to
4057498
Compare
pub fn batch_verify_range_proofs( | ||
prover: &RangeProofService, | ||
outputs: &[&TransactionOutput], | ||
) -> Result<(), RangeProofError> { | ||
// We need optimized power of two chunks, for example if we have 15 outputs, then we need chunks of 8, 4, 2, 1. | ||
let power_of_two_vec = power_of_two_chunk_sizes(outputs.len(), 8); | ||
debug!( | ||
target: LOG_TARGET, | ||
"Queueing range proof batch verify output(s): {:?}", &power_of_two_vec | ||
); | ||
let mut index = 0; | ||
for power_of_two in power_of_two_vec { | ||
let mut statements = Vec::with_capacity(power_of_two); | ||
let mut proofs = Vec::with_capacity(power_of_two); | ||
for output in outputs.iter().skip(index).take(power_of_two) { | ||
statements.push(RistrettoAggregatedPublicStatement { | ||
statements: vec![Statement { | ||
commitment: output.commitment.clone(), | ||
minimum_value_promise: 0, | ||
}], | ||
}); | ||
proofs.push(output.proof.to_vec().clone()); | ||
} | ||
index += power_of_two; | ||
prover.verify_batch(proofs.iter().collect(), statements.iter().collect())?; | ||
} | ||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be in the bulletproofs+ crate. Think about it - Verifying batches of non power-of-two sets is something you'd be writing over and over if its not there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it could move there and be totally transparent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created an issue for it
@@ -70,7 +70,7 @@ mod transaction_input; | |||
mod transaction_input_version; | |||
mod transaction_kernel; | |||
mod transaction_kernel_version; | |||
mod transaction_output; | |||
pub mod transaction_output; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather use pub use
to expose what you want to, otherwise all of these will eventually be pub
Description
Added batch verification of range proofs where ever more than one range proof needed to be verified.
Motivation and Context
Batch verification range proofs is much faster than running linear proofs
How Has This Been Tested?
Unit tests
Integration tests
System-level tests pending