1use secp256k1::Error as SecpError;
2use thiserror::Error;
3
4#[derive(Error, Debug, PartialEq, Eq)]
6pub enum Error {
7 #[error("Invalid privkey")]
9 InvalidPrivKey,
10 #[error("Invalid pubkey")]
12 InvalidPubKey,
13 #[error("Invalid signature")]
15 InvalidSignature,
16 #[error("Invalid message")]
18 InvalidMessage,
19 #[error("Invalid recovery_id")]
21 InvalidRecoveryId,
22 #[error("{0}")]
24 Other(String),
25}
26
27impl From<SecpError> for Error {
28 fn from(e: SecpError) -> Self {
29 match e {
30 SecpError::InvalidPublicKey => Error::InvalidPubKey,
31 SecpError::InvalidSecretKey => Error::InvalidPrivKey,
32 SecpError::InvalidMessage => Error::InvalidMessage,
33 SecpError::InvalidRecoveryId => Error::InvalidRecoveryId,
34 _ => Error::InvalidSignature,
35 }
36 }
37}