Skip to content

Commit b7e1440

Browse files
committed
rename: merkle tree
1 parent 5ec7beb commit b7e1440

File tree

18 files changed

+123
-119
lines changed

18 files changed

+123
-119
lines changed

demo/protocol-demo/src/types.rs

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

@@ -11,29 +11,29 @@ type D = Blake2b<U32>;
1111
/// The id of a mithril party.
1212
pub type ProtocolPartyId = String;
1313

14-
/// Alias of [MithrilStm:Stake](type@mithril_stm::stm::Stake).
14+
/// Alias of [MithrilStm:Stake](type@mithril_stm::Stake).
1515
pub type ProtocolStake = Stake;
1616

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

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

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

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

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

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

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

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

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
};
1717

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

@@ -104,7 +104,7 @@ pub enum ProtocolInitializerErrorWrapper {
104104
#[derive(Debug, Clone, Serialize, Deserialize)]
105105
pub struct StmInitializerWrapper {
106106
/// The StmInitializer
107-
stm_initializer: Initializer,
107+
stm_initializer: StmInitializer,
108108

109109
/// The KES signature over the Mithril key
110110
///
@@ -120,7 +120,7 @@ pub struct StmInitializerWrapper {
120120
/// is valid with respect to the PoolID.
121121
#[derive(Debug, Clone)]
122122
pub struct KeyRegWrapper {
123-
stm_key_reg: KeyRegistration,
123+
stm_key_reg: KeyReg,
124124
stake_distribution: HashMap<ProtocolPartyId, Stake>,
125125
}
126126

@@ -129,13 +129,13 @@ impl StmInitializerWrapper {
129129
/// This function generates the signing and verification key with a PoP, signs the verification
130130
/// key with a provided KES signing key, and initializes the structure.
131131
pub fn setup<R: RngCore + CryptoRng, P: AsRef<Path>>(
132-
params: Parameters,
132+
params: StmParameters,
133133
kes_sk_path: Option<P>,
134134
kes_period: Option<KESPeriod>,
135135
stake: Stake,
136136
rng: &mut R,
137137
) -> StdResult<Self> {
138-
let stm_initializer = Initializer::setup(params, stake, rng);
138+
let stm_initializer = StmInitializer::setup(params, stake, rng);
139139
let kes_signature = if let Some(kes_sk_path) = kes_sk_path {
140140
let mut kes_sk_bytes = Sum6KesBytes::from_file(kes_sk_path)
141141
.map_err(|e| anyhow!(e))
@@ -205,8 +205,8 @@ impl StmInitializerWrapper {
205205
/// This function fails if the initializer is not registered.
206206
pub fn new_signer(
207207
self,
208-
closed_reg: ClosedKeyRegistration<D>,
209-
) -> Result<Signer<D>, ProtocolRegistrationErrorWrapper> {
208+
closed_reg: ClosedKeyReg<D>,
209+
) -> Result<StmSigner<D>, ProtocolRegistrationErrorWrapper> {
210210
self.stm_initializer
211211
.new_signer(closed_reg)
212212
.map_err(ProtocolRegistrationErrorWrapper::CoreRegister)
@@ -231,7 +231,7 @@ impl StmInitializerWrapper {
231231
/// The function fails if the given string of bytes is not of required size.
232232
pub fn from_bytes(bytes: &[u8]) -> Result<Self, RegisterError> {
233233
let stm_initializer =
234-
Initializer::from_bytes(bytes.get(..256).ok_or(RegisterError::SerializationError)?)?;
234+
StmInitializer::from_bytes(bytes.get(..256).ok_or(RegisterError::SerializationError)?)?;
235235
let bytes = bytes.get(256..).ok_or(RegisterError::SerializationError)?;
236236
let kes_signature = if bytes.is_empty() {
237237
None
@@ -258,7 +258,7 @@ impl KeyRegWrapper {
258258
/// but we should eventually transition to only use this one.
259259
pub fn init(stake_dist: &ProtocolStakeDistribution) -> Self {
260260
Self {
261-
stm_key_reg: KeyRegistration::init(),
261+
stm_key_reg: KeyReg::init(),
262262
stake_distribution: HashMap::from_iter(stake_dist.to_vec()),
263263
}
264264
}
@@ -319,7 +319,7 @@ impl KeyRegWrapper {
319319

320320
/// Finalize the key registration.
321321
/// This function disables `KeyReg::register`, consumes the instance of `self`, and returns a `ClosedKeyReg`.
322-
pub fn close<D: Digest + FixedOutput>(self) -> ClosedKeyRegistration<D> {
322+
pub fn close<D: Digest + FixedOutput>(self) -> ClosedKeyReg<D> {
323323
self.stm_key_reg.close()
324324
}
325325
}
@@ -364,7 +364,7 @@ mod test {
364364

365365
#[test]
366366
fn test_vector_key_reg() {
367-
let params = Parameters {
367+
let params = StmParameters {
368368
m: 5,
369369
k: 5,
370370
phi_f: 1.0,

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

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

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

4444
use super::*;
4545

4646
type D = Blake2b<U32>;
4747

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

54-
impl TryFromBytes for Parameters {
54+
impl TryFromBytes for StmParameters {
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 SingleSignature {
60+
impl TryToBytes for StmSig {
6161
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
6262
Ok(self.to_bytes().to_vec())
6363
}
6464
}
6565

66-
impl TryFromBytes for SingleSignature {
66+
impl TryFromBytes for StmSig {
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 SingleSignatureWithRegisteredParty {
72+
impl TryToBytes for StmSigRegParty {
7373
fn to_bytes_vec(&self) -> StdResult<Vec<u8>> {
7474
Ok(self.to_bytes().to_vec())
7575
}
7676
}
7777

78-
impl TryFromBytes for SingleSignatureWithRegisteredParty {
78+
impl TryFromBytes for StmSigRegParty {
7979
fn try_from_bytes(bytes: &[u8]) -> StdResult<Self> {
8080
Self::from_bytes::<D>(bytes).map_err(|e| e.into())
8181
}
@@ -135,13 +135,13 @@ mod binary_mithril_stm {
135135
}
136136
}
137137

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

144-
impl TryFromBytes for Initializer {
144+
impl TryFromBytes for StmInitializer {
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: 4 additions & 4 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, ClosedKeyRegistration, Index, Parameters, Signer, Stake, StmClerk,
7+
AggregationError, ClosedKeyReg, Index, Stake, StmClerk, StmParameters, StmSigner,
88
};
99

1010
use blake2::{digest::consts::U32, Blake2b};
@@ -25,13 +25,13 @@ pub type ProtocolStake = Stake;
2525
pub type ProtocolStakeDistribution = Vec<(ProtocolPartyId, ProtocolStake)>;
2626

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

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

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

3636
/// Alias of a wrapper of [MithrilStm:StmInitializer](struct@mithril_stm::StmInitializer).
3737
pub type ProtocolInitializer = StmInitializerWrapper;
@@ -43,7 +43,7 @@ pub type ProtocolClerk = StmClerk<D>;
4343
pub type ProtocolKeyRegistration = KeyRegWrapper;
4444

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

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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use kes_summed_ed25519::kes::Sum6KesSig;
2-
use mithril_stm::{SingleSignature, StmAggrSig, StmAggrVerificationKey, StmVerificationKeyPoP};
2+
use mithril_stm::{StmAggrSig, StmAggrVerificationKey, StmSig, StmVerificationKeyPoP};
33

44
use crate::crypto_helper::{MKMapProof, MKProof, OpCert, ProtocolKey, D};
55
use crate::entities::BlockRange;
@@ -12,8 +12,8 @@ pub type ProtocolSignerVerificationKey = ProtocolKey<StmVerificationKeyPoP>;
1212
/// serialization utilities.
1313
pub type ProtocolSignerVerificationKeySignature = ProtocolKey<Sum6KesSig>;
1414

15-
/// Wrapper of [MithrilStm:SingleSignature](type@SingleSignature) to add serialization utilities.
16-
pub type ProtocolSingleSignature = ProtocolKey<SingleSignature>;
15+
/// Wrapper of [MithrilStm:StmSig](type@StmSig) to add serialization utilities.
16+
pub type ProtocolSingleSignature = ProtocolKey<StmSig>;
1717

1818
/// Wrapper of [MithrilStm:StmAggrSig](struct@StmAggrSig) to add serialization utilities.
1919
pub type ProtocolMultiSignature = ProtocolKey<StmAggrSig<D>>;
@@ -33,5 +33,5 @@ impl_codec_and_type_conversions_for_protocol_key!(
3333
);
3434

3535
impl_codec_and_type_conversions_for_protocol_key!(
36-
bytes_hex_codec => SingleSignature, ed25519_dalek::Signature
36+
bytes_hex_codec => StmSig, ed25519_dalek::Signature
3737
);

mithril-common/src/entities/single_signature.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use mithril_stm::SingleSignature as StmSingleSignature;
1+
use mithril_stm::StmSig;
22
use serde::{Deserialize, Serialize};
33
use std::fmt::{Debug, Formatter};
44

@@ -52,7 +52,7 @@ impl SingleSignature {
5252
}
5353

5454
/// Convert this [SingleSignature] to its corresponding [MithrilStm Signature][StmSig].
55-
pub fn to_protocol_signature(&self) -> StmSingleSignature {
55+
pub fn to_protocol_signature(&self) -> StmSig {
5656
self.signature.clone().into()
5757
}
5858

mithril-common/src/protocol/multi_signer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::{anyhow, Context};
2-
use mithril_stm::Parameters;
2+
use mithril_stm::StmParameters;
33

44
use crate::{
55
crypto_helper::{
@@ -14,11 +14,11 @@ use crate::{
1414
/// MultiSigner is the cryptographic engine in charge of producing multi-signatures from individual signatures
1515
pub struct MultiSigner {
1616
protocol_clerk: ProtocolClerk,
17-
protocol_parameters: Parameters,
17+
protocol_parameters: StmParameters,
1818
}
1919

2020
impl MultiSigner {
21-
pub(super) fn new(protocol_clerk: ProtocolClerk, protocol_parameters: Parameters) -> Self {
21+
pub(super) fn new(protocol_clerk: ProtocolClerk, protocol_parameters: StmParameters) -> Self {
2222
Self {
2323
protocol_clerk,
2424
protocol_parameters,

mithril-common/src/test_utils/fake_keys.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ mod test {
392392
use super::*;
393393
use ed25519_dalek::VerifyingKey;
394394
use kes_summed_ed25519::kes::Sum6KesSig;
395-
use mithril_stm::{StmAggrSig, StmAggrVerificationKey, SingleSignature, StmVerificationKeyPoP};
395+
use mithril_stm::{StmAggrSig, StmAggrVerificationKey, StmSig, StmVerificationKeyPoP};
396396
use serde::{de::DeserializeOwned, Serialize};
397397
use std::any::type_name;
398398

@@ -452,9 +452,9 @@ mod test {
452452

453453
#[test]
454454
fn assert_encoded_single_signatures_are_still_matching_concrete_type() {
455-
assert_can_deserialize_using_key_decode_hex::<SingleSignature>(&single_signature());
455+
assert_can_deserialize_using_key_decode_hex::<StmSig>(&single_signature());
456456

457-
assert_can_convert_to_protocol_key::<SingleSignature>(&single_signature());
457+
assert_can_convert_to_protocol_key::<StmSig>(&single_signature());
458458
}
459459

460460
#[test]

mithril-stm/src/aggregate_signature/aggregate_key.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
use blake2::digest::{Digest, FixedOutput};
22
use serde::{Deserialize, Serialize};
33

4-
use crate::merkle_tree::{BatchPath, MerkleTreeCommitmentBatchCompat};
4+
use crate::merkle_tree::{MerkleBatchPath, MerkleTreeBatchCommitment};
55
use crate::{ClosedKeyRegistration, Stake};
66

77
/// Stm aggregate key (batch compatible), which contains the merkle tree commitment and the total stake of the system.
88
/// Batch Compat Merkle tree commitment includes the number of leaves in the tree in order to obtain batch path.
99
#[derive(Debug, Clone, Serialize, Deserialize)]
1010
#[serde(bound(
11-
serialize = "BatchPath<D>: Serialize",
12-
deserialize = "BatchPath<D>: Deserialize<'de>"
11+
serialize = "MerkleBatchPath<D>: Serialize",
12+
deserialize = "MerkleBatchPath<D>: Deserialize<'de>"
1313
))]
1414
pub struct StmAggrVerificationKey<D: Clone + Digest + FixedOutput> {
15-
mt_commitment: MerkleTreeCommitmentBatchCompat<D>,
15+
mt_commitment: MerkleTreeBatchCommitment<D>,
1616
total_stake: Stake,
1717
}
1818

1919
impl<D: Digest + Clone + FixedOutput> StmAggrVerificationKey<D> {
20-
pub fn get_mt_commitment(&self) -> MerkleTreeCommitmentBatchCompat<D> {
20+
pub fn get_mt_commitment(&self) -> MerkleTreeBatchCommitment<D> {
2121
self.mt_commitment.clone()
2222
}
2323

mithril-stm/src/aggregate_signature/core_verifier.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::{BTreeMap, HashMap, HashSet};
22

33
use crate::bls_multi_signature::{Signature, VerificationKey};
44
use crate::key_reg::RegisteredParty;
5-
use crate::merkle_tree::MTLeaf;
5+
use crate::merkle_tree::MerkleTreeLeaf;
66
use crate::{
77
AggregationError, CoreVerifierError, Index, Parameters, SingleSignature,
88
SingleSignatureWithRegisteredParty, Stake,
@@ -30,7 +30,7 @@ impl CoreVerifier {
3030
panic!("Total stake overflow");
3131
}
3232
total_stake = res;
33-
unique_parties.insert(MTLeaf(signer.0, signer.1));
33+
unique_parties.insert(MerkleTreeLeaf(signer.0, signer.1));
3434
}
3535

3636
let mut eligible_parties: Vec<_> = unique_parties.into_iter().collect();

0 commit comments

Comments
 (0)