@@ -65,6 +65,17 @@ pub enum ProtocolRegistrationErrorWrapper {
65
65
CoreRegister ( #[ from] RegisterError ) ,
66
66
}
67
67
68
+ /// New initializer error
69
+ #[ derive( Error , Debug ) ]
70
+ pub enum ProtocolInitializerErrorWrapper {
71
+ /// Error raised when a codec parse error occurs
72
+ #[ error( "codec parse error: '{0}'" ) ]
73
+ Codec ( #[ from] ParseError ) ,
74
+
75
+ /// Error raised when a KES update error occurs
76
+ #[ error( "KES key cannot be updated for period {0}" ) ]
77
+ KesUpdate ( KESPeriod ) ,
78
+ }
68
79
/// Wrapper structure for [MithrilCore:StmInitializer](https://mithril.network/mithril-core/doc/mithril/stm/struct.StmInitializer.html).
69
80
/// It now obtains a KES signature over the Mithril key. This allows the signers prove
70
81
/// their correct identity with respect to a Cardano PoolID.
@@ -96,10 +107,18 @@ impl StmInitializerWrapper {
96
107
kes_period : Option < KESPeriod > ,
97
108
stake : Stake ,
98
109
rng : & mut R ,
99
- ) -> Result < Self , ParseError > {
110
+ ) -> Result < Self , ProtocolInitializerErrorWrapper > {
100
111
let stm_initializer = StmInitializer :: setup ( params, stake, rng) ;
101
112
let kes_signature = if let Some ( kes_sk_path) = kes_sk_path {
102
- let kes_sk: Sum6Kes = Sum6Kes :: from_file ( kes_sk_path) ?;
113
+ let mut kes_sk: Sum6Kes = Sum6Kes :: from_file ( kes_sk_path) ?;
114
+
115
+ // We need to perform the evolutions, as the key is stored in evolution 0 in `kes.skey`
116
+ for period in 0 ..kes_period. unwrap_or_default ( ) {
117
+ kes_sk
118
+ . update ( period)
119
+ . map_err ( |_| ProtocolInitializerErrorWrapper :: KesUpdate ( period) ) ?;
120
+ }
121
+
103
122
Some ( kes_sk. sign (
104
123
kes_period. unwrap_or_default ( ) ,
105
124
& stm_initializer. verification_key ( ) . to_bytes ( ) ,
0 commit comments