Skip to content

Commit

Permalink
Expose Register and Aggregation errors in mithril-common
Browse files Browse the repository at this point in the history
  • Loading branch information
iquerejeta committed Sep 5, 2022
1 parent 941fef2 commit 1b8680a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cloud-storage = "0.11.0"
config = "0.13.1"
flate2 = "1.0.23"
hex = "0.4.3"
mithril = { path = "../mithril-core" }
mithril-common = { path = "../mithril-common" }
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
11 changes: 5 additions & 6 deletions mithril-aggregator/src/multi_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use chrono::prelude::*;
use slog_scope::{debug, trace, warn};
use thiserror::Error;

use mithril::AggregationError;
use mithril_common::crypto_helper::{
key_decode_hex, key_encode_hex, ProtocolAggregateVerificationKey, ProtocolClerk,
ProtocolKeyRegistration, ProtocolMultiSignature, ProtocolParameters, ProtocolPartyId,
ProtocolSignerVerificationKey, ProtocolSingleSignature, ProtocolStakeDistribution,
PROTOCOL_VERSION,
key_decode_hex, key_encode_hex, ProtocolAggregateVerificationKey, ProtocolAggregationError,
ProtocolClerk, ProtocolKeyRegistration, ProtocolMultiSignature, ProtocolParameters,
ProtocolPartyId, ProtocolSignerVerificationKey, ProtocolSingleSignature,
ProtocolStakeDistribution, PROTOCOL_VERSION,
};
use mithril_common::entities::{self, SignerWithStake};
use mithril_common::store::{StakeStorer, StoreError};
Expand Down Expand Up @@ -694,7 +693,7 @@ impl MultiSigner for MultiSignerImpl {
self.multi_signature = Some(multi_signature.clone());
Ok(Some(multi_signature))
}
Err(AggregationError::NotEnoughSignatures(actual, expected)) => {
Err(ProtocolAggregationError::NotEnoughSignatures(actual, expected)) => {
warn!("Could not compute multi-signature: Not enough signatures. Got only {} out of {}.", actual, expected);
Ok(None)
}
Expand Down
7 changes: 7 additions & 0 deletions mithril-common/src/crypto_helper/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use mithril::stm::{
Index, Stake, StmAggrSig, StmAggrVerificationKey, StmClerk, StmInitializer, StmParameters,
StmSig, StmSigner, StmVerificationKeyPoP,
};
use mithril::{AggregationError, RegisterError};
/// A protocol version
pub type ProtocolVersion<'a> = &'a str;

Expand Down Expand Up @@ -35,3 +36,9 @@ pub type ProtocolMultiSignature = StmAggrSig<D>;
pub type ProtocolSignerVerificationKey = StmVerificationKeyPoP;
/// Alias of [MithrilCore:StmAggrVerificationKey](https://mithril.network/mithril-core/doc/mithril/stm/struct.StmAggrVerificationKey.html).
pub type ProtocolAggregateVerificationKey = StmAggrVerificationKey<D>;

// Error alias
/// Alias of [MithrilCore:RegisterError](https://mithril.network/mithril-core/doc/mithril/error/enum.RegisterError.html).
pub type ProtocolRegistrationError = RegisterError;
/// Alias of [MithrilCore:AggregationError](https://mithril.network/mithril-core/doc/mithril/error/enum.AggregationError.html).
pub type ProtocolAggregationError = AggregationError;
1 change: 0 additions & 1 deletion mithril-signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ async-trait = "0.1.52"
clap = { version = "3.1.6", features = ["derive"] }
config = "0.13.1"
hex = "0.4.3"
mithril = { path = "../mithril-core" }
mithril-common = { path = "../mithril-common" }
rand_chacha = "0.3.1"
rand_core = "0.6.3"
Expand Down
5 changes: 2 additions & 3 deletions mithril-signer/src/single_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use hex::ToHex;
use slog_scope::{info, trace, warn};
use thiserror::Error;

use mithril::RegisterError;
use mithril_common::crypto_helper::{
key_decode_hex, key_encode_hex, ProtocolClerk, ProtocolInitializer, ProtocolKeyRegistration,
ProtocolSigner,
ProtocolRegistrationError, ProtocolSigner,
};
use mithril_common::entities::{
PartyId, ProtocolMessage, ProtocolParameters, SignerWithStake, SingleSignatures, Stake,
Expand Down Expand Up @@ -83,7 +82,7 @@ pub enum SingleSignerError {

/// Could not fetch a signer from a protocol initializer.
#[error("the protocol initializer is not registered")]
ProtocolInitializerNotRegistered(#[from] RegisterError),
ProtocolInitializerNotRegistered(#[from] ProtocolRegistrationError),

/// Encoding / Decoding error.
#[error("codec error: '{0}'")]
Expand Down

0 comments on commit 1b8680a

Please sign in to comment.