Skip to main content

mithril_stm/protocol/aggregate_signature/
error.rs

1use crate::SignerIndex;
2
3use super::AggregateSignatureType;
4
5/// Error types for aggregation.
6#[derive(Debug, Clone, thiserror::Error)]
7pub enum AggregationError {
8    /// Not enough signatures were collected, got this many instead.
9    #[error("Not enough signatures. Got only {0} out of {1}.")]
10    NotEnoughSignatures(u64, u64),
11
12    #[error("Unsupported proof system: {0}")]
13    UnsupportedProofSystem(AggregateSignatureType),
14
15    /// There is a duplicate index
16    #[error("Indices are not unique.")]
17    IndexNotUnique,
18
19    /// Signer registration data could not be found during witness assembly for SNARK prover input.
20    #[error("Missing SNARK signer data for signer index {0}.")]
21    MissingSnarkSignerData(SignerIndex),
22
23    /// A signature selected for witness assembly is missing its SNARK component.
24    #[error("Missing SNARK signature for lottery index {0}.")]
25    MissingSnarkSignature(SignerIndex),
26}
27
28/// Errors which can be output by Mithril aggregate verification.
29#[derive(Debug, Clone, thiserror::Error)]
30pub enum AggregateSignatureError {
31    /// This error occurs when the serialization of the raw bytes failed
32    #[error("Invalid bytes")]
33    SerializationError,
34
35    /// Batch verification of STM aggregate signatures failed
36    #[error(
37        "Invalid batch: signatures, aggregate verification keys, message and parameters must have the same length"
38    )]
39    BatchInvalid,
40
41    /// Missing SNARK aggregate verification key
42    #[error("Missing SNARK aggregate verification key")]
43    MissingSnarkAggregateVerificationKey,
44
45    /// Missing SNARK clerk for aggregate signature verification
46    #[error("Missing SNARK clerk for aggregate signature verification")]
47    MissingSnarkClerk,
48
49    /// The proof system used in the aggregate signature is not supported
50    #[error("Unsupported proof system: {0}")]
51    UnsupportedProofSystem(AggregateSignatureType),
52
53    /// The proof system is unknown
54    #[error("Unknown proof system: {0}")]
55    UnknownProofSystem(String),
56}