-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consensus: fix panic in batch verifier (#152)
* fix panic in batch verifier * docs * review comments * Update consensus/rules/src/batch_verifier.rs Co-authored-by: hinto-janai <[email protected]> --------- Co-authored-by: hinto-janai <[email protected]>
- Loading branch information
1 parent
6df67bb
commit 07f61bd
Showing
7 changed files
with
125 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use multiexp::BatchVerifier as InternalBatchVerifier; | ||
|
||
/// This trait represents a batch verifier. | ||
/// | ||
/// A batch verifier is used to speed up verification by verifying multiple transactions together. | ||
/// | ||
/// Not all proofs can be batched and at its core it's intended to verify a series of statements are | ||
/// each equivalent to zero. | ||
pub trait BatchVerifier { | ||
/// Queue a statement for batch verification. | ||
/// | ||
/// # Panics | ||
/// This function may panic if `stmt` contains calls to `rayon`'s parallel iterators, e.g. `par_iter()`. | ||
// TODO: remove the panics by adding a generic API upstream. | ||
fn queue_statement<R>( | ||
&mut self, | ||
stmt: impl FnOnce(&mut InternalBatchVerifier<(), dalek_ff_group::EdwardsPoint>) -> R, | ||
) -> R; | ||
} | ||
|
||
// impl this for a single threaded batch verifier. | ||
impl BatchVerifier for &'_ mut InternalBatchVerifier<(), dalek_ff_group::EdwardsPoint> { | ||
fn queue_statement<R>( | ||
&mut self, | ||
stmt: impl FnOnce(&mut InternalBatchVerifier<(), dalek_ff_group::EdwardsPoint>) -> R, | ||
) -> R { | ||
stmt(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters