Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

No side-effects in getters #39

Closed
wants to merge 8 commits into from
Closed
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
14 changes: 8 additions & 6 deletions benches/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,16 @@ fn criterion_benchmark(c: &mut Criterion) {
let mut aggregator = SignatureAggregator::new(params, group_key, &message[..]);

for i in 1..THRESHOLD_OF_PARTICIPANTS + 1 {
aggregator.include_signer(
i,
participants_public_comshares[(i - 1) as usize].commitments[0],
&participants_secret_keys[(i - 1) as usize].to_public(),
);
aggregator
.include_signer(
i,
participants_public_comshares[(i - 1) as usize].commitments[0],
&participants_secret_keys[(i - 1) as usize].to_public(),
)
.unwrap();
}

let signers = aggregator.get_signers().clone();
let signers = aggregator.signers().to_vec();
let message_hash = Secp256k1Sha256::h4(&message[..]);
let message_hash_copy = message_hash;

Expand Down
20 changes: 19 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub enum Error<C: CipherSuite> {
ComplaintVerificationError,
/// The index of a participant is zero
IndexIsZero,
/// The index of a signer does not match the index in the public key
IndexMismatch(u32, u32),
/// GroupVerifyingKey generation failure
InvalidGroupKey,
/// Invalid NiZK proof of knowledge
Expand All @@ -45,6 +47,8 @@ pub enum Error<C: CipherSuite> {
InvalidMSMParameters,
/// Too many invalid participants, with their indices
TooManyInvalidParticipants(Vec<u32>),
/// Too many unique signers given the [`crate::parameters::ThresholdParameters`].
TooManySigners(usize, u32),
/// The participant is missing commitment shares
MissingCommitmentShares,
/// Invalid binding factor
Expand Down Expand Up @@ -87,7 +91,14 @@ impl<C: CipherSuite> core::fmt::Display for Error<C> {
write!(f, "The complaint is not correct.")
}
Error::IndexIsZero => {
write!(f, "The indexs of a participant cannot be 0.")
write!(f, "The index of a participant cannot be 0.")
}
Error::IndexMismatch(participant_idx, pubkey_idx) => {
write!(
f,
"Index mismatch between participant index ({}) and the public key index ({}).",
participant_idx, pubkey_idx
)
}
Error::InvalidGroupKey => {
write!(
Expand Down Expand Up @@ -136,6 +147,13 @@ impl<C: CipherSuite> core::fmt::Display for Error<C> {
indices
)
}
Error::TooManySigners(signers, n_param) => {
write!(
f,
"Too many signers ({}) given the DKG instance parameters ({}).",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: parameters may refer to both N and T here, maybe emphasize that we're talking about the total number of participants? (although it may be implied, as we don't mind having more signers than the threshold, just out of clarity).

signers, n_param
)
}
Error::MissingCommitmentShares => {
write!(
f,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@
//! #
//! # aggregator.include_signer(1, alice_public_comshares.commitments[0], &alice_public_key);
//! # aggregator.include_signer(3, carol_public_comshares.commitments[0], &carol_public_key);
//! let signers = aggregator.get_signers();
//! let signers = aggregator.signers();
//! # Ok(()) }
//! # fn main() { assert!(do_test().is_ok()); }
//! ```
Expand Down Expand Up @@ -1530,7 +1530,7 @@
//! # aggregator.include_signer(1, alice_public_comshares.commitments[0], &alice_public_key);
//! # aggregator.include_signer(3, carol_public_comshares.commitments[0], &carol_public_key);
//! #
//! # let signers = aggregator.get_signers();
//! # let signers = aggregator.signers();
//! # let message_hash = Secp256k1Sha256::h4(&message[..]);
//!
//! let alice_partial = alice_secret_key.sign(
Expand Down
Loading
Loading