Skip to content

Commit 80c3b6b

Browse files
committed
chore: cleanup removing inf from circuits - no opcode changes
1 parent 1a0e853 commit 80c3b6b

5 files changed

Lines changed: 11 additions & 36 deletions

File tree

barretenberg/cpp/pil/vm2/bytecode/address_derivation.pil

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,15 @@ namespace address_derivation;
307307

308308
// Enforces address_point = preaddress_public_key + incoming_viewing_key on Grumpkin, and that
309309
// address = address_point.x.
310-
// TODO(MW): Remove result_infinity?
311310
#[ADDRESS_ECADD]
312311
sel {
313312
preaddress_public_key_x, preaddress_public_key_y, precomputed.zero,
314313
incoming_viewing_key_x, incoming_viewing_key_y, precomputed.zero,
315-
address, address_y, precomputed.zero
314+
address, address_y
316315
} in ecc.sel {
317316
ecc.p_x, ecc.p_y, ecc.p_is_inf,
318317
ecc.q_x, ecc.q_y, ecc.q_is_inf,
319-
ecc.r_x, ecc.r_y, ecc.result_infinity
318+
ecc.r_x, ecc.r_y
320319
};
321320

322321
// Note: We can safely assume the address point is not infinity since that would imply either

barretenberg/cpp/pil/vm2/ecc_mem.pil

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ namespace ecc_add_mem;
118118
pol commit p_x, p_y;
119119
pol commit q_x, q_y;
120120

121-
// MW NOTE: Still using p_is_inf, q_is_inf just as flags to tell ecc.pil how to treat the points.
122-
// TODO(#AVM-266): Remove p_is_inf, q_is_inf entirely.
123121
// Needs to be committed columns as they are used in the lookups
124122
pol commit p_is_inf, q_is_inf; // constrained to be @boolean in the ecc subtrace (see #[INPUT_OUTPUT_ECC_ADD])
125123

@@ -185,12 +183,8 @@ namespace ecc_add_mem;
185183
pol commit sel_should_exec; // @boolean (by definition)
186184
sel_should_exec = sel * (1 - err);
187185

188-
// MW NOTE: Still using p_is_inf, q_is_inf just as flags to tell ecc.pil how to treat the points.
189-
// MW NOTE: Output inifinities - in ecc.pil, if result_infinity, then r_x = INFINITY_X = 0, r_y = INFINITY_Y = 0.
190-
// Sufficient to just lookup res_x, res_y here?
191-
192-
// TODO(#AVM-266): Remove p_is_inf, q_is_inf entirely. For now, we ensure that the flag being set means that the coordinates
193-
// are set to our infinity representation: (INFINITY_X, INFINITY_Y) = (0, 0). The reverse ((INFINITY_X, INFINITY_Y) ==> is_inf)
186+
// TODO(#AVM-266): For now, we ensure that the flag being set means that the coordinates are set to our infinity
187+
// representation: (INFINITY_X, INFINITY_Y) = (0, 0). The reverse ((INFINITY_X, INFINITY_Y) ==> is_inf)
194188
// is constrained by #[P/Q_ON_CURVE_CHECK]. Output infinities are already constrained to be (0, 0) in the subtrace.
195189
#[P_INF_X_CHECK]
196190
sel * p_is_inf * (p_x - ecc.INFINITY_X) = 0;
@@ -232,12 +226,3 @@ namespace ecc_add_mem;
232226
memory.sel_ecc_write[1] {
233227
memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw
234228
};
235-
236-
// #[WRITE_MEM_2]
237-
// sel_should_exec {
238-
// execution_clk, space_id, dst_addr[2], res_is_inf, /*U1_mem_tag=1*/ sel_should_exec, /*rw=1*/ sel_should_exec
239-
// } is
240-
// memory.sel_ecc_write[2] {
241-
// memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw
242-
// };
243-

barretenberg/cpp/pil/vm2/scalar_mul.pil

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@ namespace scalar_mul;
8181
// Point P in affine form
8282
pol commit point_x;
8383
pol commit point_y;
84-
// TODO(#AVM-266): Remove infinity flags from point representation.
8584
pol commit point_inf; // @boolean
8685
point_inf * (1 - point_inf) = 0;
8786

8887
// Point R = sP in affine form
8988
pol commit res_x;
9089
pol commit res_y;
91-
// TODO(#AVM-266): Remove infinity flags from point representation.
9290
pol commit res_inf; // @boolean (constrained to be @boolean by lookup in the ecc subtrace)
9391

