STARK Cairo prover using lambdaworks

Overview

Lambdaworks Cairo Prover

We're still moving all the code from LambdaWorks related to the STARK Cairo prover. The CI, the documentation and the GPU code hasn't yet been yet migrated.

Main building blocks

To be added:

  • Grinding
  • Skipping FRI layers
  • Optimizing verifier operations
  • Range check and Pedersen built-ins
  • Different layouts

Requirements

  • Cargo 1.69+

How to try it

Using Docker compiler

Build the compiler image with:

make docker_build_cairo_compiler

Then for example, if you have a program.json in the project folder, you can use:

make docker_compile_and_run PROGRAM=program_name.cairo

Using cairo-compile

If you have cairo-langinstalled, you can use it instead of the Dockerfile

Then for example, if you have a program.json in the project folder, you can use:

make compile_and_run PROGRAM=program_name.cairo

Comments
  • Optimize prover boundary evaluations in construction of composition polynomial

    Optimize prover boundary evaluations in construction of composition polynomial

    Improves 2 times the prover speed.

    • Computes outside of the forloop some polynomial evaluations and inverses.
    • Change lagrange evaluation to FFT.
    • Uses batch inverse.
    opened by ajgara 3
  • bug: fix root order bug

    bug: fix root order bug

    When calculating FRI layers, the lde_root_order must be passed. We were passing the regular root_order, and these was hidden because our tests had trace lengths that were not very long.

    opened by entropidelic 1
  • Run with CLI

    Run with CLI

    • Add basic cairo run for making and verifying proofs
    • Added a call to either cairo-compile or the cairo compiler Dockerfile to let the prove and verify run with a call of one line
    opened by MauroToscano 1
  • Extract main trace building

    Extract main trace building

    • Extracts the build_main_trace function from the AIR trait.
    • Refactors trace padding.
    • Refactors program generation functions so that both integration and unit tests uses the same logic to generate prover arguments.
    opened by gabrielbosio 1
  • Commit multiple columns using a single Merkle Tree

    Commit multiple columns using a single Merkle Tree

    This PR adds the following:

    1. Use a modified version of Merkle trees that don't hash back to Field Elements and builds the entire tree using bytes.
    2. Instead of building a Merkle tree for each column of the RAP, use a single Merkle tree for the trace columns of the main part of the RAP another Merkle tree for the second part. The data of each leaf of these merkle trees are the vectors of evaluations of all the polynomials involved.

    There are two merkle trees for each part of the RAP because the prover needs to commit to the first ones before getting the RAP challenges from the verifier. Improvements on this are left for another PR.

    Benchmarking CAIRO/fibonacci/10: Collecting 10 samples in estimated 31.762 s (99
    CAIRO/fibonacci/10      time:   [31.787 ms 32.771 ms 34.208 ms]
                            change: [-42.359% -40.011% -37.434%] (p = 0.00 < 0.05)
                            Performance has improved.
    Benchmarking CAIRO/fibonacci/30: Collecting 10 samples in estimated 32.952 s (44
    CAIRO/fibonacci/30      time:   [67.688 ms 68.215 ms 69.366 ms]
                            change: [-38.890% -36.275% -33.590%] (p = 0.00 < 0.05)
                            Performance has improved.
    
    
    opened by schouhy 1
  • perf: update lambdaworks and use Ruffini in deep composition poly

    perf: update lambdaworks and use Ruffini in deep composition poly

    Updates lambdaworks dep to use Ruffini division in deep composition polynomials. The update also includes a few other optimizations, namely the Merkle tree build one.

    Bench results (on M1)

    CAIRO/fibonacci/10      time:   [59.898 ms 60.048 ms 60.284 ms]
                            change: [-53.124% -52.911% -52.675%] (p = 0.00 < 0.05)
    CAIRO/fibonacci/30      time:   [132.44 ms 132.91 ms 133.17 ms]
                            change: [-66.094% -66.001% -65.920%] (p = 0.00 < 0.05)
    
    opened by Oppen 1
  • Trace to Prover Refactor

    Trace to Prover Refactor

    • Add a function to create public inputs from registers and memory
    • Add documentation
    • Add a call to the Cairo VM Runner in integration to get memory and trace from it, remove the need to use intermediate files for it
    • Remove unused test files
    • Made layouts an Enum so they are easy to pick
    • Removed ignored tests that were not runned because of proving time
    • Removed call test, since it was tested indirectly by other programs

    We need another refactor, and after optimization make a bigger test suite to be run in the CI

    opened by MauroToscano 1
  • Write proof to json in test_prove_cairo_program

    Write proof to json in test_prove_cairo_program

    It uses a helper function to convert the Stark Proof struct to Strings with conversion from montgomery representation.

    Probably not the most elegant way but it works fine at least Reviews/Suggestions welcomed

    opened by feltroidprime 0
  • bug: fix transition degrees

    bug: fix transition degrees

    There were some transitions constraints (continuous range-check values) that didn't had their degrees set in the Cairo AIR. This is something that does not affect in a lot of cases, but when developing builtin features and adding new constraints broke some things.

    opened by entropidelic 0
  • Enforce selectors can be used by a malicious Prover to remove constraints

    Enforce selectors can be used by a malicious Prover to remove constraints

    The prover is using constraints selectors to enable or disable contraints for optimizations. The verifier then doesn't check which constraints have been disabled, so incorrect proofs can be shared.

    This can lead to issues where the Prover disable constraints that shouldn't be disabled

    security 
    opened by MauroToscano 0
  • Add check to proof options to ensure they reach security level

    Add check to proof options to ensure they reach security level

    Taken from EthStark and paper

    The conjectured security in this system is the minimum of three values:

    log_n_cosets * n_queries + proof_of_work_bits (these are the parameters that appear in the parameter_file. Refer to the [Prover Inputs] section for details). The collision resistance of the hash used by the protocol. This system employs Blake2s160 for the protocol, which is considered to provide 80 bits of security at the time of writing this project. log(extension_field_size) - log(trace_length) (where the extension field is hardcoded to be of size 122 bits, and trace_length = (chain_length / 3) * 32 rounded up to nearest power of 2).

    security 
    opened by diegokingston 0
  • Cairo1 Stark Proof verifier implementation

    Cairo1 Stark Proof verifier implementation

    Work in progress.

    Done : STARK proof generated by test_prove_cairo_program in the integration tests is written to a json file. It is then parsed with the parse_cairo_proof.py script and written to a Cairo file and loaded into the correct structs to match the lambdaworks Verifier 1:1. Same for CairoAIR stuct that holds some parameters. Same for public inputs (after the proving part).

    Next steps : Complete step_1 of verification algorithm. Complete step_2 of verification algorithm. Complete step_3 of verification algorithm. Complete step_4 of verification algorithm. Optimizations. Include more builtins. Use poseidon instead of keccak. Convert to Starknet smart contract.

    [...]

    opened by feltroidprime 0
Owner
Lambdaclass
A venture studio and a engineering powerhouse at the same time
Lambdaclass
STARK 101 Workshop in Rust πŸΊπŸ¦€

STARK101-rs ?? About This repository is based on the STARK 101 workshop, originally written in Python. A Rust tutorial for a basic STARK (Scalable Tra

Lambdaclass 30 Feb 23, 2023
STARK 101 Workshop in Rust πŸΊπŸ¦€

STARK101-rs ?? About This repository is based on the STARK 101 workshop, originally written in Python. A Rust tutorial for a basic STARK (Scalable Tra

Lambdaclass 80 Apr 21, 2023
An experimental rust zksnarks compiler with embeeded bellman-bn128 prover

Za! An experimental port of the circom zk-SNARK compiler in Rust with embedded bellman-bn128 prover. I created it as a PoC port of the existing JavaSc

adria0.eth 39 Aug 26, 2022
A standalone Aleo prover build upon snarkOS and snarkVM, with multi-threading optimization

Aleo Light Prover Introduction A standalone Aleo prover build upon snarkOS and snarkVM, with multi-threading optimization. It's called "light" because

Haruka Ma 91 Dec 29, 2022
Scalable layer-2 registry and prover for subspaces

Subspacer Note: this does not fully implement the functionality described in the Spaces protocol yet and should be considered a proof of concept. Scal

Spaces Protocol 5 Feb 22, 2024
Cleaopatra is a Rust implementation of the Cairo VM

Cleopatra Cairo is a Rust implementation of the Cairo VM. Cairo is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly. Cairo and similar proof systems can be used to provide scalability to blockchains.

Lambdaclass 263 Dec 28, 2022
A minimal template for building smart contracts with Cairo 1.0

Minimal Cairo 1.0 Template Built with auditless/cairo-template A minimal template for building smart contracts with Cairo 1.0 using the Quaireaux proj

Auditless 68 Apr 21, 2023
Starknet Stack let's you easily create new Cairo Starknet chains with their own sequencers, provers and verifiers

Starknet Stack flowchart LR A("Client") ==>|"Starknet Transactions"| subGraph0["Sequencer"] subGraph0 -.->|"Blocks with txs"| 300319["Watcher prover

Lambdaclass 7 Jul 11, 2023
Safe, fast, small crypto using Rust

THE SOFTWARE IS PROVIDED "AS IS" AND BRIAN SMITH AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES

Brian Smith 3k Jan 2, 2023
X25519 elliptic curve Diffie-Hellman key exchange in pure-Rust, using curve25519-dalek.

x25519-dalek A pure-Rust implementation of x25519 elliptic curve Diffie-Hellman key exchange, with curve operations provided by curve25519-dalek. This

dalek cryptography 252 Dec 26, 2022
Exploration of using Storage instead of Allocator to parameterize collections in Rust

storage-poc aims at exploring the usage of custom Storages, rather than custom Allocators. Goals This is a Proof-of-Concept aiming at: Demonstrating t

null 106 Dec 8, 2022
A CLI Twitter client using kuon

petit A TUI Twitter client using kuon Install Use cargo $ cargo install petit How to use # Login for twitter $ petit login # Tweet $ petit tweet "Thi

uzimaru0000 11 Jan 12, 2022
Fast Hilbert space-filling curve transformation using a LUT

Fast Hilbert Fast Hilbert 2D curve computation using an efficient Lookup Table (LUT). Convert from discrete 2D space to 1D hilbert space and reverse V

Armin Becher 20 Nov 3, 2022
QuickDash A modern alternative to QuickSFV using Rust.

QuickDash A modern alternative to QuickSFV using Rust. It's supports BLAKE3 and BLAKE2 hashes, CRC32, MD5, SHA1, SHA2, SHA3, xxHash The docs for user

null 11 Nov 9, 2022
shavee is a Program to automatically decrypt and mount ZFS datasets using Yubikey HMAC as 2FA or any USB drive with support for PAM to auto mount home directories.

shavee is a simple program to decrypt and mount encrypted ZFS user home directories at login using Yubikey HMAC or a Simple USB drive as 2FA written in rust.

Ashutosh Verma 38 Dec 24, 2022
Decrypt your LUKS partition using a FIDO2 compatible authenticator

fido2luks This will allow you to unlock your LUKS encrypted disk with an FIDO2 compatible key. Note: This has only been tested under Fedora 31, Ubuntu

null 118 Dec 24, 2022
Example crate using fltk-build

white-frame This is just an example showing the use of fltk-build to create native C/C++ FLTK and cfltk modules for fltk-rs. This repo contains 2 exam

Mohammed Alyousef 1 Nov 21, 2021
A prototype project integrating jni rust into Kotlin and using protobuf to make them work together

KotlinRustProto a prototype project integrating jni rust into Kotlin and using protobuf to make them work together How to start add a RPC call in Droi

woo 11 Sep 5, 2022
Port path module (and tests) of nodejs to rust using the same algorithms.

rusty_nodejs_path Port path module (and tests) of nodejs to rust using the same algorithms. crates.io Documents Progress posix path.basename(path[, ex

Yunfei He 10 Sep 25, 2022