Cairo
A programming language for writing provable programs using STARK zero-knowledge proofs, created by StarkWare Industries.
Created by StarkWare Industries (Lior Goldberg, Shahar Papini, Michael Riabzev)
Cairo (CPU Algebraic Intermediate Representation) is a programming language created by StarkWare Industries for writing provable programs—programs whose correct execution can be mathematically verified using STARK (Scalable Transparent ARguments of Knowledge) zero-knowledge proofs. First publicly announced in September 2020 via StarkWare’s “Hello, Cairo!” blog post, Cairo occupies a unique niche as a general-purpose, Turing-complete language purpose-built for cryptographic proof generation, powering both the StarkNet Layer 2 blockchain and the StarkEx scaling engine.
History & Origins
Cairo emerged from StarkWare Industries, an Israeli cryptography company founded in 2018 by Eli Ben-Sasson, Uri Kolodny, Michael Riabzev, and Alessandro Chiesa. Ben-Sasson, a professor at the Technion and co-inventor of STARKs, had spent years developing the mathematical foundations for scalable, transparent zero-knowledge proofs. The challenge was making this technology accessible to software developers who lacked deep cryptographic expertise.
Before Cairo, creating provable programs required manually writing polynomial equations over finite fields—a task accessible only to cryptography specialists. Cairo introduced a von Neumann-style CPU architecture that is inherently “STARK-friendly,” meaning a single set of algebraic constraints can validate the execution of any program running on this virtual machine. The architecture was formally described in the academic paper “Cairo—a Turing-complete STARK-friendly CPU architecture” by Lior Goldberg, Shahar Papini, and Michael Riabzev, published on the Cryptology ePrint Archive in August 2021.
The language was first publicly introduced through StarkWare’s “Hello, Cairo!” blog post in September 2020, describing it as the first production-grade, Turing-complete platform for STARK-based provable computation. Its first real-world deployment processed 300,000 transactions in a single STARK proof for a Reddit scaling demonstration.
Design Philosophy
Cairo’s core design goal is to make provable computation practical. Every Cairo program, when executed, can produce a cryptographic proof that the computation was performed correctly. This proof can then be verified far more cheaply and quickly than re-executing the original computation—a property that enables blockchain scaling by moving computation off-chain while maintaining on-chain verifiability.
The language is built around several key principles:
- Provability by default: The language and its virtual machine are designed so that every valid program execution automatically produces a verifiable proof
- Abstraction of cryptographic complexity: Developers write normal-looking code; the proof generation machinery is handled by the compiler and runtime
- Deterministic execution: Programs must be fully deterministic to be provable, which shapes the language’s design constraints
- Scalability: A single proof can attest to the correctness of arbitrarily many computations, enabling massive throughput improvements for blockchain applications
Key Features
Linear Type System
Cairo employs a linear type system where every value must be used exactly once—it is either consumed (destroyed) or moved to a new owner. Values cannot be implicitly copied or silently dropped. This serves two critical purposes: it ensures all code paths are provable and verifiable, and it abstracts away the immutable memory model of the Cairo VM, where memory cells can only be written once.
Field Elements (felt252)
The fundamental data type in Cairo is felt252, a field element representing an integer in the range 0 to P-1, where P is a large prime number. This type aligns directly with the mathematical underpinnings of STARK proofs. While felt252 is the base type, Cairo also provides conventional integer types (u8, u16, u32, u64, u128, u256) with overflow and underflow checking for safer arithmetic.
Sierra (Safe Intermediate Representation)
Introduced with Cairo 1.0, Sierra is an intermediate layer between Cairo source code and Cairo Assembly (CASM). Sierra guarantees that every Cairo program execution can be proven—even if the program panics or fails. This is critical in a blockchain context: without Sierra, a malicious actor could craft a transaction that consumes network resources but cannot be proven, effectively performing a denial-of-service attack on the proof system.
Ownership and Borrowing
Cairo 1.0 adopted Rust-inspired ownership semantics with move-by-default behavior, references, and borrowing. This provides memory safety guarantees at compile time without garbage collection, which is essential for a language targeting a deterministic virtual machine.
Smart Contract Support
Cairo includes native support for writing StarkNet smart contracts, with decorators and conventions for defining contract storage, external functions, events, and inter-contract calls.
Evolution
Cairo has undergone a major transformation since its initial release:
Cairo 0.x (2020–2022)
The original Cairo was a Python-like domain-specific language with a syntax and tooling built on Python. Programs were written using hints, references, and a relatively low-level instruction set that mapped closely to the underlying CPU architecture. While powerful, this version required developers to think in terms of the proof system’s constraints.
Cairo 1.0+ (2022–Present)
In late 2022, StarkWare open-sourced a completely rewritten version of Cairo. The new language, announced as “Cairo 1.0” in January 2023, was a ground-up redesign strongly inspired by Rust. The Cairo Book, the official language documentation, explicitly acknowledges that “many examples and explanations have been adapted from the Rust Book.” The Cairo 1.0+ compiler is written primarily in Rust.
Key changes in the rewrite included:
- Rust-inspired syntax with ownership, borrowing, and pattern matching
- A linear type system replacing the original memory model
- Traits and generics for abstraction
- Sierra as a safety-guaranteeing intermediate representation
- Scarb, a dedicated package manager and build tool
After the initial Cairo 1.0 releases in early 2023, the versioning transitioned to the 2.x series as the language matured through rapid iteration.
Toolchain
Cairo’s modern toolchain centers on Scarb, which serves as the package manager, build tool, and project scaffolding system. Scarb bundles the Cairo compiler and a language server for IDE integration. Installation is available for Linux, macOS, and Windows through the starkup installer or direct downloads.
The compilation pipeline runs: Cairo source code → Sierra (safe intermediate representation) → CASM (Cairo Assembly) → execution on the Cairo VM with proof generation.
Current Relevance
Cairo is actively developed, with the main repository (starkware-libs/cairo) showing thousands of commits and frequent releases. The language powers the StarkNet ecosystem, a growing Layer 2 blockchain on Ethereum. Through StarkEx, Cairo proofs have been used by major platforms including dYdX, Immutable X, and Sorare.
The language occupies a genuinely novel position in programming language design—it is one of very few languages where provable correctness is not an optional add-on but a fundamental property of every program execution. As zero-knowledge proof technology gains adoption beyond cryptocurrency into areas like identity verification and private computation, Cairo’s approach to making provable programs accessible to general-purpose developers represents a significant design contribution.
Why It Matters
Cairo demonstrates that provable computation need not be limited to cryptography experts writing constraint systems by hand. By providing a familiar programming model—variables, functions, control flow, structs, enums—on top of a STARK-friendly virtual machine, Cairo bridges the gap between theoretical cryptography and practical software engineering. Its evolution from a low-level DSL to a Rust-inspired language with modern developer tooling reflects the broader maturation of zero-knowledge proof technology from research curiosity to production infrastructure.
Timeline
Notable Uses & Legacy
StarkNet
A permissionless, decentralized Ethereum Layer 2 Validity Rollup where Cairo serves as the native smart contract language for all on-chain programs
dYdX (via StarkEx)
Decentralized derivatives exchange that used StarkWare's StarkEx scaling engine powered by Cairo proofs for high-throughput trading
Immutable X (via StarkEx)
NFT scaling solution for Ethereum that leveraged Cairo-based STARK proofs to enable gas-free NFT minting and trading
Sorare (via StarkEx)
Fantasy sports and digital collectibles platform that used StarkEx with Cairo proofs to scale NFT transactions on Ethereum