You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(avm)!: Remove is_infinite flag from AVM (PIL and EC points only) (#22795)
This branch includes the changes to remove the `is_infinite` flag from
our point representation and conceptually treating a point as infinite
iff its coordinates are `(0, 0)`.
It only contains logic changes within the AVM for the above and does not
touch the opcode - this is in a lower PR - so the **CI will probably
fail**.
Will close [Foundation AVM Issue
18](https://linear.app/aztec-foundation/issue/AVM-18/remove-is-inf-flag-from-resulting-ec-points-in-avm-circuits)
---
Stack:
- #22745
- #22564
- #22921
- `mw/avm-explore-remove-is-inf` <-- here
- #22945
- #23031
Copy file name to clipboardExpand all lines: barretenberg/cpp/pil/vm2/ecc.pil
+23-20Lines changed: 23 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,32 @@
2
2
/**
3
3
* This subtrace supports point addition over the Grumpkin curve.
4
4
* Given two points, P & Q, this trace computes R = P + Q.
5
-
* PRECONDITIONS: The only assumption here is that the inputs P & Q are points on the Grumpkin curve (note that the Point at Infinity = (0, 0) is considered on the curve):
6
-
* Grumpkin Curve Eqn in SW form: Y^2 = X^3 − 17.
5
+
* PRECONDITIONS: This trace assumes that the inputs P & Q are points on the Grumpkin curve and infinity points are correctly
6
+
* flagged with p_is_inf and/or q_is_inf (note that the Point at Infinity = (0, 0) is considered on the curve):
7
+
* Grumpkin Curve Eqn in SW form: Y^2 = X^3 − 17.
7
8
* Note: Grumpkin forms a 2-cycle with BN254, i.e the base field of one is the scalar field of the other and vice-versa.
8
9
*
9
-
* Note that once TODO(#AVM-266) is complete, is_inf will no longer be part of our point representation and we must either:
10
-
* - continue to rely on the 'calling' trace to inject a constrained is_inf, or
11
-
* - derive is_inf (<==> (X, Y) == (INFINITY_X, INFINITY_Y)) within this trace.
12
-
*
13
10
* USAGE: This is a non-memory aware subtrace used to constrain point addition as defined above. Each point can be looked up
14
11
* by coordinates (lookup as defined in ecc_mem.pil):
15
12
* #[INPUT_OUTPUT_ECC_ADD]
16
13
* sel_should_exec {
17
-
* p_x_n, p_y_n, p_is_inf, // Point P
18
-
* q_x_n, q_y_n, q_is_inf, // Point Q
19
-
* res_x, res_y, res_is_inf // Point R
14
+
* p_x_n, p_y_n, // Point P
15
+
* p_is_inf, // P == O
16
+
* q_x_n, q_y_n, // Point Q
17
+
* q_is_inf, // Q == O
18
+
* res_x, res_y // Point R
20
19
* } in ecc.sel {
21
-
* ecc.p_x, ecc.p_y, ecc.p_is_inf, // Point P
22
-
* ecc.q_x, ecc.q_y, ecc.q_is_inf, // Point Q
23
-
* ecc.r_x, ecc.r_y, ecc.r_is_inf // Point R
20
+
* ecc.p_x, ecc.p_y, // Point P
21
+
* ecc.p_is_inf, // P == O
22
+
* ecc.q_x, ecc.q_y,, // Point Q
23
+
* ecc.q_is_inf, // Q == O
24
+
* ecc.r_x, ecc.r_y // Point R
24
25
* };
25
26
*
27
+
* NOTE: For now, the calling trace MUST constrain that p_is_inf, q_is_inf above are correct. This is so if we have a calling
28
+
* trace in which we know inf would never be an input we can simply use precomputed.zero and avoid wasting gates on deriving is_inf.
29
+
* This follows the same logic for points being on the curve.
30
+
*
26
31
* TRACE SHAPE: 1 single row per computation (P + Q = R).
27
32
*
28
33
* INTERACTIONS: This subtrace is looked up by:
@@ -41,11 +46,11 @@ namespace ecc;
41
46
// We perform point addition over our Short Weierstrass (SW) curve with 3 cases outlined in the last section ('Assign Result').
42
47
// The notation will be as follows:
43
48
// P + Q = R where:
44
-
// P = (p_x, p_y, p_is_inf), Q = (q_x, q_y, q_is_inf), R = (r_x, r_y, r_is_inf),
49
+
// P = (p_x, p_y), Q = (q_x, q_y), R = (r_x, r_y),
45
50
// where the coordinates satisfy:
46
51
// y^2 = x^3 - 17 (unless is_inf is true).
47
52
// The point at infinity, O, does not have valid coordinates (a property of SW curves). We represent it as:
48
-
// O = (0, 0, true).
53
+
// O = (0, 0).
49
54
// Note: this is NOT enforced here for inputs, see ecc_mem.pil for example of constraining.
50
55
//
51
56
@@ -74,20 +79,20 @@ namespace ecc;
74
79
// Point P in affine form
75
80
pol commit p_x;
76
81
pol commit p_y;
82
+
// Must be constrained by the calling trace:
77
83
pol commit p_is_inf; // @boolean
78
84
p_is_inf * (1 - p_is_inf) = 0;
79
85
80
86
// Point Q in affine form
81
87
pol commit q_x;
82
88
pol commit q_y;
89
+
// Must be constrained by the calling trace:
83
90
pol commit q_is_inf; // @boolean
84
91
q_is_inf * (1 - q_is_inf) = 0;
85
92
86
93
// Resulting Point R in affine form
87
94
pol commit r_x;
88
95
pol commit r_y;
89
-
pol commit r_is_inf; // @boolean
90
-
r_is_inf * (1 - r_is_inf) = 0;
91
96
92
97
// Check x coordinates, i.e. p_x == q_x
93
98
pol commit x_match; // @boolean
@@ -151,9 +156,9 @@ namespace ecc;
151
156
// If P != Q where x_match, this implies p_y == -q_y <==> P == -Q (INVERSE_PRED == true):
0 commit comments