Skip to content

Commit 2182a13

Browse files
committed
deprecate messages
1 parent 954363f commit 2182a13

File tree

9 files changed

+79
-55
lines changed

9 files changed

+79
-55
lines changed

mithril-stm/src/aggregate_signature/aggregate_key.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ impl<D: Digest + Clone + FixedOutput> AggregateVerificationKey<D> {
2121
self.mt_commitment.clone()
2222
}
2323

24-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
24+
#[deprecated(
25+
since = "0.4.9",
26+
note = "Use `get_merkle_tree_batch_commitment` instead"
27+
)]
2528
pub fn get_mt_commitment(&self) -> MerkleTreeBatchCommitment<D> {
2629
Self::get_merkle_tree_batch_commitment(self)
2730
}

mithril-stm/src/aggregate_signature/basic_verifier.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl BasicVerifier {
4545
/// * Collect the unique signers in a hash set,
4646
/// * Calculate the total stake of the eligible signers,
4747
/// * Sort the eligible signers.
48-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
48+
#[deprecated(since = "0.4.9", note = "Use `new` instead")]
4949
pub fn setup(public_signers: &[(BlsVerificationKey, Stake)]) -> Self {
5050
Self::new(public_signers)
5151
}
@@ -88,7 +88,7 @@ impl BasicVerifier {
8888
/// If there is no sufficient signatures, then the function fails.
8989
// todo: We need to agree on a criteria to dedup (by default we use a BTreeMap that guarantees keys order)
9090
// todo: not good, because it only removes index if there is a conflict (see benches)
91-
pub(crate) fn select_valid_signatures_for_k_indices(
91+
pub fn select_valid_signatures_for_k_indices(
9292
total_stake: &Stake,
9393
params: &Parameters,
9494
msg: &[u8],
@@ -180,7 +180,10 @@ impl BasicVerifier {
180180
/// If there is no sufficient signatures, then the function fails.
181181
// todo: We need to agree on a criteria to dedup (by default we use a BTreeMap that guarantees keys order)
182182
// todo: not good, because it only removes index if there is a conflict (see benches)
183-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
183+
#[deprecated(
184+
since = "0.4.9",
185+
note = "Use `select_valid_signatures_for_k_indices` instead"
186+
)]
184187
pub fn dedup_sigs_for_indices(
185188
total_stake: &Stake,
186189
params: &Parameters,

mithril-stm/src/aggregate_signature/clerk.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ impl<D: Digest + Clone + FixedOutput> Clerk<D> {
2828
}
2929

3030
/// Create a new `Clerk` from a closed registration instance.
31-
#[deprecated(since = "0.4.9", note = "Use `new_clerk_from_closed_key_registration` instead")]
31+
#[deprecated(
32+
since = "0.4.9",
33+
note = "Use `new_clerk_from_closed_key_registration` instead"
34+
)]
3235
pub fn from_registration(params: &Parameters, closed_reg: &ClosedKeyRegistration<D>) -> Self {
3336
Self::new_clerk_from_closed_key_registration(params, closed_reg)
3437
}
@@ -120,9 +123,12 @@ impl<D: Digest + Clone + FixedOutput> Clerk<D> {
120123
}
121124

122125
/// Compute the `AggregateVerificationKey` related to the used registration.
123-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
126+
#[deprecated(
127+
since = "0.4.9",
128+
note = "Use `compute_aggregate_verification_key` instead"
129+
)]
124130
pub fn compute_avk(&self) -> AggregateVerificationKey<D> {
125-
Clerk::compute_aggregate_verification_key(self)
131+
Self::compute_aggregate_verification_key(self)
126132
}
127133

128134
/// Get the (VK, stake) of a party given its index.
@@ -137,8 +143,8 @@ impl<D: Digest + Clone + FixedOutput> Clerk<D> {
137143
}
138144

139145
/// Get the (VK, stake) of a party given its index.
140-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
146+
#[deprecated(since = "0.4.9", note = "Use `get_registered_party_for_index` instead")]
141147
pub fn get_reg_party(&self, party_index: &Index) -> Option<(VerificationKey, Stake)> {
142-
Clerk::get_registered_party_for_index(self, party_index)
148+
Self::get_registered_party_for_index(self, party_index)
143149
}
144150
}

