Skip to content

Commit

Permalink
clippy fixes; add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xoloki committed Nov 4, 2024
1 parent 11e3ca4 commit 645c263
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
30 changes: 14 additions & 16 deletions src/state_machine/coordinator/fire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,23 +361,21 @@ impl<Aggregator: AggregatorTrait> Coordinator<Aggregator> {
))),
));
}
} else if let Some(signature) = &self.signature {
return Ok((
None,
Some(OperationResult::Sign(Signature {
R: signature.R,
z: signature.z,
})),
));
} else {
if let Some(signature) = &self.signature {
return Ok((
None,
Some(OperationResult::Sign(Signature {
R: signature.R,
z: signature.z,
})),
));
} else {
return Ok((
None,
Some(OperationResult::SignError(SignError::Coordinator(
Error::MissingSignature,
))),
));
}
return Ok((
None,
Some(OperationResult::SignError(SignError::Coordinator(
Error::MissingSignature,
))),
));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl Party {
r = -r;
}

// When using BIP-340 32-byte public keys, we have to invert the private key if the public key is odd. But if we're also using BIP-341 tweaked keys, we have to do the same thing if the tweaked public key is odd. In that case, only invert the public key if exactly one of the internal or tweaked public keys is odd
// When using BIP-340 32-byte public keys, we have to invert the private key if the public key is odd. But if we're also using BIP-341 tweaked keys, we have to do the same thing if the tweaked public key is odd. In that case, only invert the public key if exactly one of the internal or tweaked public keys is odd
let mut cx_sign = Scalar::one();
let tweaked_public_key = if let Some(t) = tweak {
if t != Scalar::zero() {
Expand Down Expand Up @@ -320,7 +320,7 @@ impl Aggregator {
z += sig_share.z_i;
}

// The signature shares have already incorporated the private key adjustments, so we just have to add the tweak. But the tweak itself needs to be adjusted if the tweaked public key is odd
// The signature shares have already incorporated the private key adjustments, so we just have to add the tweak. But the tweak itself needs to be adjusted if the tweaked public key is odd
if let Some(t) = tweak {
z += cx_sign * c * t;
}
Expand Down
4 changes: 2 additions & 2 deletions src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl Party {
nonces: &[PublicNonce],
tweak: Option<Scalar>,
) -> SignatureShare {
// When using BIP-340 32-byte public keys, we have to invert the private key if the public key is odd. But if we're also using BIP-341 tweaked keys, we have to do the same thing if the tweaked public key is odd. In that case, only invert the public key if exactly one of the internal or tweaked public keys is odd
// When using BIP-340 32-byte public keys, we have to invert the private key if the public key is odd. But if we're also using BIP-341 tweaked keys, we have to do the same thing if the tweaked public key is odd. In that case, only invert the public key if exactly one of the internal or tweaked public keys is odd
let mut cx_sign = Scalar::one();
let tweaked_public_key = if let Some(t) = tweak {
if t != Scalar::zero() {
Expand Down Expand Up @@ -288,7 +288,7 @@ impl Aggregator {
z += sig_share.z_i;
}

// The signature shares have already incorporated the private key adjustments, so we just have to add the tweak. But the tweak itself needs to be adjusted if the tweaked public key is odd
// The signature shares have already incorporated the private key adjustments, so we just have to add the tweak. But the tweak itself needs to be adjusted if the tweaked public key is odd
if let Some(t) = tweak {
z += cx_sign * c * t;
}
Expand Down

0 comments on commit 645c263

Please sign in to comment.