Skip to content

Commit

Permalink
check dkg private shares for signers specified in dkg end begin; remo…
Browse files Browse the repository at this point in the history
…ve off-by-one in v2 get_shares
  • Loading branch information
xoloki committed Jan 16, 2024
1 parent 878b07c commit 948b713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/state_machine/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl<SignerType: SignerTrait> Signer<SignerType> {

/// do we have all DkgPublicShares and DkgPrivateShares?
pub fn can_dkg_end(&self) -> bool {
info!(
debug!(
"can_dkg_end state {:?} DkgPrivateBegin {} DkgEndBegin {}",
self.state,
self.dkg_private_begin_msg.is_some(),
Expand All @@ -325,7 +325,7 @@ impl<SignerType: SignerTrait> Signer<SignerType> {

if let Some(dkg_end_begin) = &self.dkg_end_begin_msg {
// need private shares from active signers
for signer_id in &dkg_private_begin.signer_ids {
for signer_id in &dkg_end_begin.signer_ids {
if !self.dkg_private_shares.contains_key(&signer_id) {

Check failure on line 329 in src/state_machine/signer/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
info!("can_dkg_end: private shares missing {} false", signer_id);
return false;
Expand All @@ -337,7 +337,7 @@ impl<SignerType: SignerTrait> Signer<SignerType> {
}
}
} else {
info!("can_dkg_end: bad state {:?} false", self.state);
debug!("can_dkg_end: bad state {:?} false", self.state);
return false;
}
false
Expand Down
3 changes: 2 additions & 1 deletion src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Party {
/// Get the shares of this party's private polynomial for all keys
pub fn get_shares(&self) -> HashMap<u32, Scalar> {
let mut shares = HashMap::new();
for i in 0..self.num_keys {
for i in 1..self.num_keys + 1 {
shares.insert(i, self.f.eval(compute::id(i)));
}
shares
Expand Down Expand Up @@ -466,6 +466,7 @@ impl traits::Signer for Party {
for key_id in self.get_key_ids() {
let mut shares = HashMap::new();
for (signer_id, signer_shares) in private_shares.iter() {
println!("{signer_id} {}", key_id);
shares.insert(*signer_id, signer_shares[&key_id]);
}
key_shares.insert(key_id, shares);
Expand Down

0 comments on commit 948b713

Please sign in to comment.