#![allow(clippy::module_name_repetitions)]
use ps_compress::{CompressionError, DecompressionError};
use ps_ecc::{DecodeError, EncodeError};
use ps_hash::HashError;
use thiserror::Error;
#[derive(Clone, Debug, Error)]
#[non_exhaustive]
pub enum EncryptionError {
#[error("encryption failed (chacha20poly1305)")]
ChaCha(#[source] chacha20poly1305::Error),
#[error("compression failed: {0}")]
Compression(#[from] CompressionError),
#[error("ECC encoding failed: {0}")]
Ecc(#[from] EncodeError),
#[error("hashing failed: {0}")]
Hash(#[from] HashError),
}
#[derive(Clone, Debug, Error)]
#[non_exhaustive]
pub enum DecryptionError {
#[error("decryption failed (chacha20poly1305)")]
ChaCha(#[source] chacha20poly1305::Error),
#[error("decompression failed: {0}")]
Decompression(#[from] DecompressionError),
#[error("ECC decoding failed: {0}")]
Ecc(#[from] DecodeError),
#[error("hashing failed: {0}")]
Hash(#[from] HashError),
#[error("decrypted data does not hash to the decryption key")]
KeyMismatch,
}