Skip to content

Commit

Permalink
Change generator in the Stark252PrimeField to one of maximal order $2…
Browse files Browse the repository at this point in the history
…^{192}$ (#572)

* use a generator of the 2-Sylow subgroup in the Stark252PrimeField

* use square
  • Loading branch information
schouhy authored Sep 22, 2023
1 parent fe9c24f commit ba2645c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
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

0 comments on commit ba2645c

Please sign in to comment.