1#![allow(clippy::module_name_repetitions)]
2
3use ps_compress::{CompressionError, DecompressionError};
4use ps_ecc::{DecodeError, EncodeError};
5use ps_hash::HashError;
6use thiserror::Error;
7
8#[derive(Clone, Debug, Error)]
10#[non_exhaustive]
11pub enum EncryptionError {
12 #[error("encryption failed (chacha20poly1305)")]
14 ChaCha(#[source] chacha20poly1305::Error),
15 #[error("compression failed: {0}")]
17 Compression(#[from] CompressionError),
18 #[error("ECC encoding failed: {0}")]
20 Ecc(#[from] EncodeError),
21 #[error("hashing failed: {0}")]
23 Hash(#[from] HashError),
24}
25
26#[derive(Clone, Debug, Error)]
28#[non_exhaustive]
29pub enum DecryptionError {
30 #[error("decryption failed (chacha20poly1305)")]
32 ChaCha(#[source] chacha20poly1305::Error),
33 #[error("decompression failed: {0}")]
35 Decompression(#[from] DecompressionError),
36 #[error("ECC decoding failed: {0}")]
38 Ecc(#[from] DecodeError),
39 #[error("hashing failed: {0}")]
41 Hash(#[from] HashError),
42 #[error("decrypted data does not hash to the decryption key")]
44 KeyMismatch,
45}