wtfrost/
errors.rs

1use p256k1::{point::Error as PointError, scalar::Scalar};
2use thiserror::Error;
3
4#[derive(Error, Debug, Clone)]
5/// Errors which can happen during distributed key generation
6pub enum DkgError {
7    #[error("missing shares from {0:?}")]
8    /// The shares which were missing
9    MissingShares(Vec<usize>),
10    #[error("bad IDs {0:?}")]
11    /// The IDs which failed to verify
12    BadIds(Vec<usize>),
13    #[error("not enough shares {0:?}")]
14    /// Not enough shares to complete DKG
15    NotEnoughShares(Vec<usize>),
16    #[error("bad shares {0:?}")]
17    /// The shares which failed to verify
18    BadShares(Vec<usize>),
19    #[error("point error {0:?}")]
20    /// An error during point operations
21    Point(PointError),
22}
23
24impl From<PointError> for DkgError {
25    fn from(e: PointError) -> Self {
26        DkgError::Point(e)
27    }
28}
29
30#[derive(Error, Debug, Clone)]
31/// Errors which can happen during signature aggregation
32pub enum AggregatorError {
33    #[error("bad poly commitment length (expected {0} got {1}")]
34    /// The polynomial commitment was the wrong size
35    BadPolyCommitmentLen(usize, usize),
36    #[error("bad poly commitments {0:?}")]
37    /// The polynomial commitments which failed verification
38    BadPolyCommitments(Vec<Scalar>),
39    #[error("bad nonce length (expected {0} got {1}")]
40    /// The nonce length was the wrong size
41    BadNonceLen(usize, usize),
42    #[error("bad party keys from {0:?}")]
43    /// The party public keys which failed
44    BadPartyKeys(Vec<usize>),
45    #[error("bad party sigs from {0:?}")]
46    /// The party signatures which failed to verify
47    BadPartySigs(Vec<usize>),
48    #[error("bad group sig")]
49    /// The aggregate group signature failed to verify
50    BadGroupSig,
51}