Skip to content

Commit 3254f5d

Browse files
authored
Merge pull request #3431 from IntersectMBO/damrobi/msnark/refactor-pop-snark-params-decoding
refactor(stm): update PoP, protocol parameters and decoding functions
2 parents bc9d8c1 + 83390c5 commit 3254f5d

30 files changed

Lines changed: 334 additions & 253 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fixed = "1.31.0"
4646
hex = { workspace = true }
4747
kes-summed-ed25519 = { version = "0.2.1", features = ["serde_enabled", "sk_clone_enabled"] }
4848
mithril-merkle-tree = { path = "../internal/mithril-merkle-tree", version = "0.1.4" }
49-
mithril-stm = { path = "../mithril-stm", version = "0.11.4", default-features = false }
49+
mithril-stm = { path = "../mithril-stm", version = "0.12.0", default-features = false }
5050
nom = "8.0.0"
5151
rand_chacha = { workspace = true }
5252
rand_core = { workspace = true }

mithril-common/src/protocol/signer_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ mod test {
230230
);
231231

232232
match error.downcast_ref::<RegisterError>() {
233-
Some(RegisterError::EntryAlreadyRegistered { .. }) => (),
233+
Some(RegisterError::EntryAlreadyRegistered) => (),
234234
_ => panic!("Expected an CoreRegister error, got: {error:?}"),
235235
}
236236
}

mithril-stm/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.12.0 (07-29-2026)
9+
10+
### Added
11+
12+
- Added a `ProtocolError` enum with a `PhiFValueOutOfRange` variant for invalid `phi_f` values
13+
14+
### Changed
15+
16+
- Updated the `from_bytes_legacy` functions for `MerkleTreeBatchCommitment`, `MerkleTree`, `ConcatenationProof` and `SingleSignature`
17+
- Updated the validation of the `phi_f` value in the lottery/eligibility computations
18+
- Updated the visibility of `ClosedKeyRegistration`, `RegistrationEntry` and `ClosedRegistrationEntry` to ensure proper verification of the proof of possession
19+
- Updated `RegisterError::EntryAlreadyRegistered` to no longer carry the conflicting `RegistrationEntry`, since the type is now crate-private
20+
- Updated `ClosedKeyRegistration::number_of_registered_parties` to be available only when the `future_snark` feature is enabled
21+
- Updated `ConcatenationProofSigner::check_lottery` to return `StmResult<Vec<u64>>` instead of `Vec<u64>`
22+
23+
### Removed
24+
25+
- Removed the unused `to_bytes` and `from_bytes` methods from `MerkleTree`
26+
827
## 0.11.4 (07-27-2026)
928

1029
### Added

mithril-stm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-stm"
3-
version = "0.11.4"
3+
version = "0.12.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
homepage = { workspace = true }

mithril-stm/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use rayon::prelude::*;
6969

7070
use mithril_stm::{
7171
AggregateSignatureType, AggregationError, AncillaryGenesisData, AncillaryProofInput, Clerk,
72-
Initializer, KeyRegistration, Parameters, RegistrationEntry, Signer, SingleSignature,
72+
Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
7373
MithrilMembershipDigest, AggregateVerificationKey,
7474
};
7575

@@ -100,13 +100,12 @@ let mut key_reg = KeyRegistration::initialize();
100100
let mut ps: Vec<Initializer> = Vec::with_capacity(nparties as usize);
101101
for stake in parties {
102102
let p = Initializer::new(params, stake, &mut rng);
103-
let entry = RegistrationEntry::new(
104-
p.get_verification_key_proof_of_possession_for_concatenation(),
103+
key_reg.register(
105104
p.stake,
105+
&p.get_verification_key_proof_of_possession_for_concatenation(),
106106
#[cfg(feature = "future_snark")] p.schnorr_verification_key,
107107
)
108108
.unwrap();
109-
key_reg.register_by_entry(&entry).unwrap();
110109
ps.push(p);
111110
}
112111

mithril-stm/benches/size_benches.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ where
3232
let mut key_reg = KeyRegistration::initialize();
3333
for stake in parties {
3434
let p = Initializer::new(params, stake, &mut rng);
35-
key_reg.register_by_entry(&p.clone().try_into().unwrap()).unwrap();
35+
key_reg
36+
.register(
37+
stake,
38+
&p.get_verification_key_proof_of_possession_for_concatenation(),
39+
#[cfg(feature = "future_snark")]
40+
p.schnorr_verification_key,
41+
)
42+
.unwrap();
3643
ps.push(p);
3744
}
3845

mithril-stm/benches/stm.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ fn stm_benches<D: MembershipDigest>(
4444
// We need to initialise the key_reg at each iteration
4545
key_reg = KeyRegistration::initialize();
4646
for p in initializers.iter() {
47-
key_reg.register_by_entry(&p.clone().try_into().unwrap()).unwrap();
47+
key_reg
48+
.register(
49+
p.stake,
50+
&p.get_verification_key_proof_of_possession_for_concatenation(),
51+
#[cfg(feature = "future_snark")]
52+
p.schnorr_verification_key,
53+
)
54+
.unwrap();
4855
}
4956
})
5057
});
@@ -136,7 +143,14 @@ fn batch_benches<D>(
136143
}
137144
let mut key_reg = KeyRegistration::initialize();
138145
for p in initializers.iter() {
139-
key_reg.register_by_entry(&p.clone().try_into().unwrap()).unwrap();
146+
key_reg
147+
.register(
148+
p.stake,
149+
&p.get_verification_key_proof_of_possession_for_concatenation(),
150+
#[cfg(feature = "future_snark")]
151+
p.schnorr_verification_key,
152+
)
153+
.unwrap();
140154
}
141155

