Skip to main content

joy_crypt/
error.rs

1//! Error type for joy-crypt primitives.
2//!
3//! Crypto failures map onto a small set of categories. Callers in joy-core
4//! convert to their own error type at the boundary.
5
6use thiserror::Error;
7
8#[derive(Debug, Error)]
9pub enum Error {
10    #[error("invalid hex: {0}")]
11    InvalidHex(String),
12
13    #[error("invalid length: expected {expected} bytes, got {got}")]
14    InvalidLength { expected: usize, got: usize },
15
16    #[error("invalid Ed25519 key")]
17    InvalidPublicKey,
18
19    #[error("signature verification failed")]
20    SignatureVerification,
21
22    #[error("Argon2id derivation failed: {0}")]
23    Kdf(String),
24
25    #[error("AEAD operation failed")]
26    Aead,
27}