hopr_crypto_types/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use hopr_primitive_types::errors::GeneralError;
use k256::elliptic_curve;
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum CryptoError {
    #[error("cryptographic parameter '{name:?}' must be {expected:?} bytes")]
    InvalidParameterSize { name: String, expected: usize },

    #[error("input to the function has invalid value or size")]
    InvalidInputValue,

    #[error("secret scalar results in an invalid EC point")]
    InvalidSecretScalar,

    #[error("ec point represents and invalid public key")]
    InvalidPublicKey,

    #[error("mac or authentication tag did not match")]
    TagMismatch,

    #[error("curve error: {0}")]
    EllipticCurveError(#[from] elliptic_curve::Error),

    #[error("failed to perform cryptographic calculation")]
    CalculationError,

    #[error("signature verification failed")]
    SignatureVerification,

    #[error("error during sealing/unsealing of data")]
    SealingError,

    #[error("ethereum challenge on the ticket is invalid")]
    InvalidChallenge,

    #[error("invalid vrf values")]
    InvalidVrfValues,

    #[error("lower-level error: {0}")]
    Other(#[from] GeneralError),
}

pub type Result<T> = core::result::Result<T, CryptoError>;