signature_verifier/
error.rs1#[derive(Debug, Clone, PartialEq)]
2pub enum VerifyError {
3 InvalidEncoding(String),
5
6 InvalidSignature,
8}
9
10impl std::fmt::Display for VerifyError {
11 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12 match self {
13 VerifyError::InvalidEncoding(cause) => write!(f, "{}", cause),
14 VerifyError::InvalidSignature => write!(f, "Signature is invalid"),
15 }
16 }
17}
18
19impl std::error::Error for VerifyError {}
20
21#[cfg(feature = "ethereum")]
22impl From<hex::FromHexError> for VerifyError {
23 fn from(value: hex::FromHexError) -> Self {
24 Self::InvalidEncoding(value.to_string())
25 }
26}
27
28#[cfg(feature = "ethereum")]
29impl From<web3::signing::RecoveryError> for VerifyError {
30 fn from(_value: web3::signing::RecoveryError) -> Self {
31 Self::InvalidSignature
32 }
33}
34
35#[cfg(feature = "solana")]
36impl From<bs58::decode::Error> for VerifyError {
37 fn from(value: bs58::decode::Error) -> Self {
38 Self::InvalidEncoding(value.to_string())
39 }
40}
41
42#[cfg(feature = "solana")]
43impl From<solana_sdk::pubkey::ParsePubkeyError> for VerifyError {
44 fn from(value: solana_sdk::pubkey::ParsePubkeyError) -> Self {
45 Self::InvalidEncoding(value.to_string())
46 }
47}
48
49#[cfg(feature = "solana")]
50impl From<nacl::Error> for VerifyError {
51 fn from(_value: nacl::Error) -> Self {
52 Self::InvalidSignature
53 }
54}