Cleopatra Cairo VM
Cleaopatra is a Rust implementation of the Cairo VM. The VM is fully functional but we don't support builtins or hints yet. We are working on it.
Running Cleopatra
Compile with cargo build --release
, once the binary is built, it can be found in target/release/
under the name cleopatra-run
. To run a compiled json program through the VM, call the executable giving it the path and name to the file to be executed.
Full compilation and execution example:
git clone https://github.com/lambdaclass/cleopatra_cairo.git
cd cleopatra_cairo
cargo build --release
./target/release/cleopatra-run tests/support/fibonacci_compiled.json
Testing
Run the test suite with cargo:
cargo test
Code Coverage
Track of the project's code coverage: Codecov.
Cleopatra benchmarks:
Running a Cairo program that gets the 1000th Fibonacci number we got the following benchmarks:
- Execution time with Criterion
- Flamegraph
Cairo
- From Cairo Documentation: How Cairo Works
- Cairo – a Turing-complete STARK-friendly CPU architecturer
- A Verified Algebraic Representation of Cairo Program Execution
- Cairo Verifier in Rust
Original Cairo VM Internals
We wrote a document explaining how the Cairo VM works. It can be found here.
Compilers and interpreters
These is a list of recommended books to learn how to implement a compiler or an interpreter.
- How I wrote my own "proper" programming language - Mukul Rathi
- Introduction to Compilers and Language Design - Douglas Thain
- Beautiful Racket - Matthew Flatt
- Crafting interpreters - Robert Nystrom
- Engineering a Compiler - Keith D. Cooper, Linda Torczon
Computational integrity and Zero Knowledge Proofs
Basics
- Intro to zero knowledge proofs
- Security and Privacy for Crypto with Zero-Knowledge Proofs
- A Hands-On Tutorial for Zero-Knowledge Proofs Series
ZK SNARKs
- What are zk-SNARKs?
- Vitalik's introduction to how zk-SNARKs are possible
- Vitalik's post on quadratic arithmetic programs
- Why and How zk-SNARK Works - Maksym Petkus
- Comparing General Purpose zk-SNARKs
- Dark forest's intro + circuits PART 1
- Dark forest's intro + circuits PART 2
ZK STARKs
Introduction:
- Cryptography Stack Exchange Answer
- Hasu gets STARK-pilled - with Eli Ben-Sasson
- Cairo for Blockchain Developers
- Why STARKs are the key to unlocking blockchain scalability
- STARKs whitepaper: Scalable, transparent, and post-quantum secure computational integrity
- STARKs vs. SNARKs: A Cambrian Explosion of Crypto Proofs
Vitalik Buterin's blog series on zk-STARKs:
- STARKs, part 1: Proofs with Polynomials
- STARKs, part 2: Thank Goodness it's FRI-day
- STARKs, part 3: Into the Weeds
Alan Szepieniec's STARK tutorial:
StarkWare's STARK Math blog series: