EC OP Builtin

The EC OP builtin is dedicated to compute the point R = P + mQ where P and Q are points on the STARK curve and m is a scalar. Each point (P, Q and R) is represented by two field elements, x and y.

Cells organization

The EC OP builtin has its own segment during a Cairo VM run. It works with blocks of 7 cells (5 inputs and 2 outputs):

  • The first two cells are inputs storing the x and y coordinates of the point P. (Offset 0 and 1)
  • The next two cells are inputs storing the x and y coordinates of the point Q. (Offset 2 and 3)
  • The next cell is an input storing the scalar m. (Offset 4)
  • The next two cells are outputs storing the x and y coordinates of the point R. (Offset 5 and 6)

In this snapshot, we wrote the coordinates of the points P and Q and the scalar m (inputs). The runner computes the point R = P + mQ and writes the result in the last two cells (outputs).

EC OP builtin segment
Snapshot 1 - Example of the EC OP segment

On the second snapshot, we try read the coordinates of the point R but some input values are missing. This will throw an error.

Incomplete input values in EC OP builtin segment
Snapshot 2 - Incomplete input values in EC OP builtin segment

Why is there an error? We want the runner to compute the point R = P + mQ. To do so, we need to provide the coordinates of the points P and Q and the scalar m. If one or more of these values is missing or invalid (not a Felt for example), the runner will throw an error. Here, we didn't provide the coordinates of the point Q.

Implementation References

These implementation references of the EC OP builtin might not be exhaustive.