Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbejarano820 committed Sep 5, 2023
1 parent 7e71e4d commit 330b7c7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion math/src/field/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ mod tests {
fn test_inplace_batch_inverse_returns_inverses(vec in field_vec(10)) {
let input: Vec<_> = vec.into_iter().filter(|x| x != &FieldElement::<Stark252PrimeField>::zero()).collect();
let mut inverses = input.clone();
FieldElement::inplace_batch_inverse(&mut inverses);
let _ = FieldElement::inplace_batch_inverse(&mut inverses);

for (i, x) in inverses.into_iter().enumerate() {
prop_assert_eq!(x * input[i], FieldElement::<Stark252PrimeField>::one());
Expand Down
12 changes: 7 additions & 5 deletions math/src/field/fields/montgomery_backed_prime_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ where
#[inline(always)]
fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError> {
if a == &Self::ZERO {
panic!("Division by zero error.")
Err(FieldError::InvZeroError)
} else {
// Guajardo Kumar Paar Pelzl
// Efficient Software-Implementation of Finite Fields with Applications to
Expand Down Expand Up @@ -353,6 +353,7 @@ where
#[cfg(test)]
mod tests_u384_prime_fields {
use crate::field::element::FieldElement;
use crate::field::errors::FieldError;
use crate::field::fields::fft_friendly::stark_252_prime_field::Stark252PrimeField;
use crate::field::fields::montgomery_backed_prime_fields::{
IsModulus, U256PrimeField, U384PrimeField,
Expand Down Expand Up @@ -515,9 +516,9 @@ mod tests_u384_prime_fields {
}

#[test]
#[should_panic]
fn inv_0_error() {
U384F23Element::from(0).inv();
let result = U384F23Element::from(0).inv();
assert!(matches!(result, Err(FieldError::InvZeroError)))
}

#[test]
Expand Down Expand Up @@ -742,6 +743,7 @@ mod tests_u384_prime_fields {
#[cfg(test)]
mod tests_u256_prime_fields {
use crate::field::element::FieldElement;
use crate::field::errors::FieldError;
use crate::field::fields::montgomery_backed_prime_fields::{IsModulus, U256PrimeField};
use crate::field::traits::IsField;
use crate::field::traits::IsPrimeField;
Expand Down Expand Up @@ -860,9 +862,9 @@ mod tests_u256_prime_fields {
}

#[test]
#[should_panic]
fn inv_0_error() {
U256F29Element::from(0).inv();
let result = U256F29Element::from(0).inv();
assert!(matches!(result, Err(FieldError::InvZeroError)));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions math/src/field/fields/u64_prime_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ mod tests {
}

#[test]
#[should_panic]
fn inv_0_error() {
FE::new(0).inv();
let result = FE::new(0).inv();
assert!(matches!(result, Err(FieldError::InvZeroError)));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion math/src/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<F: IsField> Polynomial<FieldElement<F>> {
}
}

FieldElement::inplace_batch_inverse(&mut denominators);
let _ = FieldElement::inplace_batch_inverse(&mut denominators);

let mut result = Polynomial::zero();

Expand Down
2 changes: 1 addition & 1 deletion provers/plonk/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ where
.collect();

let mut zh_eval = zh.evaluate_offset_fft(1, Some(degree), offset).unwrap();
FieldElement::inplace_batch_inverse(&mut zh_eval);
let _ = FieldElement::inplace_batch_inverse(&mut zh_eval);
let c: Vec<_> = p_eval
.iter()
.zip(zh_eval.iter())
Expand Down

0 comments on commit 330b7c7

Please sign in to comment.