diff --git a/triton-vm/src/domain.rs b/triton-vm/src/arithmetic_domain.rs similarity index 90% rename from triton-vm/src/domain.rs rename to triton-vm/src/arithmetic_domain.rs index 9ea2d1c75..92fe39544 100644 --- a/triton-vm/src/domain.rs +++ b/triton-vm/src/arithmetic_domain.rs @@ -6,14 +6,14 @@ use twenty_first::shared_math::polynomial::Polynomial; use twenty_first::shared_math::traits::{FiniteField, ModPowU32}; #[derive(Debug, Clone, PartialEq, Eq)] -pub struct Domain { +pub struct ArithmeticDomain { pub offset: BFieldElement, pub generator: BFieldElement, pub length: usize, _finite_field: PhantomData, } -impl Domain +impl ArithmeticDomain where FF: FiniteField + From @@ -79,8 +79,10 @@ mod domain_tests { for order in [4, 8, 32] { let generator = BFieldElement::primitive_root_of_unity(order).unwrap(); let offset = BFieldElement::generator(); - let b_domain = Domain::::new(offset, generator, order as usize); - let x_domain = Domain::::new(offset, generator, order as usize); + let b_domain = + ArithmeticDomain::::new(offset, generator, order as usize); + let x_domain = + ArithmeticDomain::::new(offset, generator, order as usize); let expected_b_values: Vec = (0..order).map(|i| offset * generator.mod_pow(i)).collect(); @@ -90,7 +92,7 @@ mod domain_tests { .collect_vec(); assert_eq!( expected_b_values, actual_b_values_1, - "domain_values() generates the domain BFieldElement values" + "domain_values() generates the arithmetic domain's BFieldElement values" ); assert_eq!( expected_b_values, actual_b_values_2, @@ -105,7 +107,7 @@ mod domain_tests { .collect_vec(); assert_eq!( expected_x_values, actual_x_values_1, - "domain_values() generates the domain XFieldElement values" + "domain_values() generates the arithmetic domain's XFieldElement values" ); assert_eq!( expected_x_values, actual_x_values_2, diff --git a/triton-vm/src/cross_table_arguments.rs b/triton-vm/src/cross_table_arguments.rs index 254abcacd..fbbadfcb5 100644 --- a/triton-vm/src/cross_table_arguments.rs +++ b/triton-vm/src/cross_table_arguments.rs @@ -8,7 +8,7 @@ use twenty_first::shared_math::mpolynomial::Degree; use twenty_first::shared_math::traits::{FiniteField, Inverse}; use twenty_first::shared_math::x_field_element::XFieldElement; -use crate::domain::Domain; +use crate::arithmetic_domain::ArithmeticDomain; use crate::table::processor_table::PROCESSOR_TABLE_NUM_PERMUTATION_ARGUMENTS; use crate::table::table_collection::TableId::{ HashTable, InstructionTable, JumpStackTable, OpStackTable, ProcessorTable, ProgramTable, @@ -44,7 +44,7 @@ pub trait CrossTableArg { fn terminal_quotient( &self, ext_codeword_tables: &ExtTableCollection, - domain: &Domain, + domain: &ArithmeticDomain, trace_domain_generator: BFieldElement, ) -> Vec { let from_codeword = self.combined_from_codeword(ext_codeword_tables); @@ -454,7 +454,7 @@ impl GrandCrossTableArg { pub fn terminal_quotient_codeword( &self, ext_codeword_tables: &ExtTableCollection, - domain: &Domain, + domain: &ArithmeticDomain, trace_domain_generator: BFieldElement, ) -> Vec { let mut non_linear_sum_codeword = vec![XFieldElement::zero(); domain.length]; diff --git a/triton-vm/src/fri.rs b/triton-vm/src/fri.rs index 5236c8680..49a536b55 100644 --- a/triton-vm/src/fri.rs +++ b/triton-vm/src/fri.rs @@ -20,7 +20,7 @@ use twenty_first::shared_math::x_field_element::XFieldElement; use twenty_first::util_types::algebraic_hasher::{AlgebraicHasher, Hashable}; use twenty_first::util_types::merkle_tree::{MerkleTree, PartialAuthenticationPath}; -use crate::domain::Domain; +use crate::arithmetic_domain::ArithmeticDomain; use crate::proof_item::{FriResponse, ProofItem}; use crate::proof_stream::ProofStream; @@ -50,7 +50,7 @@ pub struct Fri { // nearest power of 2. pub expansion_factor: usize, pub colinearity_checks_count: usize, - pub domain: Domain, + pub domain: ArithmeticDomain, _hasher: PhantomData, } @@ -62,7 +62,7 @@ impl Fri { expansion_factor: usize, colinearity_checks_count: usize, ) -> Self { - let domain = Domain::new(offset, fri_domain_generator, domain_length); + let domain = ArithmeticDomain::new(offset, fri_domain_generator, domain_length); let _hasher = PhantomData; Self { domain, diff --git a/triton-vm/src/lib.rs b/triton-vm/src/lib.rs index 034328b45..516f9002c 100644 --- a/triton-vm/src/lib.rs +++ b/triton-vm/src/lib.rs @@ -1,6 +1,6 @@ +pub mod arithmetic_domain; pub mod bfield_codec; pub mod cross_table_arguments; -pub mod domain; pub mod error; pub mod fri; pub mod instruction; diff --git a/triton-vm/src/stark.rs b/triton-vm/src/stark.rs index 7457e432a..8c5098b4f 100644 --- a/triton-vm/src/stark.rs +++ b/triton-vm/src/stark.rs @@ -21,10 +21,10 @@ use twenty_first::util_types::merkle_tree::MerkleTree; use triton_profiler::triton_profiler::TritonProfiler; use triton_profiler::{prof_itr0, prof_start, prof_stop}; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{ CrossTableArg, EvalArg, GrandCrossTableArg, NUM_CROSS_TABLE_ARGS, NUM_PUBLIC_EVAL_ARGS, }; -use crate::domain::Domain; use crate::fri::{Fri, FriValidationError}; use crate::proof::{Claim, Proof}; use crate::proof_item::ProofItem; @@ -411,12 +411,12 @@ impl Stark { proof_stream.to_proof() } - fn quotient_domain(&self) -> Domain { + fn quotient_domain(&self) -> ArithmeticDomain { let offset = self.fri.domain.offset; let expansion_factor = self.fri.expansion_factor; let generator = self.fri.domain.generator.mod_pow(expansion_factor as u64); let length = self.fri.domain.length / expansion_factor; - Domain::new(offset, generator, length) + ArithmeticDomain::new(offset, generator, length) } fn get_revealed_indices( @@ -449,7 +449,7 @@ impl Stark { #[allow(clippy::too_many_arguments)] fn create_combination_codeword( &self, - quotient_domain: &Domain, + quotient_domain: &ArithmeticDomain, base_codewords: Vec>, extension_codewords: Vec>, quotient_codewords: Vec>, @@ -524,7 +524,7 @@ impl Stark { #[allow(clippy::too_many_arguments)] fn debug_check_degrees( &self, - domain: &Domain, + domain: &ArithmeticDomain, idx: &usize, degree_bound: &Degree, shift: &u32, diff --git a/triton-vm/src/table/base_table.rs b/triton-vm/src/table/base_table.rs index 0817672c2..531242125 100644 --- a/triton-vm/src/table/base_table.rs +++ b/triton-vm/src/table/base_table.rs @@ -1,4 +1,4 @@ -use super::super::domain::Domain; +use super::super::arithmetic_domain::ArithmeticDomain; use crate::table::table_collection::derive_trace_domain_generator; use num_traits::Zero; use rand_distr::{Distribution, Standard}; @@ -275,8 +275,8 @@ where /// in that order. fn dual_low_degree_extension( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, columns: Range, ) -> (Table, Table) { @@ -319,7 +319,8 @@ where let trace_domain_generator = derive_trace_domain_generator(padded_height as u64); let trace_domain = - Domain::new(1_u32.into(), trace_domain_generator, padded_height).domain_values(); + ArithmeticDomain::new(1_u32.into(), trace_domain_generator, padded_height) + .domain_values(); let randomizer_domain = disjoint_domain(num_trace_randomizers, &trace_domain); let interpolation_domain = vec![trace_domain, randomizer_domain].concat(); diff --git a/triton-vm/src/table/extension_table.rs b/triton-vm/src/table/extension_table.rs index 0acce93a2..da1f22b14 100644 --- a/triton-vm/src/table/extension_table.rs +++ b/triton-vm/src/table/extension_table.rs @@ -13,7 +13,7 @@ use twenty_first::shared_math::x_field_element::XFieldElement; use triton_profiler::triton_profiler::TritonProfiler; -use crate::domain::Domain; +use crate::arithmetic_domain::ArithmeticDomain; use crate::table::extension_table; use crate::table::table_collection::interpolant_degree; @@ -194,7 +194,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { fn initial_quotients( &self, - domain: &Domain, + domain: &ArithmeticDomain, transposed_codewords: &[Vec], challenges: &AllChallenges, ) -> Vec> { @@ -224,7 +224,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { fn consistency_quotients( &self, - domain: &Domain, + domain: &ArithmeticDomain, transposed_codewords: &[Vec], challenges: &AllChallenges, padded_height: usize, @@ -255,7 +255,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { fn transition_quotients( &self, - domain: &Domain, + domain: &ArithmeticDomain, transposed_codewords: &[Vec], challenges: &AllChallenges, trace_domain_generator: BFieldElement, @@ -307,7 +307,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { fn terminal_quotients( &self, - domain: &Domain, + domain: &ArithmeticDomain, transposed_codewords: &[Vec], challenges: &AllChallenges, trace_domain_generator: BFieldElement, @@ -340,7 +340,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { fn all_quotients( &self, - domain: &Domain, + domain: &ArithmeticDomain, transposed_codewords: Vec>, challenges: &AllChallenges, trace_domain_generator: BFieldElement, @@ -410,7 +410,7 @@ pub trait Quotientable: ExtensionTable + Evaluable { /// probably the result of un-clean division. fn debug_domain_bound_check( &self, - domain: &Domain, + domain: &ArithmeticDomain, quotient_codewords: &[Vec], quotient_type: &str, ) { diff --git a/triton-vm/src/table/hash_table.rs b/triton-vm/src/table/hash_table.rs index 11d32ca47..ce5424f50 100644 --- a/triton-vm/src/table/hash_table.rs +++ b/triton-vm/src/table/hash_table.rs @@ -15,8 +15,8 @@ use twenty_first::shared_math::traits::ModPowU32; use twenty_first::shared_math::traits::ModPowU64; use twenty_first::shared_math::x_field_element::XFieldElement; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, EvalArg}; -use crate::domain::Domain; use crate::table::base_table::Extendable; use crate::table::extension_table::Evaluable; use crate::table::table_collection::interpolant_degree; @@ -642,8 +642,8 @@ impl HashTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -800,8 +800,8 @@ impl ExtHashTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/instruction_table.rs b/triton-vm/src/table/instruction_table.rs index 650459a75..bc0a99703 100644 --- a/triton-vm/src/table/instruction_table.rs +++ b/triton-vm/src/table/instruction_table.rs @@ -6,8 +6,8 @@ use twenty_first::shared_math::b_field_element::BFieldElement; use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; use twenty_first::shared_math::x_field_element::XFieldElement; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, EvalArg, PermArg}; -use crate::domain::Domain; use crate::table::base_table::Extendable; use super::base_table::{InheritsFromTable, Table, TableLike}; @@ -346,8 +346,8 @@ impl InstructionTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -485,8 +485,8 @@ impl ExtInstructionTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/jump_stack_table.rs b/triton-vm/src/table/jump_stack_table.rs index cc9aecbcb..aca8f078f 100644 --- a/triton-vm/src/table/jump_stack_table.rs +++ b/triton-vm/src/table/jump_stack_table.rs @@ -7,8 +7,8 @@ use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; use twenty_first::shared_math::traits::Inverse; use twenty_first::shared_math::x_field_element::XFieldElement; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, PermArg}; -use crate::domain::Domain; use crate::instruction::Instruction; use crate::table::base_table::Extendable; use crate::table::table_column::JumpStackBaseTableColumn::{self, *}; @@ -332,8 +332,8 @@ impl JumpStackTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -465,8 +465,8 @@ impl ExtJumpStackTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/op_stack_table.rs b/triton-vm/src/table/op_stack_table.rs index a894b7f6e..21c00ff32 100644 --- a/triton-vm/src/table/op_stack_table.rs +++ b/triton-vm/src/table/op_stack_table.rs @@ -8,8 +8,8 @@ use twenty_first::shared_math::traits::Inverse; use twenty_first::shared_math::x_field_element::XFieldElement; use super::constraint_circuit::DualRowIndicator::*; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, PermArg}; -use crate::domain::Domain; use crate::table::base_table::Extendable; use crate::table::table_column::OpStackBaseTableColumn::{self, *}; use crate::table::table_column::OpStackExtTableColumn::{self, *}; @@ -290,8 +290,8 @@ impl OpStackTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -410,8 +410,8 @@ impl ExtOpStackTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/processor_table.rs b/triton-vm/src/table/processor_table.rs index 18370e0c0..3a9e2574d 100644 --- a/triton-vm/src/table/processor_table.rs +++ b/triton-vm/src/table/processor_table.rs @@ -11,8 +11,8 @@ use twenty_first::shared_math::b_field_element::BFieldElement; use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; use twenty_first::shared_math::x_field_element::XFieldElement; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, EvalArg, PermArg}; -use crate::domain::Domain; use crate::instruction::{all_instructions_without_args, AnInstruction::*, Instruction}; use crate::ord_n::Ord7; use crate::table::base_table::{Extendable, InheritsFromTable, Table, TableLike}; @@ -64,8 +64,8 @@ impl ProcessorTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -366,8 +366,8 @@ impl ExtProcessorTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/program_table.rs b/triton-vm/src/table/program_table.rs index 262add793..20ddd490c 100644 --- a/triton-vm/src/table/program_table.rs +++ b/triton-vm/src/table/program_table.rs @@ -7,8 +7,8 @@ use twenty_first::shared_math::mpolynomial::{Degree, MPolynomial}; use twenty_first::shared_math::x_field_element::XFieldElement; use super::constraint_circuit::DualRowIndicator::*; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, EvalArg}; -use crate::domain::Domain; use crate::table::base_table::Extendable; use crate::table::table_column::ProgramBaseTableColumn::{self, *}; use crate::table::table_column::ProgramExtTableColumn::{self, *}; @@ -197,8 +197,8 @@ impl ProgramTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -307,8 +307,8 @@ impl ExtProgramTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/ram_table.rs b/triton-vm/src/table/ram_table.rs index adda71007..2972e4d34 100644 --- a/triton-vm/src/table/ram_table.rs +++ b/triton-vm/src/table/ram_table.rs @@ -8,8 +8,8 @@ use twenty_first::shared_math::traits::Inverse; use twenty_first::shared_math::x_field_element::XFieldElement; use super::constraint_circuit::DualRowIndicator::*; +use crate::arithmetic_domain::ArithmeticDomain; use crate::cross_table_arguments::{CrossTableArg, PermArg}; -use crate::domain::Domain; use crate::table::base_table::Extendable; use crate::table::table_column::RamBaseTableColumn::{self, *}; use crate::table::table_column::RamExtTableColumn::{self, *}; @@ -90,8 +90,8 @@ impl RamTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let base_columns = 0..self.base_width(); @@ -230,8 +230,8 @@ impl ExtRamTable { pub fn to_quotient_and_fri_domain_table( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let ext_columns = self.base_width()..self.full_width(); diff --git a/triton-vm/src/table/table_collection.rs b/triton-vm/src/table/table_collection.rs index 5e9793404..33b1ace1a 100644 --- a/triton-vm/src/table/table_collection.rs +++ b/triton-vm/src/table/table_collection.rs @@ -8,7 +8,7 @@ use twenty_first::shared_math::x_field_element::XFieldElement; use triton_profiler::triton_profiler::TritonProfiler; use triton_profiler::{prof_start, prof_stop}; -use crate::domain::Domain; +use crate::arithmetic_domain::ArithmeticDomain; use crate::table::base_table::{Extendable, InheritsFromTable}; use crate::table::extension_table::DegreeWithOrigin; @@ -134,8 +134,8 @@ impl BaseTableCollection { pub fn to_quotient_and_fri_domain_tables( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let (program_table_quotient, program_table_fri) = self @@ -361,8 +361,8 @@ impl ExtTableCollection { /// Heads up: only extension columns are being low degree extended. todo: better naming. pub fn to_quotient_and_fri_domain_tables( &self, - quotient_domain: &Domain, - fri_domain: &Domain, + quotient_domain: &ArithmeticDomain, + fri_domain: &ArithmeticDomain, num_trace_randomizers: usize, ) -> (Self, Self) { let (program_table_quotient, program_table_fri) = self @@ -452,7 +452,7 @@ impl ExtTableCollection { pub fn get_all_quotients( &self, - domain: &Domain, + domain: &ArithmeticDomain, challenges: &AllChallenges, maybe_profiler: &mut Option, ) -> Vec> {