Skip to content

Commit 2bf7119

Browse files
committed
rename types, review suggestions, final corrections
1 parent 79bfa03 commit 2bf7119

File tree

20 files changed

+98
-90
lines changed

20 files changed

+98
-90
lines changed

mithril-stm/benches/size_benches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use blake2::{
55
};
66
use mithril_stm::{
77
BasicVerifier, Clerk, Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
8-
SingleSignatureWithRegisteredParty, Stake, StmVerificationKey,
8+
SingleSignatureWithRegisteredParty, Stake, VerificationKey,
99
};
1010
use rand_chacha::ChaCha20Rng;
1111
use rand_core::{RngCore, SeedableRng};
@@ -70,7 +70,7 @@ where
7070
let mut msg = [0u8; 16];
7171
rng.fill_bytes(&mut msg);
7272

73-
let mut public_signers: Vec<(StmVerificationKey, Stake)> = Vec::with_capacity(nparties);
73+
let mut public_signers: Vec<(VerificationKey, Stake)> = Vec::with_capacity(nparties);
7474
let mut initializers: Vec<Initializer> = Vec::with_capacity(nparties);
7575

7676
let parties = (0..nparties)

mithril-stm/benches/stm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use blake2::{digest::consts::U32, Blake2b};
33
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
44
use mithril_stm::{
55
AggregateSignature, BasicVerifier, Clerk, Initializer, KeyRegistration, Parameters, Signer,
6-
Stake, StmVerificationKey,
6+
Stake, VerificationKey,
77
};
88
use rand_chacha::ChaCha20Rng;
99
use rand_core::{RngCore, SeedableRng};
@@ -151,7 +151,7 @@ fn batch_benches<H>(
151151
}
152152
}
153153

