From beb8a727402cf6651fc135603046ecf346c99f4c Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Thu, 5 Oct 2023 13:13:49 -0400 Subject: [PATCH] fmt fixes thanks to less nesting --- src/state_machine/coordinator/mod.rs | 12 ++++-------- src/state_machine/signer/mod.rs | 14 +++++--------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/state_machine/coordinator/mod.rs b/src/state_machine/coordinator/mod.rs index e622fcf..2fd11bd 100644 --- a/src/state_machine/coordinator/mod.rs +++ b/src/state_machine/coordinator/mod.rs @@ -194,10 +194,7 @@ impl Coordinator { return Ok((None, None)); } else if self.state == State::Idle { // We are done with the DKG round! Return the operation result - return Ok(( - None, - Some(OperationResult::Dkg(self.aggregate_public_key)), - )); + return Ok((None, Some(OperationResult::Dkg(self.aggregate_public_key)))); } } State::NonceRequest(is_taproot, merkle_root) => { @@ -537,8 +534,8 @@ impl Coordinator { self.schnorr_proof.r, self.schnorr_proof.s ); } else { - self.signature = - self.aggregator + self.signature = self + .aggregator .sign(&self.message, &nonces, shares, &key_ids)?; info!("Signature ({}, {})", self.signature.R, self.signature.z); } @@ -584,8 +581,7 @@ impl StateMachine for Coordinator { - prev_state == &State::DkgPublicDistribute - || prev_state == &State::DkgPublicGather + prev_state == &State::DkgPublicDistribute || prev_state == &State::DkgPublicGather } State::DkgPrivateDistribute => prev_state == &State::DkgPublicGather, State::DkgEndGather => prev_state == &State::DkgPrivateDistribute, diff --git a/src/state_machine/signer/mod.rs b/src/state_machine/signer/mod.rs index 05c8518..876d7d0 100644 --- a/src/state_machine/signer/mod.rs +++ b/src/state_machine/signer/mod.rs @@ -206,9 +206,7 @@ impl SigningRound { let out_msgs = match message { Message::DkgBegin(dkg_begin) => self.dkg_begin(dkg_begin), Message::DkgPrivateBegin(_) => self.dkg_private_begin(), - Message::DkgPublicShares(dkg_public_shares) => { - self.dkg_public_share(dkg_public_shares) - } + Message::DkgPublicShares(dkg_public_shares) => self.dkg_public_share(dkg_public_shares), Message::DkgPrivateShares(dkg_private_shares) => { self.dkg_private_shares(dkg_private_shares) } @@ -299,7 +297,7 @@ impl SigningRound { self.state == State::DkgPrivateGather && self.commitments.len() == usize::try_from(self.signer.get_num_parties()).unwrap() && self.decrypted_shares.len() - == usize::try_from(self.signer.get_num_parties()).unwrap() + == usize::try_from(self.signer.get_num_parties()).unwrap() } fn nonce_request(&mut self, nonce_request: NonceRequest) -> Result, Error> { @@ -464,8 +462,7 @@ impl SigningRound { let compressed = Compressed::from(self.public_keys.key_ids[&(dst_key_id + 1)].to_bytes()); let dst_public_key = Point::try_from(&compressed).unwrap(); - let shared_secret = - make_shared_secret(&self.network_private_key, &dst_public_key); + let shared_secret = make_shared_secret(&self.network_private_key, &dst_public_key); let encrypted_share = encrypt(&shared_secret, &private_share.to_bytes(), &mut rng).unwrap(); @@ -508,9 +505,8 @@ impl SigningRound { // make a HashSet of our key_ids so we can quickly query them let key_ids: HashSet = self.signer.get_key_ids().into_iter().collect(); - let compressed = Compressed::from( - self.public_keys.signers[&dkg_private_shares.signer_id].to_bytes(), - ); + let compressed = + Compressed::from(self.public_keys.signers[&dkg_private_shares.signer_id].to_bytes()); let public_key = Point::try_from(&compressed).unwrap(); let shared_secret = make_shared_secret(&self.network_private_key, &public_key);