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

Change generator in the Stark252PrimeField to one of maximal order $2^{192}$ #572

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 4 additions & 9 deletions math/src/field/fields/fft_friendly/stark_252_prime_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ impl IsModulus<U256> for MontgomeryConfigStark252PrimeField {
pub type Stark252PrimeField = U256PrimeField<MontgomeryConfigStark252PrimeField>;

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"
Expand Down
5 changes: 3 additions & 2 deletions math/src/field/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.square());
Ok(root)
}
}

Expand Down