1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Error {
    InvalidSignature,
    InvalidPublicKey,
    InvalidSecretKey,
    InvalidRecoveryId,
    InvalidMessage,
    InvalidInputLength,
    TweakOutOfRange,
    InvalidAffine,
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}

impl core::fmt::Display for Error {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Error::InvalidSignature => write!(f, "Invalid signature"),
            Error::InvalidPublicKey => write!(f, "Invalid public key"),
            Error::InvalidSecretKey => write!(f, "Invalid secret key"),
            Error::InvalidRecoveryId => write!(f, "Invalid recovery ID"),
            Error::InvalidMessage => write!(f, "Invalid message"),
            Error::InvalidInputLength => write!(f, "Invalid input length"),
            Error::TweakOutOfRange => write!(f, "Tweak out of range"),
            Error::InvalidAffine => write!(f, "Invalid Affine"),
        }
    }
}