Cairo builtins

Last edit


Builtins in Cairo are predefined optimized low-level execution units that the Cairo VM refers to in order to perform predefined computations that are expensive to perform in standard Cairo. Builtins enhance the functionality of the Cairo VM, enabling you to perform certain tasks, such as using the Poseidon hash, range-checks, or ECDSA signature verifications, more efficiently, using fewer trace cells.

In contrast to CairoZero, where you needed to consciously write code to take advantage of builtin optimizations, in Cairo, you simply write code without doing anything special, and when the Cairo VM executes the code, certain operations use builtins internally to optimize your program.

Table 1. List of Cairo builtins
Name of builtin Description


Computes the Pedersen hash over two elements. Used internally in pedersen.cairo. For more information see Hash functions.


Computes the Hades permutation on three field elements. Used internally in poseidon.cairo. For more information, see Hash functions. The Cairo corelib functions use this builtin internally. The Cairo corelib functions are defined in info.cairo in the Cairo GitHub repository.

Range check

Checks whether a field element is in the range [0,2128-1].

Used when instantiating and comparing the various integer types.

All arithmetic comparisons use the range check builtin.


Verifies the validity of an ECDSA signature over the STARK curve.

This is used in CairoZero, but is not used in Cairo because it fails on invalid signatures. In Cairo ECDSA verification is performed with high-level code, applying the EC_OP builtin twice.


Computes the keccak-f[1600] permutation. For more information see Keccak page on the Keccak Team site.

For high level Cairo keccak functions that use this builtin internally, see keccak.cairo in the Cairo corelib.


Computes the bitwise operations OR, AND, and XOR of two felts.

Used internally when performing bitwise operations using the `

, `& and ^ operators.