1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Error, Debug)]
10pub enum Error {
11 #[error("Key generation failed: {0}")]
13 KeyGeneration(String),
14
15 #[error("Encapsulation failed: {0}")]
17 Encapsulation(String),
18
19 #[error("Decapsulation failed: {0}")]
21 Decapsulation(String),
22
23 #[error("Signing failed: {0}")]
25 Signing(String),
26
27 #[error("Signature verification failed")]
29 SignatureVerificationFailed,
30
31 #[error("Encryption failed: {0}")]
33 Encryption(String),
34
35 #[error("Decryption failed: {0}")]
37 Decryption(String),
38
39 #[error("Invalid key size: expected {expected}, got {actual}")]
41 InvalidKeySize {
42 expected: usize,
44 actual: usize,
46 },
47
48 #[error("Invalid ciphertext: {0}")]
50 InvalidCiphertext(String),
51
52 #[error("Invalid signature: {0}")]
54 InvalidSignature(String),
55
56 #[error("Invalid nonce: expected {expected} bytes, got {actual}")]
58 InvalidNonce {
59 expected: usize,
61 actual: usize,
63 },
64
65 #[error("Hex decoding error: {0}")]
67 HexDecode(#[from] hex::FromHexError),
68
69 #[error("Base64 decoding error: {0}")]
71 Base64Decode(#[from] base64::DecodeError),
72
73 #[error("JSON error: {0}")]
75 Json(#[from] serde_json::Error),
76
77 #[error("Key storage error: {0}")]
79 KeyStorage(String),
80
81 #[error("Key not found: {0}")]
83 KeyNotFound(String),
84
85 #[error("Signature timestamp expired")]
87 TimestampExpired,
88
89 #[error("Invalid security level: {0}")]
91 InvalidSecurityLevel(String),
92}