mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 13:09:24 +00:00
Port common, and most of crypto, to a more aggressive clippy
This commit is contained in:
@@ -18,7 +18,7 @@ fn flat<Id: Copy + Zeroize, G: Group + Zeroize>(
|
||||
where
|
||||
<G as Group>::Scalar: PrimeFieldBits + Zeroize,
|
||||
{
|
||||
Zeroizing::new(slice.iter().flat_map(|pairs| pairs.1.iter()).cloned().collect::<Vec<_>>())
|
||||
Zeroizing::new(slice.iter().flat_map(|pairs| pairs.1.iter()).copied().collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
/// A batch verifier intended to verify a series of statements are each equivalent to zero.
|
||||
@@ -35,9 +35,11 @@ where
|
||||
<G as Group>::Scalar: PrimeFieldBits + Zeroize,
|
||||
{
|
||||
/// Create a new batch verifier, expected to verify the following amount of statements.
|
||||
/// This is a size hint and is not required to be accurate.
|
||||
pub fn new(capacity: usize) -> BatchVerifier<Id, G> {
|
||||
BatchVerifier(Zeroizing::new(Vec::with_capacity(capacity)))
|
||||
///
|
||||
/// `capacity` is a size hint and is not required to be accurate.
|
||||
#[must_use]
|
||||
pub fn new(capacity: usize) -> Self {
|
||||
Self(Zeroizing::new(Vec::with_capacity(capacity)))
|
||||
}
|
||||
|
||||
/// Queue a statement for batch verification.
|
||||
@@ -110,6 +112,7 @@ where
|
||||
///
|
||||
/// This function will only return the ID of one invalid statement, even if multiple are invalid.
|
||||
// A constant time variant may be beneficial for robust protocols
|
||||
#[must_use]
|
||||
pub fn blame_vartime(&self) -> Option<Id> {
|
||||
let mut slice = self.0.as_slice();
|
||||
while slice.len() > 1 {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use core::ops::DerefMut;
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
@@ -39,6 +38,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
|
||||
let bit_ref = black_box(bit_ref);
|
||||
|
||||
let mut bit = black_box(*bit_ref);
|
||||
#[allow(clippy::as_conversions, clippy::cast_lossless)]
|
||||
let res = black_box(bit as u8);
|
||||
bit.zeroize();
|
||||
debug_assert!((res | 1) == 1);
|
||||
@@ -62,7 +62,7 @@ where
|
||||
groupings.push(vec![0; (bits.len() + (w_usize - 1)) / w_usize]);
|
||||
|
||||
for (i, mut bit) in bits.iter_mut().enumerate() {
|
||||
let mut bit = u8_from_bool(bit.deref_mut());
|
||||
let mut bit = u8_from_bool(&mut bit);
|
||||
groupings[p][i / w_usize] |= bit << (i % w_usize);
|
||||
bit.zeroize();
|
||||
}
|
||||
@@ -124,7 +124,7 @@ Pippenger 6 is more efficient at 250 with 655µs per
|
||||
Pippenger 7 is more efficient at 475 with 500µs per
|
||||
Pippenger 8 is more efficient at 875 with 499µs per
|
||||
*/
|
||||
fn algorithm(len: usize) -> Algorithm {
|
||||
const fn algorithm(len: usize) -> Algorithm {
|
||||
#[cfg(not(debug_assertions))]
|
||||
if len == 0 {
|
||||
Algorithm::Null
|
||||
|
||||
Reference in New Issue
Block a user