Skip to content

Commit 8a0bffa

Browse files
author
Damien LACHAUME / PALO-IT
committed
Change opcert parameter type in KeyRegWrapper register function
1 parent 0091164 commit 8a0bffa

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

mithril-aggregator/src/signer_registerer.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,7 @@ impl SignerRegisterer for MithrilSignerRegisterer {
222222
"" => None,
223223
party_id => Some(party_id.to_string()),
224224
};
225-
let operational_certificate = signer
226-
.operational_certificate
227-
.as_ref()
228-
.map(|op_cert| op_cert.to_owned().into());
229-
let kes_period = match &operational_certificate {
225+
let kes_period = match &signer.operational_certificate {
230226
Some(operational_certificate) => Some(
231227
self.chain_observer
232228
.get_current_kes_period(operational_certificate)
@@ -239,7 +235,7 @@ impl SignerRegisterer for MithrilSignerRegisterer {
239235
};
240236
let party_id_save = key_registration.register(
241237
party_id_register.clone(),
242-
operational_certificate,
238+
signer.operational_certificate.clone(),
243239
signer.verification_key_signature.clone(),
244240
kes_period,
245241
signer.verification_key.clone(),

mithril-common/src/crypto_helper/cardano/key_certification.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
//! guarantees that mithril-stm will not be misused in the context of Cardano.
55
66
use crate::crypto_helper::{
7-
cardano::{OpCert, ParseError, SerDeShelleyFileFormat},
7+
cardano::{ParseError, SerDeShelleyFileFormat},
88
types::{
99
ProtocolParameters, ProtocolPartyId, ProtocolSignerVerificationKey,
1010
ProtocolSignerVerificationKeySignature, ProtocolStakeDistribution,
1111
},
12+
ProtocolOpCert,
1213
};
1314

1415
use mithril_stm::key_reg::{ClosedKeyReg, KeyReg};
@@ -240,7 +241,7 @@ impl KeyRegWrapper {
240241
pub fn register(
241242
&mut self,
242243
party_id: Option<ProtocolPartyId>, // TODO: Parameter should be removed once the signer certification is fully deployed
243-
opcert: Option<OpCert>, // TODO: Option should be removed once the signer certification is fully deployed
244+
opcert: Option<ProtocolOpCert>, // TODO: Option should be removed once the signer certification is fully deployed
244245
kes_sig: Option<ProtocolSignerVerificationKeySignature>, // TODO: Option should be removed once the signer certification is fully deployed
245246
kes_period: Option<KESPeriod>,
246247
pk: ProtocolSignerVerificationKey,
@@ -299,7 +300,7 @@ impl KeyRegWrapper {
299300
mod test {
300301

301302
use super::*;
302-
use crate::crypto_helper::cardano::ColdKeyGenerator;
303+
use crate::crypto_helper::{cardano::ColdKeyGenerator, OpCert};
303304

304305
use rand_chacha::ChaCha20Rng;
305306
use rand_core::SeedableRng;
@@ -360,8 +361,9 @@ mod test {
360361
)
361362
.unwrap();
362363

363-
let opcert1: OpCert = OpCert::from_file(operational_certificate_file_1)
364-
.expect("opcert deserialization should not fail");
364+
let opcert1 = OpCert::from_file(operational_certificate_file_1)
365+
.expect("opcert deserialization should not fail")
366+
.into();
365367

366368
let key_registration_1 = key_reg.register(
367369
None,
@@ -381,8 +383,9 @@ mod test {
381383
)
382384
.unwrap();
383385

384-
let opcert2: OpCert = OpCert::from_file(operational_certificate_file_2)
385-
.expect("opcert deserialization should not fail");
386+
let opcert2 = OpCert::from_file(operational_certificate_file_2)
387+
.expect("opcert deserialization should not fail")
388+
.into();
386389

387390
let key_registration_2 = key_reg.register(
388391
None,

mithril-common/src/crypto_helper/tests_setup.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ fn setup_signer_with_stake(
9292
)
9393
}
9494

95-
fn decode_op_cert_in_dir(dir: Option<PathBuf>) -> Option<OpCert> {
95+
fn decode_op_cert_in_dir(dir: Option<PathBuf>) -> Option<ProtocolOpCert> {
9696
dir.as_ref().map(|dir| {
9797
OpCert::from_file(dir.join("opcert.cert"))
9898
.expect("operational certificate decoding should not fail")
99+
.into()
99100
})
100101
}
101102

@@ -122,7 +123,7 @@ pub fn setup_signers_from_stake_distribution(
122123
party_id,
123124
*stake,
124125
&protocol_initializer,
125-
operational_certificate.as_ref().map(|o| o.clone().into()),
126+
operational_certificate.clone(),
126127
kes_period,
127128
);
128129

mithril-common/src/protocol/signer_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl SignerBuilder {
5151
key_registration
5252
.register(
5353
Some(signer.party_id.to_owned()),
54-
signer.operational_certificate.as_deref().cloned(),
54+
signer.operational_certificate.clone(),
5555
signer.verification_key_signature.clone(),
5656
signer.kes_period,
5757
signer.verification_key.clone(),

0 commit comments

Comments
 (0)