@@ -1033,6 +1033,19 @@ impl PcDoubleReadRs1Constraint {
10331033 pub fn new ( idx : usize ) -> Self {
10341034 Self { idx }
10351035 }
1036+
1037+ fn compute < F , E > ( & self , step : & TableView < F , E > ) -> FieldElement < F >
1038+ where
1039+ F : IsSubFieldOf < E > ,
1040+ E : IsField ,
1041+ {
1042+ let pc_double_read = step
1043+ . get_main_evaluation_element ( 0 , cols:: PC_DOUBLE_READ )
1044+ . clone ( ) ;
1045+ let rs1 = step. get_main_evaluation_element ( 0 , cols:: RS1 ) . clone ( ) ;
1046+ let val_255 = FieldElement :: < F > :: from ( 255u64 ) ;
1047+ pc_double_read * ( rs1 - val_255)
1048+ }
10361049}
10371050
10381051impl TransitionConstraint < GoldilocksField , GoldilocksExtension > for PcDoubleReadRs1Constraint {
@@ -1044,32 +1057,12 @@ impl TransitionConstraint<GoldilocksField, GoldilocksExtension> for PcDoubleRead
10441057 self . idx
10451058 }
10461059
1047- fn evaluate (
1048- & self ,
1049- evaluation_context : & TransitionEvaluationContext < GoldilocksField , GoldilocksExtension > ,
1050- transition_evaluations : & mut [ FieldElement < GoldilocksExtension > ] ,
1051- ) {
1052- match evaluation_context {
1053- TransitionEvaluationContext :: Prover { frame, .. } => {
1054- let step = frame. get_evaluation_step ( 0 ) ;
1055- let pc_double_read = step
1056- . get_main_evaluation_element ( 0 , cols:: PC_DOUBLE_READ )
1057- . clone ( ) ;
1058- let rs1 = step. get_main_evaluation_element ( 0 , cols:: RS1 ) . clone ( ) ;
1059- let val_255 = FieldElement :: < GoldilocksField > :: from ( 255u64 ) ;
1060- transition_evaluations[ self . idx ] =
1061- ( & pc_double_read * ( rs1 - val_255) ) . to_extension ( ) ;
1062- }
1063- TransitionEvaluationContext :: Verifier { frame, .. } => {
1064- let step = frame. get_evaluation_step ( 0 ) ;
1065- let pc_double_read = step
1066- . get_main_evaluation_element ( 0 , cols:: PC_DOUBLE_READ )
1067- . clone ( ) ;
1068- let rs1 = step. get_main_evaluation_element ( 0 , cols:: RS1 ) . clone ( ) ;
1069- let val_255 = FieldElement :: < GoldilocksExtension > :: from ( 255u64 ) ;
1070- transition_evaluations[ self . idx ] = & pc_double_read * ( rs1 - val_255) ;
1071- }
1072- }
1060+ fn evaluate < F , E > ( & self , step : & TableView < F , E > ) -> FieldElement < F >
1061+ where
1062+ F : IsSubFieldOf < E > ,
1063+ E : IsField ,
1064+ {
1065+ self . compute ( step)
10731066 }
10741067}
10751068
@@ -1083,6 +1076,20 @@ impl PcDoubleReadBorrowConstraint {
10831076 pub fn new ( idx : usize ) -> Self {
10841077 Self { idx }
10851078 }
1079+
1080+ fn compute < F , E > ( & self , step : & TableView < F , E > ) -> FieldElement < F >
1081+ where
1082+ F : IsSubFieldOf < E > ,
1083+ E : IsField ,
1084+ {
1085+ let pc_double_read = step
1086+ . get_main_evaluation_element ( 0 , cols:: PC_DOUBLE_READ )
1087+ . clone ( ) ;
1088+ let borrow = step
1089+ . get_main_evaluation_element ( 0 , cols:: PREV_PC_TIMESTAMP_BORROW )
1090+ . clone ( ) ;
1091+ pc_double_read * borrow
1092+ }
10861093}
10871094
10881095impl TransitionConstraint < GoldilocksField , GoldilocksExtension > for PcDoubleReadBorrowConstraint {
@@ -1094,33 +1101,12 @@ impl TransitionConstraint<GoldilocksField, GoldilocksExtension> for PcDoubleRead
10941101 self . idx
10951102 }
10961103
1097- fn evaluate (
1098- & self ,
1099- evaluation_context : & TransitionEvaluationContext < GoldilocksField , GoldilocksExtension > ,
1100- transition_evaluations : & mut [ FieldElement < GoldilocksExtension > ] ,
1101- ) {
1102- match evaluation_context {
1103- TransitionEvaluationContext :: Prover { frame, .. } => {
1104- let step = frame. get_evaluation_step ( 0 ) ;
1105- let pc_double_read = step
1106- . get_main_evaluation_element ( 0 , cols:: PC_DOUBLE_READ )
1107- . clone ( ) ;
1108- let borrow = step
1109- . get_main_evaluation_element ( 0 , cols:: PREV_PC_TIMESTAMP_BORROW )
1110- . clone ( ) ;
1111- transition_evaluations[ self . idx ] = ( & pc_double_read * borrow) . to_extension ( ) ;
1112- }
1113- TransitionEvaluationContext :: Verifier { frame, .. } => {
1114- let step = frame. get_evaluation_step ( 0 ) ;
1115- let pc_double_read = step
1116- . get_main_evaluation_element ( 0 , cols:: PC_DOUBLE_READ )
1117- . clone ( ) ;
1118- let borrow = step
1119- . get_main_evaluation_element ( 0 , cols:: PREV_PC_TIMESTAMP_BORROW )
1120- . clone ( ) ;
1121- transition_evaluations[ self . idx ] = & pc_double_read * borrow;
1122- }
1123- }
1104+ fn evaluate < F , E > ( & self , step : & TableView < F , E > ) -> FieldElement < F >
1105+ where
1106+ F : IsSubFieldOf < E > ,
1107+ E : IsField ,
1108+ {
1109+ self . compute ( step)
11241110 }
11251111}
11261112
@@ -1252,9 +1238,9 @@ pub fn create_all_cpu_constraints() -> (
12521238 next_idx += 2 ;
12531239
12541240 // Inline PC constraints
1255- other. push ( Box :: new ( PcDoubleReadRs1Constraint :: new ( next_idx) ) ) ;
1241+ other. push ( PcDoubleReadRs1Constraint :: new ( next_idx) . boxed ( ) ) ;
12561242 next_idx += 1 ;
1257- other. push ( Box :: new ( PcDoubleReadBorrowConstraint :: new ( next_idx) ) ) ;
1243+ other. push ( PcDoubleReadBorrowConstraint :: new ( next_idx) . boxed ( ) ) ;
12581244 next_idx += 1 ;
12591245
12601246 ( is_bit, add_constraints, other, next_idx)
0 commit comments