$ account starkware-libs
This repository is the official compiler for the Cairo programming language, a Turing-complete language designed for provable computation (zero-knowledge proofs). It compiles Cairo source through a multi-stage pipeline: parsing (via LALRPOP), semantic analysis with type inference and trait resolution, lowering to a control-flow graph with extensive optimizations (CSE, constant folding, inlining, match optimization, gas redeposit), generation of the Sierra intermediate representation (a safe, bounded subset for ZK provability), and final compilation to CASM (Cairo Assembly) for execution on the Cairo VM. The compiler uses the Salsa incremental computation framework for query-based caching and is split into 40+ crates organized by compiler phase (parser, semantic, lowering, sierra-generator, sierra-to-casm, etc.). It also includes a full toolchain for Starknet smart contract development, with plugins for contracts, storage, events, and ABI generation. CLI tools (cairo-compile, cairo-run, sierra-compile, starknet-compile, cairo-test, cairo-format) provide end-to-end functionality. The standard library ('corelib'), written in Cairo, provides fundamental types, collections, hash functions, and Starknet-specific primitives. The codebase demonstrates high craftsmanship with clean abstractions, a generic dataflow analysis framework, deterministic hash map utilities, and a reusable graph algorithm library. It is actively maintained with extensive CI, benchmarks, and a golden-file test infrastructure.
This repository implements Stwo, a high-performance STARK proof system based on Circle STARKs (ePrint 2024/278) and the Stwo whitepaper. It is a Rust library providing a prover and verifier for zero-knowledge proofs over the Mersenne prime field M31 (p = 2^31 − 1) with extension fields CM31 and QM31. The architecture is modular: a core crate defines field arithmetic, FRI, polynomial commitment, and verification logic; a prover crate provides backend-agnostic proving with CPU and SIMD (AVX2/AVX-512, NEON, WASM) implementations; a constraint-framework crate offers a DSL for building AIR constraints and lookup arguments (LogUp, GKR). The system supports multiple hash channels (Blake2s, Poseidon252, Keccak256) and includes a no_std verifier suitable for on-chain deployment. Key entry points are `prover::prove()` and `core::verifier::verify()`. External dependencies include blake2, blake3, sha3, keccak, and starknet-crypto. The codebase is used in production by StarkWare's SHARP shared prover and by the Cairo VM prover (stwo-cairo). It demonstrates exceptional craftsmanship in SIMD optimization, field arithmetic, and protocol implementation, though it relies on nightly Rust and contains some unsafe code for performance.