Skip to content

Commit

Permalink
rename Domain to ArithmeticDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Nov 17, 2022
1 parent 0b8f313 commit e656ecd
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 70 deletions.
14 changes: 8 additions & 6 deletions triton-vm/src/domain.rs → triton-vm/src/arithmetic_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FF> {
pub struct ArithmeticDomain<FF> {
pub offset: BFieldElement,
pub generator: BFieldElement,
pub length: usize,
_finite_field: PhantomData<FF>,
}

impl<FF> Domain<FF>
impl<FF> ArithmeticDomain<FF>
where
FF: FiniteField
+ From<BFieldElement>
Expand Down Expand Up @@ -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::<BFieldElement>::new(offset, generator, order as usize);
let x_domain = Domain::<XFieldElement>::new(offset, generator, order as usize);
let b_domain =
ArithmeticDomain::<BFieldElement>::new(offset, generator, order as usize);
let x_domain =
ArithmeticDomain::<XFieldElement>::new(offset, generator, order as usize);

let expected_b_values: Vec<BFieldElement> =
(0..order).map(|i| offset * generator.mod_pow(i)).collect();
Expand All @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions triton-vm/src/cross_table_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -44,7 +44,7 @@ pub trait CrossTableArg {
fn terminal_quotient(
&self,
ext_codeword_tables: &ExtTableCollection,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
trace_domain_generator: BFieldElement,
) -> Vec<XFieldElement> {
let from_codeword = self.combined_from_codeword(ext_codeword_tables);
Expand Down Expand Up @@ -454,7 +454,7 @@ impl GrandCrossTableArg {
pub fn terminal_quotient_codeword(
&self,
ext_codeword_tables: &ExtTableCollection,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
trace_domain_generator: BFieldElement,
) -> Vec<XFieldElement> {
let mut non_linear_sum_codeword = vec![XFieldElement::zero(); domain.length];
Expand Down
6 changes: 3 additions & 3 deletions triton-vm/src/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -50,7 +50,7 @@ pub struct Fri<H> {
// nearest power of 2.
pub expansion_factor: usize,
pub colinearity_checks_count: usize,
pub domain: Domain<BFieldElement>,
pub domain: ArithmeticDomain<BFieldElement>,
_hasher: PhantomData<H>,
}

Expand All @@ -62,7 +62,7 @@ impl<H: AlgebraicHasher> Fri<H> {
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,
Expand Down
2 changes: 1 addition & 1 deletion triton-vm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
10 changes: 5 additions & 5 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -411,12 +411,12 @@ impl Stark {
proof_stream.to_proof()
}

fn quotient_domain(&self) -> Domain<BFieldElement> {
fn quotient_domain(&self) -> ArithmeticDomain<BFieldElement> {
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(
Expand Down Expand Up @@ -449,7 +449,7 @@ impl Stark {
#[allow(clippy::too_many_arguments)]
fn create_combination_codeword(
&self,
quotient_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
base_codewords: Vec<Vec<BFieldElement>>,
extension_codewords: Vec<Vec<XFieldElement>>,
quotient_codewords: Vec<Vec<XFieldElement>>,
Expand Down Expand Up @@ -524,7 +524,7 @@ impl Stark {
#[allow(clippy::too_many_arguments)]
fn debug_check_degrees(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
idx: &usize,
degree_bound: &Degree,
shift: &u32,
Expand Down
9 changes: 5 additions & 4 deletions triton-vm/src/table/base_table.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -275,8 +275,8 @@ where
/// in that order.
fn dual_low_degree_extension(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
columns: Range<usize>,
) -> (Table<FF>, Table<FF>) {
Expand Down Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions triton-vm/src/table/extension_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -194,7 +194,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {

fn initial_quotients(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
transposed_codewords: &[Vec<XFieldElement>],
challenges: &AllChallenges,
) -> Vec<Vec<XFieldElement>> {
Expand Down Expand Up @@ -224,7 +224,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {

fn consistency_quotients(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
transposed_codewords: &[Vec<XFieldElement>],
challenges: &AllChallenges,
padded_height: usize,
Expand Down Expand Up @@ -255,7 +255,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {

fn transition_quotients(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
transposed_codewords: &[Vec<XFieldElement>],
challenges: &AllChallenges,
trace_domain_generator: BFieldElement,
Expand Down Expand Up @@ -307,7 +307,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {

fn terminal_quotients(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
transposed_codewords: &[Vec<XFieldElement>],
challenges: &AllChallenges,
trace_domain_generator: BFieldElement,
Expand Down Expand Up @@ -340,7 +340,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {

fn all_quotients(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
transposed_codewords: Vec<Vec<XFieldElement>>,
challenges: &AllChallenges,
trace_domain_generator: BFieldElement,
Expand Down Expand Up @@ -410,7 +410,7 @@ pub trait Quotientable: ExtensionTable + Evaluable {
/// probably the result of un-clean division.
fn debug_domain_bound_check(
&self,
domain: &Domain<BFieldElement>,
domain: &ArithmeticDomain<BFieldElement>,
quotient_codewords: &[Vec<XFieldElement>],
quotient_type: &str,
) {
Expand Down
10 changes: 5 additions & 5 deletions triton-vm/src/table/hash_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -642,8 +642,8 @@ impl HashTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
Expand Down Expand Up @@ -800,8 +800,8 @@ impl ExtHashTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
Expand Down
10 changes: 5 additions & 5 deletions triton-vm/src/table/instruction_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -346,8 +346,8 @@ impl InstructionTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
Expand Down Expand Up @@ -485,8 +485,8 @@ impl ExtInstructionTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
Expand Down
10 changes: 5 additions & 5 deletions triton-vm/src/table/jump_stack_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, *};
Expand Down Expand Up @@ -332,8 +332,8 @@ impl JumpStackTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
Expand Down Expand Up @@ -465,8 +465,8 @@ impl ExtJumpStackTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
Expand Down
10 changes: 5 additions & 5 deletions triton-vm/src/table/op_stack_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, *};
Expand Down Expand Up @@ -290,8 +290,8 @@ impl OpStackTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let base_columns = 0..self.base_width();
Expand Down Expand Up @@ -410,8 +410,8 @@ impl ExtOpStackTable {

pub fn to_quotient_and_fri_domain_table(
&self,
quotient_domain: &Domain<BFieldElement>,
fri_domain: &Domain<BFieldElement>,
quotient_domain: &ArithmeticDomain<BFieldElement>,
fri_domain: &ArithmeticDomain<BFieldElement>,
num_trace_randomizers: usize,
) -> (Self, Self) {
let ext_columns = self.base_width()..self.full_width();
Expand Down
Loading

0 comments on commit e656ecd

Please sign in to comment.