1#[derive(Debug, thiserror::Error)]
5pub enum PrimitivesError {
6 #[error("invalid private key: {0}")]
8 InvalidPrivateKey(String),
9
10 #[error("invalid public key: {0}")]
12 InvalidPublicKey(String),
13
14 #[error("invalid signature: {0}")]
16 InvalidSignature(String),
17
18 #[error("invalid WIF format: {0}")]
20 InvalidWif(String),
21
22 #[error("checksum mismatch")]
24 ChecksumMismatch,
25
26 #[error("point not on curve")]
28 PointNotOnCurve,
29
30 #[error("invalid key length: expected {expected}, got {got}")]
32 InvalidKeyLength {
33 expected: usize,
35 got: usize,
37 },
38
39 #[error("encryption error: {0}")]
41 EncryptionError(String),
42
43 #[error("decryption error: {0}")]
45 DecryptionError(String),
46
47 #[error("invalid hex: {0}")]
49 InvalidHex(String),
50
51 #[error("invalid hash: {0}")]
53 InvalidHash(String),
54
55 #[error("invalid base58: {0}")]
57 InvalidBase58(String),
58
59 #[error("insufficient shares for recovery: need {threshold}, got {got}")]
61 InsufficientShares {
62 threshold: usize,
64 got: usize,
66 },
67
68 #[error("invalid threshold: {0}")]
70 InvalidThreshold(String),
71
72 #[error("duplicate share detected")]
74 DuplicateShare,
75
76 #[error("varint too large")]
78 VarIntTooLarge,
79
80 #[error("unexpected end of data")]
82 UnexpectedEof,
83
84 #[error("hex decode error: {0}")]
86 HexDecode(#[from] hex::FromHexError),
87
88 #[error("elliptic curve error: {0}")]
90 EllipticCurve(#[from] k256::elliptic_curve::Error),
91
92 #[error("ecdsa error: {0}")]
94 Ecdsa(#[from] k256::ecdsa::signature::Error),
95
96 #[error("aead error")]
98 Aead,
99
100 #[error("{0}")]
102 Other(String),
103}
104
105impl From<aes_gcm::Error> for PrimitivesError {
106 fn from(_: aes_gcm::Error) -> Self {
107 PrimitivesError::Aead
108 }
109}