Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mithril-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fixed = "1.31.0"
hex = { workspace = true }
kes-summed-ed25519 = { version = "0.2.1", features = ["serde_enabled", "sk_clone_enabled"] }
mithril-merkle-tree = { path = "../internal/mithril-merkle-tree", version = "0.1.4" }
mithril-stm = { path = "../mithril-stm", version = "0.11.4", default-features = false }
mithril-stm = { path = "../mithril-stm", version = "0.12.0", default-features = false }
nom = "8.0.0"
rand_chacha = { workspace = true }
rand_core = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion mithril-common/src/protocol/signer_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ mod test {
);

match error.downcast_ref::<RegisterError>() {
Some(RegisterError::EntryAlreadyRegistered { .. }) => (),
Some(RegisterError::EntryAlreadyRegistered) => (),
_ => panic!("Expected an CoreRegister error, got: {error:?}"),
}
}
Expand Down
19 changes: 19 additions & 0 deletions mithril-stm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.12.0 (07-29-2026)

### Added

- Added a `ProtocolError` enum with a `PhiFValueOutOfRange` variant for invalid `phi_f` values

### Changed

- Updated the `from_bytes_legacy` functions for `MerkleTreeBatchCommitment`, `MerkleTree`, `ConcatenationProof` and `SingleSignature`
- Updated the validation of the `phi_f` value in the lottery/eligibility computations
- Updated the visibility of `ClosedKeyRegistration`, `RegistrationEntry` and `ClosedRegistrationEntry` to ensure proper verification of the proof of possession
- Updated `RegisterError::EntryAlreadyRegistered` to no longer carry the conflicting `RegistrationEntry`, since the type is now crate-private
- Updated `ClosedKeyRegistration::number_of_registered_parties` to be available only when the `future_snark` feature is enabled
- Updated `ConcatenationProofSigner::check_lottery` to return `StmResult<Vec<u64>>` instead of `Vec<u64>`

### Removed

- Removed the unused `to_bytes` and `from_bytes` methods from `MerkleTree`

## 0.11.4 (07-27-2026)

### Added
Expand Down
2 changes: 1 addition & 1 deletion mithril-stm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-stm"
version = "0.11.4"
version = "0.12.0"
edition = { workspace = true }
authors = { workspace = true }
homepage = { workspace = true }
Expand Down
7 changes: 3 additions & 4 deletions mithril-stm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use rayon::prelude::*;

use mithril_stm::{
AggregateSignatureType, AggregationError, AncillaryGenesisData, AncillaryProofInput, Clerk,
Initializer, KeyRegistration, Parameters, RegistrationEntry, Signer, SingleSignature,
Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
MithrilMembershipDigest, AggregateVerificationKey,
};

Expand Down Expand Up @@ -100,13 +100,12 @@ let mut key_reg = KeyRegistration::initialize();
let mut ps: Vec<Initializer> = Vec::with_capacity(nparties as usize);
for stake in parties {
let p = Initializer::new(params, stake, &mut rng);
let entry = RegistrationEntry::new(
p.get_verification_key_proof_of_possession_for_concatenation(),
key_reg.register(
p.stake,
&p.get_verification_key_proof_of_possession_for_concatenation(),
#[cfg(feature = "future_snark")] p.schnorr_verification_key,
)
.unwrap();
key_reg.register_by_entry(&entry).unwrap();
ps.push(p);
}

Expand Down
9 changes: 8 additions & 1 deletion mithril-stm/benches/size_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ where
let mut key_reg = KeyRegistration::initialize();
for stake in parties {
let p = Initializer::new(params, stake, &mut rng);
key_reg.register_by_entry(&p.clone().try_into().unwrap()).unwrap();
key_reg
.register(
stake,
&p.get_verification_key_proof_of_possession_for_concatenation(),
#[cfg(feature = "future_snark")]
p.schnorr_verification_key,
)
.unwrap();
ps.push(p);
}

Expand Down
18 changes: 16 additions & 2 deletions mithril-stm/benches/stm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ fn stm_benches<D: MembershipDigest>(
// We need to initialise the key_reg at each iteration
key_reg = KeyRegistration::initialize();
for p in initializers.iter() {
key_reg.register_by_entry(&p.clone().try_into().unwrap()).unwrap();
key_reg
.register(
p.stake,
&p.get_verification_key_proof_of_possession_for_concatenation(),
#[cfg(feature = "future_snark")]
p.schnorr_verification_key,
)
.unwrap();
}
})
});
Expand Down Expand Up @@ -136,7 +143,14 @@ fn batch_benches<D>(
}
let mut key_reg = KeyRegistration::initialize();
for p in initializers.iter() {
key_reg.register_by_entry(&p.clone().try_into().unwrap()).unwrap();
key_reg
.register(
p.stake,
&p.get_verification_key_proof_of_possession_for_concatenation(),
#[cfg(feature = "future_snark")]
p.schnorr_verification_key,
)
.unwrap();
}

