Skip to content

Commit

Permalink
fmt fixes thanks to less nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
xoloki committed Oct 5, 2023
1 parent 6b4cec6 commit beb8a72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
12 changes: 4 additions & 8 deletions src/state_machine/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ impl<Aggregator: AggregatorTrait> Coordinator<Aggregator> {
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) => {
Expand Down Expand Up @@ -537,8 +534,8 @@ impl<Aggregator: AggregatorTrait> Coordinator<Aggregator> {
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);
}
Expand Down Expand Up @@ -584,8 +581,7 @@ impl<Aggregator: AggregatorTrait> StateMachine<State, Error> for Coordinator<Agg
|| prev_state == &State::DkgEndGather
}
State::DkgPublicGather => {
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,
Expand Down
14 changes: 5 additions & 9 deletions src/state_machine/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ impl<Signer: SignerTrait> SigningRound<Signer> {
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)
}
Expand Down Expand Up @@ -299,7 +297,7 @@ impl<Signer: SignerTrait> SigningRound<Signer> {
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<Vec<Message>, Error> {
Expand Down Expand Up @@ -464,8 +462,7 @@ impl<Signer: SignerTrait> SigningRound<Signer> {
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();

Expand Down Expand Up @@ -508,9 +505,8 @@ impl<Signer: SignerTrait> SigningRound<Signer> {

// make a HashSet of our key_ids so we can quickly query them
let key_ids: HashSet<u32> = 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);

Expand Down

0 comments on commit beb8a72

Please sign in to comment.