Skip to content

Commit

Permalink
use fri_domain_generator instead of omega
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Nov 15, 2022
1 parent 5e85155 commit 3b79a73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions triton-vm/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ mod domain_tests {
let poly = Polynomial::<BFieldElement>::new(x_squared_coefficients.clone());

for order in [4, 8, 32] {
let omega = BFieldElement::primitive_root_of_unity(order).unwrap();
let generator = BFieldElement::primitive_root_of_unity(order).unwrap();
let offset = BFieldElement::generator();
let b_domain = Domain::<BFieldElement>::new(offset, omega, order as usize);
let x_domain = Domain::<XFieldElement>::new(offset, omega, order as usize);
let b_domain = Domain::<BFieldElement>::new(offset, generator, order as usize);
let x_domain = Domain::<XFieldElement>::new(offset, generator, order as usize);

let expected_b_values: Vec<BFieldElement> =
(0..order).map(|i| offset * omega.mod_pow(i)).collect();
(0..order).map(|i| offset * generator.mod_pow(i)).collect();
let actual_b_values_1 = b_domain.domain_values();
let actual_b_values_2 = (0..order as u32)
.map(|i| b_domain.domain_value(i))
Expand Down
12 changes: 6 additions & 6 deletions triton-vm/src/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ pub struct Fri<H> {
impl<H: AlgebraicHasher> Fri<H> {
pub fn new(
offset: BFieldElement,
omega: BFieldElement,
fri_domain_generator: BFieldElement,
domain_length: usize,
expansion_factor: usize,
colinearity_checks_count: usize,
) -> Self {
let domain = Domain::new(offset, omega, domain_length);
let domain = Domain::new(offset, fri_domain_generator, domain_length);
let _hasher = PhantomData;
Self {
domain,
Expand Down Expand Up @@ -346,11 +346,11 @@ impl<H: AlgebraicHasher> Fri<H> {
let log_2_of_n = log_2_floor(last_codeword.len() as u128) as u32;
let mut last_polynomial = last_codeword.clone();

let last_omega = self
let last_fri_domain_generator = self
.domain
.generator
.mod_pow_u32(2u32.pow(num_rounds as u32));
intt::<XFieldElement>(&mut last_polynomial, last_omega, log_2_of_n);
intt::<XFieldElement>(&mut last_polynomial, last_fri_domain_generator, log_2_of_n);

let last_poly_degree: isize = (Polynomial::<XFieldElement> {
coefficients: last_polynomial,
Expand Down Expand Up @@ -666,7 +666,7 @@ mod triton_xfri_tests {
expansion_factor: usize,
colinearity_checks: usize,
) -> Fri<H> {
let omega = BFieldElement::primitive_root_of_unity(subgroup_order).unwrap();
let fri_domain_generator = BFieldElement::primitive_root_of_unity(subgroup_order).unwrap();

// The following offset was picked arbitrarily by copying the one found in
// `get_b_field_fri_test_object`. It does not generate the full Z_p\{0}, but
Expand All @@ -675,7 +675,7 @@ mod triton_xfri_tests {

let fri: Fri<H> = Fri::new(
offset,
omega,
fri_domain_generator,
subgroup_order as usize,
expansion_factor,
colinearity_checks,
Expand Down
4 changes: 2 additions & 2 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ impl Stark {
empty_table_collection.max_degree_with_origin(parameters.num_trace_randomizers);
let max_degree = (other::roundup_npo2(max_degree_with_origin.degree as u64) - 1) as i64;
let fri_domain_length = parameters.fri_expansion_factor * (max_degree as usize + 1);
let omega =
let fri_domain_generator =
BFieldElement::primitive_root_of_unity(fri_domain_length.try_into().unwrap()).unwrap();
let coset_offset = BFieldElement::generator();
let fri = Fri::new(
coset_offset,
omega,
fri_domain_generator,
fri_domain_length,
parameters.fri_expansion_factor,
parameters.num_colinearity_checks,
Expand Down

0 comments on commit 3b79a73

Please sign in to comment.