11//! 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.
33//! These wrappers allows keeping mithril-stm agnostic to Cardano, while providing some
44//! guarantees that mithril-stm will not be misused in the context of Cardano.
55
@@ -15,8 +15,8 @@ use serde::{Deserialize, Serialize};
1515use thiserror:: Error ;
1616
1717use mithril_stm:: {
18- ClosedKeyReg , KeyReg , RegisterError , Stake , StmInitializer , StmParameters , StmSigner ,
19- StmVerificationKeyPoP ,
18+ ClosedKeyRegistration , Initializer , KeyRegistration , Parameters , RegisterError , Signer , Stake ,
19+ VerificationKeyProofOfPossession ,
2020} ;
2121
2222use crate :: {
@@ -95,13 +95,13 @@ pub enum ProtocolInitializerErrorWrapper {
9595 KesMismatch ( KesPeriod , KesPeriod ) ,
9696}
9797
98- /// Wrapper structure for [MithrilStm:StmInitializer ](mithril_stm::stm::StmInitializer ).
98+ /// Wrapper structure for [MithrilStm:Initializer ](mithril_stm::stm::Initializer ).
9999/// It now obtains a KES signature over the Mithril key. This allows the signers prove
100100/// their correct identity with respect to a Cardano PoolID.
101101#[ derive( Debug , Clone , Serialize , Deserialize ) ]
102102pub struct StmInitializerWrapper {
103- /// The StmInitializer
104- stm_initializer : StmInitializer ,
103+ /// The Initializer
104+ stm_initializer : Initializer ,
105105
106106 /// The KES signature over the Mithril key
107107 ///
@@ -110,17 +110,17 @@ pub struct StmInitializerWrapper {
110110}
111111
112112impl 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.
114114 /// This function generates the signing and verification key with a PoP, signs the verification
115115 /// key with a provided KES signer implementation, and initializes the structure.
116116 pub fn setup < R : RngCore + CryptoRng > (
117- params : StmParameters ,
117+ params : Parameters ,
118118 kes_signer : Option < Arc < dyn KesSigner > > ,
119119 kes_period : Option < KesPeriod > ,
120120 stake : Stake ,
121121 rng : & mut R ,
122122 ) -> StdResult < Self > {
123- let stm_initializer = StmInitializer :: setup ( params, stake, rng) ;
123+ let stm_initializer = Initializer :: setup ( params, stake, rng) ;
124124 let kes_signature = if let Some ( kes_signer) = kes_signer {
125125 let ( signature, _op_cert) = kes_signer. sign (
126126 & stm_initializer. verification_key ( ) . to_bytes ( ) ,
@@ -142,7 +142,7 @@ impl StmInitializerWrapper {
142142 }
143143
144144 /// Extract the verification key.
145- pub fn verification_key ( & self ) -> StmVerificationKeyPoP {
145+ pub fn verification_key ( & self ) -> VerificationKeyProofOfPossession {
146146 self . stm_initializer . verification_key ( )
147147 }
148148
@@ -163,8 +163,8 @@ impl StmInitializerWrapper {
163163
164164 /// Build the `avk` for the given list of parties.
165165 ///
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.
168168 ///
169169 /// Returns a `StmSignerWrapper` specialized to
170170 /// * this `StmSignerWrapper`'s ID and current stake
@@ -175,8 +175,8 @@ impl StmInitializerWrapper {
175175 /// This function fails if the initializer is not registered.
176176 pub fn new_signer (
177177 self ,
178- closed_reg : ClosedKeyReg < D > ,
179- ) -> Result < StmSigner < D > , ProtocolRegistrationErrorWrapper > {
178+ closed_reg : ClosedKeyRegistration < D > ,
179+ ) -> Result < Signer < D > , ProtocolRegistrationErrorWrapper > {
180180 self . stm_initializer
181181 . new_signer ( closed_reg)
182182 . map_err ( ProtocolRegistrationErrorWrapper :: CoreRegister )
@@ -201,7 +201,7 @@ impl StmInitializerWrapper {
201201 /// The function fails if the given string of bytes is not of required size.
202202 pub fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self , RegisterError > {
203203 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 ) ?) ?;
205205 let bytes = bytes. get ( 256 ..) . ok_or ( RegisterError :: SerializationError ) ?;
206206 let kes_signature = if bytes. is_empty ( ) {
207207 None
@@ -216,14 +216,14 @@ impl StmInitializerWrapper {
216216 }
217217
218218 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.
220220 pub fn override_protocol_parameters( & mut self , protocol_parameters: & ProtocolParameters ) {
221221 self . stm_initializer. params = protocol_parameters. to_owned( ) ;
222222 }
223223 }
224224}
225225
226- /// Wrapper structure for [MithrilStm:KeyReg ](mithril_stm::key_reg::KeyReg ).
226+ /// Wrapper structure for [MithrilStm:KeyRegistration ](mithril_stm::key_reg::KeyRegistration ).
227227/// The wrapper not only contains a map between `Mithril vkey <-> Stake`, but also
228228/// a map `PoolID <-> Stake`. This information is recovered from the node state, and
229229/// is used to verify the identity of a Mithril signer. Furthermore, the `register` function
@@ -232,7 +232,7 @@ impl StmInitializerWrapper {
232232#[ derive( Debug , Clone ) ]
233233pub struct KeyRegWrapper {
234234 kes_verifier : Arc < dyn KesVerifier > ,
235- stm_key_reg : KeyReg ,
235+ stm_key_reg : KeyRegistration ,
236236 stake_distribution : HashMap < ProtocolPartyId , Stake > ,
237237}
238238
@@ -242,7 +242,7 @@ impl KeyRegWrapper {
242242 pub fn init ( stake_dist : & ProtocolStakeDistribution ) -> Self {
243243 Self {
244244 kes_verifier : Arc :: new ( KesVerifierStandard ) ,
245- stm_key_reg : KeyReg :: init ( ) ,
245+ stm_key_reg : KeyRegistration :: init ( ) ,
246246 stake_distribution : HashMap :: from_iter ( stake_dist. to_vec ( ) ) ,
247247 }
248248 }
@@ -293,8 +293,8 @@ impl KeyRegWrapper {
293293 }
294294
295295 /// 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 > {
298298 self . stm_key_reg . close ( )
299299 }
300300}
@@ -317,7 +317,7 @@ mod test {
317317
318318 #[ test]
319319 fn test_vector_key_reg ( ) {
320- let params = StmParameters {
320+ let params = Parameters {
321321 m : 5 ,
322322 k : 5 ,
323323 phi_f : 1.0 ,
0 commit comments