@@ -118,16 +118,12 @@ void process_ROM_operations(Builder& builder,
118
118
// For a ROM table, constant read should be optimized out:
119
119
// The rom_table won't work with a constant read because the table may not be initialized
120
120
ASSERT (op.index .q_l != 0 );
121
- // We create a new witness w to avoid issues with non-valid witness assignements:
122
- // if witness are not assigned, then w will be zero and table[w] will work
123
- fr w_value = 0 ;
124
- if (has_valid_witness_assignments) {
125
- // If witness are assigned, we use the correct value for w
126
- w_value = index.get_value ();
121
+
122
+ if (!has_valid_witness_assignments) {
123
+ // If witness are not assigned, we set the index value to 0
124
+ builder.set_variable (index.witness_index , 0 );
127
125
}
128
- field_ct w = field_ct::from_witness (&builder, w_value);
129
- value.assert_equal (table[w]);
130
- w.assert_equal (index);
126
+ value.assert_equal (table[index]);
131
127
}
132
128
}
133
129
@@ -145,11 +141,10 @@ void process_RAM_operations(Builder& builder,
145
141
field_ct value = poly_to_field_ct (op.value , builder);
146
142
field_ct index = poly_to_field_ct (op.index , builder);
147
143
148
- // We create a new witness w to avoid issues with non-valid witness assignements.
149
- // If witness are not assigned, then index will be zero and table[index] won't hit bounds check.
150
- fr index_value = has_valid_witness_assignments ? index.get_value () : 0 ;
151
- // Create new witness and ensure equal to index.
152
- field_ct::from_witness (&builder, index_value).assert_equal (index);
144
+ if (!has_valid_witness_assignments) {
145
+ // If witness are not assigned, we set the index value to 0
146
+ builder.set_variable (index.witness_index , 0 );
147
+ }
153
148
154
149
if (op.access_type == 0 ) {
155
150
value.assert_equal (table.read (index));
@@ -179,10 +174,11 @@ void process_call_data_operations(Builder& builder,
179
174
BB_ASSERT_EQ (op.access_type , 0 );
180
175
field_ct value = poly_to_field_ct (op.value , builder);
181
176
field_ct index = poly_to_field_ct (op.index , builder);
182
- value.assert_equal (calldata_array[index]);
183
177
if (!has_valid_witness_assignments) {
184
- index.is_zero ();
178
+ // If witness are not assigned, we set the index value to 0
179
+ builder.set_variable (index.witness_index , 0 );
185
180
}
181
+ value.assert_equal (calldata_array[index]);
186
182
}
187
183
};
188
184
0 commit comments