re-libs/cairo-lang/blob/ab8be40403a7634ba296c467b26b8bd945ba5cfa/src/starkware/cairo/common/cairo_blake2s/blake2s.cairo#L671). **SP1** and **R0** do not support precompiles for BLAKE.
### Prover Time (s)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 2048 | 14.272 | 28.817 | 35.206 |
| 4096 | 14.773 | 52.33 | 34.752 |
| 8192 | 17.678 | 65.67 | 30.911 |
| 16384 | 24.308 | 126.219 | 32.214 |
| 32768 | 37.485 | 240.843 | 30.324 |
| 65536 | 55.119 | 476.273 | 38.614 |
| 131072 | 101.786 | 947.306 | 35.269 |
| 262144 | 162.863 | 1888.15 | 33.434 |
<img alt="" />
### Verifier Time (ms)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 2048 | 102 | 10 | 11 |
| 4096 | 105 | 23 | 11 |
| 8192 | 111 | 22 | 11 |
| 16384 | 99 | 24 | 11 |
| 32768 | 104 | 23 | 12 |
| 65536 | 81 | 22 | 12 |
| 131072 | 81 | 23 | 37 |
| 262144 | 81 | 22 | 48 |
<img alt="" />
### Proof Size (KB)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 2048 | 1315.56 | 223.482 | 1117.14 |
| 4096 | 1315.56 | 223.482 | 1138.83 |
| 8192 | 1315.56 | 223.482 | 1134.37 |
| 16384 | 1315.56 | 223.482 | 1121.81 |
| 32768 | 1315.56 | 223.482 | 1144.87 |
| 65536 | 1315.56 | 223.482 | 1158.19 |
| 131072 | 1315.56 | 223.482 | 1141.67 |
| 262144 | 1315.56 | 223.482 | 1148.66 |
<img alt="" />
### Cycle Count
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 2048 | 100997 | 264515 | 65535 |
| 4096 | 193061 | 521763 | 65535 |
| 8192 | 377189 | 1036259 | 65535 |
| 16384 | 745445 | 2065251 | 65535 |
| 32768 | 1481957 | 4123235 | 131071 |
| 65536 | 2954981 | 8239203 | 262143 |
| 131072 | 5901029 | 16471139 | 524287 |
| 262144 | 11793125 | 32935011 | 1048575 |
<img alt="" />
### Peak Memory (GB)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 2048 | 4.55 | 4.58 | 19.98 |
| 4096 | 5 | 9.14 | 19.94 |
| 8192 | 6.09 | 9.17 | 19.98 |
| 16384 | 8.83 | 9.18 | 20.02 |
| 32768 | 13.83 | 9.18 | 20.17 |
| 65536 | 16.59 | 9.18 | 20.5 |
| 131072 | 38 | 9.19 | 20.88 |
| 262144 | 45.31 | 9.19 | 21.97 |
<img alt="" />
## BLAKE-Chain
Benchmark Blake2s256 hash of 32 bytes for `n` iteration. For the **S-two** benchmarks, a dedicated opcode for BLAKE was used, as illustrated in [this Cairo source file](https://github.com/starkware-libs/cairo-lang/blob/ab8be40403a7634ba296c467b26b8bd945ba5cfa/src/starkware/cairo/common/cairo_blake2s/blake2s.cairo#L671). **SP1** and **R0** do not support precompiles for BLAKE.
### Prover Time (s)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 128 | 17.319 | 28.76 | 30.885 |
| 256 | 24.279 | 52.074 | 32.974 |
| 512 | 38.5 | 86.181 | 33.26 |
| 1024 | 53.129 | 166.706 | 30.723 |
| 2048 | 89.423 | 316.029 | 38.153 |
| 4096 | 145.299 | 628.118 | 31.717 |
| 8192 | 259.23 | 1260.14 | 37.422 |
| 16384 | 495.878 | 2521.17 | 35.82 |
<img alt="" />
### Verifier Time (ms)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 128 | 105 | 22 | 11 |
| 256 | 104 | 22 | 11 |
| 512 | 108 | 23 | 11 |
| 1024 | 84 | 23 | 11 |
| 2048 | 81 | 23 | 41 |
| 4096 | 85 | 23 | 40 |
| 8192 | 81 | 23 | 49 |
| 16384 | 81 | 22 | 39 |
<img alt="" />
### Proof Size (KB)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 128 | 1315.56 | 223.482 | 1119.07 |
| 256 | 1315.56 | 223.482 | 1121.09 |
| 512 | 1315.56 | 223.482 | 1128.54 |
| 1024 | 1315.56 | 223.482 | 1119.77 |
| 2048 | 1315.56 | 223.482 | 1127.81 |
| 4096 | 1315.56 | 223.482 | 1127.26 |
| 8192 | 1315.56 | 223.482 | 1134 |
| 16384 | 1315.56 | 223.482 | 1143.83 |
<img alt="" />
### Cycle Count
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 128 | 376249 | 356507 | 65535 |
| 256 | 742841 | 702491 | 65535 |
| 512 | 1476025 | 1394459 | 131071 |
| 1024 | 2942393 | 2778395 | 262143 |
| 2048 | 5875129 | 5546267 | 524287 |
| 4096 | 11740601 | 11082011 | 1048575 |
| 8192 | 23471545 | 22153499 | 2097151 |
| 16384 | 46933433 | 44296475 | 4194303 |
<img alt="" />
### Peak Memory (GB)
| n | sp1 | r0 | stwo-precompile |
| -: | -: | -: | -: |
| 128 | 6.16 | 4.58 | 19.99 |
| 256 | 9.12 | 9.15 | 20.01 |
| 512 | 13.17 | 9.17 | 20.13 |
| 1024 | 15.96 | 9.17 | 20.39 |
| 2048 | 32.88 | 9.17 | 20.72 |
| 4096 | 44.6 | 9.19 | 21.54 |
| 8192 | 50.57 | 9.19 | 23.31 |
| 16384 | 53.25 | 9.21 | 27.19 |
<img alt="" />
## Matrix Multiplication
Benchmark multiplication of two matrices of size n x n.
### Prover Time (s)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 4 | 1.196 | 13.179 | 29.508 | 6.763 | 10.922 | 12.72 |
| 8 | 1.648 | 12.862 | 30.119 | 8.21 | 9.879 | 19.566 |
| 16 | 4.979 | 15.252 | 33.467 | 17.135 | 26.384 | 16.531 |
| 32 | 27.702 | 26.491 | 58.102 | 65.806 | 💾 | 14.655 |
| 64 | ❌ | 135.352 | 292.125 | 480.724 | 💾 | 21.199 |
| 128 | ❌ | 881.29 | 2671.68 | 3809.76 | 💾 | 76.061 |
<img alt="" />
### Verifier Time (ms)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 4 | 44.0 | 110 | 140 | 23 | 111.0 | 10 |
| 8 | 51.0 | 110 | 140 | 22 | 120.0 | 10 |
| 16 | 86.0 | 102 | 139 | 23 | 139.0 | 10 |
| 32 | 84.0 | 109 | 140 | 25 | 💾 | 18 |
| 64 | ❌ | 85 | 140 | 22 | 💾 | 41 |
| 128 | ❌ | 84 | 56 | 23 | 💾 | 45 |
<img alt="" />
### Proof Size (KB)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 4 | 144.647 | 1315.53 | 1708.31 | 223.234 | 109.032 | 815.674 |
| 8 | 169.607 | 1315.53 | 1708.31 | 223.234 | 108.52 | 833.086 |
| 16 | 198.911 | 1315.53 | 1708.31 | 223.234 | 116.456 | 844.238 |
| 32 | 233.591 | 1315.53 | 1708.31 | 223.234 | 💾 | 844.914 |
| 64 | ❌ | 1315.53 | 1708.31 | 223.234 | 💾 | 876.354 |
| 128 | ❌ | 1315.53 | 852.937 | 223.234 | 💾 | 981.178 |
<img alt="" />
### Cycle Count
| n | jolt | sp1 | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: |
| 4 | 7181.0 | 8430 | 5820 | 2181.0 | 32767 |
| 8 | 42753.0 | 23951 | 21352 | 13521.0 | 32767 |
| 16 | 314782 | 139844 | 137280 | 94569.0 | 131071 |
| 32 | 2457710 | 1044394 | 1041904 | 💾 | 1048575 |
| 64 | ❌ | 8211062 | 8208720 | 💾 | 8388607 |
| 128 | ❌ | 65306638 | 65304592 | 💾 | 67108863 |
<img alt="" />
### Peak Memory (GB)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 4 | 5.43 | 4.45 | 5.43 | 1.42 | 9.09 | 10.73 |
| 8 | 4.91 | 4.29 | 5.43 | 1.43 | 9.03 | 10.73 |
| 16 | 5.8 | 5.12 | 5.43 | 2.29 | 29.68 | 10.82 |
| 32 | 26.45 | 10.34 | 5.43 | 9.17 | 💾 | 11.61 |
| 64 | ❌ | 39.28 | 19.69 | 9.17 | 💾 | 19.92 |
| 128 | ❌ | 60.01 | 20.09 | 9.19 | 💾 | 101.6 |
<img alt="" />
## Elliptic Curve Addition
Benchmark n point doubling for secp256k1.
### Prover Time (s)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 256 | 50.41 | 70.731 | 158.631 | 283.941 | 18.869 | 11.993 |
| 512 | 96.814 | 116.11 | 292.691 | 531.309 | 30.529 | 19.268 |
| 1024 | ❌ | 211.962 | 582.356 | 1037.16 | 65.693 | 15.356 |
| 2048 | ❌ | 394.022 | 1048.01 | 2072.757 | 114.312 | 14.318 |
| 4096 | ❌ | 741.169 | 2029.72 | 4079.796 | 💾 | 14.407 |
| 8192 | ❌ | 1426.64 | 4046.32 | 8181.789 | 💾 | 16.635 |
| 16384 | ❌ | 2844.32 | 7953.88 | ❌ | 💾 | 24.382 |
| 32768 | ❌ | 5628.39 | 15793.7 | ❌ | 💾 | 28.304 |
<img alt="" />
### Verifier Time (ms)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 256 | 67.0 | 83 | 140 | 22.0 | 188.0 | 10 |
| 512 | 60.0 | 83 | 140 | 23.0 | 181.0 | 10 |
| 1024 | ❌ | 83 | 56 | 23.0 | 187.0 | 34 |
| 2048 | ❌ | 83 | 56 | 25.0 | 238.0 | 39 |
| 4096 | ❌ | 83 | 57 | 23.0 | 💾 | 41 |
| 8192 | ❌ | 83 | 56 | 11.0 | 💾 | 36 |
| 16384 | ❌ | 83 | 56 | ❌ | 💾 | 130 |
| 32768 | ❌ | 83 | 55 | ❌ | 💾 | 15 |
<img alt="" />
### Proof Size (KB)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 256 | 249.399 | 1315.56 | 1708.31 | 223.482 | 111.592 | 918.41 |
| 512 | 261.663 | 1315.56 | 1708.31 | 223.482 | 120.04 | 897.182 |
| 1024 | ❌ | 1315.56 | 852.937 | 223.482 | 127.784 | 889.49 |
| 2048 | ❌ | 1315.56 | 852.937 | 223.482 | 131.976 | 896.15 |
| 4096 | ❌ | 1315.56 | 816.649 | 223.482 | 💾 | 901.758 |
| 8192 | ❌ | 1315.56 | 816.649 | 223.482 | 💾 | 910.154 |
| 16384 | ❌ | 1315.56 | 852.937 | ❌ | 💾 | 929.282 |
| 32768 | ❌ | 1315.56 | 816.649 | ❌ | 💾 | 931.042 |
<img alt="" />
### Cycle Count
| n | jolt | sp1 | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: |
| 256 | 4760760 | 4715656 | 4711913 | 59936.0 | 131071 |
| 512 | 9290168 | 9169544 | 9165801 | 119840 | 262143 |
| 1024 | ❌ | 18077320 | 18073577 | 239648 | 262143 |
| 2048 | ❌ | 35892872 | 35889129 | 479264 | 524287 |
| 4096 | ❌ | 71523976 | 71520233 | 💾 | 1048575 |
| 8192 | ❌ | 142786184 | 142782441 | 💾 | 2097151 |
| 16384 | ❌ | 285310600 | ❌ | 💾 | 4194303 |
| 32768 | ❌ | 570359432 | ❌ | 💾 | 8388607 |
<img alt="" />
### Peak Memory (GB)
| n | jolt | sp1 | openvm | r0 | stone | stwo |
| -: | -: | -: | -: | -: | -: | -: |
| 256 | 48.62 | 23.6 | 10.37 | 9.18 | 17.93 | 10.9 |
| 512 | 93.9 | 47.38 | 19.8 | 9.19 | 35.7 | 11.08 |
| 1024 | ❌ | 44.31 | 19.83 | 9.19 | 71.47 | 11.27 |
| 2048 | ❌ | 55.82 | 19.84 | 9.19 | 142.68 | 11.81 |
| 4096 | ❌ | 62.49 | 19.86 | 9.22 | 💾 | 13.22 |
| 8192 | ❌ | 63.14 | 19.94 | 9.26 | 💾 | 16.01 |
| 16384 | ❌ | 66.48 | 19.95 | ❌ | 💾 | 21.62 |
| 32768 | ❌ | 66.97 | 19.96 | ❌ | 💾 | 32.64 |
<img alt="" />
# ADD Opcode Walkthrough
Source: https://docs.starknet.io/learn/S-two-book/cairo-air/add-opcode/index
To better understand how `Opcode` components work, let's walk through the implementation of the `AddOpcode` component.
<div>
<img alt="" />
*Figure 1: The `AddOpcode` columns*
</div>
Above is the list of all the columns used in the `AddOpcode` component. Note that the `dst_val`, `op0_val`, and `op1_val` columns are actually 28 columns each (to support 28 9-bit limbs), but we show them as single columns for brevity.
To reiterate what an `Opcode` component does from the [Main Components](../main-components/index#opcode-component) section, it verifies the following:
1. The offsets and flag values are correct using the `VerifyInstruction` component.
2. The instruction is correctly mapped to the current `Opcode` component using the flags.
3. The operand values `op0`, `op1`, and `dst` computed with the registers and the offsets are correct using the `Memory` component.
4. The operation for the current `Opcode` component is done correctly.
5. The state transition of the three registers (`pc`, `ap`, `fp`) is done correctly using the flags.
<Callout icon="question">
An instruction should contain 15 bits of flags but only 5 bits are represented in the `AddOpcode` columns.
Can you see why?
</Callout>
<Tip>
Check out how a Cairo instruction is pattern-matched to an `ADD` opcode [here](https://github.com/starkware-libs/stwo-cairo/blob/04f142e0376e2a0e797cdb64973449aa3e58a18f/stwo_cairo_prover/crates/adapter/src/opcodes.rs#L349).
</Tip>
<Tip>
Check out how the decomposition of the flags is verified [here](https://github.com/starkware-libs/stwo-cairo/blob/04f142e0376e2a0e797cdb64973449aa3e58a18f/stwo_cairo_prover/crates/cairo-air/src/components/subroutines/decode_instruction_bc3cd.rs#L59).
</Tip>
Items 1 and 3 should be familiar, as we already covered them in the [Main Components](../main-components/index#opcode-component) section. For item 2, you can check the specs for the `ADD` opcode [here](https://github.com/starkware-libs/stwo-cairo/blob/04f142e0376e2a0e797cdb64973449aa3e58a18f/stwo_cairo_prover/crates/adapter/src/opcodes.rs#L349). For item 5, the specs for a valid state transition can be found in Section 4.5 of the [Cairo paper](https://eprint.iacr.org/2021/1063.pdf).
In this section, we will focus on how item 4 is implemented.
## Adding two 252-bit integers
Assuming that the operands `op0`, `op1`, and `dst` are correctly accessed from the `Memory` table, we now check that the addition of two 252-bit integers is done correctly, i.e. `op0 + op1 = dst`. As noted in the [Felt252 to M31](../basic-building-blocks/index#felt252-to-m31) section, a 252-bit integer is stored as 28 9-bit limbs, so we need to check addition for each of the 28 limbs.
We will incrementally build up to the final constraint.
### Limb-wise Addition and Carry
To verify that the two sets of limbs are correctly added, we check limb-wise addition. Since each limb can create a carry, we also add the carry from the previous limb (except for the first limb). Thus, the constraints look like this:
```python theme={null}
carry_limb_1 = (op0[0] + op1[0] - dst[0]) / 2^9
carry_limb_1 * (carry_limb_1 - 1) = 0
carry_limb_2 = (op0[1] + op1[1] + carry_limb_1 - dst[1]) / 2^9
carry_limb_2 * (carry_limb_2 - 1) = 0
...
op0[27] + op1[27] + carry_limb_27 - dst[27] = 0
```
We divide `op0[0] + op1[0] - dst[0]` by `2^9` since this quantity is either `2^9` (if a carry exists) or `0` (if no carry exists). Dividing by `2^9` yields one or zero, respectively. To check that the carry is either `0` or `1`, we add the constraint `carry_limb_0 * (carry_limb_0 - 1) = 0`. For the final limb, we simply check that the addition is correct.
### Handling overflow beyond the 252-bit prime field
We also need to account for addition overflowing the 252-bit prime field `P` (i.e., `op0 + op1 = dst + P`). To check this, we introduce a witness variable `sub_p_bit`, a 1-bit value set to 1 if there is an overflow. Note that since `P = 2^251 + 17 * 2^192 + 1`, we only subtract in the three limbs where `P` has a non-zero limb: `0`, `22`, `27`.
Now let's revisit the constraints:
```python theme={null}
sub_p_bit * (sub_p_bit - 1) = 0
carry_limb_1 = (op0[0] + op1[0] - dst[0] - sub_p_bit) / 2^9
carry_limb_1 * (carry_limb_1 - 1) = 0
...
carry_limb_23 = (op0[22] + op1[22] + carry_limb_22 - dst[22] - sub_p_bit * 136) / 2^9
carry_limb_23 * (carry_limb_23 - 1) = 0
...
op0[27] + op1[27] + carry_limb_27 - dst[27] - sub_p_bit * 256 = 0
```
First, we verify that `sub_p_bit` is a bit. Then, we subtract `sub_p_bit` from the first limb, `sub_p_bit * 136` from the 22nd limb, and `sub_p_bit * 256` from the 27th limb. (Note that `136` and `256` are the values of `P` in the 22nd and 27th limbs, respectively.)
A caveat of this approach is that subtracting `sub_p_bit` can introduce an underflow, i.e., `(op0[0] + op1[0] - dst[0] - sub_p_bit) / 2^9 = -1`. This means that `carry_limb_0` can be `-1` as well as `0` or `1`. Thus, we update the constraint for all carries to the following:
```python theme={null}
...
carry_limb_1 * (carry_limb_1 - 1) * (carry_limb_1 + 1) = 0
...
```
### Optimization
To optimize the number of constraints, we can combine all the constraints for each limb into a single constraint. Naively checking that `carry_limb_1 = (op0[0] + op1[0] - dst[0] - sub_p_bit) / 2^9` would require a dedicated column for `carry_limb_1`. Instead, we keep `carry_limb_1` as an intermediate value and inline the equation when computing the next carry. For example, the second-limb carry is computed as follows:
```python theme={null}
carry_limb_2 = (op0[1] + op1[1] + ((op0[0] + op1[0] - dst[0] - sub_p_bit) / 2^9) - dst[1]) / 2^9
```
This way, we avoid allocating extra columns for the carries and proceed until the last limb, where we check that the giant equation is correct.
This is possible because the computation does not involve any multiplication of witness values, so the constraint degree does not blow up.
### Final constraint
One last note: in the implementation, we replace division by `2^9` with multiplication by `2^22`, which is equivalent in the M31 field since `2^9` and `2^22` are multiplicative inverses—i.e., `2^9 * 2^22 = 1 mod 2^31 - 1`.
So the final constraint looks like this:
```python theme={null}
sub_p_bit * (sub_p_bit - 1) = 0
carry_limb_1 = (op0[0] + op1[0] - dst[0] - sub_p_bit) * 2^22 // intermediate representation
carry_limb_1 * (carry_limb_1 - 1) * (carry_limb_1 + 1) = 0
...
carry_limb_27 = (op0[26] + op1[26] + carry_limb_26 - dst[26]) * 2^22 // intermediate representation
carry_limb_27 * (carry_limb_27 - 1) * (carry_limb_27 + 1) = 0
op0[27] + op1[27] + carry_limb_27 - dst[27] - sub_p_bit * 256 = 0
```
## Enabler column
Finally, we introduce the last column in the `AddOpcode` component: the `enabler` column. As the name suggests, this column enables or disables the constraint for the current row. It is used to support the dummy rows added to the end of the table to make the number of rows a power of two. In other words, it is set to `1` for all valid `ADD` opcode calls and `0` for all dummy rows.
# Basic Building Blocks
Source: https://docs.starknet.io/learn/S-two-book/cairo-air/basic-building-blocks/index
This section covers the basic building blocks used to build the Cairo AIR.
## Felt252 to M31
Cairo works over the prime field $P = 2^{251} + 17 \cdot 2^{192} + 1$, while S-two works over the prime field $M31 = 2^{31} - 1$. Thus, in order to represent the execution of Cairo with S-two, we need to decompose the 252-bit integers into 31-bit integers. The Cairo AIR chooses to use the 9-bit decomposition, so a single 252-bit integer will result in 28 9-bit limbs.
## Range checks
Range-checks are very commonly used in the Cairo AIR. They are used to ensure that the witness values are within a certain range, most commonly within a certain bit length. For example, in the previous section, we saw that a 252-bit integer is decomposed into 28 9-bit limbs, so we need to verify that each limb is in the range $0 \leq \text{limb} < 2^{9}$.
This is done by using a preprocessed column that contains the entire range of possible values for the bit length. For example, for a 9-bit range check, the column will contain the values from 0 to $2^9 - 1$. We also have another column that contains the number of times the range-check was invoked for each valid value and we use lookups to check that each range-check is valid. For a more practical example, please refer to the [Static Lookups](../../air-development/static-lookups/index) section.
# Overview of Cairo
Source: https://docs.starknet.io/learn/S-two-book/cairo-air/cairo/index
<Note>
This is an informal overview of Cairo. For a more formal explanation, please refer to the original [Cairo paper](https://eprint.iacr.org/2021/1063.pdf).
</Note>
Let's start by understanding how Cairo works. Essentially, Cairo is a Turing-complete CPU architecture specifically designed to enable efficient proofs of execution using STARKs. In particular, Cairo uses a read-only memory model instead of the more common read-write memory model and does not use any general-purpose registers.
## Non-Deterministic Read-Only Memory
A read-only memory model is one where each address in memory can have only a single value throughout the program's execution. This contrasts with the more common read-write memory model, where an address can have multiple values at different points during execution.
The memory is also non-deterministic: the prover provides the values of the memory cells as witness values, and they do not need further constraints beyond ensuring that each address has a single value throughout the program's execution.
## Registers
In physical CPUs, accessing memory is expensive compared to accessing registers due to physical proximity. This is why instructions typically operate over registers rather than directly over memory cells. In Cairo, accessing memory and registers incur the same cost, so Cairo instructions operate directly over memory cells. Thus, the three registers used by Cairo do not store instructions or operand values like in physical CPUs, but rather pointers to the memory cells where the instructions and operands are stored:
* `pc` is the **program counter**, which points to the current Cairo instruction
* `ap` is the **allocation pointer**, which points to the current available memory address
* `fp` is the **frame pointer**, which points to the current frame in the "call stack"
## Cairo Instructions
Let's now see what a Cairo instruction looks like.
<div>
<img alt="" />
*Figure 1: Cairo instruction (little-endian)*
</div>
As the figure above from the Cairo paper shows프로젝트로 돌아가기