Skip to main content

platform_encryption/
error.rs

1//! Error type shared across the DIP-15 crypto modules.
2
3/// Errors that can occur during cryptographic operations
4#[derive(Debug, thiserror::Error)]
5pub enum CryptoError {
6    #[error("Decryption failed")]
7    DecryptionFailed,
8
9    #[error("Invalid UTF-8 in decrypted data")]
10    InvalidUtf8,
11
12    #[error("Invalid ciphertext length (must be at least 16 bytes for IV)")]
13    InvalidCiphertextLength,
14
15    #[error("Invalid compact xpub length (DIP-15 requires exactly 69 bytes, got {0})")]
16    InvalidCompactXpubLength(usize),
17
18    #[error("Invalid encrypted shielded address length (expected 64 bytes, got {0})")]
19    InvalidEncryptedShieldedAddressLength(usize),
20
21    #[error("Invalid shielded address length (expected 43 bytes, got {0})")]
22    InvalidShieldedAddressLength(usize),
23}