Skip to content

Commit

Permalink
Updated Cairo builtins, changed name of file from builtins.adoc to ca…
Browse files Browse the repository at this point in the history
…iro-builtins.adoc.
  • Loading branch information
stoobie committed May 2, 2024
1 parent d2d0450 commit 9aea1fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*** xref:Smart_Contracts/starknet-events.adoc[Events]
*** xref:Smart_Contracts/contract-syntax.adoc[Migrating a contract from Cairo v1 to Cairo v2]
*** xref:Smart_Contracts/cairo-and-sierra.adoc[Cairo and Sierra]
*** xref:Smart_Contracts/builtins.adoc[Builtins]
*** xref:Smart_Contracts/cairo-builtins.adoc[Builtins]
*** xref:Smart_Contracts/serialization_of_Cairo_types.adoc[Serialization of Cairo types]
*** xref:Smart_Contracts/system-calls-cairo1.adoc[System calls]
*** xref:Smart_Contracts/execution_info.adoc[Execution information for the current block]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[id="cairo-builtins"]
= 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 less gas.

In contrast to CairoZero, where you needed to consiously write code to take advantage of builitn optimizations, in Cairo, you simply write high-level code without doing anything special, and when the Cairo VM executes the code, certain operations take advantage of builtins to optimize logic and use less gas.

[#list-of-cairo-builtins]
.List of Cairo builtins

[cols="1,2",]
|===
|Name of builtin | Description

|Pedersen |Computes the Pedersen hash over two elements. For more information see xref:architecture_and_concepts:Cryptography/hash-functions.adoc[].
|Poseidon |Computes the Hades permutation on three field elements. For more info, see xref to Hash functions topic. The Cairo corelib functions use this builtin under the hood. The Cairo corelib functions are defined in link:https://github.com/starkware-libs/cairo/blob/v2.6.0/corelib/src/starknet/info.cairo[`info.cairo`] in the Cairo GitHub repository.
|Range check a|
Checks whether a field element is in the range [0,2^128^-1].

All arithmetic comparisons use the range check builtin.

|ECDSA |Verifies the validity of an ECDSA signature over the STARK curve.
|Keccak | _TBD_
|Bitwise |Computes the bitwise operations `OR`, `AND`, and `XOR` of two felts.
|EC_OP |Multiplies a point on the STARK curve by a scalar.
|===

0 comments on commit 9aea1fc

Please sign in to comment.