@@ -144,6 +144,43 @@ pub struct PrecompileFootprint {
144144 pub multilinear_eval_powers : [ EF ; 6 ] ,
145145}
146146
147+
148+ const PRECOMP_INDEX_OPERAND_A : usize = 0 ;
149+ const PRECOMP_INDEX_OPERAND_B : usize = 1 ;
150+ const PRECOMP_INDEX_FLAG_A : usize = 2 ;
151+ const PRECOMP_INDEX_FLAG_B : usize = 3 ;
152+ const PRECOMP_INDEX_FLAG_C : usize = 4 ;
153+ const PRECOMP_INDEX_AUX : usize = 5 ;
154+ const PRECOMP_INDEX_POSEIDON_16 : usize = 6 ;
155+ const PRECOMP_INDEX_POSEIDON_24 : usize = 7 ;
156+ const PRECOMP_INDEX_DOT_PRODUCT : usize = 8 ;
157+ const PRECOMP_INDEX_MULTILINEAR_EVAL : usize = 9 ;
158+ const PRECOMP_INDEX_MEM_VALUE_A : usize = 10 ;
159+ const PRECOMP_INDEX_MEM_VALUE_B : usize = 11 ;
160+ const PRECOMP_INDEX_MEM_VALUE_C : usize = 12 ;
161+ const PRECOMP_INDEX_FP : usize = 13 ;
162+
163+ pub fn reorder_full_trace_for_precomp_foot_print < A : Copy > ( full_trace : Vec < A > ) -> Vec < A >
164+ {
165+ assert_eq ! ( full_trace. len( ) , N_TOTAL_COLUMNS ) ;
166+ vec ! [
167+ full_trace[ COL_INDEX_OPERAND_A ] ,
168+ full_trace[ COL_INDEX_OPERAND_B ] ,
169+ full_trace[ COL_INDEX_FLAG_A ] ,
170+ full_trace[ COL_INDEX_FLAG_B ] ,
171+ full_trace[ COL_INDEX_FLAG_C ] ,
172+ full_trace[ COL_INDEX_AUX ] ,
173+ full_trace[ COL_INDEX_POSEIDON_16 ] ,
174+ full_trace[ COL_INDEX_POSEIDON_24 ] ,
175+ full_trace[ COL_INDEX_DOT_PRODUCT ] ,
176+ full_trace[ COL_INDEX_MULTILINEAR_EVAL ] ,
177+ full_trace[ COL_INDEX_MEM_VALUE_A ] ,
178+ full_trace[ COL_INDEX_MEM_VALUE_B ] ,
179+ full_trace[ COL_INDEX_MEM_VALUE_C ] ,
180+ full_trace[ COL_INDEX_FP ] ,
181+ ]
182+ }
183+
147184impl PrecompileFootprint {
148185 fn air_eval <
149186 PointF : PrimeCharacteristicRing + Copy ,
@@ -153,36 +190,36 @@ impl PrecompileFootprint {
153190 point : & [ PointF ] ,
154191 mul_point_f_and_ef : impl Fn ( PointF , EF ) -> ResultF ,
155192 ) -> ResultF {
156- let nu_a = ( ResultF :: ONE - point[ COL_INDEX_FLAG_A ] ) * point[ COL_INDEX_MEM_VALUE_A ]
157- + point[ COL_INDEX_FLAG_A ] * point[ COL_INDEX_OPERAND_A ] ;
158- let nu_b = ( ResultF :: ONE - point[ COL_INDEX_FLAG_B ] ) * point[ COL_INDEX_MEM_VALUE_B ]
159- + point[ COL_INDEX_FLAG_B ] * point[ COL_INDEX_OPERAND_B ] ;
160- let nu_c = ( ResultF :: ONE - point[ COL_INDEX_FLAG_C ] ) * point[ COL_INDEX_MEM_VALUE_C ]
161- + point[ COL_INDEX_FLAG_C ] * point[ COL_INDEX_FP ] ;
193+ let nu_a = ( ResultF :: ONE - point[ PRECOMP_INDEX_FLAG_A ] ) * point[ PRECOMP_INDEX_MEM_VALUE_A ]
194+ + point[ PRECOMP_INDEX_FLAG_A ] * point[ PRECOMP_INDEX_OPERAND_A ] ;
195+ let nu_b = ( ResultF :: ONE - point[ PRECOMP_INDEX_FLAG_B ] ) * point[ PRECOMP_INDEX_MEM_VALUE_B ]
196+ + point[ PRECOMP_INDEX_FLAG_B ] * point[ PRECOMP_INDEX_OPERAND_B ] ;
197+ let nu_c = ( ResultF :: ONE - point[ PRECOMP_INDEX_FLAG_C ] ) * point[ PRECOMP_INDEX_MEM_VALUE_C ]
198+ + point[ PRECOMP_INDEX_FLAG_C ] * point[ PRECOMP_INDEX_FP ] ;
162199
163200 ( nu_a * self . p16_powers [ 2 ]
164201 + nu_b * self . p16_powers [ 3 ]
165202 + nu_c * self . p16_powers [ 4 ]
166- + mul_point_f_and_ef ( point[ COL_INDEX_AUX ] , self . p16_powers [ 5 ] )
203+ + mul_point_f_and_ef ( point[ PRECOMP_INDEX_AUX ] , self . p16_powers [ 5 ] )
167204 + self . p16_powers [ 1 ] )
168- * point[ COL_INDEX_POSEIDON_16 ]
205+ * point[ PRECOMP_INDEX_POSEIDON_16 ]
169206 + ( nu_a * self . p24_powers [ 2 ]
170207 + nu_b * self . p24_powers [ 3 ]
171208 + nu_c * self . p24_powers [ 4 ]
172209 + self . p24_powers [ 1 ] )
173- * point[ COL_INDEX_POSEIDON_24 ]
210+ * point[ PRECOMP_INDEX_POSEIDON_24 ]
174211 + ( nu_a * self . dot_product_powers [ 2 ]
175212 + nu_b * self . dot_product_powers [ 3 ]
176213 + nu_c * self . dot_product_powers [ 4 ]
177- + mul_point_f_and_ef ( point[ COL_INDEX_AUX ] , self . dot_product_powers [ 5 ] )
214+ + mul_point_f_and_ef ( point[ PRECOMP_INDEX_AUX ] , self . dot_product_powers [ 5 ] )
178215 + self . dot_product_powers [ 1 ] )
179- * point[ COL_INDEX_DOT_PRODUCT ]
216+ * point[ PRECOMP_INDEX_DOT_PRODUCT ]
180217 + ( nu_a * self . multilinear_eval_powers [ 2 ]
181218 + nu_b * self . multilinear_eval_powers [ 3 ]
182219 + nu_c * self . multilinear_eval_powers [ 4 ]
183- + mul_point_f_and_ef ( point[ COL_INDEX_AUX ] , self . multilinear_eval_powers [ 5 ] )
220+ + mul_point_f_and_ef ( point[ PRECOMP_INDEX_AUX ] , self . multilinear_eval_powers [ 5 ] )
184221 + self . multilinear_eval_powers [ 1 ] )
185- * point[ COL_INDEX_MULTILINEAR_EVAL ]
222+ * point[ PRECOMP_INDEX_MULTILINEAR_EVAL ]
186223 + self . global_challenge
187224 }
188225}
0 commit comments