mithril-stm/src/bls_multi_signature/verification_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ impl BlsVerificationKeyProofOfPossession {
164164
/// manually.
165165
// If we are really looking for performance improvements, we can combine the
166166
// two final exponentiations (for verifying k1 and k2) into a single one.
167-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
167+
#[deprecated(since = "0.4.9", note = "Use `verify_proof_of_possesion` instead")]
168168
pub fn check(&self) -> Result<(), MultiSignatureError> {
169-
BlsVerificationKeyProofOfPossession::verify_proof_of_possesion(self)
169+
Self::verify_proof_of_possesion(self)
170170
}
171171

172172
/// Convert to a 144 byte string.

mithril-stm/src/merkle_tree/commitment.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ impl<D: Digest + FixedOutput> MerkleTreeCommitment<D> {
5656
/// Check an inclusion proof that `val` is part of the tree by traveling the whole path until the root.
5757
/// # Error
5858
/// If the merkle tree path is invalid, then the function fails.
59-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
59+
#[deprecated(
60+
since = "0.4.9",
61+
note = "Use `verify_leaf_membership_from_path` instead"
62+
)]
6063
pub fn check(
6164
&self,
6265
val: &MerkleTreeLeaf,
@@ -65,7 +68,7 @@ impl<D: Digest + FixedOutput> MerkleTreeCommitment<D> {
6568
where
6669
D: FixedOutput + Clone,
6770
{
68-
MerkleTreeCommitment::verify_leaf_membership_from_path(self, val, proof)
71+
Self::verify_leaf_membership_from_path(self, val, proof)
6972
}
7073

7174
/// Serializes the Merkle Tree commitment together with a message in a single vector of bytes.
@@ -83,12 +86,12 @@ impl<D: Digest + FixedOutput> MerkleTreeCommitment<D> {
8386

8487
/// Serializes the Merkle Tree commitment together with a message in a single vector of bytes.
8588
/// Outputs `msg || self` as a vector of bytes.
86-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
89+
#[deprecated(since = "0.4.9", note = "Use `concatenate_with_message` instead")]
8790
pub fn concat_with_msg(&self, msg: &[u8]) -> Vec<u8>
8891
where
8992
D: Digest,
9093
{
91-
MerkleTreeCommitment::concatenate_with_message(self, msg)
94+
Self::concatenate_with_message(self, msg)
9295
}
9396
}
9497

@@ -133,9 +136,9 @@ impl<D: Digest> MerkleTreeBatchCommitment<D> {
133136
/// Serializes the Merkle Tree commitment together with a message in a single vector of bytes.
134137
/// Outputs `msg || self` as a vector of bytes.
135138
// todo: Do we need to concat msg to whole commitment (nr_leaves and root) or just the root?
136-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
139+
#[deprecated(since = "0.4.9", note = "Use `concatenate_with_message` instead")]
137140
pub fn concat_with_msg(&self, msg: &[u8]) -> Vec<u8> {
138-
MerkleTreeBatchCommitment::concatenate_with_message(self, msg)
141+
Self::concatenate_with_message(self, msg)
139142
}
140143

141144
/// Check a proof of a batched opening. The indices must be ordered.
@@ -237,7 +240,10 @@ impl<D: Digest> MerkleTreeBatchCommitment<D> {
237240
// todo: Update doc.
238241
// todo: Simplify the algorithm.
239242
// todo: Maybe we want more granular errors, rather than only `BatchPathInvalid`
240-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
243+
#[deprecated(
244+
since = "0.4.9",
245+
note = "Use `verify_leaves_membership_from_batch_path` instead"
246+
)]
241247
pub fn check(
242248
&self,
243249
batch_val: &[MerkleTreeLeaf],
@@ -246,7 +252,7 @@ impl<D: Digest> MerkleTreeBatchCommitment<D> {
246252
where
247253
D: FixedOutput + Clone,
248254
{
249-
MerkleTreeBatchCommitment::verify_leaves_membership_from_batch_path(self, batch_val, proof)
255+
Self::verify_leaves_membership_from_batch_path(self, batch_val, proof)
250256
}
251257
}
252258

mithril-stm/src/merkle_tree/tree.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ impl<D: Digest + FixedOutput> MerkleTree<D> {
6464
}
6565

6666
/// Provided a non-empty list of leaves, `create` generates its corresponding `MerkleTree`.
67-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
67+
#[deprecated(since = "0.4.9", note = "Use `new` instead")]
6868
pub fn create(leaves: &[MerkleTreeLeaf]) -> MerkleTree<D> {
69-
MerkleTree::new(leaves)
69+
Self::new(leaves)
7070
}
7171

7272
/// Return the index of the leaf.
@@ -82,9 +82,12 @@ impl<D: Digest + FixedOutput> MerkleTree<D> {
8282

8383
/// Convert merkle tree to a batch compatible commitment.
8484
/// This function simply returns the root and the number of leaves in the tree.
85-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
85+
#[deprecated(
86+
since = "0.4.9",
87+
note = "Use `to_merkle_tree_batch_commitment` instead"
88+
)]
8689
pub fn to_commitment_batch_compat(&self) -> MerkleTreeBatchCommitment<D> {
87-
MerkleTree::to_merkle_tree_batch_commitment(self)
90+
Self::to_merkle_tree_batch_commitment(self)
8891
}
8992

9093
/// Get a path for a batch of leaves. The indices must be ordered. We use the Octopus algorithm to
@@ -166,12 +169,12 @@ impl<D: Digest + FixedOutput> MerkleTree<D> {
166169
/// If the indices provided are out of bounds (higher than the number of elements
167170
/// committed in the `MerkleTree`) or are not ordered, the function fails.
168171
// todo: Update doc.
169-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
172+
#[deprecated(since = "0.4.9", note = "Use `compute_merkle_tree_batch_path` instead")]
170173
pub fn get_batched_path(&self, indices: Vec<usize>) -> MerkleBatchPath<D>
171174
where
172175
D: FixedOutput,
173176
{
174-
MerkleTree::compute_merkle_tree_batch_path(self, indices)
177+
Self::compute_merkle_tree_batch_path(self, indices)
175178
}
176179

177180
/// Convert a `MerkleTree` into a byte string, containing $4 + n * S$ bytes where $n$ is the
@@ -223,9 +226,9 @@ impl<D: Digest + FixedOutput> MerkleTree<D> {
223226
}
224227

225228
/// Convert merkle tree to a commitment. This function simply returns the root.
226-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
229+
#[deprecated(since = "0.4.9", note = "Use `to_merkle_tree_commitment` instead")]
227230
pub fn to_commitment(&self) -> MerkleTreeCommitment<D> {
228-
MerkleTree::to_merkle_tree_commitment(self)
231+
Self::to_merkle_tree_commitment(self)
229232
}
230233

231234
/// Get a path (hashes of siblings of the path to the root node)
@@ -257,9 +260,9 @@ impl<D: Digest + FixedOutput> MerkleTree<D> {
257260
/// Get a path (hashes of siblings of the path to the root node)
258261
/// for the `i`th value stored in the tree.
259262
/// Requires `i < self.n`
260-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
263+
#[deprecated(since = "0.4.9", note = "Use `compute_merkle_tree_path` instead")]
261264
pub fn get_path(&self, i: usize) -> MerklePath<D> {
262-
MerkleTree::compute_merkle_tree_path(self, i)
265+
Self::compute_merkle_tree_path(self, i)
263266
}
264267
}
265268

mithril-stm/src/participant/initializer.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ impl Initializer {
4141

4242
/// Builds an `Initializer` that is ready to register with the key registration service.
4343
/// This function generates the signing and verification key with a PoP, and initialises the structure.
44-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
44+
#[deprecated(since = "0.4.9", note = "Use `new` instead")]
4545
pub fn setup<R: RngCore + CryptoRng>(params: Parameters, stake: Stake, rng: &mut R) -> Self {
46-
Initializer::new(params, stake, rng)
46+
Self::new(params, stake, rng)
4747
}
4848

4949
/// Extract the verification key with proof of possession.
@@ -52,9 +52,12 @@ impl Initializer {
5252
}
5353

5454
/// Extract the verification key.
55-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
55+
#[deprecated(
56+
since = "0.4.9",
57+
note = "Use `get_verification_key_proof_of_possession` instead"
58+
)]
5659
pub fn verification_key(&self) -> VerificationKeyProofOfPossession {
57-
Initializer::get_verification_key_proof_of_possession(self)
60+
Self::get_verification_key_proof_of_possession(self)
5861
}
5962

6063
/// Build the `avk` for the given list of parties.
@@ -106,15 +109,15 @@ impl Initializer {
106109
/// * the current total stake (according to the registration service)
107110
/// # Error
108111
/// This function fails if the initializer is not registered.
109-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
112+
#[deprecated(since = "0.4.9", note = "Use `create_signer` instead")]
110113
pub fn new_signer<D: Digest + Clone + FixedOutput>(
111114
self,
112115
closed_reg: ClosedKeyRegistration<D>,
113116
) -> Result<Signer<D>, RegisterError> {
114-
Initializer::create_signer(self, closed_reg)
117+
Self::create_signer(self, closed_reg)
115118
}
116119

117-
/// Creates a new core signer that does not include closed registration.
120+
/// Creates a new basic signer that does not include closed registration.
118121
/// Takes `eligible_parties` as a parameter and determines the signer's index in the parties.
119122
/// `eligible_parties` is verified and trusted which is only run by a full-node
120123
/// that has already verified the parties.
@@ -144,16 +147,16 @@ impl Initializer {
144147
}
145148
}
146149

147-
/// Creates a new core signer that does not include closed registration.
150+
/// Creates a new basic signer that does not include closed registration.
148151
/// Takes `eligible_parties` as a parameter and determines the signer's index in the parties.
149152
/// `eligible_parties` is verified and trusted which is only run by a full-node
150153
/// that has already verified the parties.
151-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
154+
#[deprecated(since = "0.4.9", note = "Use `create_basic_signer` instead")]
152155
pub fn new_core_signer<D: Digest + Clone + FixedOutput>(
153156
self,
154157
eligible_parties: &[RegisteredParty],
155158
) -> Option<Signer<D>> {
156-
Initializer::create_basic_signer(self, eligible_parties)
159+
Self::create_basic_signer(self, eligible_parties)
157160
}
158161

159162
/// Convert to bytes

mithril-stm/src/participant/signer.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
4646
}
4747

4848
/// Create a Signer for given input
49-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
49+
#[deprecated(since = "0.4.9", note = "Use `set_signer` instead")]
5050
pub fn set_stm_signer(
5151
signer_index: u64,
5252
stake: Stake,
@@ -55,7 +55,7 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
5555
vk: VerificationKey,
5656
closed_reg: ClosedKeyRegistration<D>,
5757
) -> Signer<D> {
58-
Signer::set_signer(signer_index, stake, params, sk, vk, closed_reg)
58+
Self::set_signer(signer_index, stake, params, sk, vk, closed_reg)
5959
}
6060

6161
/// Create a basic signer (no registration data) for given input
@@ -77,15 +77,15 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
7777
}
7878

