@@ -144,6 +144,41 @@ pub struct PrecompileFootprint {
144144 pub multilinear_eval_powers : [ EF ; 6 ] ,
145145}
146146
147+ const PRECOMP_INDEX_OPERAND_A : usize = 0 ;
148+ const PRECOMP_INDEX_OPERAND_B : usize = 1 ;
149+ const PRECOMP_INDEX_FLAG_A : usize = 2 ;
150+ const PRECOMP_INDEX_FLAG_B : usize = 3 ;
151+ const PRECOMP_INDEX_FLAG_C : usize = 4 ;
152+ const PRECOMP_INDEX_AUX : usize = 5 ;
153+ const PRECOMP_INDEX_POSEIDON_16 : usize = 6 ;
154+ const PRECOMP_INDEX_POSEIDON_24 : usize = 7 ;
155+ const PRECOMP_INDEX_DOT_PRODUCT : usize = 8 ;
156+ const PRECOMP_INDEX_MULTILINEAR_EVAL : usize = 9 ;
157+ const PRECOMP_INDEX_MEM_VALUE_A : usize = 10 ;
158+ const PRECOMP_INDEX_MEM_VALUE_B : usize = 11 ;
159+ const PRECOMP_INDEX_MEM_VALUE_C : usize = 12 ;
160+ const PRECOMP_INDEX_FP : usize = 13 ;
161+
162+ pub fn reorder_full_trace_for_precomp_foot_print < A : Copy > ( full_trace : Vec < A > ) -> Vec < A > {
163+ assert_eq ! ( full_trace. len( ) , N_TOTAL_COLUMNS ) ;
164+ vec ! [
165+ full_trace[ COL_INDEX_OPERAND_A ] ,
166+ full_trace[ COL_INDEX_OPERAND_B ] ,
167+ full_trace[ COL_INDEX_FLAG_A ] ,
168+ full_trace[ COL_INDEX_FLAG_B ] ,
169+ full_trace[ COL_INDEX_FLAG_C ] ,
170+ full_trace[ COL_INDEX_AUX ] ,
171+ full_trace[ COL_INDEX_POSEIDON_16 ] ,
172+ full_trace[ COL_INDEX_POSEIDON_24 ] ,
173+ full_trace[ COL_INDEX_DOT_PRODUCT ] ,
174+ full_trace[ COL_INDEX_MULTILINEAR_EVAL ] ,
175+ full_trace[ COL_INDEX_MEM_VALUE_A ] ,
176+ full_trace[ COL_INDEX_MEM_VALUE_B ] ,
177+ full_trace[ COL_INDEX_MEM_VALUE_C ] ,
178+ full_trace[ COL_INDEX_FP ] ,
179+ ]
180+ }
181+
147182impl PrecompileFootprint {
148183 fn air_eval <
149184 PointF : PrimeCharacteristicRing + Copy ,
@@ -153,36 +188,36 @@ impl PrecompileFootprint {
153188 point : & [ PointF ] ,
154189 mul_point_f_and_ef : impl Fn ( PointF , EF ) -> ResultF ,
155190 ) -> 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 ] ;
191+ let nu_a = ( ResultF :: ONE - point[ PRECOMP_INDEX_FLAG_A ] ) * point[ PRECOMP_INDEX_MEM_VALUE_A ]
192+ + point[ PRECOMP_INDEX_FLAG_A ] * point[ PRECOMP_INDEX_OPERAND_A ] ;
193+ let nu_b = ( ResultF :: ONE - point[ PRECOMP_INDEX_FLAG_B ] ) * point[ PRECOMP_INDEX_MEM_VALUE_B ]
194+ + point[ PRECOMP_INDEX_FLAG_B ] * point[ PRECOMP_INDEX_OPERAND_B ] ;
195+ let nu_c = ( ResultF :: ONE - point[ PRECOMP_INDEX_FLAG_C ] ) * point[ PRECOMP_INDEX_MEM_VALUE_C ]
196+ + point[ PRECOMP_INDEX_FLAG_C ] * point[ PRECOMP_INDEX_FP ] ;
162197
163198 ( nu_a * self . p16_powers [ 2 ]
164199 + nu_b * self . p16_powers [ 3 ]
165200 + nu_c * self . p16_powers [ 4 ]
166- + mul_point_f_and_ef ( point[ COL_INDEX_AUX ] , self . p16_powers [ 5 ] )
201+ + mul_point_f_and_ef ( point[ PRECOMP_INDEX_AUX ] , self . p16_powers [ 5 ] )
167202 + self . p16_powers [ 1 ] )
168- * point[ COL_INDEX_POSEIDON_16 ]
203+ * point[ PRECOMP_INDEX_POSEIDON_16 ]
169204 + ( nu_a * self . p24_powers [ 2 ]
170205 + nu_b * self . p24_powers [ 3 ]
171206 + nu_c * self . p24_powers [ 4 ]
172207 + self . p24_powers [ 1 ] )
173- * point[ COL_INDEX_POSEIDON_24 ]
208+ * point[ PRECOMP_INDEX_POSEIDON_24 ]
174209 + ( nu_a * self . dot_product_powers [ 2 ]
175210 + nu_b * self . dot_product_powers [ 3 ]
176211 + nu_c * self . dot_product_powers [ 4 ]
177- + mul_point_f_and_ef ( point[ COL_INDEX_AUX ] , self . dot_product_powers [ 5 ] )
212+ + mul_point_f_and_ef ( point[ PRECOMP_INDEX_AUX ] , self . dot_product_powers [ 5 ] )
178213 + self . dot_product_powers [ 1 ] )
179- * point[ COL_INDEX_DOT_PRODUCT ]
214+ * point[ PRECOMP_INDEX_DOT_PRODUCT ]
180215 + ( nu_a * self . multilinear_eval_powers [ 2 ]
181216 + nu_b * self . multilinear_eval_powers [ 3 ]
182217 + nu_c * self . multilinear_eval_powers [ 4 ]
183- + mul_point_f_and_ef ( point[ COL_INDEX_AUX ] , self . multilinear_eval_powers [ 5 ] )
218+ + mul_point_f_and_ef ( point[ PRECOMP_INDEX_AUX ] , self . multilinear_eval_powers [ 5 ] )
184219 + self . multilinear_eval_powers [ 1 ] )
185- * point[ COL_INDEX_MULTILINEAR_EVAL ]
220+ * point[ PRECOMP_INDEX_MULTILINEAR_EVAL ]
186221 + self . global_challenge
187222 }
188223}
0 commit comments