diff --git a/src/field/crandall_field.rs b/src/field/crandall_field.rs index 3e84ae41..1c57efa7 100644 --- a/src/field/crandall_field.rs +++ b/src/field/crandall_field.rs @@ -252,15 +252,14 @@ impl Field for CrandallField { } fn from_canonical_biguint(n: BigUint) -> Self { - let last_two: Vec<_> = n + let smallest_two: Vec<_> = n .to_u32_digits() .iter() - .rev() .take(2) .pad_using(2, |_| &0u32) .map(|x| *x as u64) .collect(); - let n_u64 = last_two[0] + (1u64 << 32) * last_two[1]; + let n_u64 = smallest_two[0] + (1u64 << 32) * smallest_two[1]; Self(n_u64) } diff --git a/src/field/extension_field/quadratic.rs b/src/field/extension_field/quadratic.rs index 3d58e34e..a5b78ab6 100644 --- a/src/field/extension_field/quadratic.rs +++ b/src/field/extension_field/quadratic.rs @@ -98,16 +98,15 @@ impl Field for QuadraticCrandallField { } fn from_canonical_biguint(n: BigUint) -> Self { - let last_four: Vec<_> = n + let smallest_four: Vec<_> = n .to_u32_digits() .iter() - .rev() .take(4) .pad_using(4, |_| &0u32) .map(|x| *x as u64) .collect(); - let last_u64 = last_four[0] + (1u64 << 32) * last_four[1]; - let next_last_u64 = last_four[2] + (1u64 << 32) * last_four[3]; + let last_u64 = smallest_four[0] + (1u64 << 32) * smallest_four[1]; + let next_last_u64 = smallest_four[2] + (1u64 << 32) * smallest_four[3]; Self([ >::BaseField::from_canonical_u64(last_u64), diff --git a/src/field/extension_field/quartic.rs b/src/field/extension_field/quartic.rs index 206d07c8..39016533 100644 --- a/src/field/extension_field/quartic.rs +++ b/src/field/extension_field/quartic.rs @@ -138,18 +138,17 @@ impl Field for QuarticCrandallField { } fn from_canonical_biguint(n: BigUint) -> Self { - let last_eight: Vec<_> = n + let smallest_eight: Vec<_> = n .to_u32_digits() .iter() - .rev() .take(8) .pad_using(8, |_| &0u32) .map(|x| *x as u64) .collect(); - let last_u64 = last_eight[0] + (1u64 << 32) * last_eight[1]; - let next_last_u64 = last_eight[2] + (1u64 << 32) * last_eight[3]; - let third_last_u64 = last_eight[4] + (1u64 << 32) * last_eight[5]; - let fourth_last_u64 = last_eight[6] + (1u64 << 32) * last_eight[7]; + let last_u64 = smallest_eight[0] + (1u64 << 32) * smallest_eight[1]; + let next_last_u64 = smallest_eight[2] + (1u64 << 32) * smallest_eight[3]; + let third_last_u64 = smallest_eight[4] + (1u64 << 32) * smallest_eight[5]; + let fourth_last_u64 = smallest_eight[6] + (1u64 << 32) * smallest_eight[7]; Self([ >::BaseField::from_canonical_u64(last_u64),