Skip to content

Commit 5d9f1bb

Browse files
committed
deprecate old struct names
1 parent 81d08dc commit 5d9f1bb

File tree

19 files changed

+172
-139
lines changed

19 files changed

+172
-139
lines changed

demo/protocol-demo/src/types.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use mithril_stm::{
2-
KeyReg, Stake, StmAggrSig, StmClerk, StmInitializer, StmParameters, StmSig, StmSigner,
3-
StmVerificationKeyPoP,
2+
AggregateSignature, Clerk, Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
3+
Stake, VerificationKeyProofOfPossession,
44
};
55

66
use blake2::{Blake2b, digest::consts::U32};
@@ -14,26 +14,26 @@ pub type ProtocolPartyId = String;
1414
/// Alias of [MithrilStm:Stake](type@mithril_stm::Stake).
1515
pub type ProtocolStake = Stake;
1616

17-
/// Alias of [MithrilStm::StmParameters](struct@mithril_stm::StmParameters).
18-
pub type ProtocolParameters = StmParameters;
17+
/// Alias of [MithrilStm::Parameters](struct@mithril_stm::Parameters).
18+
pub type ProtocolParameters = Parameters;
1919

20-
/// Alias of [MithrilStm:StmSigner](struct@mithril_stm::StmSigner).
21-
pub type ProtocolSigner = StmSigner<D>;
20+
/// Alias of [MithrilStm:Signer](struct@mithril_stm::Signer).
21+
pub type ProtocolSigner = Signer<D>;
2222

23-
/// Alias of [MithrilStm:StmClerk](struct@mithril_stm::StmClerk).
24-
pub type ProtocolClerk = StmClerk<D>;
23+
/// Alias of [MithrilStm:Clerk](struct@mithril_stm::Clerk).
24+
pub type ProtocolClerk = Clerk<D>;
2525

26-
/// Alias of [MithrilStm:StmInitializer](struct@mithril_stm::StmInitializer).
27-
pub type ProtocolInitializerNotCertified = StmInitializer;
26+
/// Alias of [MithrilStm:Initializer](struct@mithril_stm::Initializer).
27+
pub type ProtocolInitializerNotCertified = Initializer;
2828

29-
/// Alias of [MithrilStm:KeyReg](struct@mithril_stm::KeyReg). (Test only)
30-
pub type ProtocolKeyRegistrationNotCertified = KeyReg;
29+
/// Alias of [MithrilStm:KeyRegistration](struct@mithril_stm::KeyRegistration). (Test only)
30+
pub type ProtocolKeyRegistrationNotCertified = KeyRegistration;
3131

32-
/// Alias of [MithrilStm:StmSig](struct@mithril_stm::StmSig).
33-
pub type ProtocolSingleSignature = StmSig;
32+
/// Alias of [MithrilStm:SingleSignature](struct@mithril_stm::SingleSignature).
33+
pub type ProtocolSingleSignature = SingleSignature;
3434

35-
/// Alias of [MithrilStm:StmAggrSig](struct@mithril_stm::StmAggrSig).
36-
pub type ProtocolMultiSignature = StmAggrSig<D>;
35+
/// Alias of [MithrilStm:AggregateSignature](struct@mithril_stm::AggregateSignature).
36+
pub type ProtocolMultiSignature = AggregateSignature<D>;
3737

38-
/// Alias of [MithrilStm:StmVerificationKeyPoP](type@mithril_stm::StmVerificationKeyPoP).
39-
pub type ProtocolSignerVerificationKey = StmVerificationKeyPoP;
38+
/// Alias of [MithrilStm:VerificationKeyProofOfPossession](type@mithril_stm::VerificationKeyProofOfPossession).
39+
pub type ProtocolSignerVerificationKey = VerificationKeyProofOfPossession;

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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};
1515
use thiserror::Error;
1616

1717
use mithril_stm::{
18-
ClosedKeyReg, KeyReg, RegisterError, Stake, StmInitializer, StmParameters, StmSigner,
19-
StmVerificationKeyPoP,
18+
ClosedKeyRegistration, Initializer, KeyRegistration, Parameters, RegisterError, Signer, Stake,
19+
VerificationKeyProofOfPossession,
2020
};
2121

