diff --git a/triton-vm/src/cross_table_arguments.rs b/triton-vm/src/cross_table_arguments.rs index 1a6268b06..0802771ea 100644 --- a/triton-vm/src/cross_table_arguments.rs +++ b/triton-vm/src/cross_table_arguments.rs @@ -44,13 +44,13 @@ pub trait CrossTableArg { fn terminal_quotient( &self, ext_codeword_tables: &ExtTableCollection, - fri_domain: &Domain, + domain: &Domain, omicron: BFieldElement, ) -> Vec { let from_codeword = self.combined_from_codeword(ext_codeword_tables); let to_codeword = self.combined_to_codeword(ext_codeword_tables); - let zerofier = fri_domain + let zerofier = domain .domain_values() .into_iter() .map(|x| x - omicron.inverse()) @@ -453,10 +453,10 @@ impl GrandCrossTableArg { pub fn terminal_quotient_codeword( &self, ext_codeword_tables: &ExtTableCollection, - fri_domain: &Domain, + domain: &Domain, omicron: BFieldElement, ) -> Vec { - let mut non_linear_sum_codeword = vec![XFieldElement::zero(); fri_domain.length]; + let mut non_linear_sum_codeword = vec![XFieldElement::zero(); domain.length]; // cross-table arguments for (arg, weight) in self.into_iter() { @@ -472,7 +472,7 @@ impl GrandCrossTableArg { } // standard input - let input_terminal_codeword = vec![self.input_terminal; fri_domain.length]; + let input_terminal_codeword = vec![self.input_terminal; domain.length]; let (to_table, to_column) = self.input_to_processor; let to_codeword = &ext_codeword_tables.data(to_table)[to_column]; let weight = self.input_to_processor_weight; @@ -487,7 +487,7 @@ impl GrandCrossTableArg { // standard output let (from_table, from_column) = self.processor_to_output; let from_codeword = &ext_codeword_tables.data(from_table)[from_column]; - let output_terminal_codeword = vec![self.output_terminal; fri_domain.length]; + let output_terminal_codeword = vec![self.output_terminal; domain.length]; let weight = self.processor_to_output_weight; let non_linear_summand = weighted_difference_codeword(from_codeword, &output_terminal_codeword, weight); @@ -497,7 +497,7 @@ impl GrandCrossTableArg { XFieldElement::add, ); - let zerofier = fri_domain + let zerofier = domain .domain_values() .into_iter() .map(|x| x - omicron.inverse()) diff --git a/triton-vm/src/stark.rs b/triton-vm/src/stark.rs index 3eea7eb09..e7505359b 100644 --- a/triton-vm/src/stark.rs +++ b/triton-vm/src/stark.rs @@ -150,14 +150,16 @@ impl Stark { prof_start!(maybe_profiler, "dual LDE 1"); let arithmetic_domain = self.arithmetic_domain(); - let base_fri_domain_tables = base_trace_tables.to_arithmetic_and_fri_domain_tables( - &arithmetic_domain, - &self.fri.domain, - self.parameters.num_trace_randomizers, - ); + let (base_arithmetic_domain_tables, base_fri_domain_tables) = base_trace_tables + .to_arithmetic_and_fri_domain_tables( + &arithmetic_domain, + &self.fri.domain, + self.parameters.num_trace_randomizers, + ); + let base_arithmetic_domain_codewords = base_arithmetic_domain_tables.get_all_base_columns(); let base_fri_domain_codewords = base_fri_domain_tables.get_all_base_columns(); let randomizer_and_base_fri_domain_codewords = - vec![b_rand_codewords, base_fri_domain_codewords.clone()].concat(); + vec![b_rand_codewords, base_fri_domain_codewords].concat(); prof_stop!(maybe_profiler, "dual LDE 1"); prof_start!(maybe_profiler, "Merkle tree 1"); @@ -188,11 +190,14 @@ impl Stark { prof_stop!(maybe_profiler, "extend"); prof_start!(maybe_profiler, "dual LDE 2"); - let ext_fri_domain_tables = ext_trace_tables.to_arithmetic_and_fri_domain_tables( - &arithmetic_domain, - &self.fri.domain, - self.parameters.num_trace_randomizers, - ); + let (ext_arithmetic_domain_tables, ext_fri_domain_tables) = ext_trace_tables + .to_arithmetic_and_fri_domain_tables( + &arithmetic_domain, + &self.fri.domain, + self.parameters.num_trace_randomizers, + ); + let extension_arithmetic_domain_codewords = + ext_arithmetic_domain_tables.collect_all_columns(); let extension_fri_domain_codewords = ext_fri_domain_tables.collect_all_columns(); prof_stop!(maybe_profiler, "dual LDE 2"); @@ -206,26 +211,26 @@ impl Stark { prof_start!(maybe_profiler, "degree bounds"); prof_start!(maybe_profiler, "base"); - let base_degree_bounds = - base_fri_domain_tables.get_base_degree_bounds(self.parameters.num_trace_randomizers); + let base_degree_bounds = base_arithmetic_domain_tables + .get_base_degree_bounds(self.parameters.num_trace_randomizers); prof_stop!(maybe_profiler, "base"); prof_start!(maybe_profiler, "extension"); - let extension_degree_bounds = ext_fri_domain_tables + let extension_degree_bounds = ext_arithmetic_domain_tables .get_extension_degree_bounds(self.parameters.num_trace_randomizers); prof_stop!(maybe_profiler, "extension"); prof_start!(maybe_profiler, "quotient"); - let full_fri_domain_tables = - ExtTableCollection::join(base_fri_domain_tables, ext_fri_domain_tables); - let mut quotient_degree_bounds = full_fri_domain_tables + let full_arithmetic_domain_tables = + ExtTableCollection::join(base_arithmetic_domain_tables, ext_arithmetic_domain_tables); + let mut quotient_degree_bounds = full_arithmetic_domain_tables .get_all_quotient_degree_bounds(self.parameters.num_trace_randomizers); prof_stop!(maybe_profiler, "quotient"); prof_stop!(maybe_profiler, "degree bounds"); prof_start!(maybe_profiler, "quotient codewords"); - let mut quotient_codewords = full_fri_domain_tables.get_all_quotients( - &self.fri.domain, + let mut quotient_codewords = full_arithmetic_domain_tables.get_all_quotients( + &arithmetic_domain, &extension_challenges, maybe_profiler, ); @@ -234,8 +239,8 @@ impl Stark { prof_start!(maybe_profiler, "grand cross table"); let num_grand_cross_table_args = 1; let num_non_lin_combi_weights = self.parameters.num_randomizer_polynomials - + 2 * base_fri_domain_codewords.len() - + 2 * extension_fri_domain_codewords.len() + + 2 * base_arithmetic_domain_codewords.len() + + 2 * extension_arithmetic_domain_codewords.len() + 2 * quotient_degree_bounds.len() + 2 * num_grand_cross_table_args; let num_grand_cross_table_arg_weights = NUM_CROSS_TABLE_ARGS + NUM_PUBLIC_EVAL_ARGS; @@ -272,38 +277,52 @@ impl Stark { ); let grand_cross_table_arg_quotient_codeword = grand_cross_table_arg .terminal_quotient_codeword( - &full_fri_domain_tables, - &self.fri.domain, - derive_omicron(full_fri_domain_tables.padded_height as u64), + &full_arithmetic_domain_tables, + &arithmetic_domain, + derive_omicron(full_arithmetic_domain_tables.padded_height as u64), ); quotient_codewords.push(grand_cross_table_arg_quotient_codeword); let grand_cross_table_arg_quotient_degree_bound = grand_cross_table_arg .quotient_degree_bound( - &full_fri_domain_tables, + &full_arithmetic_domain_tables, self.parameters.num_trace_randomizers, ); quotient_degree_bounds.push(grand_cross_table_arg_quotient_degree_bound); prof_stop!(maybe_profiler, "grand cross table"); prof_start!(maybe_profiler, "nonlinear combination"); + // magic number `1` corresponds to `num_randomizer_polynomials`, which is currently ignored + let (randomizer_weight, base_ext_quot_weights) = non_lin_combi_weights.split_at(1); let combination_codeword = self.create_combination_codeword( - vec![x_rand_codeword], - base_fri_domain_codewords, - extension_fri_domain_codewords, + &arithmetic_domain, + base_arithmetic_domain_codewords, + extension_arithmetic_domain_codewords, quotient_codewords, - non_lin_combi_weights.to_vec(), + base_ext_quot_weights.to_vec(), base_degree_bounds, extension_degree_bounds, quotient_degree_bounds, maybe_profiler, ); + + prof_start!(maybe_profiler, "LDE 3"); + let combination_polynomial = arithmetic_domain.interpolate(&combination_codeword); + let fri_combination_codeword_without_randomizer = + self.fri.domain.evaluate(&combination_polynomial); + prof_stop!(maybe_profiler, "LDE 3"); + + let fri_combination_codeword: Vec<_> = fri_combination_codeword_without_randomizer + .into_par_iter() + .zip_eq(x_rand_codeword.into_par_iter()) + .map(|(cc_elem, rand_elem)| cc_elem + randomizer_weight[0] * rand_elem) + .collect(); prof_stop!(maybe_profiler, "nonlinear combination"); prof_start!(maybe_profiler, "Merkle tree 3"); let mut combination_codeword_digests: Vec = - Vec::with_capacity(combination_codeword.len()); - combination_codeword + Vec::with_capacity(fri_combination_codeword.len()); + fri_combination_codeword .clone() .into_par_iter() .map(|elem| StarkHasher::hash(&elem)) @@ -331,7 +350,7 @@ impl Stark { } prof_start!(maybe_profiler, "FRI"); - match self.fri.prove(&combination_codeword, &mut proof_stream) { + match self.fri.prove(&fri_combination_codeword, &mut proof_stream) { Ok((_, fri_first_round_merkle_root)) => assert_eq!( combination_root, fri_first_round_merkle_root, "Combination root from STARK and from FRI must agree." @@ -368,7 +387,7 @@ impl Stark { // as the latter includes adjacent table rows relative to the values in `indices` let revealed_combination_elements: Vec = cross_codeword_slice_indices .iter() - .map(|i| combination_codeword[*i]) + .map(|i| fri_combination_codeword[*i]) .collect(); let revealed_combination_auth_paths = combination_tree.get_authentication_structure(&cross_codeword_slice_indices); @@ -429,7 +448,7 @@ impl Stark { #[allow(clippy::too_many_arguments)] fn create_combination_codeword( &self, - randomizer_codewords: Vec>, + arithmetic_domain: &Domain, base_codewords: Vec>, extension_codewords: Vec>, quotient_codewords: Vec>, @@ -439,13 +458,7 @@ impl Stark { quotient_degree_bounds: Vec, maybe_profiler: &mut Option, ) -> Vec { - assert_eq!( - self.parameters.num_randomizer_polynomials, - randomizer_codewords.len() - ); - prof_start!(maybe_profiler, "create combination codeword"); - let base_codewords_lifted = base_codewords .into_iter() .map(|base_codeword| { @@ -456,20 +469,10 @@ impl Stark { }) .collect_vec(); let mut weights_iterator = weights.into_iter(); - let mut combination_codeword: Vec = vec![0.into(); self.fri.domain.length]; + let mut combination_codeword: Vec = vec![0.into(); arithmetic_domain.length]; // TODO don't keep the entire domain's values in memory, create them lazily when needed - let fri_x_values = self.fri.domain.domain_values(); - - for randomizer_codeword in randomizer_codewords { - combination_codeword = Self::non_linearly_add_to_codeword( - &combination_codeword, - &randomizer_codeword, - &weights_iterator.next().unwrap(), - &randomizer_codeword, - &0.into(), - ); - } + let domain_values = arithmetic_domain.domain_values(); for (codewords, bounds, identifier) in [ (base_codewords_lifted, base_degree_bounds, "base"), @@ -484,7 +487,7 @@ impl Stark { codewords.into_iter().zip_eq(bounds.iter()).enumerate() { let shift = (self.max_degree as Degree - degree_bound) as u32; - let codeword_shifted = Self::shift_codeword(&fri_x_values, &codeword, shift); + let codeword_shifted = Self::shift_codeword(&domain_values, &codeword, shift); combination_codeword = Self::non_linearly_add_to_codeword( &combination_codeword, @@ -494,6 +497,7 @@ impl Stark { &weights_iterator.next().unwrap(), ); self.debug_check_degrees( + arithmetic_domain, &idx, degree_bound, &shift, @@ -507,7 +511,9 @@ impl Stark { if std::env::var("DEBUG").is_ok() { println!( "The combination codeword corresponds to a polynomial of degree {}", - self.fri.domain.interpolate(&combination_codeword).degree() + arithmetic_domain + .interpolate(&combination_codeword) + .degree() ); } @@ -519,6 +525,7 @@ impl Stark { #[allow(clippy::too_many_arguments)] fn debug_check_degrees( &self, + domain: &Domain, idx: &usize, degree_bound: &Degree, shift: &u32, @@ -529,8 +536,8 @@ impl Stark { if std::env::var("DEBUG").is_err() { return; } - let interpolated = self.fri.domain.interpolate(extension_codeword); - let interpolated_shifted = self.fri.domain.interpolate(extension_codeword_shifted); + let interpolated = domain.interpolate(extension_codeword); + let interpolated_shifted = domain.interpolate(extension_codeword_shifted); let int_shift_deg = interpolated_shifted.degree(); let maybe_excl_mark = if int_shift_deg > self.max_degree as isize { "!!!" diff --git a/triton-vm/src/table/extension_table.rs b/triton-vm/src/table/extension_table.rs index 5b3a0dc1b..b1c0160fe 100644 --- a/triton-vm/src/table/extension_table.rs +++ b/triton-vm/src/table/extension_table.rs @@ -194,13 +194,13 @@ pub trait Quotientable: ExtensionTable + Evaluable { fn initial_quotients( &self, - fri_domain: &Domain, + domain: &Domain, transposed_codewords: &[Vec], challenges: &AllChallenges, ) -> Vec> { - debug_assert_eq!(fri_domain.length, transposed_codewords.len()); + debug_assert_eq!(domain.length, transposed_codewords.len()); - let zerofier_codeword = fri_domain + let zerofier_codeword = domain .domain_values() .into_iter() .map(|x| x - BFieldElement::one()) @@ -210,28 +210,28 @@ pub trait Quotientable: ExtensionTable + Evaluable { let transposed_quotient_codewords: Vec<_> = zerofier_inverse .par_iter() .enumerate() - .map(|(fri_dom_i, &z_inv)| { - let row = &transposed_codewords[fri_dom_i]; + .map(|(domain_index, &z_inv)| { + let row = &transposed_codewords[domain_index]; let evaluated_bcs = self.evaluate_initial_constraints(row, challenges); evaluated_bcs.iter().map(|&ebc| ebc * z_inv).collect() }) .collect(); let quotient_codewords = transpose(&transposed_quotient_codewords); - self.debug_fri_domain_bound_check(fri_domain, "ient_codewords, "initial"); + self.debug_domain_bound_check(domain, "ient_codewords, "initial"); quotient_codewords } fn consistency_quotients( &self, - fri_domain: &Domain, + domain: &Domain, transposed_codewords: &[Vec], challenges: &AllChallenges, padded_height: usize, ) -> Vec> { - debug_assert_eq!(fri_domain.length, transposed_codewords.len()); + debug_assert_eq!(domain.length, transposed_codewords.len()); - let zerofier_codeword = fri_domain + let zerofier_codeword = domain .domain_values() .iter() .map(|x| x.mod_pow_u32(padded_height as u32) - BFieldElement::one()) @@ -241,54 +241,54 @@ pub trait Quotientable: ExtensionTable + Evaluable { let transposed_quotient_codewords: Vec<_> = zerofier_inverse .par_iter() .enumerate() - .map(|(fri_dom_i, &z_inv)| { - let row = &transposed_codewords[fri_dom_i]; + .map(|(domain_index, &z_inv)| { + let row = &transposed_codewords[domain_index]; let evaluated_ccs = self.evaluate_consistency_constraints(row, challenges); evaluated_ccs.iter().map(|&ecc| ecc * z_inv).collect() }) .collect(); let quotient_codewords = transpose(&transposed_quotient_codewords); - self.debug_fri_domain_bound_check(fri_domain, "ient_codewords, "consistency"); + self.debug_domain_bound_check(domain, "ient_codewords, "consistency"); quotient_codewords } fn transition_quotients( &self, - fri_domain: &Domain, + domain: &Domain, transposed_codewords: &[Vec], challenges: &AllChallenges, omicron: BFieldElement, padded_height: usize, ) -> Vec> { - debug_assert_eq!(fri_domain.length, transposed_codewords.len()); + debug_assert_eq!(domain.length, transposed_codewords.len()); let one = XFieldElement::one(); let omicron_inverse = omicron.inverse(); - let fri_domain_values = fri_domain.domain_values(); + let domain_values = domain.domain_values(); - let subgroup_zerofier: Vec<_> = fri_domain_values + let subgroup_zerofier: Vec<_> = domain_values .par_iter() - .map(|fri_dom_v| fri_dom_v.mod_pow_u32(padded_height as u32) - one) + .map(|domain_value| domain_value.mod_pow_u32(padded_height as u32) - one) .collect(); let subgroup_zerofier_inverse = XFieldElement::batch_inversion(subgroup_zerofier); - let zerofier_inverse: Vec<_> = fri_domain_values + let zerofier_inverse: Vec<_> = domain_values .into_par_iter() .zip_eq(subgroup_zerofier_inverse.into_par_iter()) - .map(|(fri_dom_v, sub_z_inv)| (fri_dom_v - omicron_inverse) * sub_z_inv) + .map(|(domain_value, sub_z_inv)| (domain_value - omicron_inverse) * sub_z_inv) .collect(); - // the relation between the FRI domain and the omicron domain - let unit_distance = fri_domain.length / padded_height; + // the relation between the arithmetic domain and the trace domain + let unit_distance = domain.length / padded_height; - let fri_domain_bit_mask = fri_domain.length - 1; + let domain_length_bit_mask = domain.length - 1; let transposed_quotient_codewords: Vec<_> = zerofier_inverse .par_iter() .enumerate() .map(|(current_row_idx, &z_inv)| { - // `& fri_domain_bit_mask` performs cheap modulo: - // `fri_domain.length - 1` is a bit-mask with all 1s - // because fri_domain.length is 2^k for some k. - let next_row_index = (current_row_idx + unit_distance) & fri_domain_bit_mask; + // `&domain_length_bit_mask` performs the modulo operation cheaply: + // `domain.length - 1` is a bit-mask with all 1s because `domain.length` is 2^k + // for some k. + let next_row_index = (current_row_idx + unit_distance) & domain_length_bit_mask; let current_row = &transposed_codewords[current_row_idx]; let next_row = &transposed_codewords[next_row_index]; @@ -298,23 +298,23 @@ pub trait Quotientable: ExtensionTable + Evaluable { }) .collect(); let quotient_codewords = transpose(&transposed_quotient_codewords); - self.debug_fri_domain_bound_check(fri_domain, "ient_codewords, "transition"); + self.debug_domain_bound_check(domain, "ient_codewords, "transition"); quotient_codewords } fn terminal_quotients( &self, - fri_domain: &Domain, + domain: &Domain, transposed_codewords: &[Vec], challenges: &AllChallenges, omicron: BFieldElement, ) -> Vec> { - debug_assert_eq!(fri_domain.length, transposed_codewords.len()); + debug_assert_eq!(domain.length, transposed_codewords.len()); // The zerofier for the terminal quotient has a root in the last // value in the cyclical group generated from omicron. - let zerofier_codeword = fri_domain + let zerofier_codeword = domain .domain_values() .into_iter() .map(|x| x - omicron.inverse()) @@ -324,21 +324,21 @@ pub trait Quotientable: ExtensionTable + Evaluable { let transposed_quotient_codewords: Vec<_> = zerofier_inverse .par_iter() .enumerate() - .map(|(fri_dom_i, &z_inv)| { - let row = &transposed_codewords[fri_dom_i]; + .map(|(domain_index, &z_inv)| { + let row = &transposed_codewords[domain_index]; let evaluated_termcs = self.evaluate_terminal_constraints(row, challenges); evaluated_termcs.iter().map(|&etc| etc * z_inv).collect() }) .collect(); let quotient_codewords = transpose(&transposed_quotient_codewords); - self.debug_fri_domain_bound_check(fri_domain, "ient_codewords, "terminal"); + self.debug_domain_bound_check(domain, "ient_codewords, "terminal"); quotient_codewords } fn all_quotients( &self, - fri_domain: &Domain, + domain: &Domain, transposed_codewords: Vec>, challenges: &AllChallenges, omicron: BFieldElement, @@ -348,8 +348,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { if let Some(p) = maybe_profiler.as_mut() { p.start("initial quotients") } - let initial_quotients = - self.initial_quotients(fri_domain, &transposed_codewords, challenges); + let initial_quotients = self.initial_quotients(domain, &transposed_codewords, challenges); if let Some(p) = maybe_profiler.as_mut() { p.stop("initial quotients") } @@ -357,12 +356,8 @@ pub trait Quotientable: ExtensionTable + Evaluable { if let Some(p) = maybe_profiler.as_mut() { p.start("consistency quotients") } - let consistency_quotients = self.consistency_quotients( - fri_domain, - &transposed_codewords, - challenges, - padded_height, - ); + let consistency_quotients = + self.consistency_quotients(domain, &transposed_codewords, challenges, padded_height); if let Some(p) = maybe_profiler.as_mut() { p.stop("consistency quotients") } @@ -371,7 +366,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { p.start("transition quotients") } let transition_quotients = self.transition_quotients( - fri_domain, + domain, &transposed_codewords, challenges, omicron, @@ -385,7 +380,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { p.start("terminal quotients") } let terminal_quotients = - self.terminal_quotients(fri_domain, &transposed_codewords, challenges, omicron); + self.terminal_quotients(domain, &transposed_codewords, challenges, omicron); if let Some(p) = maybe_profiler.as_mut() { p.stop("terminal quotients") } @@ -402,14 +397,14 @@ pub trait Quotientable: ExtensionTable + Evaluable { /// Intended for debugging. Will not do anything unless environment variable `DEBUG` is set. /// The performed check /// 1. takes `quotients` in value form (i.e., as codewords), - /// 1. interpolates them over the given `fri_domain`, and + /// 1. interpolates them over the given `domain`, and /// 1. checks their degree. /// /// Panics if an interpolant has maximal degree, indicating that the quotient codeword is most /// probably the result of un-clean division. - fn debug_fri_domain_bound_check( + fn debug_domain_bound_check( &self, - fri_domain: &Domain, + domain: &Domain, quotient_codewords: &[Vec], quotient_type: &str, ) { @@ -417,16 +412,16 @@ pub trait Quotientable: ExtensionTable + Evaluable { return; } for (idx, qc) in quotient_codewords.iter().enumerate() { - let interpolated = fri_domain.interpolate(qc); + let interpolated = domain.interpolate(qc); assert!( - interpolated.degree() < fri_domain.length as isize - 1, + interpolated.degree() < domain.length as isize - 1, "Degree of {} quotient index {idx} (total {} quotients) in {} must not be maximal. \ - Got degree {}, and FRI domain length was {}.", + Got degree {}, and domain length was {}.", quotient_type, quotient_codewords.len(), self.name(), interpolated.degree(), - fri_domain.length, + domain.length, ); } } diff --git a/triton-vm/src/table/table_collection.rs b/triton-vm/src/table/table_collection.rs index d0276c2ae..bc97693d2 100644 --- a/triton-vm/src/table/table_collection.rs +++ b/triton-vm/src/table/table_collection.rs @@ -137,63 +137,82 @@ impl BaseTableCollection { arithmetic_domain: &Domain, fri_domain: &Domain, num_trace_randomizers: usize, - ) -> BaseTableCollection { + ) -> (Self, Self) { let padded_height = self.padded_height; let omicron = derive_omicron(padded_height as u64); - let (_, program_table) = self.program_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, instruction_table) = self.instruction_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, processor_table) = self.processor_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, op_stack_table) = self.op_stack_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, ram_table) = self.ram_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, jump_stack_table) = self.jump_stack_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, hash_table) = self.hash_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); + let (program_table_arithmetic, program_table_fri) = + self.program_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (instruction_table_arithmetic, instruction_table_fri) = + self.instruction_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (processor_table_arithmetic, processor_table_fri) = + self.processor_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (op_stack_table_arithmetic, op_stack_table_fri) = + self.op_stack_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (ram_table_arithmetic, ram_table_fri) = + self.ram_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (jump_stack_table_arithmetic, jump_stack_table_fri) = + self.jump_stack_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (hash_table_arithmetic, hash_table_fri) = + self.hash_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); - BaseTableCollection { + let arithmetic_domain_tables = BaseTableCollection { padded_height, - program_table, - instruction_table, - processor_table, - op_stack_table, - ram_table, - jump_stack_table, - hash_table, - } + program_table: program_table_arithmetic, + instruction_table: instruction_table_arithmetic, + processor_table: processor_table_arithmetic, + op_stack_table: op_stack_table_arithmetic, + ram_table: ram_table_arithmetic, + jump_stack_table: jump_stack_table_arithmetic, + hash_table: hash_table_arithmetic, + }; + let fri_domain_tables = BaseTableCollection { + padded_height, + program_table: program_table_fri, + instruction_table: instruction_table_fri, + processor_table: processor_table_fri, + op_stack_table: op_stack_table_fri, + ram_table: ram_table_fri, + jump_stack_table: jump_stack_table_fri, + hash_table: hash_table_fri, + }; + + (arithmetic_domain_tables, fri_domain_tables) } pub fn get_all_base_columns(&self) -> Vec> { @@ -374,63 +393,82 @@ impl ExtTableCollection { arithmetic_domain: &Domain, fri_domain: &Domain, num_trace_randomizers: usize, - ) -> Self { + ) -> (Self, Self) { let padded_height = self.padded_height; let omicron = derive_omicron(padded_height as u64); - let (_, program_table) = self.program_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, instruction_table) = self.instruction_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, processor_table) = self.processor_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, op_stack_table) = self.op_stack_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, ram_table) = self.ram_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, jump_stack_table) = self.jump_stack_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); - let (_, hash_table) = self.hash_table.to_arithmetic_and_fri_domain_table( - arithmetic_domain, - fri_domain, - omicron, - num_trace_randomizers, - ); + let (program_table_arithmetic, program_table_fri) = + self.program_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (instruction_table_arithmetic, instruction_table_fri) = + self.instruction_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (processor_table_arithmetic, processor_table_fri) = + self.processor_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (op_stack_table_arithmetic, op_stack_table_fri) = + self.op_stack_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (ram_table_arithmetic, ram_table_fri) = + self.ram_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (jump_stack_table_arithmetic, jump_stack_table_fri) = + self.jump_stack_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); + let (hash_table_arithmetic, hash_table_fri) = + self.hash_table.to_arithmetic_and_fri_domain_table( + arithmetic_domain, + fri_domain, + omicron, + num_trace_randomizers, + ); - ExtTableCollection { + let arithmetic_domain_tables = ExtTableCollection { padded_height, - program_table, - instruction_table, - processor_table, - op_stack_table, - ram_table, - jump_stack_table, - hash_table, - } + program_table: program_table_arithmetic, + instruction_table: instruction_table_arithmetic, + processor_table: processor_table_arithmetic, + op_stack_table: op_stack_table_arithmetic, + ram_table: ram_table_arithmetic, + jump_stack_table: jump_stack_table_arithmetic, + hash_table: hash_table_arithmetic, + }; + let fri_domain_tables = ExtTableCollection { + padded_height, + program_table: program_table_fri, + instruction_table: instruction_table_fri, + processor_table: processor_table_fri, + op_stack_table: op_stack_table_fri, + ram_table: ram_table_fri, + jump_stack_table: jump_stack_table_fri, + hash_table: hash_table_fri, + }; + + (arithmetic_domain_tables, fri_domain_tables) } pub fn collect_all_columns(&self) -> Vec> { @@ -472,7 +510,7 @@ impl ExtTableCollection { pub fn get_all_quotients( &self, - fri_domain: &Domain, + domain: &Domain, challenges: &AllChallenges, maybe_profiler: &mut Option, ) -> Vec> { @@ -488,7 +526,7 @@ impl ExtTableCollection { // This would require more complicated indexing, but it would save a lot of allocation. let transposed_codewords = transpose(ext_codeword_table.data()); let res = ext_codeword_table.all_quotients( - fri_domain, + domain, transposed_codewords, challenges, omicron,