Skip to content

Commit

Permalink
use trace_domain_generator instead of omicron
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Nov 15, 2022
1 parent 095f645 commit 5e85155
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 67 deletions.
10 changes: 6 additions & 4 deletions triton-vm/src/cross_table_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ pub trait CrossTableArg {
&self,
ext_codeword_tables: &ExtTableCollection,
domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
) -> Vec<XFieldElement> {
let from_codeword = self.combined_from_codeword(ext_codeword_tables);
let to_codeword = self.combined_to_codeword(ext_codeword_tables);

let trace_domain_generator_inverse = trace_domain_generator.inverse();
let zerofier = domain
.domain_values()
.into_iter()
.map(|x| x - omicron.inverse())
.map(|x| x - trace_domain_generator_inverse)
.collect();
let zerofier_inverse = BFieldElement::batch_inversion(zerofier);

Expand Down Expand Up @@ -454,7 +455,7 @@ impl GrandCrossTableArg {
&self,
ext_codeword_tables: &ExtTableCollection,
domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
) -> Vec<XFieldElement> {
let mut non_linear_sum_codeword = vec![XFieldElement::zero(); domain.length];

Expand Down Expand Up @@ -497,10 +498,11 @@ impl GrandCrossTableArg {
XFieldElement::add,
);

let trace_domain_generator_inverse = trace_domain_generator.inverse();
let zerofier = domain
.domain_values()
.into_iter()
.map(|x| x - omicron.inverse())
.map(|x| x - trace_domain_generator_inverse)
.collect();
let zerofier_inverse = BFieldElement::batch_inversion(zerofier);

Expand Down
22 changes: 12 additions & 10 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use crate::proof_item::ProofItem;
use crate::proof_stream::ProofStream;
use crate::table::base_matrix::AlgebraicExecutionTrace;
use crate::table::challenges::AllChallenges;
use crate::table::table_collection::{derive_omicron, BaseTableCollection, ExtTableCollection};
use crate::table::table_collection::{
derive_trace_domain_generator, BaseTableCollection, ExtTableCollection,
};

use super::table::base_matrix::BaseMatrices;

Expand Down Expand Up @@ -279,7 +281,7 @@ impl Stark {
.terminal_quotient_codeword(
&full_arithmetic_domain_tables,
&arithmetic_domain,
derive_omicron(full_arithmetic_domain_tables.padded_height as u64),
derive_trace_domain_generator(full_arithmetic_domain_tables.padded_height as u64),
);
quotient_codewords.push(grand_cross_table_arg_quotient_codeword);

Expand Down Expand Up @@ -360,7 +362,7 @@ impl Stark {
prof_stop!(maybe_profiler, "FRI");

prof_start!(maybe_profiler, "open trace leafs");
// the relation between the FRI domain and the omicron domain
// the relation between the FRI domain and the trace domain
let unit_distance = self.fri.domain.length / base_trace_tables.padded_height;
// Open leafs of zipped codewords at indicated positions
let revealed_indices =
Expand Down Expand Up @@ -762,7 +764,7 @@ impl Stark {

prof_start!(maybe_profiler, "check leafs");
prof_start!(maybe_profiler, "get indices");
// the relation between the FRI domain and the omicron domain
// the relation between the FRI domain and the trace domain
let unit_distance = self.fri.domain.length / ext_table_collection.padded_height;
// Open leafs of zipped codewords at indicated positions
let revealed_indices = self.get_revealed_indices(unit_distance, &combination_check_indices);
Expand Down Expand Up @@ -867,8 +869,8 @@ impl Stark {
let base_offset = self.parameters.num_randomizer_polynomials;
let ext_offset = base_offset + num_base_polynomials;
let final_offset = ext_offset + num_extension_polynomials;
let omicron = derive_omicron(padded_height as u64);
let omicron_inverse = omicron.inverse();
let trace_domain_generator = derive_trace_domain_generator(padded_height as u64);
let trace_domain_generator_inverse = trace_domain_generator.inverse();
for (combination_check_index, revealed_combination_leaf) in combination_check_indices
.into_iter()
.zip_eq(revealed_combination_leafs)
Expand Down Expand Up @@ -1008,7 +1010,7 @@ impl Stark {
{
let shift = self.max_degree - degree_bound;
let quotient = {
let numerator = current_fri_domain_value - omicron_inverse;
let numerator = current_fri_domain_value - trace_domain_generator_inverse;
let denominator = current_fri_domain_value
.mod_pow_u32(padded_height as u32)
- BFieldElement::one();
Expand All @@ -1028,8 +1030,8 @@ impl Stark {
.zip_eq(terminal_quotient_degree_bounds.iter())
{
let shift = self.max_degree - degree_bound;
let quotient =
evaluated_termc / (current_fri_domain_value - omicron_inverse).lift();
let quotient = evaluated_termc
/ (current_fri_domain_value - trace_domain_generator_inverse).lift();
let quotient_shifted =
quotient * current_fri_domain_value.mod_pow_u32(shift as u32);
summands.push(quotient);
Expand All @@ -1050,7 +1052,7 @@ impl Stark {
let grand_cross_table_arg_evaluated =
grand_cross_table_arg.evaluate_non_linear_sum_of_differences(&cross_slice_by_table);
let grand_cross_table_arg_quotient = grand_cross_table_arg_evaluated
/ (current_fri_domain_value - omicron_inverse).lift();
/ (current_fri_domain_value - trace_domain_generator_inverse).lift();
let grand_cross_table_arg_quotient_shifted =
grand_cross_table_arg_quotient * current_fri_domain_value.mod_pow_u32(shift as u32);
summands.push(grand_cross_table_arg_quotient);
Expand Down
26 changes: 16 additions & 10 deletions triton-vm/src/table/extension_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ pub trait Quotientable: ExtensionTable + Evaluable {
domain: &Domain<BFieldElement>,
transposed_codewords: &[Vec<XFieldElement>],
challenges: &AllChallenges,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
padded_height: usize,
) -> Vec<Vec<XFieldElement>> {
debug_assert_eq!(domain.length, transposed_codewords.len());

let one = XFieldElement::one();
let omicron_inverse = omicron.inverse();
let trace_domain_generator_inverse = trace_domain_generator.inverse();
let domain_values = domain.domain_values();

let subgroup_zerofier: Vec<_> = domain_values
Expand All @@ -275,7 +275,9 @@ pub trait Quotientable: ExtensionTable + Evaluable {
let zerofier_inverse: Vec<_> = domain_values
.into_par_iter()
.zip_eq(subgroup_zerofier_inverse.into_par_iter())
.map(|(domain_value, sub_z_inv)| (domain_value - omicron_inverse) * sub_z_inv)
.map(|(domain_value, sub_z_inv)| {
(domain_value - trace_domain_generator_inverse) * sub_z_inv
})
.collect();
// the relation between the arithmetic domain and the trace domain
let unit_distance = domain.length / padded_height;
Expand Down Expand Up @@ -308,16 +310,16 @@ pub trait Quotientable: ExtensionTable + Evaluable {
domain: &Domain<BFieldElement>,
transposed_codewords: &[Vec<XFieldElement>],
challenges: &AllChallenges,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
) -> Vec<Vec<XFieldElement>> {
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.
// value in the cyclical group generated from the trace domain's generator.
let zerofier_codeword = domain
.domain_values()
.into_iter()
.map(|x| x - omicron.inverse())
.map(|x| x - trace_domain_generator.inverse())
.collect_vec();
let zerofier_inverse = BFieldElement::batch_inversion(zerofier_codeword);

Expand All @@ -341,7 +343,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {
domain: &Domain<BFieldElement>,
transposed_codewords: Vec<Vec<XFieldElement>>,
challenges: &AllChallenges,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
padded_height: usize,
maybe_profiler: &mut Option<TritonProfiler>,
) -> Vec<Vec<XFieldElement>> {
Expand Down Expand Up @@ -369,7 +371,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {
domain,
&transposed_codewords,
challenges,
omicron,
trace_domain_generator,
padded_height,
);
if let Some(p) = maybe_profiler.as_mut() {
Expand All @@ -379,8 +381,12 @@ pub trait Quotientable: ExtensionTable + Evaluable {
if let Some(p) = maybe_profiler.as_mut() {
p.start("terminal quotients")
}
let terminal_quotients =
self.terminal_quotients(domain, &transposed_codewords, challenges, omicron);
let terminal_quotients = self.terminal_quotients(
domain,
&transposed_codewords,
challenges,
trace_domain_generator,
);
if let Some(p) = maybe_profiler.as_mut() {
p.stop("terminal quotients")
}
Expand Down
8 changes: 4 additions & 4 deletions triton-vm/src/table/instruction_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ impl InstructionTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
base_columns,
);
Expand Down Expand Up @@ -489,14 +489,14 @@ impl ExtInstructionTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
ext_columns,
);
Expand Down
8 changes: 4 additions & 4 deletions triton-vm/src/table/jump_stack_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ impl JumpStackTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
base_columns,
);
Expand Down Expand Up @@ -469,14 +469,14 @@ impl ExtJumpStackTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
ext_columns,
);
Expand Down
8 changes: 4 additions & 4 deletions triton-vm/src/table/op_stack_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ impl OpStackTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
base_columns,
);
Expand Down Expand Up @@ -414,14 +414,14 @@ impl ExtOpStackTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
ext_columns,
);
Expand Down
8 changes: 4 additions & 4 deletions triton-vm/src/table/processor_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ impl ProcessorTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
base_columns,
);
Expand Down Expand Up @@ -370,14 +370,14 @@ impl ExtProcessorTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
ext_columns,
);
Expand Down
8 changes: 4 additions & 4 deletions triton-vm/src/table/program_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ impl ProgramTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
base_columns,
);
Expand Down Expand Up @@ -311,14 +311,14 @@ impl ExtProgramTable {
&self,
arithmetic_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
omicron: BFieldElement,
trace_domain_generator: BFieldElement,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
let (arithmetic_domain_table, fri_domain_table) = self.dual_low_degree_extension(
arithmetic_domain,
fri_domain,
omicron,
trace_domain_generator,
num_trace_randomizers,
ext_columns,
);
Expand Down
Loading

0 comments on commit 5e85155

Please sign in to comment.