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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#![allow(non_snake_case)]
use core::fmt;
use core::fmt::Display;
#[cfg(feature = "std")]
use std::error::Error;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub(crate) enum InternalError {
    PointDecompressionError,
    ScalarFormatError,
    
    
    
    
    
    BytesLengthError {
        name: &'static str,
        length: usize,
    },
    
    VerifyError,
    
    
    ArrayLengthError{ name_a: &'static str, length_a: usize,
                      name_b: &'static str, length_b: usize,
                      name_c: &'static str, length_c: usize, },
    
    PrehashedContextLengthError,
}
impl Display for InternalError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match *self {
            InternalError::PointDecompressionError
                => write!(f, "Cannot decompress Edwards point"),
            InternalError::ScalarFormatError
                => write!(f, "Cannot use scalar with high-bit set"),
            InternalError::BytesLengthError{ name: n, length: l}
                => write!(f, "{} must be {} bytes in length", n, l),
            InternalError::VerifyError
                => write!(f, "Verification equation was not satisfied"),
            InternalError::ArrayLengthError{ name_a: na, length_a: la,
                                             name_b: nb, length_b: lb,
                                             name_c: nc, length_c: lc, }
                => write!(f, "Arrays must be the same length: {} has length {},
                              {} has length {}, {} has length {}.", na, la, nb, lb, nc, lc),
            InternalError::PrehashedContextLengthError
                => write!(f, "An ed25519ph signature can only take up to 255 octets of context"),
        }
    }
}
#[cfg(feature = "std")]
impl Error for InternalError { }
pub type SignatureError = ed25519::signature::Error;
impl From<InternalError> for SignatureError {
    #[cfg(not(feature = "std"))]
    fn from(_err: InternalError) -> SignatureError {
        SignatureError::new()
    }
    #[cfg(feature = "std")]
    fn from(err: InternalError) -> SignatureError {
        SignatureError::from_source(err)
    }
}