Skip to main content

affinidi_crypto/
error.rs

1//! Error types for cryptographic operations
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum CryptoError {
7    #[error("Key error: {0}")]
8    KeyError(String),
9
10    #[error("Decoding error: {0}")]
11    Decoding(String),
12
13    #[error("Unsupported key type: {0}")]
14    UnsupportedKeyType(String),
15
16    #[error("Encoding error: {0}")]
17    Encoding(#[from] affinidi_encoding::EncodingError),
18
19    // ─── JOSE primitives (`jose` feature) ───────────────────────────────────
20    #[error("Key agreement error: {0}")]
21    KeyAgreement(String),
22
23    #[error("Key derivation error: {0}")]
24    KeyDerivation(String),
25
26    #[error("Key wrap error: {0}")]
27    KeyWrap(String),
28
29    #[error("Content encryption error: {0}")]
30    ContentEncryption(String),
31
32    #[error("Signing error: {0}")]
33    Signing(String),
34
35    #[error("Verification error: {0}")]
36    Verification(String),
37}
38
39pub type Result<T> = std::result::Result<T, CryptoError>;