1
- use crate :: StdResult ;
2
- use ed25519_dalek:: { SignatureError , Signer , SigningKey } ;
1
+ use crate :: { StdError , StdResult } ;
2
+ use anyhow:: anyhow;
3
+ use ed25519_dalek:: { Signer , SigningKey } ;
3
4
use rand_chacha:: rand_core:: { self , CryptoRng , RngCore , SeedableRng } ;
4
5
use rand_chacha:: ChaCha20Rng ;
5
6
use serde:: { Deserialize , Serialize } ;
@@ -10,11 +11,8 @@ use super::{ProtocolGenesisSecretKey, ProtocolGenesisSignature, ProtocolGenesisV
10
11
11
12
#[ derive( Error , Debug ) ]
12
13
/// [ProtocolGenesisSigner] and [ProtocolGenesisVerifier] related errors.
13
- pub enum ProtocolGenesisError {
14
- /// Error raised when a Genesis Signature verification fail
15
- #[ error( "genesis signature verification error: '{0}'" ) ]
16
- SignatureVerification ( #[ from] SignatureError ) ,
17
- }
14
+ #[ error( "genesis signature verification error: '{0}'" ) ]
15
+ pub struct ProtocolGenesisError ( StdError ) ;
18
16
19
17
/// A protocol Genesis Signer that is responsible for signing the
20
18
/// [Genesis Certificate](https://mithril.network/doc/mithril/mithril-protocol/certificates#the-certificate-chain-design)
@@ -90,12 +88,11 @@ impl ProtocolGenesisVerifier {
90
88
}
91
89
92
90
/// Verifies the signature of a message
93
- pub fn verify (
94
- & self ,
95
- message : & [ u8 ] ,
96
- signature : & ProtocolGenesisSignature ,
97
- ) -> Result < ( ) , ProtocolGenesisError > {
98
- Ok ( self . verification_key . verify_strict ( message, signature) ?)
91
+ pub fn verify ( & self , message : & [ u8 ] , signature : & ProtocolGenesisSignature ) -> StdResult < ( ) > {
92
+ Ok ( self
93
+ . verification_key
94
+ . verify_strict ( message, signature)
95
+ . map_err ( |e| ProtocolGenesisError ( anyhow ! ( e) ) ) ?)
99
96
}
100
97
}
101
98
0 commit comments