Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/crypto/src/hash/monolith/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<const WIDTH: usize, const NUM_FULL_ROUNDS: usize> MonolithMersenne31<WIDTH,
pub fn new() -> Self {
assert!(WIDTH >= 8);
assert!(WIDTH <= 24);
assert!(WIDTH % 4 == 0);
assert!(WIDTH.is_multiple_of(4));
Self {
round_constants: Self::instantiate_round_constants(),
lookup1: Self::instantiate_lookup1(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl RescuePrimeOptimized {
pub fn hash(&self, input_sequence: &[Fp]) -> Vec<Fp> {
let mut state = vec![Fp::zero(); self.m];
let input_len = input_sequence.len();
if input_len % self.rate != 0 {
if !input_len.is_multiple_of(self.rate) {
state[0] = Fp::one();
}
let num_full_chunks = input_len / self.rate;
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/src/merkle_tree/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<T: PartialEq + Eq> Proof<T> {
let mut hashed_value = B::hash_data(value);

for sibling_node in self.merkle_path.iter() {
if index % 2 == 0 {
if index.is_multiple_of(2) {
hashed_value = B::hash_new_parent(&hashed_value, sibling_node);
} else {
hashed_value = B::hash_new_parent(sibling_node, &hashed_value);
Expand Down
4 changes: 2 additions & 2 deletions crates/crypto/src/merkle_tree/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use super::traits::IsMerkleTreeBackend;
use rayon::prelude::*;

pub fn sibling_index(node_index: usize) -> usize {
if node_index % 2 == 0 {
if node_index.is_multiple_of(2) {
node_index - 1
} else {
node_index + 1
}
}

pub fn parent_index(node_index: usize) -> usize {
if node_index % 2 == 0 {
if node_index.is_multiple_of(2) {
(node_index - 1) / 2
} else {
node_index / 2
Expand Down
2 changes: 1 addition & 1 deletion crates/math/benches/elliptic_curves/bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn bls12_381_elliptic_curve_benchmarks(c: &mut Criterion) {

// Subgroup Check G1
group.bench_function("Subgroup Check G1", |bencher| {
bencher.iter(|| (black_box(a_g1.is_in_subgroup())));
bencher.iter(|| black_box(a_g1.is_in_subgroup()));
});

// Ate Pairing
Expand Down
2 changes: 1 addition & 1 deletion crates/math/benches/elliptic_curves/bn_254.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn bn_254_elliptic_curve_benchmarks(c: &mut Criterion) {

// Subgroup Check G2
group.bench_function("Subgroup Check G2", |bencher| {
bencher.iter(|| (black_box(a_g2.is_in_subgroup())));
bencher.iter(|| black_box(a_g2.is_in_subgroup()));
});

// Ate Pairing
Expand Down
4 changes: 2 additions & 2 deletions crates/math/src/elliptic_curve/short_weierstrass/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ where
) -> Result<Self, DeserializationError> {
match point_format {
PointFormat::Projective => {
if bytes.len() % 3 != 0 {
if !bytes.len().is_multiple_of(3) {
return Err(DeserializationError::InvalidAmountOfBytes);
}

Expand Down Expand Up @@ -369,7 +369,7 @@ where
}
}
PointFormat::Uncompressed => {
if bytes.len() % 2 != 0 {
if !bytes.len().is_multiple_of(2) {
return Err(DeserializationError::InvalidAmountOfBytes);
}

Expand Down
3 changes: 1 addition & 2 deletions crates/math/src/fft/cpu/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
E: IsField,
{
debug_assert!(input.len().is_power_of_two());
debug_assert!(input.len().ilog2() % 2 == 0); // Even power of 2 => x is power of 4
debug_assert!(input.len().ilog2().is_multiple_of(2)); // Even power of 2 => x is power of 4

// divide input in groups, starting with 1, duplicating the number of groups in each stage.
let mut group_count = 1;
Expand Down Expand Up @@ -183,7 +183,6 @@ mod tests {
use crate::fft::cpu::roots_of_unity::get_twiddles;
use crate::fft::test_helpers::naive_matrix_dft_test;
use crate::field::{test_fields::u64_test_field::U64TestField, traits::RootsConfig};
use alloc::format;
use proptest::{collection, prelude::*};

use super::*;
Expand Down
1 change: 0 additions & 1 deletion crates/math/src/fft/cpu/roots_of_unity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ mod tests {
},
field::{test_fields::u64_test_field::U64TestField, traits::RootsConfig},
};
use alloc::format;
use proptest::prelude::*;

type F = U64TestField;
Expand Down
2 changes: 0 additions & 2 deletions crates/math/src/fft/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ mod tests {
#[cfg(not(feature = "cuda"))]
use crate::field::traits::IsField;

use alloc::format;

use crate::field::{
test_fields::u64_test_field::{U64TestField, U64TestFieldExtension},
traits::RootsConfig,
Expand Down
1 change: 0 additions & 1 deletion crates/math/src/fft/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ mod fft_helpers_test {
use super::*;
use crate::{field::test_fields::u64_test_field::U64TestField, polynomial::Polynomial};

use alloc::format;
use proptest::{collection, prelude::*};

type F = U64TestField;
Expand Down
2 changes: 0 additions & 2 deletions crates/math/src/field/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,6 @@ mod tests {
#[cfg(feature = "alloc")]
#[test]
fn test_inplace_batch_inverse_returns_inverses(vec in field_vec(10)) {
use alloc::format;

let input: Vec<_> = vec.into_iter().filter(|x| x != &FieldElement::<Stark252PrimeField>::zero()).collect();
let mut inverses = input.clone();
FieldElement::inplace_batch_inverse(&mut inverses).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/math/src/field/fields/mersenne31/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Mersenne31Field {
iter: I,
) -> <Self as IsField>::BaseType {
// Delayed reduction
Self::from_u64(iter.map(|x| (x as u64)).sum::<u64>())
Self::from_u64(iter.map(|x| x as u64).sum::<u64>())
}

/// Computes a * 2^k, with 0 < k < 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<const MODULUS: u32> IsPrimeField for U32MontgomeryBackendPrimeField<MODULUS

u64::from_str_radix(hex, 16)
.map_err(|_| CreationError::InvalidHexString)
.map(|value| ((value % MODULUS as u64) as u32))
.map(|value| (value % MODULUS as u64) as u32)
}

#[cfg(feature = "std")]
Expand Down
2 changes: 1 addition & 1 deletion crates/math/src/msm/pippenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ mod tests {
},
unsigned_integer::element::UnsignedInteger,
};
use alloc::{format, vec::Vec};
use alloc::vec::Vec;
use proptest::{collection, prelude::*, prop_assert_eq, prop_compose, proptest};

const _CASES: u32 = 20;
Expand Down
1 change: 0 additions & 1 deletion crates/math/src/polynomial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,6 @@ mod tests {
assert_eq!(p1, &p1_expected);
}

use alloc::format;
use proptest::prelude::*;
proptest! {
#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/math/src/polynomial/sparse_multilinear_poly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
/// Returns the bit decomposition (Vec<bool>) of the `index` of an evaluation within the sparse multilinear polynomial.
fn get_bits(n: usize, num_bits: usize) -> Vec<bool> {
(0..num_bits)
.map(|shift_amount| ((n & (1 << (num_bits - shift_amount - 1))) > 0))
.map(|shift_amount| (n & (1 << (num_bits - shift_amount - 1))) > 0)
.collect::<Vec<bool>>()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl IsWinterfellFieldElement for AdapterFieldElement {
}

unsafe fn bytes_as_elements(bytes: &[u8]) -> Result<&[Self], DeserializationError> {
if bytes.len() % Self::ELEMENT_BYTES != 0 {
if !bytes.len().is_multiple_of(Self::ELEMENT_BYTES) {
return Err(DeserializationError::InvalidValue(format!(
"number of bytes ({}) does not divide into whole number of field elements",
bytes.len(),
Expand All @@ -74,7 +74,7 @@ impl IsWinterfellFieldElement for AdapterFieldElement {
let p = bytes.as_ptr();
let len = bytes.len() / Self::ELEMENT_BYTES;

if (p as usize) % mem::align_of::<u64>() != 0 {
if !(p as usize).is_multiple_of(mem::align_of::<u64>()) {
return Err(DeserializationError::InvalidValue(
"slice memory alignment is not valid for this field element type".to_string(),
));
Expand Down
Loading