142156
let closed_reg = key_reg.close_registration(&params).unwrap();

mithril-stm/examples/key_registration.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rand_core::{RngCore, SeedableRng};
77
use mithril_stm::{
88
AggregateSignature, AggregateSignatureType, AncillaryGenesisData, AncillaryProofInput, Clerk,
99
ClosedKeyRegistration, Initializer, KeyRegistration, MithrilMembershipDigest, Parameters,
10-
RegistrationEntry, Stake, VerificationKeyProofOfPossessionForConcatenation,
10+
Stake, VerificationKeyProofOfPossessionForConcatenation,
1111
};
1212

1313
type D = MithrilMembershipDigest;
@@ -236,14 +236,14 @@ fn local_reg(
236236
};
237237
// data, such as the public key, stake and id.
238238
for (pk, _) in pks.iter().zip(ids.iter()) {
239-
let entry = RegistrationEntry::new(
240-
*pk,
241-
1,
242-
#[cfg(feature = "future_snark")]
243-
None,
244-
)
245-
.unwrap();
246-
local_keyreg.register_by_entry(&entry).unwrap();
239+
local_keyreg
240+
.register(
241+
1,
242+
pk,
243+
#[cfg(feature = "future_snark")]
244+
None,
245+
)
246+
.unwrap();
247247
}
248248
local_keyreg.close_registration(&params).unwrap()
249249
}

mithril-stm/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//! use mithril_stm::{
1717
//! AggregateSignatureType, AggregationError, AncillaryGenesisData, AncillaryProofInput, Clerk,
18-
//! Initializer, KeyRegistration, Parameters, RegistrationEntry, Signer, SingleSignature,
18+
//! Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
1919
//! MithrilMembershipDigest,
2020
//! };
2121
//!
@@ -59,13 +59,12 @@
5959
//! // Create keys for this party
6060
//! let p = Initializer::new(params, stake, &mut rng);
6161
//! // Register keys with the KeyRegistration service
62-
//! let entry = RegistrationEntry::new(
63-
//! p.get_verification_key_proof_of_possession_for_concatenation(),
62+
//! key_reg.register(
6463
//! p.stake,
64+
//! &p.get_verification_key_proof_of_possession_for_concatenation(),
6565
//! #[cfg(feature = "future_snark")] p.schnorr_verification_key,
6666
//! )
6767
//! .unwrap();
68-
//! key_reg.register_by_entry(&entry).unwrap();
6968
//! ps.push(p);
7069
//! }
7170
//!
@@ -148,14 +147,15 @@ mod protocol;
148147
mod signature_scheme;
149148

150149
pub use proof_system::AggregateVerificationKeyForConcatenation;
150+
pub(crate) use protocol::RegistrationEntry;
151151
pub use protocol::{
152152
AggregateSignature, AggregateSignatureError, AggregateSignatureType, AggregateVerificationKey,
153153
AggregationError, AncillaryGenesisData, AncillaryProofInput, AncillaryProofOutput,
154154
AncillaryProverData, AncillaryVerifierData, Clerk, ClosedKeyRegistration,
155155
ClosedRegistrationEntry, GenesisVerificationKeyBundle, Initializer, KeyRegistration,
156-
Parameters, RegisterError, RegistrationEntry, RegistrationEntryForConcatenation,
157-
SignatureError, Signer, SingleSignature, SingleSignatureWithRegisteredParty,
158-
VerificationKeyForConcatenation, VerificationKeyProofOfPossessionForConcatenation,
156+
Parameters, RegisterError, RegistrationEntryForConcatenation, SignatureError, Signer,
157+
SingleSignature, SingleSignatureWithRegisteredParty, VerificationKeyForConcatenation,
158+
VerificationKeyProofOfPossessionForConcatenation,
159159
};
160160
pub use signature_scheme::BlsSignatureError;
161161

0 commit comments

Comments
 (0)