1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::commitment::{CommitmentScheme, Verifier};
use crate::plonk::Error;

/// Guards is unfinished verification result. Implement this to construct various
/// verification strategies such as aggregation and recursion.
pub trait Guard<Scheme: CommitmentScheme> {
    /// Multi scalar engine which is not evaluated yet.
    type MSMAccumulator;
}

/// Trait representing a strategy for verifying Halo 2 proofs.
pub trait VerificationStrategy<'params, Scheme: CommitmentScheme, V: Verifier<'params, Scheme>> {
    /// Creates new verification strategy instance
    fn new(params: &'params Scheme::ParamsVerifier) -> Self;

    /// Obtains an MSM from the verifier strategy and yields back the strategy
    fn process(
        self,
        f: impl FnOnce(V::MSMAccumulator) -> Result<V::Guard, Error>,
    ) -> Result<Self, Error>
    where
        Self: Sized;

    /// Finalizes the batch and checks its validity.
    ///
    /// Returns `false` if *some* proof was invalid. If the caller needs to identify
    /// specific failing proofs, it must re-process the proofs separately.
    fn finalize(self) -> bool;
}