7979
/// Create a core signer (no registration data) for given input
80-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
80+
#[deprecated(since = "0.4.9", note = "Use `set_basic_signer` instead")]
8181
pub fn set_core_signer(
8282
signer_index: u64,
8383
stake: Stake,
8484
params: Parameters,
8585
sk: BlsSigningKey,
8686
vk: VerificationKey,
8787
) -> Signer<D> {
88-
Signer::set_basic_signer(signer_index, stake, params, sk, vk)
88+
Self::set_basic_signer(signer_index, stake, params, sk, vk)
8989
}
9090

9191
/// This function produces a signature following the description of Section 2.4.
@@ -115,7 +115,7 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
115115
}
116116

117117
/// Extract the verification key.
118-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
118+
#[deprecated(since = "0.4.9", note = "Use `get_verification_key` instead")]
119119
pub fn verification_key(&self) -> VerificationKey {
120120
Self::get_verification_key(self)
121121
}
@@ -125,8 +125,8 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
125125
self.stake
126126
}
127127

128-
/// A core signature generated without closed registration.
129-
/// The core signature can be verified by core verifier.
128+
/// A basic signature generated without closed key registration.
129+
/// The basic signature can be verified by basic verifier.
130130
/// Once the signature is produced, this function checks whether any index in `[0,..,self.params.m]`
131131
/// wins the lottery by evaluating the dense mapping.
132132
/// It records all the winning indexes in `Self.indexes`.
@@ -145,14 +145,14 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
145145
}
146146
}
147147

