diff --git a/Cargo.toml b/Cargo.toml index 861c9a1..a8e67da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,4 @@ ark-serialize = { git = "https://github.com/arkworks-rs/algebra" } ark-bls12-381 = { git = "https://github.com/arkworks-rs/algebra" } ark-curve25519 = { git = "https://github.com/arkworks-rs/algebra" } ark-pallas = { git = "https://github.com/arkworks-rs/algebra" } -ark-vesta = { git = "https://github.com/arkworks-rs/algebra" } \ No newline at end of file +ark-vesta = { git = "https://github.com/arkworks-rs/algebra" } diff --git a/nimue-anemoi/src/lib.rs b/nimue-anemoi/src/lib.rs index 3707711..07819be 100644 --- a/nimue-anemoi/src/lib.rs +++ b/nimue-anemoi/src/lib.rs @@ -2,7 +2,6 @@ //! //! The main reason for this code not being deployed is that [anemoi](https://anemoi-hash.github.io/)'s Rust implementation //! is not published as a crate and thus `nimue` cannot publish it along with a new release. -use anemoi; use ark_ff::{Field, PrimeField}; use zeroize::Zeroize; diff --git a/nimue-poseidon/src/lib.rs b/nimue-poseidon/src/lib.rs index fd1553e..3e356e0 100644 --- a/nimue-poseidon/src/lib.rs +++ b/nimue-poseidon/src/lib.rs @@ -53,12 +53,12 @@ impl PoseidonSpo // Full rounds apply the S Box (x^alpha) to every element of state if is_full_round { for elem in state { - *elem = elem.pow(&[self.alpha]); + *elem = elem.pow([self.alpha]); } } // Partial rounds apply the S Box (x^alpha) to just the first element of state else { - state[0] = state[0].pow(&[self.alpha]); + state[0] = state[0].pow([self.alpha]); } } @@ -69,6 +69,7 @@ impl PoseidonSpo }); } + #[allow(clippy::needless_range_loop)] fn apply_mds(&self, state: &mut [F]) { let mut new_state = [F::ZERO; N]; for i in 0..N { @@ -108,7 +109,7 @@ where fn permute(&mut self) { let full_rounds_over_2 = self.full_rounds / 2; - let mut state = self.state.clone(); + let mut state = self.state; for i in 0..full_rounds_over_2 { self.apply_ark(&mut state, i); self.apply_s_box(&mut state, true); diff --git a/nimue-pow/src/blake3.rs b/nimue-pow/src/blake3.rs index 455abe0..7c928bf 100644 --- a/nimue-pow/src/blake3.rs +++ b/nimue-pow/src/blake3.rs @@ -74,7 +74,7 @@ impl PowStrategy for Blake3PoW { // Use atomics to find the unique deterministic lowest satisfying nonce. let global_min = AtomicU64::new(u64::MAX); let _ = broadcast(|ctx| { - let mut worker = self.clone(); + let mut worker = *self; let nonces = ((MAX_SIMD_DEGREE * ctx.index()) as u64..) .step_by(MAX_SIMD_DEGREE * ctx.num_threads()); for nonce in nonces { diff --git a/nimue/Cargo.toml b/nimue/Cargo.toml index 4b79163..e6fb7c0 100644 --- a/nimue/Cargo.toml +++ b/nimue/Cargo.toml @@ -58,3 +58,7 @@ required-features = ["ark"] [[example]] name = "bulletproof" required-features = ["ark"] + +[lints.clippy] +too_long_first_doc_paragraph = "allow" +doc_lazy_continuation = "allow" diff --git a/nimue/examples/bulletproof.rs b/nimue/examples/bulletproof.rs index b350dfc..eadfeed 100644 --- a/nimue/examples/bulletproof.rs +++ b/nimue/examples/bulletproof.rs @@ -107,8 +107,8 @@ where { let mut g = generators.0.to_vec(); let mut h = generators.1.to_vec(); - let u = generators.2.clone(); - let mut statement = statement.clone(); + let u = *generators.2; + let mut statement = *statement; while n != 1 { let [left, right]: [G; 2] = arthur.next_points().unwrap(); diff --git a/nimue/src/arthur.rs b/nimue/src/arthur.rs index dafb540..97611b7 100644 --- a/nimue/src/arthur.rs +++ b/nimue/src/arthur.rs @@ -6,6 +6,7 @@ use crate::traits::{ByteReader, UnitTranscript}; use crate::DefaultHash; /// [`Arthur`] contains the verifier state. +/// /// Internally, it is a wrapper around a SAFE sponge. /// Given as input an [`IOPattern`] and a protocol transcript, it allows to /// de-serialize elements from the transcript and make them available to the zero-knowledge verifier. diff --git a/nimue/src/hash/legacy.rs b/nimue/src/hash/legacy.rs index 4d36bb8..62b4346 100644 --- a/nimue/src/hash/legacy.rs +++ b/nimue/src/hash/legacy.rs @@ -78,7 +78,7 @@ impl DigestBridge { // and the current digest let byte_count = count * Self::DIGEST_SIZE - self.leftovers.len(); let mut squeeze_hasher = D::new(); - Digest::update(&mut squeeze_hasher, &Self::mask_squeeze_end()); + Digest::update(&mut squeeze_hasher, Self::mask_squeeze_end()); Digest::update(&mut squeeze_hasher, &self.cv); Digest::update(&mut squeeze_hasher, byte_count.to_be_bytes()); self.cv = Digest::finalize(squeeze_hasher); @@ -127,7 +127,7 @@ impl DuplexHash for Di if self.mode == Mode::Start { self.mode = Mode::Absorb; - Digest::update(&mut self.hasher, &Self::mask_absorb()); + Digest::update(&mut self.hasher, Self::mask_absorb()); Digest::update(&mut self.hasher, &self.cv); } @@ -138,7 +138,7 @@ impl DuplexHash for Di fn ratchet_unchecked(&mut self) -> &mut Self { self.squeeze_end(); // Double hash - self.cv = ::digest(&self.hasher.finalize_reset()); + self.cv = ::digest(self.hasher.finalize_reset()); // Restart the rest of the data self.leftovers.zeroize(); self.leftovers.clear(); @@ -150,7 +150,7 @@ impl DuplexHash for Di if self.mode == Mode::Start { self.mode = Mode::Squeeze(0); // create the prefix hash - Digest::update(&mut self.hasher, &Self::mask_squeeze()); + Digest::update(&mut self.hasher, Self::mask_squeeze()); Digest::update(&mut self.hasher, &self.cv); self.squeeze_unchecked(output) // If Absorbing, ratchet diff --git a/nimue/src/plugins/ark/common.rs b/nimue/src/plugins/ark/common.rs index 61d47db..9a48030 100644 --- a/nimue/src/plugins/ark/common.rs +++ b/nimue/src/plugins/ark/common.rs @@ -109,9 +109,8 @@ where fn public_scalars(&mut self, input: &[F]) -> ProofResult { let flattened: Vec<_> = input - .into_iter() - .map(|f| f.to_base_prime_field_elements()) - .flatten() + .iter() + .flat_map(|f| f.to_base_prime_field_elements()) .collect(); self.public_units(&flattened)?; Ok(()) @@ -147,9 +146,8 @@ where fn public_scalars(&mut self, input: &[F]) -> ProofResult { let flattened: Vec<_> = input - .into_iter() - .map(|f| f.to_base_prime_field_elements()) - .flatten() + .iter() + .flat_map(|f| f.to_base_prime_field_elements()) .collect(); self.public_units(&flattened)?; Ok(()) @@ -206,7 +204,7 @@ where } } -impl<'a, H, R, C, const N: usize> BytePublic for Merlin, R> +impl BytePublic for Merlin, R> where C: FpConfig, H: DuplexHash>, @@ -220,14 +218,14 @@ where } } -impl<'a, H, R, C, const N: usize> ByteChallenges for Merlin, R> +impl ByteChallenges for Merlin, R> where C: FpConfig, H: DuplexHash>, R: CryptoRng + rand::RngCore, { fn fill_challenge_bytes(&mut self, output: &mut [u8]) -> Result<(), IOPatternError> { - if output == &[] { + if output.is_empty() { Ok(()) } else { let len_good = usize::min( @@ -252,7 +250,7 @@ where H: DuplexHash>, { fn fill_challenge_bytes(&mut self, output: &mut [u8]) -> Result<(), IOPatternError> { - if output == &[] { + if output.is_empty() { Ok(()) } else { let len_good = usize::min( diff --git a/nimue/src/plugins/ark/mod.rs b/nimue/src/plugins/ark/mod.rs index 2c8e46f..ccecb04 100644 --- a/nimue/src/plugins/ark/mod.rs +++ b/nimue/src/plugins/ark/mod.rs @@ -146,7 +146,7 @@ pub fn swap_field(a_f1: F1) -> P let a_f2 = F2::from_le_bytes_mod_order(&a_f1.into_bigint().to_bytes_le()); let a_f1_control = F1::from_le_bytes_mod_order(&a_f2.into_bigint().to_bytes_le()); (a_f1 == a_f1_control) - .then(|| a_f2) + .then_some(a_f2) .ok_or(ProofError::SerializationError) } diff --git a/nimue/src/plugins/mod.rs b/nimue/src/plugins/mod.rs index 5b1f6e0..12a1da0 100644 --- a/nimue/src/plugins/mod.rs +++ b/nimue/src/plugins/mod.rs @@ -37,7 +37,7 @@ pub(super) fn random_bits_in_random_modp(b: ark_ff::BigInt) - // compute the remainder of b by 2^n let r_bits = &b.to_bits_le()[..n as usize]; let r = BigInt::::from_bits_le(r_bits); - let log2_a_minus_r = r_bits.into_iter().rev().skip_while(|&&bit| bit).count() as u32; + let log2_a_minus_r = r_bits.iter().rev().skip_while(|&&bit| bit).count() as u32; if b.num_bits() + n - 1 - r.num_bits() - log2_a_minus_r >= 128 { return n as usize; }