@@ -3,12 +3,12 @@ use std::borrow::Borrow;
33
44use openvm_circuit_primitives:: { encoder:: Encoder , utils:: assert_array_eq} ;
55use openvm_stark_backend:: {
6- air_builders :: PartitionedAirBuilder , interaction :: InteractionBuilder , BaseAirWithPublicValues ,
7- PartitionedBaseAir ,
6+ BaseAirWithPublicValues , PartitionedBaseAir , air_builders :: PartitionedAirBuilder ,
7+ interaction :: InteractionBuilder ,
88} ;
99use openvm_stark_sdk:: config:: baby_bear_poseidon2:: D_EF ;
1010use p3_air:: { Air , AirBuilder , AirBuilderWithPublicValues , BaseAir } ;
11- use p3_field:: { extension :: BinomiallyExtendable , Field , PrimeCharacteristicRing } ;
11+ use p3_field:: { Field , PrimeCharacteristicRing , extension :: BinomiallyExtendable } ;
1212use p3_matrix:: Matrix ;
1313use stark_recursion_circuit_derive:: AlignedBorrow ;
1414use strum:: { EnumCount , IntoEnumIterator } ;
@@ -37,25 +37,26 @@ pub const ENCODER_MAX_DEGREE: u32 = 2;
3737
3838#[ derive( Debug , Clone , Copy , EnumIter , EnumCount ) ]
3939pub enum NodeKind {
40- VarPreprocessed = 0 ,
41- VarMain = 1 ,
42- VarPublicValue = 2 ,
43- SelIsFirst = 3 ,
44- SelIsLast = 4 ,
45- SelIsTransition = 5 ,
46- Constant = 6 ,
47- Add = 7 ,
48- Sub = 8 ,
49- Neg = 9 ,
50- Mul = 10 ,
51- InteractionMult = 11 ,
52- InteractionMsgComp = 12 ,
53- InteractionBusIndex = 13 ,
40+ WitIn = 0 ,
41+ StructuralWitIn = 1 ,
42+ Fixed = 2 ,
43+ Instance = 3 ,
44+ SelIsFirst = 4 ,
45+ SelIsLast = 5 ,
46+ SelIsTransition = 6 ,
47+ Constant = 7 ,
48+ Add = 8 ,
49+ Sub = 9 ,
50+ Neg = 10 ,
51+ Mul = 11 ,
52+ InteractionMult = 12 ,
53+ InteractionMsgComp = 13 ,
54+ InteractionBusIndex = 14 ,
5455}
5556
5657impl Default for NodeKind {
5758 fn default ( ) -> Self {
58- NodeKind :: VarPreprocessed
59+ NodeKind :: WitIn
5960 }
6061}
6162
@@ -161,12 +162,22 @@ where
161162 NodeKind :: Neg ,
162163 NodeKind :: InteractionMult ,
163164 NodeKind :: InteractionMsgComp ,
165+ NodeKind :: WitIn ,
166+ NodeKind :: StructuralWitIn ,
167+ NodeKind :: Fixed ,
168+ NodeKind :: Instance ,
164169 ]
165170 . map ( |x| x as usize ) ,
166171 ) ;
167172 let is_arg1_node_idx = enc. contains_flag :: < AB > (
168173 & flags,
169- & [ NodeKind :: Add , NodeKind :: Sub , NodeKind :: Mul ] . map ( |x| x as usize ) ,
174+ & [
175+ NodeKind :: Add ,
176+ NodeKind :: Sub ,
177+ NodeKind :: Mul ,
178+ NodeKind :: InteractionMsgComp ,
179+ ]
180+ . map ( |x| x as usize ) ,
170181 ) ;
171182
172183 for ( proof_idx, ( & cols, & next_cols) ) in main_cols. iter ( ) . zip ( & next_main_cols) . enumerate ( ) {
@@ -180,9 +191,8 @@ where
180191 let next_proof_present = next_slot_state. clone ( )
181192 * ( AB :: Expr :: from_u8 ( 3 ) - next_slot_state)
182193 * AB :: F :: TWO . inverse ( ) ;
183- let air_present = slot_state. clone ( )
184- * ( slot_state. clone ( ) - AB :: Expr :: ONE )
185- * AB :: F :: TWO . inverse ( ) ;
194+ let air_present =
195+ slot_state. clone ( ) * ( slot_state. clone ( ) - AB :: Expr :: ONE ) * AB :: F :: TWO . inverse ( ) ;
186196
187197 let arg_ef0: [ AB :: Var ; D_EF ] = cols. args [ ..D_EF ] . try_into ( ) . unwrap ( ) ;
188198 let arg_ef1: [ AB :: Var ; D_EF ] = cols. args [ D_EF ..2 * D_EF ] . try_into ( ) . unwrap ( ) ;
@@ -207,15 +217,16 @@ where
207217 NodeKind :: Neg => scalar_subtract_ext_field :: < AB :: Expr > ( AB :: Expr :: ZERO , arg_ef0) ,
208218 NodeKind :: Mul => ext_field_multiply :: < AB :: Expr > ( arg_ef0, arg_ef1) ,
209219 NodeKind :: Constant => base_to_ext ( cached_cols. attrs [ 0 ] ) ,
210- NodeKind :: VarPublicValue => base_to_ext ( cols. args [ 0 ] ) ,
220+ NodeKind :: Instance => base_to_ext ( cols. args [ 0 ] ) ,
211221 NodeKind :: SelIsFirst => ext_field_multiply ( arg_ef0, arg_ef1) ,
212222 NodeKind :: SelIsLast => ext_field_multiply ( arg_ef0, arg_ef1) ,
213223 NodeKind :: SelIsTransition => scalar_subtract_ext_field (
214224 AB :: Expr :: ONE ,
215225 ext_field_multiply ( arg_ef0, arg_ef1) ,
216226 ) ,
217- NodeKind :: VarPreprocessed
218- | NodeKind :: VarMain
227+ NodeKind :: WitIn
228+ | NodeKind :: StructuralWitIn
229+ | NodeKind :: Fixed
219230 | NodeKind :: InteractionMult
220231 | NodeKind :: InteractionMsgComp => arg_ef0. map ( Into :: into) ,
221232 NodeKind :: InteractionBusIndex => {
@@ -261,7 +272,7 @@ where
261272
262273 let is_var = enc. contains_flag :: < AB > (
263274 & flags,
264- & [ NodeKind :: VarMain , NodeKind :: VarPreprocessed ] . map ( |x| x as usize ) ,
275+ & [ NodeKind :: WitIn , NodeKind :: StructuralWitIn , NodeKind :: Fixed ] . map ( |x| x as usize ) ,
265276 ) ;
266277 self . column_claims_bus . receive (
267278 builder,
@@ -283,8 +294,7 @@ where
283294 pv_idx : cached_cols. attrs [ 0 ] ,
284295 value : cols. args [ 0 ] ,
285296 } ,
286- enc. get_flag_expr :: < AB > ( NodeKind :: VarPublicValue as usize , & flags)
287- * air_present. clone ( ) ,
297+ enc. get_flag_expr :: < AB > ( NodeKind :: Instance as usize , & flags) * air_present. clone ( ) ,
288298 ) ;
289299 self . air_shape_bus . lookup_key (
290300 builder,
0 commit comments