148-
/// A core signature generated without closed registration.
149-
/// The core signature can be verified by core verifier.
148+
/// A basic signature generated without closed key registration.
149+
/// The basic signature can be verified by basic verifier.
150150
/// Once the signature is produced, this function checks whether any index in `[0,..,self.params.m]`
151151
/// wins the lottery by evaluating the dense mapping.
152152
/// It records all the winning indexes in `Self.indexes`.
153-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
153+
#[deprecated(since = "0.4.9", note = "Use `basic_sign` instead")]
154154
pub fn core_sign(&self, msg: &[u8], total_stake: Stake) -> Option<SingleSignature> {
155-
Signer::basic_sign(self, msg, total_stake)
155+
Self::basic_sign(self, msg, total_stake)
156156
}
157157

158158
/// Collects and returns the winning indices.
@@ -177,9 +177,9 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
177177
}
178178

179179
/// Get Parameters
180-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
180+
#[deprecated(since = "0.4.9", note = "Use `get_parameters` instead")]
181181
pub fn get_params(&self) -> Parameters {
182-
Signer::get_parameters(self)
182+
Self::get_parameters(self)
183183
}
184184

185185
/// Get closed key registration
@@ -188,8 +188,8 @@ impl<D: Clone + Digest + FixedOutput> Signer<D> {
188188
}
189189

190190
/// Get closed key registration
191-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
191+
#[deprecated(since = "0.4.9", note = "Use `get_closed_key_registration` instead")]
192192
pub fn get_closed_reg(&self) -> Option<ClosedKeyRegistration<D>> {
193-
Signer::get_closed_key_registration(self)
193+
Self::get_closed_key_registration(self)
194194
}
195195
}

mithril-stm/src/single_signature/signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl SingleSignature {
153153
}
154154

155155
/// Will be deprecated. Use `basic_verify` instead.
156-
#[deprecated(since = "0.4.9", note = "This function will be removed")]
156+
#[deprecated(since = "0.4.9", note = "Use `basic_verify` instead")]
157157
pub fn core_verify(
158158
&self,
159159
params: &Parameters,

0 commit comments

Comments
 (0)