Skip to content

Commit 8a43590

Browse files
committed
Adapt code to last version of KES
1 parent a43b1b8 commit 8a43590

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ glob = "0.3"
2727
hex = "0.4.3"
2828
http = "0.2.6"
2929
jsonschema = "0.16.0"
30-
kes-summed-ed25519 = { git = "https://github.com/input-output-hk/kes", rev = "1418efa", features = ["serde_enabled"] }
30+
kes-summed-ed25519 = { version = "0.1.0", features = ["serde_enabled"] }
3131
mockall = "0.11.0"
3232
nom = "7.1"
3333
rand-chacha-dalek-compat = { package = "rand_chacha", version = "0.2" }

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use thiserror::Error;
2929
type D = Blake2b<U32>;
3030

3131
/// The KES period that is used to check if the KES keys is expired
32-
pub type KESPeriod = usize;
32+
pub type KESPeriod = u32;
3333

3434
/// New registration error
3535
#[derive(Error, Debug, PartialEq, Eq)]
@@ -53,7 +53,7 @@ pub enum ProtocolRegistrationErrorWrapper {
5353

5454
/// Error raised when a KES Signature verification fails
5555
#[error("KES signature verification error: CurrentKesPeriod={0}, StartKesPeriod={1}")]
56-
KesSignatureInvalid(usize, u64),
56+
KesSignatureInvalid(u32, u64),
5757

5858
/// Error raised when a KES Signature is needed but not provided
5959
#[error("missing KES signature")]
@@ -122,14 +122,11 @@ impl StmInitializerWrapper {
122122
// We need to perform the evolutions, as the key is stored in evolution 0 in `kes.skey`
123123
for period in 0..kes_period.unwrap_or_default() {
124124
kes_sk
125-
.update(period)
125+
.update()
126126
.map_err(|_| ProtocolInitializerErrorWrapper::KesUpdate(period))?;
127127
}
128128

129-
Some(kes_sk.sign(
130-
kes_period.unwrap_or_default(),
131-
&stm_initializer.verification_key().to_bytes(),
132-
))
129+
Some(kes_sk.sign(&stm_initializer.verification_key().to_bytes()))
133130
} else {
134131
println!("WARNING: Non certified signer registration by providing only a Pool Id is decommissionned and must be used for tests only!");
135132
None

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use blake2::{digest::consts::U28, Blake2b, Digest};
99
#[cfg(any(test, feature = "test_only"))]
1010
use ed25519_dalek::{Keypair as EdKeypair, Signer};
1111
use ed25519_dalek::{PublicKey as EdPublicKey, Signature as EdSignature, Verifier};
12-
use kes_summed_ed25519::common::PublicKey as KesPublicKey;
12+
use kes_summed_ed25519::PublicKey as KesPublicKey;
1313
use serde::de::Error;
1414
use serde::{Deserialize, Deserializer, Serialize, Serializer};
1515
use sha2::Sha256;

mithril-signer/src/single_signer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use std::path::PathBuf;
44
use thiserror::Error;
55

66
use mithril_common::crypto_helper::{
7-
key_decode_hex, key_encode_hex, ProtocolClerk, ProtocolInitializer, ProtocolKeyRegistration,
8-
ProtocolPartyId, ProtocolRegistrationError, ProtocolSigner, ProtocolStakeDistribution,
7+
key_decode_hex, key_encode_hex, KESPeriod, ProtocolClerk, ProtocolInitializer,
8+
ProtocolKeyRegistration, ProtocolPartyId, ProtocolRegistrationError, ProtocolSigner,
9+
ProtocolStakeDistribution,
910
};
1011
use mithril_common::entities::{
1112
PartyId, ProtocolMessage, ProtocolParameters, SignerWithStake, SingleSignatures, Stake,
@@ -38,7 +39,7 @@ impl MithrilProtocolInitializerBuilder {
3839
stake: &Stake,
3940
protocol_parameters: &ProtocolParameters,
4041
kes_secret_key_path: Option<PathBuf>,
41-
kes_period: Option<usize>,
42+
kes_period: Option<KESPeriod>,
4243
) -> Result<ProtocolInitializer, MithrilProtocolInitializerBuilderError> {
4344
let mut rng = rand_core::OsRng;
4445
let protocol_initializer = ProtocolInitializer::setup(

0 commit comments

Comments
 (0)