hopr_crypto_types/
errors.rs

1use hopr_primitive_types::errors::GeneralError;
2use k256::elliptic_curve;
3use thiserror::Error;
4
5#[derive(Error, Debug, PartialEq)]
6pub enum CryptoError {
7    #[error("cryptographic parameter '{name:?}' must be {expected:?} bytes")]
8    InvalidParameterSize { name: String, expected: usize },
9
10    #[error("input to the function has invalid value or size")]
11    InvalidInputValue,
12
13    #[error("secret scalar results in an invalid EC point")]
14    InvalidSecretScalar,
15
16    #[error("ec point represents and invalid public key")]
17    InvalidPublicKey,
18
19    #[error("mac or authentication tag did not match")]
20    TagMismatch,
21
22    #[error("curve error: {0}")]
23    EllipticCurveError(#[from] elliptic_curve::Error),
24
25    #[error("failed to perform cryptographic calculation")]
26    CalculationError,
27
28    #[error("signature verification failed")]
29    SignatureVerification,
30
31    #[error("error during sealing/unsealing of data")]
32    SealingError,
33
34    #[error("ethereum challenge on the ticket is invalid")]
35    InvalidChallenge,
36
37    #[error("invalid vrf values")]
38    InvalidVrfValues,
39
40    #[error("lower-level error: {0}")]
41    Other(#[from] GeneralError),
42}
43
44pub type Result<T> = core::result::Result<T, CryptoError>;