2222
use 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)]
102102
pub 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

112112
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.
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)]
233233
pub 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,

mithril-common/src/crypto_helper/codec/binary.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,95 +37,95 @@ mod binary_mithril_stm {
3737

3838
use digest::consts::U32;
3939
use mithril_stm::{
40-
StmAggrSig, StmAggrVerificationKey, StmInitializer, StmParameters, StmSig, StmSigRegParty,
41-
StmVerificationKey, StmVerificationKeyPoP,
40+
AggregateSignature, AggregateVerificationKey, Initializer, Parameters, SingleSignature,
41+
SingleSignatureWithRegisteredParty, VerificationKey, VerificationKeyProofOfPossession,
4242
};
4343

4444
use super::*;
4545

4646
type D = Blake2b<U32>;
4747

48-
impl TryToBytes for StmParameters {
48+
impl TryToBytes for Parameters {
4949
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
5050
Ok(self.to_bytes().to_vec())
5151
}
5252
}
5353

54-
impl TryFromBytes for StmParameters {
54+
impl TryFromBytes for Parameters {
5555
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
5656
Self::from_bytes(bytes).map_err(|e| e.into())
5757
}
5858
}
5959

60-
impl TryToBytes for StmSig {
60+
impl TryToBytes for SingleSignature {
6161
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
6262
Ok(self.to_bytes().to_vec())
6363
}
6464
}
6565

66-
impl TryFromBytes for StmSig {
66+
impl TryFromBytes for SingleSignature {
6767
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
6868
Self::from_bytes::<D>(bytes).map_err(|e| e.into())
6969
}
7070
}
7171

72-
impl TryToBytes for StmSigRegParty {
72+
impl TryToBytes for SingleSignatureWithRegisteredParty {
7373
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
7474
Ok(self.to_bytes().to_vec())
7575
}
7676
}
7777

78-
impl TryFromBytes for StmSigRegParty {
78+
impl TryFromBytes for SingleSignatureWithRegisteredParty {
7979
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
8080
Self::from_bytes::<D>(bytes).map_err(|e| e.into())
8181
}
8282
}
8383

84-
impl TryToBytes for StmAggrSig<D> {
84+
impl TryToBytes for AggregateSignature<D> {
8585
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
8686
Ok(self.to_bytes().to_vec())
8787
}
8888
}
8989

90-
impl TryFromBytes for StmAggrSig<D> {
90+
impl TryFromBytes for AggregateSignature<D> {
9191
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
9292
Self::from_bytes(bytes).map_err(|e| anyhow!("{e}"))
9393
}
9494
}
9595

96-
impl TryToBytes for StmVerificationKey {
96+
impl TryToBytes for VerificationKey {
9797
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
9898
Ok(self.to_bytes().to_vec())
9999
}
100100
}
101101

102-
impl TryFromBytes for StmVerificationKey {
102+
impl TryFromBytes for VerificationKey {
103103
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
104104
Self::from_bytes(bytes).map_err(|e| e.into())
105105
}
106106
}
107107

108-
impl TryToBytes for StmVerificationKeyPoP {
108+
impl TryToBytes for VerificationKeyProofOfPossession {
109109
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
110110
Ok(self.to_bytes().to_vec())
111111
}
112112
}
113113

114-
impl TryFromBytes for StmVerificationKeyPoP {
114+
impl TryFromBytes for VerificationKeyProofOfPossession {
115115
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
116116
Self::from_bytes(bytes).map_err(|e| e.into())
117117
}
118118
}
119119

120-
impl TryToBytes for StmAggrVerificationKey<D> {
120+
impl TryToBytes for AggregateVerificationKey<D> {
121121
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
122122
bincode::serde::encode_to_vec(self, bincode::config::standard()).map_err(|e| e.into())
123123
}
124124
}
125125

126-
impl TryFromBytes for StmAggrVerificationKey<D> {
126+
impl TryFromBytes for AggregateVerificationKey<D> {
127127
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
128-
let (res, _) = bincode::serde::decode_from_slice::<StmAggrVerificationKey<D>, _>(
128+
let (res, _) = bincode::serde::decode_from_slice::<AggregateVerificationKey<D>, _>(
129129
bytes,
130130
bincode::config::standard(),
131131
)
@@ -135,13 +135,13 @@ mod binary_mithril_stm {
135135
}
136136
}
137137

138-
impl TryToBytes for StmInitializer {
138+
impl TryToBytes for Initializer {
139139
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
140140
Ok(self.to_bytes().to_vec())
141141
}
142142
}
143143

144-
impl TryFromBytes for StmInitializer {
144+
impl TryFromBytes for Initializer {
145145
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
146146
Self::from_bytes(bytes).map_err(|e| e.into())
147147
}

mithril-common/src/crypto_helper/types/alias.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::crypto_helper::cardano::{
44
};
55

66
use mithril_stm::{
7-
AggregationError, ClosedKeyReg, Index, Stake, StmClerk, StmParameters, StmSigner,
7+
AggregationError, Clerk, ClosedKeyRegistration, Index, Parameters, Signer, Stake,
88
};
99

1010
use blake2::{Blake2b, digest::consts::U32};
@@ -24,26 +24,26 @@ pub type ProtocolStake = Stake;
2424
/// A list of [Party Id][ProtocolPartyId] associated with its [Stake][ProtocolStake].
2525
pub type ProtocolStakeDistribution = Vec<(ProtocolPartyId, ProtocolStake)>;
2626

27-
/// Alias of [MithrilStm::StmParameters](struct@mithril_stm::StmParameters).
28-
pub type ProtocolParameters = StmParameters;
27+
/// Alias of [MithrilStm::Parameters](struct@mithril_stm::Parameters).
28+
pub type ProtocolParameters = Parameters;
2929

3030
/// Alias of [MithrilStm::Index](type@mithril_stm::Index).
3131
pub type ProtocolLotteryIndex = Index;
3232

33-
/// Alias of [MithrilStm:StmSigner](struct@mithril_stm::StmSigner).
34-
pub type ProtocolSigner = StmSigner<D>;
33+
/// Alias of [MithrilStm:Signer](struct@mithril_stm::Signer).
34+
pub type ProtocolSigner = Signer<D>;
3535

36-
/// Alias of a wrapper of [MithrilStm:StmInitializer](struct@mithril_stm::StmInitializer).
36+
/// Alias of a wrapper of [MithrilStm:Initializer](struct@mithril_stm::Initializer).
3737
pub type ProtocolInitializer = StmInitializerWrapper;
3838

39-
/// Alias of [MithrilStm:StmClerk](struct@mithril_stm::StmClerk).
40-
pub type ProtocolClerk = StmClerk<D>;
39+
/// Alias of [MithrilStm:Clerk](struct@mithril_stm::Clerk).
40+
pub type ProtocolClerk = Clerk<D>;
4141

42-
/// Alias of a wrapper of [MithrilStm:KeyReg](struct@mithril_stm::KeyReg).
42+
/// Alias of a wrapper of [MithrilStm:KeyRegistration](struct@mithril_stm::KeyRegistration).
4343
pub type ProtocolKeyRegistration = KeyRegWrapper;
4444

45-
/// Alias of a wrapper of [MithrilStm:ClosedKeyReg](struct@mithril_stm::KeyReg).
46-
pub type ProtocolClosedKeyRegistration = ClosedKeyReg<D>;
45+
/// Alias of a wrapper of [MithrilStm:ClosedKeyRegistration](struct@mithril_stm::ClosedKeyRegistration).
46+
pub type ProtocolClosedKeyRegistration = ClosedKeyRegistration<D>;
4747

4848
// Error alias
4949
/// Alias of a wrapper of [MithrilCommon:ProtocolRegistrationErrorWrapper](enum@ProtocolRegistrationErrorWrapper).

0 commit comments

Comments
 (0)