154-
fn core_verifier_benches<H>(c: &mut Criterion, nr_parties: usize, params: Parameters)
154+
fn basic_verifier_benches<H>(c: &mut Criterion, nr_parties: usize, params: Parameters)
155155
where
156156
H: Clone + Debug + Digest + Send + Sync + FixedOutput + Default,
157157
{
@@ -160,7 +160,7 @@ where
160160
let mut msg = [0u8; 16];
161161
rng.fill_bytes(&mut msg);
162162

163-
let mut public_signers: Vec<(StmVerificationKey, Stake)> = Vec::with_capacity(nr_parties);
163+
let mut public_signers: Vec<(VerificationKey, Stake)> = Vec::with_capacity(nr_parties);
164164
let mut initializers: Vec<Initializer> = Vec::with_capacity(nr_parties);
165165

166166
let param_string = format!(
@@ -229,7 +229,7 @@ fn stm_benches_blake_300(c: &mut Criterion) {
229229
}
230230

231231
fn core_verifier_benches_blake_300(c: &mut Criterion) {
232-
core_verifier_benches::<Blake2b<U32>>(
232+
basic_verifier_benches::<Blake2b<U32>>(
233233
c,
234234
300,
235235
Parameters {
@@ -268,7 +268,7 @@ fn stm_benches_blake_2000(c: &mut Criterion) {
268268
}
269269

270270
fn core_verifier_benches_blake_2000(c: &mut Criterion) {
271-
core_verifier_benches::<Blake2b<U32>>(
271+
basic_verifier_benches::<Blake2b<U32>>(
272272
c,
273273
2000,
274274
Parameters {

mithril-stm/examples/key_registration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use blake2::{digest::consts::U32, Blake2b};
55
use mithril_stm::{
66
Clerk, ClosedKeyRegistration, Initializer, KeyRegistration, Parameters, Stake,
7-
StmVerificationKeyPoP,
7+
VerificationKeyProofOfPossession,
88
};
99

1010
use rand_chacha::ChaCha20Rng;
@@ -44,7 +44,7 @@ fn main() {
4444
let party_3_init = Initializer::setup(params, stakes[3], &mut rng);
4545

4646
// The public keys are broadcast. All participants will have the same keys.
47-
let parties_pks: Vec<StmVerificationKeyPoP> = vec![
47+
let parties_pks: Vec<VerificationKeyProofOfPossession> = vec![
4848
party_0_init.verification_key(),
4949
party_1_init.verification_key(),
5050
party_2_init.verification_key(),
@@ -133,7 +133,7 @@ fn main() {
133133
assert!(msig_3.is_err());
134134
}
135135

136-
fn local_reg(ids: &[u64], pks: &[StmVerificationKeyPoP]) -> ClosedKeyRegistration<H> {
136+
fn local_reg(ids: &[u64], pks: &[VerificationKeyProofOfPossession]) -> ClosedKeyRegistration<H> {
137137
let mut local_keyreg = KeyRegistration::init();
138138
// data, such as the public key, stake and id.
139139
for (&pk, id) in pks.iter().zip(ids.iter()) {

mithril-stm/src/aggregate_signature/core_verifier.rs renamed to mithril-stm/src/aggregate_signature/basic_verifier.rs

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

33
use crate::bls_multi_signature::{BlsSignature, BlsVerificationKey};
4-
use crate::key_reg::RegisteredParty;
4+
use crate::key_registration::RegisteredParty;
55
use crate::merkle_tree::MerkleTreeLeaf;
66
use crate::{
77
AggregationError, CoreVerifierError, Index, Parameters, SingleSignature,
@@ -17,7 +17,7 @@ pub struct BasicVerifier {
1717
}
1818

1919
impl BasicVerifier {
20-
/// Setup a core verifier for given list of signers.
20+
/// Setup a basic verifier for given list of signers.
2121
/// * Collect the unique signers in a hash set,
2222
/// * Calculate the total stake of the eligible signers,
2323
/// * Sort the eligible signers.
@@ -164,7 +164,7 @@ impl BasicVerifier {
164164
Err(AggregationError::NotEnoughSignatures(count, params.k))
165165
}
166166

167-
/// Collect and return `Vec<Signature>, Vec<VerificationKey>` which will be used
167+
/// Collect and return `Vec<BlsSignature>, Vec<BlsVerificationKey>` which will be used
168168
/// by the aggregate verification.
169169
pub(crate) fn collect_sigs_vks(
170170
sig_reg_list: &[SingleSignatureWithRegisteredParty],

mithril-stm/src/aggregate_signature/clerk.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use blake2::digest::{Digest, FixedOutput};
33
use crate::{
44
AggregateSignature, AggregateVerificationKey, AggregationError, BasicVerifier,
55
ClosedKeyRegistration, Index, Parameters, Signer, SingleSignature,
6-
SingleSignatureWithRegisteredParty, Stake, StmVerificationKey,
6+
SingleSignatureWithRegisteredParty, Stake, VerificationKey,
77
};
88

9-
/// `StmClerk` can verify and aggregate `StmSig`s and verify `StmMultiSig`s.
9+
/// `Clerk` can verify and aggregate `SingleSignature`s and verify `AggregateSignature`s.
1010
/// Clerks can only be generated with the registration closed.
1111
/// This avoids that a Merkle Tree is computed before all parties have registered.
1212
#[derive(Debug, Clone)]
@@ -43,7 +43,7 @@ impl<D: Digest + Clone + FixedOutput> Clerk<D> {
4343
/// This function first deduplicates the repeated signatures, and if there are enough signatures, it collects the merkle tree indexes of unique signatures.
4444
/// The list of merkle tree indexes is used to create a batch proof, to prove that all signatures are from eligible signers.
4545
///
46-
/// It returns an instance of `StmAggrSig`.
46+
/// It returns an instance of `AggregateSignature`.
4747
pub fn aggregate(
4848
&self,
4949
sigs: &[SingleSignature],
@@ -87,7 +87,7 @@ impl<D: Digest + Clone + FixedOutput> Clerk<D> {
8787
}
8888

8989
/// Get the (VK, stake) of a party given its index.
90-
pub fn get_reg_party(&self, party_index: &Index) -> Option<(StmVerificationKey, Stake)> {
90+
pub fn get_reg_party(&self, party_index: &Index) -> Option<(VerificationKey, Stake)> {
9191
self.closed_reg
9292
.reg_parties
9393
.get(*party_index as usize)

mithril-stm/src/aggregate_signature/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
mod aggregate_key;
2+
mod basic_verifier;
23
mod clerk;
3-
mod core_verifier;
44
mod signature;
55

66
pub use aggregate_key::*;
7+
pub use basic_verifier::*;
78
pub use clerk::*;
8-
pub use core_verifier::*;
99
pub use signature::*;
1010

1111
#[cfg(test)]
@@ -481,7 +481,7 @@ mod tests {
481481
}
482482

483483
// ---------------------------------------------------------------------
484-
// Core verifier
484+
// Basic verifier
485485
// ---------------------------------------------------------------------
486486
fn setup_equal_core_parties(
487487
params: Parameters,

mithril-stm/src/aggregate_signature/signature.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use blake2::digest::{Digest, FixedOutput};
33
use serde::{Deserialize, Serialize};
44

55
use crate::bls_multi_signature::{BlsSignature, BlsVerificationKey};
6-
use crate::key_reg::RegisteredParty;
6+
use crate::key_registration::RegisteredParty;
77
use crate::merkle_tree::MerkleBatchPath;
88
use crate::{
99
AggregateVerificationKey, BasicVerifier, Parameters, SingleSignatureWithRegisteredParty,
1010
StmAggregateSignatureError,
1111
};
1212

13-
/// `StmMultiSig` uses the "concatenation" proving system (as described in Section 4.3 of the original paper.)
13+
/// `AggregateSignature` uses the "concatenation" proving system (as described in Section 4.3 of the original paper.)
1414
/// This means that the aggregated signature contains a vector with all individual signatures.
1515
/// BatchPath is also a part of the aggregate signature which covers path for all signatures.
1616
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -27,7 +27,7 @@ pub struct AggregateSignature<D: Clone + Digest + FixedOutput> {
2727
impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
2828
/// Verify all checks from signatures, except for the signature verification itself.
2929
///
30-
/// Indices and quorum are checked by `CoreVerifier::preliminary_verify` with `msgp`.
30+
/// Indices and quorum are checked by `BasicVerifier::preliminary_verify` with `msgp`.
3131
/// It collects leaves from signatures and checks the batch proof.
3232
/// After batch proof is checked, it collects and returns the signatures and
3333
/// verification keys to be used by aggregate verification.
@@ -157,7 +157,7 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
157157
out
158158
}
159159

160-
///Extract a `StmAggrSig` from a byte slice.
160+
///Extract a `AggregateSignature` from a byte slice.
161161
pub fn from_bytes(
162162
bytes: &[u8],
163163
) -> Result<AggregateSignature<D>, StmAggregateSignatureError<D>> {

mithril-stm/src/bls_multi_signature/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mod tests {
9696

9797
use crate::bls_multi_signature::helper::unsafe_helpers::{p1_affine_to_sig, p2_affine_to_vk};
9898
use crate::error::{MultiSignatureError, RegisterError};
99-
use crate::key_reg::KeyRegistration;
99+
use crate::key_registration::KeyRegistration;
100100

101101
use super::*;
102102

@@ -156,7 +156,7 @@ mod tests {
156156

157157
let p2 = blst_p2::default();
158158
let vk_infinity = BlsVerificationKey(p2_affine_to_vk(&p2));
159-
let vkpop_infinity = BlsVerificationKeyProofOfPossesion { vk: vk_infinity, pop };
159+
let vkpop_infinity = BlsVerificationKeyProofOfPossession { vk: vk_infinity, pop };
160160

161161
let result = vkpop_infinity.check();
162162
assert_eq!(result, Err(MultiSignatureError::VerificationKeyInfinity(Box::new(vkpop_infinity.vk))));
@@ -171,11 +171,11 @@ mod tests {
171171
let pop = BlsProofOfPossession::from(&sk);
172172
let p2 = blst_p2::default();
173173
let vk_infinity = BlsVerificationKey(p2_affine_to_vk(&p2));
174-
let vkpop_infinity = BlsVerificationKeyProofOfPossesion { vk: vk_infinity, pop };
174+
let vkpop_infinity = BlsVerificationKeyProofOfPossession { vk: vk_infinity, pop };
175175

176176
for _ in 0..num_sigs {
177177
let sk = BlsSigningKey::generate(&mut rng);
178-
let vkpop = BlsVerificationKeyProofOfPossesion::from(&sk);
178+
let vkpop = BlsVerificationKeyProofOfPossession::from(&sk);
179179
let _ = kr.register(1, vkpop);
180180
}
181181

@@ -221,9 +221,9 @@ mod tests {
221221
let vk_bytes = vk.to_bytes();
222222
let vk2 = BlsVerificationKey::from_bytes(&vk_bytes).unwrap();
223223
assert_eq!(vk, vk2);
224-
let vkpop = BlsVerificationKeyProofOfPossesion::from(&sk);
224+
let vkpop = BlsVerificationKeyProofOfPossession::from(&sk);
225225
let vkpop_bytes = vkpop.to_bytes();
226-
let vkpop2: BlsVerificationKeyProofOfPossesion = BlsVerificationKeyProofOfPossesion::from_bytes(&vkpop_bytes).unwrap();
226+
let vkpop2: BlsVerificationKeyProofOfPossession = BlsVerificationKeyProofOfPossession::from_bytes(&vkpop_bytes).unwrap();
227227
assert_eq!(vkpop, vkpop2);
228228

229229
// Now we test serde
@@ -232,7 +232,7 @@ mod tests {
232232
let (decoded,_) = bincode::serde::decode_from_slice::<BlsVerificationKey,_>(&encoded, bincode::config::legacy()).unwrap();
233233
assert_eq!(vk, decoded);
234234
let encoded = bincode::serde::encode_to_vec(vkpop, bincode::config::legacy()).unwrap();
235-
let (decoded,_) = bincode::serde::decode_from_slice::<BlsVerificationKeyProofOfPossesion,_>(&encoded, bincode::config::legacy()).unwrap();
235+
let (decoded,_) = bincode::serde::decode_from_slice::<BlsVerificationKeyProofOfPossession,_>(&encoded, bincode::config::legacy()).unwrap();
236236
assert_eq!(vkpop, decoded);
237237
}
238238

mithril-stm/src/bls_multi_signature/verification_key.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ impl From<&BlsSigningKey> for BlsVerificationKey {
124124

125125
/// MultiSig public key, contains the verification key and the proof of possession.
126126
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
127-
pub struct BlsVerificationKeyProofOfPossesion {
127+
pub struct BlsVerificationKeyProofOfPossession {
128128
/// The verification key.
129129
pub vk: BlsVerificationKey,
130130
/// Proof of Possession.
131131
pub pop: BlsProofOfPossession,
132132
}
133133

134-
impl BlsVerificationKeyProofOfPossesion {
134+
impl BlsVerificationKeyProofOfPossession {
135135
/// if `e(k1,g2) = e(H_G1("PoP" || mvk),mvk)` and `e(g1,mvk) = e(k2,g2)`
136136
/// are both true, return 1. The first part is a signature verification
137137
/// of message "PoP", while the second we need to compute the pairing
@@ -170,7 +170,7 @@ impl BlsVerificationKeyProofOfPossesion {
170170
vkpop_bytes
171171
}
172172

173-
/// Deserialize a byte string to a `PublicKeyPoP`.
173+
/// Deserialize a byte string to a `BlsVerificationKeyProofOfPossession`.
174174
pub fn from_bytes(bytes: &[u8]) -> Result<Self, MultiSignatureError> {
175175
let mvk = BlsVerificationKey::from_bytes(
176176
bytes
@@ -188,8 +188,8 @@ impl BlsVerificationKeyProofOfPossesion {
188188
}
189189
}
190190

191-
impl From<&BlsSigningKey> for BlsVerificationKeyProofOfPossesion {
192-
/// Convert a secret key into a `VerificationKeyPoP` by simply converting to a
191+
impl From<&BlsSigningKey> for BlsVerificationKeyProofOfPossession {
192+
/// Convert a secret key into a `BlsVerificationKeyProofOfPossession` by simply converting to a
193193
/// `MspMvk` and `MspPoP`.
194194
fn from(sk: &BlsSigningKey) -> Self {
195195
Self {

mithril-stm/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use blake2::digest::{Digest, FixedOutput};
33
use blst::BLST_ERROR;
44

55
use crate::bls_multi_signature::{
6-
BlsSignature, BlsVerificationKey, BlsVerificationKeyProofOfPossesion,
6+
BlsSignature, BlsVerificationKey, BlsVerificationKeyProofOfPossession,
77
};
88
use crate::merkle_tree::{MerkleBatchPath, MerklePath};
99

@@ -24,7 +24,7 @@ pub enum MultiSignatureError {
2424

2525
/// Incorrect proof of possession
2626
#[error("Key with invalid PoP")]
27-
KeyInvalid(Box<BlsVerificationKeyProofOfPossesion>),
27+
KeyInvalid(Box<BlsVerificationKeyProofOfPossession>),
2828

2929
/// At least one signature in the batch is invalid
3030
#[error("One signature in the batch is invalid")]
@@ -251,7 +251,7 @@ pub enum RegisterError {
251251

252252
/// The supplied key is not valid
253253
#[error("The verification of correctness of the supplied key is invalid.")]
254-
KeyInvalid(Box<BlsVerificationKeyProofOfPossesion>),
254+
KeyInvalid(Box<BlsVerificationKeyProofOfPossession>),
255255

256256
/// Serialization error
257257
#[error("Serialization error")]

0 commit comments

Comments
 (0)