9492
///////////////////////////////
@@ -123,6 +121,7 @@ namespace scalar_mul;
123121
sel_not_end * (point_x - point_x') = 0;
124122
#[INPUT_CONSISTENCY_Y]
125123
sel_not_end * (point_y - point_y') = 0;
124+
// TODO(MW): remove/rework below? only used at end
126125
#[INPUT_CONSISTENCY_INF]
127126
sel_not_end * (point_inf - point_inf') = 0;
128127
#[INPUT_CONSISTENCY_SCALAR]
@@ -175,7 +174,6 @@ namespace scalar_mul;
175174
end * (temp_y - point_y) = 0;
176175
end * (temp_inf - point_inf) = 0;
177176

178-
// TODO(MW): Remove result_infinity?
179177
#[DOUBLE]
180178
sel_not_end { temp_x, temp_y, temp_inf, temp_x', temp_y', temp_inf', sel_not_end /* = 1 */ }
181179
in
@@ -204,7 +202,6 @@ namespace scalar_mul;
204202
SHOULD_PASS * (res_y - res_y') = 0;
205203
SHOULD_PASS * (res_inf - res_inf') = 0;
206204

207-
// TODO(MW): Remove result_infinity?
208205
#[ADD]
209206
should_add { res_x, res_y, res_inf, res_x', res_y', res_inf', temp_x, temp_y, temp_inf }
210207
in

barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_address_derivation.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ using lookup_address_derivation_preaddress_scalar_mul_relation =
332332
struct lookup_address_derivation_address_ecadd_settings_ {
333333
static constexpr std::string_view NAME = "LOOKUP_ADDRESS_DERIVATION_ADDRESS_ECADD";
334334
static constexpr std::string_view RELATION_NAME = "address_derivation";
335-
static constexpr size_t LOOKUP_TUPLE_SIZE = 9;
335+
static constexpr size_t LOOKUP_TUPLE_SIZE = 8;
336336
static constexpr Column SRC_SELECTOR = Column::address_derivation_sel;
337337
static constexpr Column DST_SELECTOR = Column::ecc_sel;
338338
static constexpr Column COUNTS = Column::lookup_address_derivation_address_ecadd_counts;
@@ -345,13 +345,12 @@ struct lookup_address_derivation_address_ecadd_settings_ {
345345
ColumnAndShifts::address_derivation_incoming_viewing_key_y,
346346
ColumnAndShifts::precomputed_zero,
347347
ColumnAndShifts::address_derivation_address,
348-
ColumnAndShifts::address_derivation_address_y,
349-
ColumnAndShifts::precomputed_zero
348+
ColumnAndShifts::address_derivation_address_y
350349
};
351350
static constexpr std::array<ColumnAndShifts, LOOKUP_TUPLE_SIZE> DST_COLUMNS = {
352351
ColumnAndShifts::ecc_p_x, ColumnAndShifts::ecc_p_y, ColumnAndShifts::ecc_p_is_inf,
353352
ColumnAndShifts::ecc_q_x, ColumnAndShifts::ecc_q_y, ColumnAndShifts::ecc_q_is_inf,
354-
ColumnAndShifts::ecc_r_x, ColumnAndShifts::ecc_r_y, ColumnAndShifts::ecc_result_infinity
353+
ColumnAndShifts::ecc_r_x, ColumnAndShifts::ecc_r_y
355354
};
356355
};
357356

barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/ecc.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,14 @@ void Ecc::add(MemoryInterface& memory,
112112
uint16_t space_id = memory.get_space_id();
113113

114114
try {
115-
// TODO(#AVM-266): Remove is_infinity flag from point representation.
116-
// The resulting EmbeddedCurvePoint is a triple of (x, y, is_infinity).
117-
// The x and y coordinates are stored at dst_address and dst_address + 1 respectively,
118-
// and the is_infinity flag is stored at dst_address + 2.
119-
// Therefore, the maximum address that needs to be written to is dst_address + 2.
120-
uint64_t max_write_address = static_cast<uint64_t>(dst_address) + 2;
115+
// The resulting EmbeddedCurvePoint is (x, y), stored at dst_address and dst_address + 1 respectively.
116+
// Therefore, the maximum address that needs to be written to is dst_address + 1.
117+
uint64_t max_write_address = static_cast<uint64_t>(dst_address) + 1;
121118
// Emits GreaterThanEvent, see #[CHECK_DST_ADDR_IN_RANGE] in ecc_mem.pil.
122119
if (gt.gt(max_write_address, AVM_HIGHEST_MEM_ADDRESS)) {
123120
throw InternalEccException("dst address out of range");
124121
}
125122

126-
// TODO(#AVM-266): Remove is_infinity flag from point representation. We assume here input
127-
// points follow the Noir convention of (x=0, y=0) <==> is_infinity.
128123
if (!p.on_curve() || !q.on_curve()) {
129124
throw InternalEccException("One of the points is not on the curve");
130125
}

0 commit comments

Comments
 (0)