Cairo builtins
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.
Name of builtin | Description |
---|---|
Pedersen |
Computes the Pedersen hash over two elements. Used internally in |
Poseidon |
Computes the Hades permutation on three field elements. Used internally in |
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. |
ECDSA |
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 |
Keccak |
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 |
Bitwise |
Computes the bitwise operations Used internally when performing bitwise operations using the ` |
|
EC_OP |