ed25519_compact/
error.rs

1use core::fmt::{self, Display};
2
3#[derive(Debug, Copy, Clone, Eq, PartialEq)]
4pub enum Error {
5    /// The signature doesn't verify.
6    SignatureMismatch,
7    /// A weak public key was used.
8    WeakPublicKey,
9    /// The public key is invalid.
10    InvalidPublicKey,
11    /// The secret key is invalid.
12    InvalidSecretKey,
13    /// The signature is invalid.
14    InvalidSignature,
15    /// The seed doesn't have the expected length.
16    InvalidSeed,
17    /// The blind doesn't have the expected length.
18    InvalidBlind,
19    /// The noise doesn't have the expected length.
20    InvalidNoise,
21    /// Parse error
22    ParseError,
23    /// Non-canonical encoding
24    NonCanonical,
25}
26
27#[cfg(feature = "std")]
28impl std::error::Error for Error {}
29
30impl Display for Error {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        match self {
33            Error::SignatureMismatch => write!(f, "Signature doesn't verify"),
34            Error::WeakPublicKey => write!(f, "Weak public key"),
35            Error::InvalidPublicKey => write!(f, "Invalid public key"),
36            Error::InvalidSecretKey => write!(f, "Invalid secret key"),
37            Error::InvalidSignature => write!(f, "Invalid signature"),
38            Error::InvalidSeed => write!(f, "Invalid seed length"),
39            Error::InvalidBlind => write!(f, "Invalid blind length"),
40            Error::InvalidNoise => write!(f, "Invalid noise length"),
41            Error::ParseError => write!(f, "Parse error"),
42            Error::NonCanonical => write!(f, "Non-canonical encoding"),
43        }
44    }
45}