let closed_reg = key_reg.close_registration(&params).unwrap();
Expand Down
18 changes: 9 additions & 9 deletions mithril-stm/examples/key_registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rand_core::{RngCore, SeedableRng};
use mithril_stm::{
AggregateSignature, AggregateSignatureType, AncillaryGenesisData, AncillaryProofInput, Clerk,
ClosedKeyRegistration, Initializer, KeyRegistration, MithrilMembershipDigest, Parameters,
RegistrationEntry, Stake, VerificationKeyProofOfPossessionForConcatenation,
Stake, VerificationKeyProofOfPossessionForConcatenation,
};

type D = MithrilMembershipDigest;
Expand Down Expand Up @@ -236,14 +236,14 @@ fn local_reg(
};
// data, such as the public key, stake and id.
for (pk, _) in pks.iter().zip(ids.iter()) {
let entry = RegistrationEntry::new(
*pk,
1,
#[cfg(feature = "future_snark")]
None,
)
.unwrap();
local_keyreg.register_by_entry(&entry).unwrap();
local_keyreg
.register(
1,
pk,
#[cfg(feature = "future_snark")]
None,
)
.unwrap();
}
local_keyreg.close_registration(&params).unwrap()
}
14 changes: 7 additions & 7 deletions mithril-stm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//!
//! use mithril_stm::{
//! AggregateSignatureType, AggregationError, AncillaryGenesisData, AncillaryProofInput, Clerk,
//! Initializer, KeyRegistration, Parameters, RegistrationEntry, Signer, SingleSignature,
//! Initializer, KeyRegistration, Parameters, Signer, SingleSignature,
//! MithrilMembershipDigest,
//! };
//!
Expand Down Expand Up @@ -59,13 +59,12 @@
//! // Create keys for this party
//! let p = Initializer::new(params, stake, &mut rng);
//! // Register keys with the KeyRegistration service
//! let entry = RegistrationEntry::new(
//! p.get_verification_key_proof_of_possession_for_concatenation(),
//! key_reg.register(
//! p.stake,
//! &p.get_verification_key_proof_of_possession_for_concatenation(),
//! #[cfg(feature = "future_snark")] p.schnorr_verification_key,
//! )
//! .unwrap();
//! key_reg.register_by_entry(&entry).unwrap();
//! ps.push(p);
//! }
//!
Expand Down Expand Up @@ -148,14 +147,15 @@ mod protocol;
mod signature_scheme;

pub use proof_system::AggregateVerificationKeyForConcatenation;
pub(crate) use protocol::RegistrationEntry;
pub use protocol::{
AggregateSignature, AggregateSignatureError, AggregateSignatureType, AggregateVerificationKey,
AggregationError, AncillaryGenesisData, AncillaryProofInput, AncillaryProofOutput,
AncillaryProverData, AncillaryVerifierData, Clerk, ClosedKeyRegistration,
ClosedRegistrationEntry, GenesisVerificationKeyBundle, Initializer, KeyRegistration,
Parameters, RegisterError, RegistrationEntry, RegistrationEntryForConcatenation,
SignatureError, Signer, SingleSignature, SingleSignatureWithRegisteredParty,
VerificationKeyForConcatenation, VerificationKeyProofOfPossessionForConcatenation,
Parameters, RegisterError, RegistrationEntryForConcatenation, SignatureError, Signer,
SingleSignature, SingleSignatureWithRegisteredParty, VerificationKeyForConcatenation,
VerificationKeyProofOfPossessionForConcatenation,
};
pub use signature_scheme::BlsSignatureError;

Expand Down
27 changes: 22 additions & 5 deletions mithril-stm/src/membership_commitment/merkle_tree/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,31 @@ impl<D: Digest + FixedOutput, L: MerkleTreeLeaf> MerkleTreeBatchCommitment<D, L>
)));
}

let nr_nodes = self.nr_leaves + self.nr_leaves.next_power_of_two() - 1;
let nr_leaves_next_pow_2 = self
.nr_leaves
.checked_next_power_of_two()
.ok_or(MerkleTreeError::SerializationError)?;

let nr_nodes = nr_leaves_next_pow_2
.checked_add(self.nr_leaves)
.and_then(|nr_nodes| nr_nodes.checked_sub(1))
.ok_or(MerkleTreeError::SerializationError)?;

ordered_indices = ordered_indices
.into_iter()
.map(|i| i + self.nr_leaves.next_power_of_two() - 1)
.collect();

let mut idx = ordered_indices[0];
.map(|i| {
nr_leaves_next_pow_2
.checked_add(i)
.and_then(|idx| idx.checked_sub(1))
.ok_or(MerkleTreeError::SerializationError)
})
.collect::<Result<Vec<_>, _>>()?;

let mut idx = ordered_indices
.first()
.copied()
.ok_or(MerkleTreeError::SerializationError)
.with_context(|| "The ordered indices list is empty.")?;
// First we need to hash the leave values
let mut leaves: Vec<Vec<u8>> = batch_val
.iter()
Expand Down
Loading