Skip to main content

frost_dkg/
error.rs

1use thiserror::Error;
2
3/// Error type for the library.
4#[derive(Error, Debug)]
5pub enum Error {
6    /// Error during formatting.
7    #[error("fmt error: {0}")]
8    Fmt(#[from] std::fmt::Error),
9    /// Error during I/O operations.
10    #[error("io error: {0}")]
11    Io(#[from] std::io::Error),
12    /// Error during VSSS operations.
13    #[error("vsss error: {0}")]
14    Vsss(vsss_rs::Error),
15    /// Error during postcard serialization/deserialization.
16    #[error("Postcard error: {0}")]
17    Postcard(#[from] postcard::Error),
18    /// The received protocol message is malformed.
19    #[error("invalid protocol message: {0}")]
20    InvalidMessage(String),
21    /// Error during participant initialization.
22    #[error("error during participant initialization: {0}")]
23    Initialization(String),
24    /// Error during a round of the DKG protocol.
25    #[error("round error: {0}")]
26    Round(String),
27    /// Publicly verifiable secret sharing verification error.
28    #[error("publicly verifiable secret sharing error: {0}")]
29    Pvss(String),
30}
31
32impl From<vsss_rs::Error> for Error {
33    fn from(e: vsss_rs::Error) -> Self {
34        Error::Vsss(e)
35    }
36}
37
38/// Result type for the library.
39pub type DkgResult<T> = Result<T, Error>;