Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for Modulus plus one div four #552

Merged
merged 4 commits into from
Dec 21, 2022
Merged
Changes from 3 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
7 changes: 6 additions & 1 deletion test-templates/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@ macro_rules! __test_field {
assert_eq!(BigUint::from(<$field>::MODULUS_MINUS_ONE_DIV_TWO), &modulus_minus_one / 2u32);
assert_eq!(<$field>::MODULUS_BIT_SIZE as u64, modulus.bits());
if let Some(SqrtPrecomputation::Case3Mod4 { modulus_plus_one_div_four }) = <$field>::SQRT_PRECOMP {
assert_eq!(modulus_plus_one_div_four, &((&modulus + 1u8) / 4u8).to_u64_digits());
// Handle the case where `(MODULUS + 1) / 4`
// has fewer limbs than `MODULUS`.
let check = ((&modulus + 1u8) / 4u8).to_u64_digits();
let len = check.len()
Pratyush marked this conversation as resolved.
Show resolved Hide resolved
assert_eq!(&modulus_plus_one_div_four[..len], &check);
assert!(modulus_plus_one_div_four[len..].iter().all(|l| *l == 0));
}

let mut two_adicity = 0;
Expand Down