• Stars
    star
    255
  • Rank 159,729 (Top 4 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created about 1 year ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Overview

STARK is a proof system. It uses cutting-edge cryptography to provide poly-logarithmic verification resources and proof size, with minimal and post-quantum-secure assumptions.

This repository contains a prover and a verifier for STARKs, and in particular for the CPU AIR underlying the CairoZero programming language.

Installation instructions

Building using the dockerfile

The root directory contains a dedicated Dockerfile which automatically builds the package and runs the unit tests on a simulated machine. You should have docker installed (see https://docs.docker.com/get-docker/).

Clone the repository:

git clone https://github.com/starkware-libs/stone-prover.git

Build the docker image:

cd stone-prover
docker build --tag prover .

This will run an end-to-end test with an example cairo program. Once the docker image is built, you can fetch the prover and verifier executables using:

container_id=$(docker create prover)
docker cp -L ${container_id}:/bin/cpu_air_prover .
docker cp -L ${container_id}:/bin/cpu_air_verifier .

Creating and verifying a proof of a CairoZero program

To run and prove the example program fibonacci.cairo, install cairo-lang version 0.12.0 (see further instructions in the cairo-lang repository):

pip install cairo-lang==0.12.0

Navigate to the example test directory (e2e_test):

cd e2e_test

Compile fibonacci.cairo:

cairo-compile fibonacci.cairo --output fibonacci_compiled.json --proof_mode

Run the compiled program to generate the prover input files:

cairo-run \
    --program=fibonacci_compiled.json \
    --layout=small \
    --program_input=fibonacci_input.json \
    --air_public_input=fibonacci_public_input.json \
    --air_private_input=fibonacci_private_input.json \
    --trace_file=fibonacci_trace.json \
    --memory_file=fibonacci_memory.json \
    --print_output \
    --proof_mode

Run the prover:

cpu_air_prover \
    --out_file=fibonacci_proof.json \
    --private_input_file=fibonacci_private_input.json \
    --public_input_file=fibonacci_public_input.json \
    --prover_config_file=cpu_air_prover_config.json \
    --parameter_file=cpu_air_params.json

The proof is now available in the file fibonacci_proof.json.

Finally, run the verifier to verify the proof:

cpu_air_verifier --in_file=fibonacci_proof.json && echo "Successfully verified example proof."

Note: The verifier only checks that the proof is consistent with the public input section that appears in the proof file. The public input section itself is not checked. For example, the verifier does not check what CairoZero program is being proved, or that the builtins memory segments are of valid size. These things need to be checked externally.

Configuration for other input sizes

The number of steps affects the size of the trace. Such changes may require modification of cpu_air_params.json. Specifically, the following equation must be satisfied.

log₂(last_layer_degree_bound) + ∑fri_step_list = log₂(#steps) + 4

For instance, assuming a fixed last_layer_degree_bound, a larger number of steps requires changes to the fri_step_list to maintain the equality.

FRI steps should typically be in the range 2-4; the degree bound should be in the range 4-7.

The constant 4 that appears in the equation is hardcoded logâ‚‚(trace_rows_per_step) = logâ‚‚(16) = 4.

For Mac users

To build the docker, run:

docker build --tag prover . --build-arg CMAKE_ARGS=-DNO_AVX=1

To freely use the cairo-run, cpu_air_prover, and cpu_air_verifier commands, work inside the docker using:

docker run -it prover bash

More Repositories

1

cairo

Cairo is the first Turing-complete language for creating provable programs for general computation.
Rust
1,586
star
2

cairo-lang

Python
1,342
star
3

papyrus

Papyrus is a StarkNet full node written in Rust.
Rust
309
star
4

starkex-contracts

Solidity
276
star
5

stwo

Rust
237
star
6

ethSTARK

C++
223
star
7

blockifier

Blockifier is a Rust implementation for the transaction-executing component in the StarkNet sequencer, in charge of creating state diffs and blocks.
Rust
170
star
8

starknet-specs

JavaScript
92
star
9

starkex-resources

Python
82
star
10

veedo

Solidity
77
star
11

starknet-staking

starknet-staking
Cairo
72
star
12

starkgate-frontend

Bridge interface allows users to transfer ERC20 tokens from Ethereum to StarkNet and vice versa.
JavaScript
63
star
13

starknet-api

Rust
59
star
14

starkware-crypto-utils

Signatures, keys and Pedersen hash on STARK friendly elliptic curve
TypeScript
54
star
15

formal-proofs

Lean
52
star
16

stark-perpetual

Cairo
49
star
17

starkgate-contracts

Python
35
star
18

crypto-cpp

C++
32
star
19

starkex-js

JavaScript SDK for StarkEx
TypeScript
28
star
20

starkex-for-spot-trading

Cairo
24
star
21

cairo-examples

Shell
24
star
22

stwo-cairo

Cairo
23
star
23

sequencer

Rust
23
star
24

starkex-core

21
star
25

mempool

Rust
14
star
26

starkex-data-availability-committee

Python
9
star
27

tree-sitter-cairo

JavaScript
7
star
28

starknet-snap

HTML
7
star
29

StarkNet-AllCoreDevs-Meetings

6
star
30

starkex-apps-api

6
star
31

starkex-playground

Python
6
star
32

okx-config

6
star
33

cairo-playground

Playground environment for those who want to learn and get to know Cairo language better.
JavaScript
5
star
34

davion-config

DavionLabs Perpetual StarkEx Configuration
4
star
35

starkex-resources-wip

Python
4
star
36

starknet-tutorials-erc20

3
star
37

starknet-addresses

3
star
38

starknet-tutorials-global

2
star
39

committer

Rust
2
star
40

stwo-air-schema

Shell
2
star
41

starknet-tutorials-erc721

2
star
42

dydx-config

2
star
43

starknet-tutorials-cairo-syntax

2
star
44

gammax-config

GammaX Perpetual StarkEx Configuration
2
star
45

starknet-tutorials-utils

1
star
46

x10-config

1
star
47

karpenter

1
star