Skip to content

Commit

Permalink
use Sum from p256k1 7.2; impl PartialEq for PartyState and SignerState
Browse files Browse the repository at this point in the history
  • Loading branch information
xoloki committed Nov 25, 2024
1 parent a535269 commit cbdd76b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ num-traits = "0.2"
polynomial = { version = "0.2.5", features = ["serde"] }
primitive-types = "0.12"
rand_core = "0.6"
p256k1 = { version = "7.1", default-features = false }
p256k1 = { version = "7.2", default-features = false }
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
thiserror = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
taproot::SchnorrProof,
};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
/// The saved state required to reconstruct a party
pub struct PartyState {
/// The party's private polynomial
Expand All @@ -22,7 +22,7 @@ pub struct PartyState {
pub nonce: Nonce,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
/// The saved state required to reconstruct a signer
pub struct SignerState {
/// The signer ID
Expand Down
2 changes: 1 addition & 1 deletion src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Party {
return Err(DkgError::BadPrivateShares(bad_shares));
}

self.private_key = private_shares.values().fold(Scalar::zero(), |a, s| a + s);
self.private_key = private_shares.values().sum();
self.public_key = self.private_key * G;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Party {
for key_id in &self.key_ids {
self.private_keys.insert(*key_id, Scalar::zero());
if let Some(shares) = private_shares.get(key_id) {
let secret = shares.values().fold(Scalar::zero(), |acc, s| acc + s);
let secret = shares.values().sum();
self.private_keys.insert(*key_id, secret);
} else {
warn!(
Expand Down

0 comments on commit cbdd76b

Please sign in to comment.