Skip to content
Open
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
8 changes: 5 additions & 3 deletions crates/math/src/circle/cosets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use alloc::vec::Vec;
pub struct Coset {
// Coset: shift + <g_n> where n = 2^{log_2_size}.
// Example: g_16 + <g_8>, n = 8, log_2_size = 3, shift = g_16.
pub log_2_size: u32, //TODO: Change log_2_size to u8 because log_2_size < 31.
pub log_2_size: u8,
pub shift: CirclePoint<Mersenne31Field>,
}

Expand All @@ -23,16 +23,18 @@ impl Coset {
Coset { log_2_size, shift }
}

22 + pub fn new(log_2_size: u8, shift: CirclePoint<Mersenne31Field>) -> Self {

/// Returns the coset g_2n + <g_n>
pub fn new_standard(log_2_size: u32) -> Self {
ppub fn new_standard(log_2_size: u8) -> Self {
// shift is a generator of the subgroup of order 2n = 2^{log_2_size + 1}.
let shift = CirclePoint::get_generator_of_subgroup(log_2_size + 1);
Coset { log_2_size, shift }
}

/// Returns g_n, the generator of the subgroup of order n = 2^log_2_size.
pub fn get_generator(&self) -> CirclePoint<Mersenne31Field> {
CirclePoint::GENERATOR.repeated_double(31 - self.log_2_size)
CirclePoint::GENERATOR.repeated_double((31 - self.log_2_size) as u32)
}

/// Given a standard coset g_2n + <g_n>, returns the subcoset with half size g_2n + <g_{n/2}>
Expand Down
4 changes: 2 additions & 2 deletions crates/math/src/circle/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl<F: IsField + HasCircleParams<F>> CirclePoint<F> {

/// Returns the generator of the subgroup of order n = 2^log_2_size.
/// We are using that 2^k * g is a generator of the subgroup of order 2^{31 - k}.
pub fn get_generator_of_subgroup(log_2_size: u32) -> Self {
Self::GENERATOR.repeated_double(31 - log_2_size)
pub fn get_generator_of_subgroup(log_2_size: u8) -> Self {
Self::GENERATOR.repeated_double((31 - log_2_size) as u32)
}

pub const ORDER: u128 = F::ORDER;
Expand Down
4 changes: 2 additions & 2 deletions crates/math/src/circle/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn evaluate_cfft(

// We get the twiddles for the Evaluation.
let domain_log_2_size: u32 = coeff.len().trailing_zeros();
let coset = Coset::new_standard(domain_log_2_size);
let coset = Coset::new_standard(domain_log_2_size as u8);
let config = TwiddlesConfig::Evaluation;
let twiddles = get_twiddles(coset, config);

Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn interpolate_cfft(

// We get the twiddles for the interpolation.
let domain_log_2_size: u32 = eval.len().trailing_zeros();
let coset = Coset::new_standard(domain_log_2_size);
let coset = Coset::new_standard(domain_log_2_size as u8);
let config = TwiddlesConfig::Interpolation;
let twiddles = get_twiddles(coset, config);

Expand Down