cuprate_consensus_rules/
batch_verifier.rs

1use monero_serai::ringct::bulletproofs::BatchVerifier as InternalBatchVerifier;
2
3/// This trait represents a batch verifier.
4///
5/// A batch verifier is used to speed up verification by verifying multiple transactions together.
6///
7/// Not all proofs can be batched and at its core it's intended to verify a series of statements are
8/// each equivalent to zero.
9pub trait BatchVerifier {
10    /// Queue a statement for batch verification.
11    ///
12    /// # Panics
13    /// This function may panic if `stmt` contains calls to `rayon`'s parallel iterators, e.g. `par_iter()`.
14    // TODO: remove the panics by adding a generic API upstream.
15    fn queue_statement<R>(&mut self, stmt: impl FnOnce(&mut InternalBatchVerifier) -> R) -> R;
16}
17
18// impl this for a single threaded batch verifier.
19impl BatchVerifier for &'_ mut InternalBatchVerifier {
20    fn queue_statement<R>(&mut self, stmt: impl FnOnce(&mut InternalBatchVerifier) -> R) -> R {
21        stmt(self)
22    }
23}