Skip to content

Commit d6ac2dd

Browse files
committed
changed to use set_variable
1 parent d9f1b05 commit d6ac2dd

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,12 @@ void process_ROM_operations(Builder& builder,
118118
// For a ROM table, constant read should be optimized out:
119119
// The rom_table won't work with a constant read because the table may not be initialized
120120
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);
127125
}
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]);
131127
}
132128
}
133129

@@ -145,11 +141,10 @@ void process_RAM_operations(Builder& builder,
145141
field_ct value = poly_to_field_ct(op.value, builder);
146142
field_ct index = poly_to_field_ct(op.index, builder);
147143

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+
}
153148

154149
if (op.access_type == 0) {
155150
value.assert_equal(table.read(index));
@@ -179,10 +174,11 @@ void process_call_data_operations(Builder& builder,
179174
BB_ASSERT_EQ(op.access_type, 0);
180175
field_ct value = poly_to_field_ct(op.value, builder);
181176
field_ct index = poly_to_field_ct(op.index, builder);
182-
value.assert_equal(calldata_array[index]);
183177
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);
185180
}
181+
value.assert_equal(calldata_array[index]);
186182
}
187183
};
188184

0 commit comments

Comments
 (0)