ed25519_zebra/
error.rs

1use core::fmt;
2
3/// An error related to Ed25519 signatures.
4#[derive(Debug, Copy, Clone, Eq, PartialEq)]
5pub enum Error {
6    /// The encoding of a secret key was malformed.
7    MalformedSecretKey,
8    /// The encoding of a public key was malformed.
9    MalformedPublicKey,
10    /// Signature verification failed.
11    InvalidSignature,
12    /// A byte slice of the wrong length was supplied during parsing.
13    InvalidSliceLength,
14}
15
16impl fmt::Display for Error {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        let msg = match self {
19            Self::MalformedSecretKey => "Malformed secret key encoding.",
20            Self::MalformedPublicKey => "Malformed public key encoding.",
21            Self::InvalidSignature => "Invalid signature.",
22            Self::InvalidSliceLength => "Invalid length when parsing byte slice.",
23        };
24
25        msg.fmt(f)
26    }
27}
28
29#[cfg(feature = "std")]
30impl std::error::Error for Error {}