Skip to content

Commit a8de81d

Browse files
committed
feat(aggregator): add support for aggregate signature type in multi signer aggregation
1 parent a37e292 commit a8de81d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

mithril-aggregator/src/dependency_injection/builder/protocol/certificates.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ impl DependenciesBuilder {
7474
}
7575

7676
async fn build_multi_signer(&mut self) -> Result<Arc<dyn MultiSigner>> {
77-
let multi_signer =
78-
MultiSignerImpl::new(self.get_epoch_service().await?, self.root_logger());
77+
let multi_signer = MultiSignerImpl::new(
78+
self.configuration.aggregate_signature_type(),
79+
self.get_epoch_service().await?,
80+
self.root_logger(),
81+
);
7982

8083
Ok(Arc::new(multi_signer))
8184
}

mithril-aggregator/src/multi_signer.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use async_trait::async_trait;
33
use slog::{Logger, debug, warn};
44

55
use mithril_common::{
6-
StdResult,
6+
AggregateSignatureType, StdResult,
77
crypto_helper::{ProtocolAggregationError, ProtocolMultiSignature},
88
entities::{self},
99
logging::LoggerExtensions,
@@ -40,16 +40,22 @@ pub trait MultiSigner: Sync + Send {
4040

4141
/// MultiSignerImpl is an implementation of the MultiSigner
4242
pub struct MultiSignerImpl {
43+
aggregate_signature_type: AggregateSignatureType,
4344
epoch_service: EpochServiceWrapper,
4445
logger: Logger,
4546
}
4647

4748
impl MultiSignerImpl {
4849
/// MultiSignerImpl factory
49-
pub fn new(epoch_service: EpochServiceWrapper, logger: Logger) -> Self {
50+
pub fn new(
51+
aggregate_signature_type: AggregateSignatureType,
52+
epoch_service: EpochServiceWrapper,
53+
logger: Logger,
54+
) -> Self {
5055
let logger = logger.new_with_component_name::<Self>();
5156
debug!(logger, "New MultiSignerImpl created");
5257
Self {
58+
aggregate_signature_type,
5359
epoch_service,
5460
logger,
5561
}
@@ -121,6 +127,7 @@ impl MultiSigner for MultiSignerImpl {
121127
match protocol_multi_signer.aggregate_single_signatures(
122128
&open_message.single_signatures,
123129
&open_message.protocol_message,
130+
self.aggregate_signature_type,
124131
) {
125132
Ok(multi_signature) => Ok(Some(multi_signature)),
126133
Err(ProtocolAggregationError::NotEnoughSignatures(actual, expected)) => {
@@ -183,6 +190,7 @@ mod tests {
183190
let fixture = MithrilFixtureBuilder::default().with_signers(5).build();
184191
let next_fixture = MithrilFixtureBuilder::default().with_signers(4).build();
185192
let multi_signer = MultiSignerImpl::new(
193+
AggregateSignatureType::default(),
186194
Arc::new(RwLock::new(
187195
FakeEpochServiceBuilder {
188196
current_epoch_settings: AggregatorEpochSettings {
@@ -243,6 +251,7 @@ mod tests {
243251
let fixture = MithrilFixtureBuilder::default().with_signers(5).build();
244252
let protocol_parameters = fixture.protocol_parameters();
245253
let multi_signer = MultiSignerImpl::new(
254+
AggregateSignatureType::default(),
246255
Arc::new(RwLock::new(FakeEpochService::from_fixture(epoch, &fixture))),
247256
TestLogger::stdout(),
248257
);

0 commit comments

Comments
 (0)