Skip to content

Commit

Permalink
chore: avoid duplicate crates (#942)
Browse files Browse the repository at this point in the history
* chore: avoid duplicate crates

* fix clippy warnings

---------

Co-authored-by: Pratyush Mishra <[email protected]>
  • Loading branch information
rex4539 and Pratyush authored Mar 5, 2025
1 parent fcd7673 commit 3dc7620
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ec/src/hashing/curve_maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pub fn parity<F: Field>(element: &F) -> bool {
element
.to_base_prime_field_elements()
.find(|&x| !x.is_zero())
.map_or(false, |x| x.into_bigint().is_odd())
.is_some_and(|x| x.into_bigint().is_odd())
}
2 changes: 1 addition & 1 deletion ec/src/models/bn/g2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl<P: BnConfig> From<G2Affine<P>> for G2Prepared<P> {
match bit {
1 => ell_coeffs.push(r.add_in_place(&q)),
-1 => ell_coeffs.push(r.add_in_place(&neg_q)),
_ => continue,
_ => {},
}
}

Expand Down
2 changes: 1 addition & 1 deletion ec/src/models/bw6/g2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<P: BW6Config> From<G2Affine<P>> for G2Prepared<P> {
match bit {
1 => ell_coeffs_2.push(r.add_in_place(&qu)),
-1 => ell_coeffs_2.push(r.add_in_place(&neg_qu)),
_ => continue,
_ => {},
}
}

Expand Down
2 changes: 1 addition & 1 deletion ff/src/fields/field_hashers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ const fn get_len_per_elem<F: Field, const SEC_PARAM: usize>() -> usize {
let base_field_size_with_security_padding_in_bits = base_field_size_in_bits + SEC_PARAM;
// ceil( (ceil(log(p)) + security_parameter) / 8)
let bytes_per_base_field_elem =
((base_field_size_with_security_padding_in_bits + 7) / 8) as u64;
base_field_size_with_security_padding_in_bits.div_ceil(8) as u64;
bytes_per_base_field_elem as usize
}
2 changes: 1 addition & 1 deletion ff/src/fields/prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub trait PrimeField:
/// If the integer represented by `bytes` is larger than the modulus `p`, this method
/// performs the appropriate reduction.
fn from_le_bytes_mod_order(bytes: &[u8]) -> Self {
let num_modulus_bytes = ((Self::MODULUS_BIT_SIZE + 7) / 8) as usize;
let num_modulus_bytes = Self::MODULUS_BIT_SIZE.div_ceil(8) as usize;
let num_bytes_to_directly_convert = min(num_modulus_bytes - 1, bytes.len());
// Copy the leading little-endian bytes directly into a field element.
// The number of bytes directly converted must be less than the
Expand Down
2 changes: 1 addition & 1 deletion poly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ark-test-curves = { path = "../test-curves", default-features = false, features
"bn384_small_two_adicity_curve",
"mnt4_753_curve",
] }
criterion = "0.5.1"
criterion = { workspace = true }


[features]
Expand Down
2 changes: 1 addition & 1 deletion poly/src/domain/radix2/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<F: FftField> Radix2EvaluationDomain<F> {

// recursive case:
// 1. split log_powers in half
let (lr_lo, lr_hi) = log_powers.split_at((1 + log_powers.len()) / 2);
let (lr_lo, lr_hi) = log_powers.split_at(log_powers.len().div_ceil(2));
let mut scr_lo = vec![F::default(); 1 << lr_lo.len()];
let mut scr_hi = vec![F::default(); 1 << lr_hi.len()];
// 2. compute each half individually
Expand Down
2 changes: 1 addition & 1 deletion poly/src/evaluations/multivariate/multilinear/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<F: Field> MultilinearExtension<F> for SparseMultilinearExtension<F> {
self.evaluations
.iter()
.map(|(&i, &v)| evaluations[i] = v)
.last();
.next_back();
evaluations
}
}
Expand Down
2 changes: 1 addition & 1 deletion poly/src/polynomial/multivariate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Term for SparseTerm {

/// Returns whether `self` is a constant
fn is_constant(&self) -> bool {
self.len() == 0 || self.degree() == 0
self.is_empty() || self.degree() == 0
}

/// Evaluates `self` at the given `point` in the field.
Expand Down
4 changes: 2 additions & 2 deletions poly/src/polynomial/univariate/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<F: Field> Polynomial<F> for DensePolynomial<F> {
if self.is_zero() {
0
} else {
assert!(self.coeffs.last().map_or(false, |coeff| !coeff.is_zero()));
assert!(self.coeffs.last().is_some_and(|coeff| !coeff.is_zero()));
self.coeffs.len() - 1
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ impl<F: FftField> DensePolynomial<F> {

impl<F: Field> DensePolynomial<F> {
fn truncate_leading_zeros(&mut self) {
while self.coeffs.last().map_or(false, |c| c.is_zero()) {
while self.coeffs.last().is_some_and(|c| c.is_zero()) {
self.coeffs.pop();
}
}
Expand Down
4 changes: 2 additions & 2 deletions poly/src/polynomial/univariate/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<F: Field> Polynomial<F> for SparsePolynomial<F> {
if self.is_zero() {
0
} else {
assert!(self.coeffs.last().map_or(false, |(_, c)| !c.is_zero()));
assert!(self.coeffs.last().is_some_and(|(_, c)| !c.is_zero()));
self.coeffs.last().unwrap().0
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ impl<F: Field> SparsePolynomial<F> {
/// of the same degree are ignored.
pub fn from_coefficients_vec(mut coeffs: Vec<(usize, F)>) -> Self {
// While there are zeros at the end of the coefficient vector, pop them off.
while coeffs.last().map_or(false, |(_, c)| c.is_zero()) {
while coeffs.last().is_some_and(|(_, c)| c.is_zero()) {
coeffs.pop();
}
// Ensure that coeffs are in ascending order.
Expand Down
2 changes: 1 addition & 1 deletion serialize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,5 @@ pub const fn buffer_bit_byte_size(modulus_bits: usize) -> (usize, usize) {
/// into the number of bytes required to represent it.
#[inline]
pub const fn buffer_byte_size(modulus_bits: usize) -> usize {
(modulus_bits + 7) / 8
modulus_bits.div_ceil(8)
}
2 changes: 1 addition & 1 deletion test-templates/src/glv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn glv_scalar_decomposition<P: GLVConfig>() {
}

// check if k1 and k2 are indeed small.
let expected_max_bits = (P::ScalarField::MODULUS_BIT_SIZE + 1) / 2;
let expected_max_bits = P::ScalarField::MODULUS_BIT_SIZE.div_ceil(2);
assert!(
k1.into_bigint().num_bits() <= expected_max_bits,
"k1 has {} bits",
Expand Down

0 comments on commit 3dc7620

Please sign in to comment.