Skip to content

Commit 072b50c

Browse files
author
Damien LACHAUME / PALO-IT
committed
Add anyhow context
1 parent 3e9837c commit 072b50c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mithril-aggregator/src/multi_signer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::Context;
12
use async_trait::async_trait;
23
use slog_scope::{debug, warn};
34
use std::sync::Arc;
@@ -457,6 +458,7 @@ impl MultiSigner for MultiSignerImpl {
457458

458459
protocol_multi_signer
459460
.verify_single_signature(message, single_signature)
461+
.with_context(|| "Multi Signer can not verify multi-signature")
460462
.map_err(|error| ProtocolError::Core(error.to_string()))
461463
}
462464

mithril-signer/src/single_signer.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::Context;
12
use hex::ToHex;
23
use slog_scope::{info, trace, warn};
34
use std::path::PathBuf;
@@ -102,8 +103,20 @@ impl SingleSigner for MithrilSingleSigner {
102103
info!("Signing protocol message"; "protocol_message" => #?protocol_message, "signed message" => protocol_message.compute_hash().encode_hex::<String>());
103104
let signatures = builder
104105
.restore_signer_from_initializer(self.party_id.clone(), protocol_initializer.clone())
106+
.with_context(|| {
107+
format!(
108+
"Mithril Single Signer can not restore signer with party_id: '{}'",
109+
self.party_id.clone()
110+
)
111+
})
105112
.map_err(|e| SingleSignerError::ProtocolSignerCreationFailure(e.to_string()))?
106113
.sign(protocol_message)
114+
.with_context(|| {
115+
format!(
116+
"Mithril Single Signer can not sign protocol_message: '{:?}'",
117+
protocol_message
118+
)
119+
})
107120
.map_err(SingleSignerError::SignatureFailed)?;
108121

109122
match &signatures {

0 commit comments

Comments
 (0)