neo3/neo_crypto/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, PartialEq, Clone)]
4pub enum CryptoError {
5	#[error("Invalid passphrase: {0}")]
6	InvalidPassphrase(String),
7	#[error("Invalid format: {0}")]
8	InvalidFormat(String),
9	#[error("invalid signature length, got {0}, expected 65")]
10	HeaderOutOfRange(u8),
11	#[error("Could not recover public key from signature")]
12	RecoverFailed,
13	#[error("Invalid public key")]
14	InvalidPublicKey,
15	#[error("Invalid private key")]
16	InvalidPrivateKey,
17	#[error("Invalid private key")]
18	P256Error(#[from] p256::elliptic_curve::Error),
19	#[error("Signing error")]
20	SigningError,
21	#[error("Signature verification error")]
22	SignatureVerificationError,
23	#[error(transparent)]
24	FromHexError(#[from] hex::FromHexError),
25	#[error("Decryption error: {0}")]
26	DecryptionError(String),
27	#[error("Key error: {0}")]
28	KeyError(String),
29}
30
31#[derive(Error, Debug, Clone, PartialEq, Eq)]
32pub enum Nep2Error {
33	#[error("Invalid passphrase: {0}")]
34	InvalidPassphrase(String),
35	#[error("Invalid format: {0}")]
36	InvalidFormat(String),
37	#[error("Invalid private key: {0}")]
38	InvalidPrivateKey(String),
39	#[error("Encryption error: {0}")]
40	EncryptionError(String),
41	#[error("Decryption error: {0}")]
42	DecryptionError(String),
43	#[error("Verification failed: {0}")]
44	VerificationFailed(String),
45	#[error("Scrypt error: {0}")]
46	ScryptError(String),
47	#[error("Base58 error: {0}")]
48	Base58Error(String),
49}
50
51#[derive(Error, Debug, PartialEq, Eq, Hash, Clone)]
52pub enum SignError {
53	#[error("Header byte out of range: {0}")]
54	HeaderOutOfRange(u8),
55	#[error("Could not recover public key from signature")]
56	RecoverFailed,
57}