Skip to content

Commit 8d83f60

Browse files
committed
Use anyhow in era crypto helper
1 parent 666c255 commit 8d83f60

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

mithril-common/src/crypto_helper/era.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use ed25519_dalek::{SignatureError, Signer, SigningKey};
1+
use ed25519_dalek::{Signer, SigningKey};
22
use rand_chacha::rand_core::{self, CryptoRng, RngCore, SeedableRng};
33
use rand_chacha::ChaCha20Rng;
44
use serde::{Deserialize, Serialize};
55
use thiserror::Error;
66

7+
use crate::{StdError, StdResult};
8+
79
use super::ProtocolKey;
810

911
/// Wrapper of [Ed25519:PublicKey](https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.VerifyingKey.html).
@@ -20,7 +22,7 @@ pub type EraMarkersVerifierSignature = ProtocolKey<ed25519_dalek::Signature>;
2022
pub enum EraMarkersVerifierError {
2123
/// Error raised when a Signature verification fail
2224
#[error("era markers signature verification error: '{0}'")]
23-
SignatureVerification(#[from] SignatureError),
25+
SignatureVerification(StdError),
2426
}
2527

2628
/// A cryptographic signer that is responsible for signing the EraMarkers
@@ -85,11 +87,7 @@ impl EraMarkersVerifier {
8587
}
8688

8789
/// Verifies the signature of a message
88-
pub fn verify(
89-
&self,
90-
message: &[u8],
91-
signature: &EraMarkersVerifierSignature,
92-
) -> Result<(), EraMarkersVerifierError> {
90+
pub fn verify(&self, message: &[u8], signature: &EraMarkersVerifierSignature) -> StdResult<()> {
9391
Ok(self.verification_key.verify_strict(message, signature)?)
9492
}
9593
}

mithril-common/src/era/adapters/cardano_chain.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
era::{EraMarker, EraReaderAdapter},
88
StdError, StdResult,
99
};
10-
use anyhow::anyhow;
10+
use anyhow::{anyhow, Context};
1111
use async_trait::async_trait;
1212
use serde::{Deserialize, Serialize};
1313
use std::sync::Arc;
@@ -80,7 +80,8 @@ impl EraMarkersPayload {
8080

8181
markers_verifier
8282
.verify(&self.message_to_bytes()?, &signature)
83-
.map_err(|e| EraMarkersPayloadError::VerifySignature(e.into()))
83+
.with_context(|| "era markers payload could not verify signature")
84+
.map_err(EraMarkersPayloadError::VerifySignature)
8485
}
8586

8687
/// Sign an era markers payload

0 commit comments

Comments
 (0)