Trace
The execution of a Cairo program produces a memory vector and a matrix of size with the evolution of the three registers pc
, ap
, fp
. All of them with entries in .
Construction of execution trace :
In this section we describe the construction of the execution trace . This is the matrix mentioned here in the description of the STARK protocol
- Augment each row of with information about the pointed instruction as follows: For each entry of , unpack the -th value of . The result is a new matrix with the following layout
A. flags (16) : Decoded instruction flags
B. res (1) : Res value
C. pointers (2) : Temporary memory pointers (ap and fp)
D. mem_a (4) : Memory addresses (pc, dst_addr, op0_addr, op1_addr)
E. mem_v (4) : Memory values (inst, dst, op0, op1)
F. offsets (3) : (off_dst, off_op0, off_op1)
G. derived (3) : (t0, t1, mul)
A B C D E F G
|xxxxxxxxxxxxxxxx|x|xx|xxxx|xxxx|xxx|xxx|
-
Let and be respectively the minimum and maximum values of the entries of the submatrix defined by the columns of the group
offsets
. Let be the vector of all the values between and that are not in . If the length of is not a multiple of three, extend it to the nearest multiple of three using one arbitrary value of . -
Let be the last row of , and let be the vector that's equal to except that it has zeroes in entries corresponding to the ordered set of columns
mem_a
andmem_v
. The set is ordered incrementally bymem_a
. Let be the length of the public input (program code). Extend with additional rows to obtain a matrix by appending copies of at the bottom (the notation means the ceiling function, defined as the smallest integer that is not smaller than ). -
Let be the vector that's equal to except that it has zeroes in entries corresponding to the set of columns
mem_a
andmem_v
, let be the submatrix defined by the columns of the groupaddresses
, let the submatrix that asserts , where and and . Extend with additional rows to obtain a matrix by appending copies of at the bottom. -
Pad with copies of its last row until it has a power of two number of rows. As a result we obtain a matrix .