Skip to main content

relay_crypto/crypto/
mod.rs

1pub mod e2e;
2pub mod shamir;
3pub mod sign;
4
5#[derive(Debug, PartialEq, Eq, thiserror::Error)]
6pub enum CryptoError {
7    #[error("Key derivation failed")]
8    KeyDerivationError,
9    #[error("Key record expired")]
10    ExpiredKeyRecord,
11    #[error("Bad public signature key")]
12    BadPublicSignatureKey,
13    #[error("Encryption failed")]
14    BadSignature,
15    #[error("Missing signature")]
16    MissingSignature,
17    #[error("Encryption failed: {0}")]
18    Encrypt(String),
19    #[error("Decryption failed: {0}")]
20    Decrypt(String),
21    #[error("Invalid metadata: {0}")]
22    InvalidMeta(String),
23    #[error("Threshold must be at least 2, but got {0}")]
24    ThresholdTooLow(u32),
25    #[error("Share count must be between 1 and 255, but got {0}")]
26    ShareCountError(u32),
27    #[error(
28        "Share count must be at least equal to the threshold, but got {0} shares for threshold {1}"
29    )]
30    ThresholdMoreThanShareCound(u32, u32),
31    #[error(
32        "Not enough shares to reconstruct the secret. Provided {0} shares, but threshold is {1}"
33    )]
34    NotEnoughShares(u32, u32),
35    #[error("Inconsistent shares provided")]
36    InconsistentShares,
37    #[error("Duplicate share index: {0} and {1}")]
38    DuplicateShareIndex(u8, u8),
39}