1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use thiserror::Error;
#[derive(Error, Debug)]
pub enum KeystoreError {
#[error("Mac Mismatch")]
MacMismatch,
#[error("IO: {0}")]
StdIo(String),
#[error("serde-json: {0}")]
SerdeJson(String),
#[error("scrypt {0:?}")]
ScryptInvalidParams(scrypt::errors::InvalidParams),
#[error("scrypt {0:?}")]
ScryptInvalidOuputLen(scrypt::errors::InvalidOutputLen),
#[error("aes {0:?}")]
AesInvalidKeyNonceLength(aes::cipher::InvalidLength),
#[cfg(feature = "geth-compat")]
#[error(transparent)]
K256Error(#[from] k256::ecdsa::Error),
}
impl From<scrypt::errors::InvalidParams> for KeystoreError {
fn from(e: scrypt::errors::InvalidParams) -> Self {
Self::ScryptInvalidParams(e)
}
}
impl From<scrypt::errors::InvalidOutputLen> for KeystoreError {
fn from(e: scrypt::errors::InvalidOutputLen) -> Self {
Self::ScryptInvalidOuputLen(e)
}
}
impl From<aes::cipher::InvalidLength> for KeystoreError {
fn from(e: aes::cipher::InvalidLength) -> Self {
Self::AesInvalidKeyNonceLength(e)
}
}
impl From<std::io::Error> for KeystoreError {
fn from(e: std::io::Error) -> KeystoreError {
KeystoreError::StdIo(e.to_string())
}
}
impl From<serde_json::Error> for KeystoreError {
fn from(e: serde_json::Error) -> KeystoreError {
KeystoreError::SerdeJson(e.to_string())
}
}