Correct clippy warnings

Currently intended to be done with:
cargo clippy --features "recommended merlin batch serialize experimental 
ed25519 ristretto p256 secp256k1 multisig" -- -A clippy::type_complexity 
-A dead_code
This commit is contained in:
Luke Parker
2022-07-22 02:34:36 -04:00
parent 3556584478
commit 76a7160ea5
36 changed files with 129 additions and 122 deletions

View File

@@ -8,7 +8,7 @@ use crate::{Commitment, wallet::TransactionError, serialize::*};
pub(crate) const MAX_OUTPUTS: usize = 16;
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Bulletproofs {
pub A: EdwardsPoint,
pub S: EdwardsPoint,

View File

@@ -41,7 +41,7 @@ pub enum ClsagError {
InvalidC1,
}
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct ClsagInput {
// The actual commitment for the true spend
pub commitment: Commitment,
@@ -69,6 +69,7 @@ impl ClsagInput {
}
}
#[allow(clippy::large_enum_variant)]
enum Mode {
Sign(usize, EdwardsPoint, EdwardsPoint),
#[cfg(feature = "experimental")]
@@ -182,7 +183,7 @@ fn core(
((D, c * mu_P, c * mu_C), c1.unwrap_or(c))
}
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Clsag {
pub D: EdwardsPoint,
pub s: Vec<Scalar>,

View File

@@ -65,7 +65,7 @@ impl ClsagDetails {
}
#[allow(non_snake_case)]
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
struct Interim {
p: Scalar,
c: Scalar,
@@ -147,7 +147,7 @@ impl Algorithm<Ed25519> for ClsagMultisig {
l: u16,
serialized: &mut Re,
) -> Result<(), FrostError> {
if self.image.is_identity().into() {
if self.image.is_identity() {
self.transcript.domain_separate(b"CLSAG");
self.input().transcript(&mut self.transcript);
self.transcript.append_message(b"mask", &self.mask().to_bytes());
@@ -189,15 +189,13 @@ impl Algorithm<Ed25519> for ClsagMultisig {
&self.image,
&self.input(),
self.mask(),
&self.msg.as_ref().unwrap(),
self.msg.as_ref().unwrap(),
nonce_sums[0][0].0,
nonce_sums[0][1].0,
);
self.interim = Some(Interim { p, c, clsag, pseudo_out });
let share = dfg::Scalar(nonces[0].0 - (p * view.secret_share().0));
share
dfg::Scalar(nonces[0].0 - (p * view.secret_share().0))
}
#[must_use]
@@ -215,13 +213,13 @@ impl Algorithm<Ed25519> for ClsagMultisig {
&self.input().decoys.ring,
&self.image,
&interim.pseudo_out,
&self.msg.as_ref().unwrap(),
self.msg.as_ref().unwrap(),
)
.is_ok()
{
return Some((clsag, interim.pseudo_out));
}
return None;
None
}
#[must_use]
@@ -232,7 +230,6 @@ impl Algorithm<Ed25519> for ClsagMultisig {
share: dfg::Scalar,
) -> bool {
let interim = self.interim.as_ref().unwrap();
return (&share.0 * &ED25519_BASEPOINT_TABLE) ==
(nonces[0][0].0 - (interim.p * verification_share.0));
(&share.0 * &ED25519_BASEPOINT_TABLE) == (nonces[0][0].0 - (interim.p * verification_share.0))
}
}

View File

@@ -59,7 +59,7 @@ pub(crate) fn rust_hash_to_point(key: EdwardsPoint) -> EdwardsPoint {
#[allow(non_snake_case)]
let mut Y = z - w;
Y = Y * Z.invert().unwrap();
Y *= Z.invert().unwrap();
let mut bytes = Y.to_repr();
bytes[31] |= sign.unwrap_u8() << 7;

View File

@@ -15,7 +15,7 @@ pub fn generate_key_image(secret: Scalar) -> EdwardsPoint {
secret * hash_to_point(&secret * &ED25519_BASEPOINT_TABLE)
}
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct RctBase {
pub fee: u64,
pub ecdh_info: Vec<[u8; 8]>,
@@ -68,7 +68,7 @@ impl RctBase {
}
}
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum RctPrunable {
Null,
Clsag { bulletproofs: Vec<Bulletproofs>, clsags: Vec<Clsag>, pseudo_outs: Vec<EdwardsPoint> },
@@ -90,9 +90,9 @@ impl RctPrunable {
match self {
RctPrunable::Null => Ok(()),
RctPrunable::Clsag { bulletproofs, clsags, pseudo_outs } => {
write_vec(Bulletproofs::serialize, &bulletproofs, w)?;
write_raw_vec(Clsag::serialize, &clsags, w)?;
write_raw_vec(write_point, &pseudo_outs, w)
write_vec(Bulletproofs::serialize, bulletproofs, w)?;
write_raw_vec(Clsag::serialize, clsags, w)?;
write_raw_vec(write_point, pseudo_outs, w)
}
}
}
@@ -122,13 +122,13 @@ impl RctPrunable {
match self {
RctPrunable::Null => panic!("Serializing RctPrunable::Null for a signature"),
RctPrunable::Clsag { bulletproofs, .. } => {
bulletproofs.iter().map(|bp| bp.signature_serialize(w)).collect()
bulletproofs.iter().try_for_each(|bp| bp.signature_serialize(w))
}
}
}
}
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct RctSignatures {
pub base: RctBase,
pub prunable: RctPrunable,