1extern crate core;
19
20mod private_key;
21pub use private_key::PrivateKey;
22
23mod public_key;
24pub use public_key::PublicKey;
25
26pub mod aes;
27pub mod k256;
28pub mod totp;
29
30pub mod error {
31
32 #[derive(Debug, PartialEq, Eq)]
34 pub enum Error {
35 LengthError(String),
36 HexError(String),
37 DecryptError(String),
38 EncryptError(String),
39 RecoveryError(String),
40 InvalidSignature,
41 PrivateKeyError,
42 InvalidPublicKey,
43 }
44
45 impl std::fmt::Display for Error {
46 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
47 match self {
48 Error::LengthError(s) => write!(f, "LengthError: {}", s),
49 Error::HexError(s) => write!(f, "HexError: {}", s),
50 Error::DecryptError(s) => write!(f, "DecryptError: {}", s),
51 Error::EncryptError(s) => write!(f, "EncryptError: {}", s),
52 Error::RecoveryError(s) => write!(f, "RecoveryError: {}", s),
53 Error::InvalidSignature => write!(f, "InvalidSignature"),
54 Error::PrivateKeyError => write!(f, "PrivateKeyError"),
55 Error::InvalidPublicKey => write!(f, "InvalidPublicKey"),
56 }
57 }
58 }
59
60 impl std::error::Error for Error {}
61
62 impl From<hex::FromHexError> for Error {
63 fn from(value: hex::FromHexError) -> Self {
64 Error::HexError(value.to_string())
65 }
66 }
67
68 pub type Result<T> = std::result::Result<T, Error>;
70}