ed448_goldilocks_plus/sign/
error.rs1use core::fmt::{self, Display, Formatter};
2
3#[cfg(feature = "std")]
4use std::error::Error;
5
6#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
8pub enum SigningError {
9 PrehashedContextLength,
11 InvalidPublicKeyBytes,
13 InvalidSignatureSComponent,
15 InvalidSignatureRComponent,
17 InvalidSignatureLength,
19 Verify,
21}
22
23impl Display for SigningError {
24 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
25 match self {
26 SigningError::PrehashedContextLength => {
27 write!(f, "prehashed context length is invalid")
28 }
29 SigningError::InvalidPublicKeyBytes => write!(f, "public key bytes are invalid"),
30 SigningError::InvalidSignatureSComponent => {
31 write!(f, "signature S component is invalid")
32 }
33 SigningError::InvalidSignatureRComponent => {
34 write!(f, "signature R component is invalid")
35 }
36 SigningError::InvalidSignatureLength => write!(f, "signature length is invalid"),
37 SigningError::Verify => write!(f, "signature verification failed"),
38 }
39 }
40}
41
42#[cfg(feature = "std")]
43impl Error for SigningError {}
44
45impl From<SigningError> for crypto_signature::Error {
46 #[cfg(feature = "std")]
47 fn from(err: SigningError) -> Self {
48 crypto_signature::Error::from_source(err)
49 }
50
51 #[cfg(not(feature = "std"))]
52 fn from(err: SigningError) -> Self {
53 crypto_signature::Error::new()
54 }
55}