diff --git a/math/src/field/fields/fft_friendly/stark_252_prime_field.rs b/math/src/field/fields/fft_friendly/stark_252_prime_field.rs index c9baf79b0..abea28907 100644 --- a/math/src/field/fields/fft_friendly/stark_252_prime_field.rs +++ b/math/src/field/fields/fft_friendly/stark_252_prime_field.rs @@ -17,16 +17,11 @@ impl IsModulus for MontgomeryConfigStark252PrimeField { pub type Stark252PrimeField = U256PrimeField; impl IsFFTField for Stark252PrimeField { - const TWO_ADICITY: u64 = 48; + const TWO_ADICITY: u64 = 192; // Change this line for a new function like `from_limbs`. - const TWO_ADIC_PRIMITVE_ROOT_OF_UNITY: U256 = UnsignedInteger { - limbs: [ - 219038664817244121, - 2879838607450979157, - 15244050560987562958, - 16338897044258952332, - ], - }; + const TWO_ADIC_PRIMITVE_ROOT_OF_UNITY: U256 = UnsignedInteger::from_hex_unchecked( + "5282db87529cfa3f0464519c8b0fa5ad187148e11a61616070024f42f8ef94", + ); fn field_name() -> &'static str { "stark256" diff --git a/math/src/field/traits.rs b/math/src/field/traits.rs index 7953e8b04..31d58dff3 100644 --- a/math/src/field/traits.rs +++ b/math/src/field/traits.rs @@ -42,8 +42,9 @@ pub trait IsFFTField: IsPrimeField { if order > F::TWO_ADICITY { return Err(FieldError::RootOfUnityError(order)); } - let power = 1u64 << (F::TWO_ADICITY - order); - Ok(two_adic_primitive_root_of_unity.pow(power)) + let log_power = F::TWO_ADICITY - order; + let root = (0..log_power).fold(two_adic_primitive_root_of_unity, |acc, _| &acc * &acc); + Ok(root) } }