wildland_crypto/
error.rs

1//
2// Wildland Project
3//
4// Copyright © 2022 Golem Foundation
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License version 3 as published by
8// the Free Software Foundation.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
18use thiserror::Error;
19
20#[derive(Error, Debug, PartialEq, Eq, Clone)]
21#[repr(C)]
22pub enum CryptoError {
23    #[error("Key has incorrect length - should be 32 bytes long. Key length = {0}")]
24    KeyParsingError(usize),
25    #[error("Cannot verify message: {0}")]
26    MessageVerificationError(String),
27    #[error("Invalid key signature: {0}")]
28    InvalidSignatureBytesError(String),
29    #[error("Failed to create a mnemonic: {0}")]
30    MnemonicGenerationError(String),
31    #[error("Identity generation failed: {0}")]
32    IdentityGenerationError(String),
33    #[error("Too low entropy")]
34    EntropyTooLow,
35    #[error("Could not decrypt content")]
36    DecryptionError,
37}
38
39#[derive(Error, Debug, PartialEq, Eq, Clone)]
40#[error("Error while deriving an extended secret key fom the current using a derivation path: {0}")]
41pub struct KeyDeriveError(pub String);