-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* migrate cli to extern crate * add clap4 for cli handling * cargo fmt * readme changes * Add disclaimer readme * Remove bit security text from cairo prover crate * add compile option to makefile * add compile and run all to makefile * add example to readme * cargo fmt * add compile and prove to makefile * better readme * add quiet flag to makefile binaries * reorganized readme --------- Co-authored-by: Jmunoz <[email protected]> Co-authored-by: Mariano A. Nicolini <[email protected]> Co-authored-by: MauroFab <[email protected]>
- Loading branch information
1 parent
5a938e7
commit 50b9fbd
Showing
11 changed files
with
246 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "cairo-platinum-prover-cli" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
|
||
[[bin]] | ||
name = "cairo-platinum-prover-cli" | ||
path = "src/main.rs" | ||
|
||
[dependencies] | ||
lambdaworks-math = { workspace = true , features = ["lambdaworks-serde"] } | ||
stark-platinum-prover = { workspace = true, features = ["wasm"] } | ||
cairo-platinum-prover = { workspace = true} | ||
clap = { version = "4.4.6", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.PHONY: test coverage clippy clean | ||
|
||
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
# Variable to give compiled Cairo programas a proper name. It extracts the file extension and adds | ||
# the .json extension to it. | ||
COMPILED_PROGRAM=$(basename $(PROGRAM_PATH)).json | ||
|
||
build: | ||
cargo build --release | ||
|
||
docker_build_cairo_compiler: | ||
docker build -f cairo_compile.Dockerfile -t cairo . | ||
|
||
compile: | ||
cairo-compile --proof_mode $(PROGRAM_PATH) > $(COMPILED_PROGRAM) 2>/dev/null || \ | ||
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM_PATH) > $(COMPILED_PROGRAM) | ||
|
||
prove: | ||
cargo run --quiet --release prove $(PROGRAM_PATH) $(PROOF_PATH) | ||
|
||
verify: | ||
cargo run --quiet --release verify $(PROOF_PATH) | ||
|
||
run_all: | ||
cargo run --quiet --release prove-and-verify $(PROGRAM_PATH) | ||
|
||
compile_and_prove: | ||
@cairo-compile --proof_mode $(PROGRAM_PATH) > $(COMPILED_PROGRAM) 2>/dev/null || \ | ||
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM_PATH) > $(COMPILED_PROGRAM) | ||
@echo "Compiling done \n" | ||
@cargo run --quiet --release prove $(COMPILED_PROGRAM) $(PROOF_PATH) | ||
@rm $(COMPILED_PROGRAM) | ||
|
||
compile_and_run_all: | ||
@cairo-compile --proof_mode $(PROGRAM_PATH) > $(COMPILED_PROGRAM) 2>/dev/null || \ | ||
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM_PATH) > $(COMPILED_PROGRAM) | ||
@echo "Compiling done \n" | ||
@cargo run --quiet --release prove-and-verify $(COMPILED_PROGRAM) $(PROOF_PATH) | ||
@rm $(COMPILED_PROGRAM) | ||
|
||
clippy: | ||
cargo clippy --workspace --all-targets -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<div align="center"> | ||
|
||
# Lambdaworks Cairo Platinum Prover CLI | ||
|
||
</div> | ||
|
||
## ⚠️ Disclaimer | ||
|
||
This prover is still in development and may contain bugs. It is not intended to be used in production yet. | ||
|
||
Please check issues under security label, and wait for them to be resolved if they are relevant your project. | ||
|
||
Output builtin is finished, and range check is supported but it's not sound yet. | ||
|
||
CLI currently runs with 100 bits of conjecturable security | ||
|
||
## [Cairo Platinum Prover Docs](<[lambdaclass.github.io/lambdaworks/](https://github.com/lambdaclass/lambdaworks/blob/main/provers/cairo/README.md)>) | ||
|
||
### Usage: | ||
|
||
To prove programs Cairo has to be compiled. For compilation you need to have `cairo-lang` or `docker` installed. | ||
|
||
When using Docker, start by creating the container image with: | ||
|
||
```**bash** | ||
make docker_build_cairo_compiler | ||
``` | ||
|
||
Examples of Cairo 0 programs can be found [here](https://github.com/lambdaclass/lambdaworks/tree/main/provers/cairo/cairo_programs/cairo0) | ||
|
||
|
||
**To compile and generate a proof you can use:** | ||
|
||
```bash | ||
make compile_and_prove PROGRAM_PATH=<program_path> PROOF_PATH=<output_proof_path> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
make compile_and_prove PROGRAM_PATH=cairo_programs/cairo0/fibonacci_5.cairo PROOF_PATH=cairo_programs/cairo0/fibonacci_5.proof | ||
``` | ||
|
||
|
||
**To verify a proof you can use:** | ||
|
||
```bash | ||
make verify PROOF_PATH=<proof_path> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
make verify PROOF_PATH=fibonacci_5.proof | ||
``` | ||
|
||
**To compile Cairo:** | ||
|
||
```bash | ||
make compile PROGRAM_PATH=<uncompiled_program_path> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
make compile PROGRAM_PATH=cairo_programs/cairo0/fibonacci_5.cairo | ||
``` | ||
|
||
**To prove a compiled program:** | ||
|
||
```bash | ||
make prove PROGRAM_PATH=<compiled_program_path> PROOF_PATH=<output_proof_path> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
make prove PROGRAM_PATH=cairo_programs/cairo0/fibonacci_5.json PROOF_PATH=program_proof.proof | ||
``` | ||
|
||
|
||
|
||
**To prove and verify with a single command you can use:** | ||
|
||
```bash | ||
make run_all PROGRAM_PATH=<compiled_program_path> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
make run_all PROGRAM_PATH=cairo_programs/cairo0/fibonacci_5.json | ||
``` | ||
|
||
|
||
|
||
**To compile, proof, prove and verify at the same time you can use:** | ||
|
||
```bash | ||
make compile_and_run_all PROGRAM_PATH=<program_path> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
make compile_and_run_all PROGRAM_PATH=cairo_programs/cairo0/fibonacci_5.cairo | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends g++ libgmp3-dev | ||
|
||
COPY requirements.txt / | ||
|
||
RUN pip install -r /requirements.txt | ||
|
||
ENTRYPOINT ["cairo-compile"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ecdsa==0.18.0 | ||
bitarray==2.7.3 | ||
fastecdsa==2.2.3 | ||
sympy==1.11.1 | ||
typeguard==2.13.3 | ||
cairo-lang==0.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.