diff --git a/triton-air/src/lib.rs b/triton-air/src/lib.rs index 0e413fc1..cc93991a 100644 --- a/triton-air/src/lib.rs +++ b/triton-air/src/lib.rs @@ -12,6 +12,10 @@ pub mod cross_table_argument; pub mod table; pub mod table_column; +mod private { + pub trait Seal {} +} + /// The degree of the AIR after the degree lowering step. /// /// Using substitution and the introduction of new variables, the degree of the AIR as specified @@ -28,7 +32,17 @@ pub mod table_column; /// The degree lowering happens in Triton VM's build script, `build.rs`. pub const TARGET_DEGREE: isize = 4; -pub trait AIR { +/// The main trait for the [tables]' Arithmetic Intermediate Representation. +/// +/// This is a _sealed_ trait. It is not intended (or possible) to implement this +/// trait outside the crate defining it. +/// +/// [tables]: table::TableId +/// +/// ### Object safety +/// +/// This trait is _not_ object safe. +pub trait AIR: private::Seal { type MainColumn: MasterMainColumn + EnumCount; type AuxColumn: MasterAuxColumn + EnumCount; diff --git a/triton-air/src/table/cascade.rs b/triton-air/src/table/cascade.rs index d7be94b1..610f9dd7 100644 --- a/triton-air/src/table/cascade.rs +++ b/triton-air/src/table/cascade.rs @@ -25,6 +25,8 @@ use crate::AIR; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct CascadeTable; +impl crate::private::Seal for CascadeTable {} + impl AIR for CascadeTable { type MainColumn = crate::table_column::CascadeMainColumn; type AuxColumn = crate::table_column::CascadeAuxColumn; diff --git a/triton-air/src/table/hash.rs b/triton-air/src/table/hash.rs index f5245620..9b793f21 100644 --- a/triton-air/src/table/hash.rs +++ b/triton-air/src/table/hash.rs @@ -39,6 +39,8 @@ pub type PermutationTrace = [[BFieldElement; tip5::STATE_SIZE]; PERMUTATION_TRAC #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct HashTable; +impl crate::private::Seal for HashTable {} + type MainColumn = ::MainColumn; type AuxColumn = ::AuxColumn; diff --git a/triton-air/src/table/jump_stack.rs b/triton-air/src/table/jump_stack.rs index 18624345..58da30bc 100644 --- a/triton-air/src/table/jump_stack.rs +++ b/triton-air/src/table/jump_stack.rs @@ -34,6 +34,8 @@ use crate::AIR; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct JumpStackTable; +impl crate::private::Seal for JumpStackTable {} + impl AIR for JumpStackTable { type MainColumn = crate::table_column::JumpStackMainColumn; type AuxColumn = crate::table_column::JumpStackAuxColumn; diff --git a/triton-air/src/table/lookup.rs b/triton-air/src/table/lookup.rs index 7706b1f5..2ab3cf85 100644 --- a/triton-air/src/table/lookup.rs +++ b/triton-air/src/table/lookup.rs @@ -33,6 +33,8 @@ use crate::AIR; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct LookupTable; +impl crate::private::Seal for LookupTable {} + impl AIR for LookupTable { type MainColumn = LookupMainColumn; type AuxColumn = LookupAuxColumn; diff --git a/triton-air/src/table/op_stack.rs b/triton-air/src/table/op_stack.rs index cc417af3..0fc7f72f 100644 --- a/triton-air/src/table/op_stack.rs +++ b/triton-air/src/table/op_stack.rs @@ -27,6 +27,8 @@ pub const PADDING_VALUE: BFieldElement = BFieldElement::new(2); #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct OpStackTable; +impl crate::private::Seal for OpStackTable {} + impl AIR for OpStackTable { type MainColumn = crate::table_column::OpStackMainColumn; type AuxColumn = crate::table_column::OpStackAuxColumn; diff --git a/triton-air/src/table/processor.rs b/triton-air/src/table/processor.rs index a0b6c04e..677176f8 100644 --- a/triton-air/src/table/processor.rs +++ b/triton-air/src/table/processor.rs @@ -40,6 +40,8 @@ pub const NUM_HELPER_VARIABLE_REGISTERS: usize = 6; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct ProcessorTable; +impl crate::private::Seal for ProcessorTable {} + type MainColumn = ::MainColumn; type AuxColumn = ::AuxColumn; diff --git a/triton-air/src/table/program.rs b/triton-air/src/table/program.rs index d85544f5..5c131d27 100644 --- a/triton-air/src/table/program.rs +++ b/triton-air/src/table/program.rs @@ -21,6 +21,8 @@ use crate::AIR; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct ProgramTable; +impl crate::private::Seal for ProgramTable {} + impl AIR for ProgramTable { type MainColumn = crate::table_column::ProgramMainColumn; type AuxColumn = crate::table_column::ProgramAuxColumn; diff --git a/triton-air/src/table/ram.rs b/triton-air/src/table/ram.rs index e3a7e071..66abf02c 100644 --- a/triton-air/src/table/ram.rs +++ b/triton-air/src/table/ram.rs @@ -25,6 +25,8 @@ pub const PADDING_INDICATOR: BFieldElement = BFieldElement::new(2); #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct RamTable; +impl crate::private::Seal for RamTable {} + impl AIR for RamTable { type MainColumn = crate::table_column::RamMainColumn; type AuxColumn = crate::table_column::RamAuxColumn; diff --git a/triton-air/src/table/u32.rs b/triton-air/src/table/u32.rs index a86e8d53..2b3cec71 100644 --- a/triton-air/src/table/u32.rs +++ b/triton-air/src/table/u32.rs @@ -22,6 +22,8 @@ use crate::AIR; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct U32Table; +impl crate::private::Seal for U32Table {} + impl AIR for U32Table { type MainColumn = crate::table_column::U32MainColumn; type AuxColumn = crate::table_column::U32AuxColumn;