1
1
//! API for mithril key certification.
2
- //! Includes the wrappers for StmInitializer and KeyReg , and ProtocolRegistrationErrorWrapper.
2
+ //! Includes the wrappers for Initializer and KeyRegistration , and ProtocolRegistrationErrorWrapper.
3
3
//! These wrappers allows keeping mithril-stm agnostic to Cardano, while providing some
4
4
//! guarantees that mithril-stm will not be misused in the context of Cardano.
5
5
@@ -15,8 +15,8 @@ use serde::{Deserialize, Serialize};
15
15
use thiserror:: Error ;
16
16
17
17
use mithril_stm:: {
18
- ClosedKeyReg , KeyReg , RegisterError , Stake , StmInitializer , StmParameters , StmSigner ,
19
- StmVerificationKeyPoP ,
18
+ ClosedKeyRegistration , Initializer , KeyRegistration , Parameters , RegisterError , Signer , Stake ,
19
+ VerificationKeyProofOfPossession ,
20
20
} ;
21
21
22
22
use crate :: {
@@ -95,13 +95,13 @@ pub enum ProtocolInitializerErrorWrapper {
95
95
KesMismatch ( KesPeriod , KesPeriod ) ,
96
96
}
97
97
98
- /// Wrapper structure for [MithrilStm:StmInitializer ](mithril_stm::stm::StmInitializer ).
98
+ /// Wrapper structure for [MithrilStm:Initializer ](mithril_stm::stm::Initializer ).
99
99
/// It now obtains a KES signature over the Mithril key. This allows the signers prove
100
100
/// their correct identity with respect to a Cardano PoolID.
101
101
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
102
102
pub struct StmInitializerWrapper {
103
- /// The StmInitializer
104
- stm_initializer : StmInitializer ,
103
+ /// The Initializer
104
+ stm_initializer : Initializer ,
105
105
106
106
/// The KES signature over the Mithril key
107
107
///
@@ -110,17 +110,17 @@ pub struct StmInitializerWrapper {
110
110
}
111
111
112
112
impl StmInitializerWrapper {
113
- /// Builds an `StmInitializer ` that is ready to register with the key registration service.
113
+ /// Builds an `Initializer ` that is ready to register with the key registration service.
114
114
/// This function generates the signing and verification key with a PoP, signs the verification
115
115
/// key with a provided KES signer implementation, and initializes the structure.
116
116
pub fn setup < R : RngCore + CryptoRng > (
117
- params : StmParameters ,
117
+ params : Parameters ,
118
118
kes_signer : Option < Arc < dyn KesSigner > > ,
119
119
kes_period : Option < KesPeriod > ,
120
120
stake : Stake ,
121
121
rng : & mut R ,
122
122
) -> StdResult < Self > {
123
- let stm_initializer = StmInitializer :: setup ( params, stake, rng) ;
123
+ let stm_initializer = Initializer :: setup ( params, stake, rng) ;
124
124
let kes_signature = if let Some ( kes_signer) = kes_signer {
125
125
let ( signature, _op_cert) = kes_signer. sign (
126
126
& stm_initializer. verification_key ( ) . to_bytes ( ) ,
@@ -142,7 +142,7 @@ impl StmInitializerWrapper {
142
142
}
143
143
144
144
/// Extract the verification key.
145
- pub fn verification_key ( & self ) -> StmVerificationKeyPoP {
145
+ pub fn verification_key ( & self ) -> VerificationKeyProofOfPossession {
146
146
self . stm_initializer . verification_key ( )
147
147
}
148
148
@@ -163,8 +163,8 @@ impl StmInitializerWrapper {
163
163
164
164
/// Build the `avk` for the given list of parties.
165
165
///
166
- /// Note that if this StmInitializer was modified *between* the last call to `register`,
167
- /// then the resulting `StmSigner ` may not be able to produce valid signatures.
166
+ /// Note that if this Initializer was modified *between* the last call to `register`,
167
+ /// then the resulting `Signer ` may not be able to produce valid signatures.
168
168
///
169
169
/// Returns a `StmSignerWrapper` specialized to
170
170
/// * this `StmSignerWrapper`'s ID and current stake
@@ -175,8 +175,8 @@ impl StmInitializerWrapper {
175
175
/// This function fails if the initializer is not registered.
176
176
pub fn new_signer (
177
177
self ,
178
- closed_reg : ClosedKeyReg < D > ,
179
- ) -> Result < StmSigner < D > , ProtocolRegistrationErrorWrapper > {
178
+ closed_reg : ClosedKeyRegistration < D > ,
179
+ ) -> Result < Signer < D > , ProtocolRegistrationErrorWrapper > {
180
180
self . stm_initializer
181
181
. new_signer ( closed_reg)
182
182
. map_err ( ProtocolRegistrationErrorWrapper :: CoreRegister )
@@ -201,7 +201,7 @@ impl StmInitializerWrapper {
201
201
/// The function fails if the given string of bytes is not of required size.
202
202
pub fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self , RegisterError > {
203
203
let stm_initializer =
204
- StmInitializer :: from_bytes ( bytes. get ( ..256 ) . ok_or ( RegisterError :: SerializationError ) ?) ?;
204
+ Initializer :: from_bytes ( bytes. get ( ..256 ) . ok_or ( RegisterError :: SerializationError ) ?) ?;
205
205
let bytes = bytes. get ( 256 ..) . ok_or ( RegisterError :: SerializationError ) ?;
206
206
let kes_signature = if bytes. is_empty ( ) {
207
207
None
@@ -216,14 +216,14 @@ impl StmInitializerWrapper {
216
216
}
217
217
218
218
cfg_test_tools ! {
219
- /// Override the protocol parameters of the `StmInitializer ` for testing purposes only.
219
+ /// Override the protocol parameters of the `Initializer ` for testing purposes only.
220
220
pub fn override_protocol_parameters( & mut self , protocol_parameters: & ProtocolParameters ) {
221
221
self . stm_initializer. params = protocol_parameters. to_owned( ) ;
222
222
}
223
223
}
224
224
}
225
225
226
- /// Wrapper structure for [MithrilStm:KeyReg ](mithril_stm::key_reg::KeyReg ).
226
+ /// Wrapper structure for [MithrilStm:KeyRegistration ](mithril_stm::key_reg::KeyRegistration ).
227
227
/// The wrapper not only contains a map between `Mithril vkey <-> Stake`, but also
228
228
/// a map `PoolID <-> Stake`. This information is recovered from the node state, and
229
229
/// is used to verify the identity of a Mithril signer. Furthermore, the `register` function
@@ -232,7 +232,7 @@ impl StmInitializerWrapper {
232
232
#[ derive( Debug , Clone ) ]
233
233
pub struct KeyRegWrapper {
234
234
kes_verifier : Arc < dyn KesVerifier > ,
235
- stm_key_reg : KeyReg ,
235
+ stm_key_reg : KeyRegistration ,
236
236
stake_distribution : HashMap < ProtocolPartyId , Stake > ,
237
237
}
238
238
@@ -242,7 +242,7 @@ impl KeyRegWrapper {
242
242
pub fn init ( stake_dist : & ProtocolStakeDistribution ) -> Self {
243
243
Self {
244
244
kes_verifier : Arc :: new ( KesVerifierStandard ) ,
245
- stm_key_reg : KeyReg :: init ( ) ,
245
+ stm_key_reg : KeyRegistration :: init ( ) ,
246
246
stake_distribution : HashMap :: from_iter ( stake_dist. to_vec ( ) ) ,
247
247
}
248
248
}
@@ -293,8 +293,8 @@ impl KeyRegWrapper {
293
293
}
294
294
295
295
/// Finalize the key registration.
296
- /// This function disables `KeyReg ::register`, consumes the instance of `self`, and returns a `ClosedKeyReg `.
297
- pub fn close < D : Digest + FixedOutput > ( self ) -> ClosedKeyReg < D > {
296
+ /// This function disables `ClosedKeyRegistration ::register`, consumes the instance of `self`, and returns a `ClosedKeyRegistration `.
297
+ pub fn close < D : Digest + FixedOutput > ( self ) -> ClosedKeyRegistration < D > {
298
298
self . stm_key_reg . close ( )
299
299
}
300
300
}
@@ -317,7 +317,7 @@ mod test {
317
317
318
318
#[ test]
319
319
fn test_vector_key_reg ( ) {
320
- let params = StmParameters {
320
+ let params = Parameters {
321
321
m : 5 ,
322
322
k : 5 ,
323
323
phi_f : 1.0 ,
0 commit comments