1use serde::{Deserialize, Serialize};
2use thiserror::Error as DError;
3
4#[derive(DError, Debug)]
6pub enum Error {
7 #[error("fmt error")]
9 FmtError(#[from] std::fmt::Error),
10 #[error("io error")]
12 IoError(#[from] std::io::Error),
13 #[error("vsss error")]
15 VsssError(vsss_rs::Error),
16 #[error("error during secret_participant creation: {0}")]
18 InitializationError(String),
19 #[error("round {0} invalid input: `{1}`")]
21 RoundError(usize, String),
22}
23
24impl From<vsss_rs::Error> for Error {
25 fn from(value: vsss_rs::Error) -> Self {
26 Self::VsssError(value)
27 }
28}
29
30pub type DkgResult<T> = anyhow::Result<T, Error>;
32
33#[derive(DError, Debug, Deserialize, Serialize)]
35pub enum ParticipantError {
36 #[error("secret_participant {0} has broadcast data but no peer-to-peer data")]
38 MissingP2PData(usize),
39 #[error("secret_participant {0} has peer-to-peer data but no broadcast data")]
41 MissingBroadcastData(usize),
42 #[error("secret_participant {0} is using the different parameters than expected")]
44 MismatchedParameters(usize),
45 #[error("secret_participant {0} has identity element pedersen commitments")]
47 IdentityElementPedersenCommitments(usize),
48 #[error("secret_participant {0} has zero value shares")]
50 ZeroValueShares(usize),
51 #[error("secret_participant {0} has shares that do not verify with the given commitments")]
53 NoVerifyShares(usize),
54 #[error("secret_participant {0} has shares that are not in the field")]
56 BadFormatShare(usize),
57 #[error("broadcast data for secret_participant {0} is not expected")]
59 UnexpectedBroadcast(usize),
60 #[error("secret_participant {0} is missing peer-to-peer data from round 1")]
62 MissingP2PDataRound1(usize),
63 #[error("secret_participant {0} is missing broadcast data from round 1")]
65 MissingBroadcastDataRound1(usize),
66 #[error("secret_participant {0} has identity element feldman commitments")]
68 IdentityElementFeldmanCommitments(usize),
69}