Skip to content

Commit

Permalink
Resolved some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
byteZorvin committed Sep 9, 2024
1 parent 497945e commit c14a612
Show file tree
Hide file tree
Showing 19 changed files with 204 additions and 5,512 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Task - Linters

on:
workflow_dispatch:
workflow_call:

jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run prettier
run: |-
npx prettier --check .
14 changes: 14 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Workflow - Pull Request

on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
linters:
name: Run linters
uses: ./.github/workflows/linters.yml
40 changes: 25 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

LAYOUT ?= small

CPU_AIR_PROVER := ./dependencies/stone-prover/cpu_air_prover
CAIRO_ENV := ./dependencies/cairo-vm/cairo-vm-env/bin/activate

# Extract the base name without extension
BASE_NAME := $(basename $(CAIRO_PROGRAM))
FILENAME_WITH_EXT := $(notdir $(CAIRO_PROGRAM))
FILENAME_WITHOUT_EXT := $(basename $(FILENAME_WITH_EXT))
DIR_NAME := $(dir $(CAIRO_PROGRAM))
OUTPUT_DIR := $(DIR_NAME)output/
OUTPUT_BASE_NAME := $(OUTPUT_DIR)$(FILENAME_WITHOUT_EXT)
INPUT_BASE_NAME := $(basename $(CAIRO_PROGRAM))

# Variables
CAIRO_ENV := ./dependencies/cairo-vm/cairo-vm-env/bin/activate
COMPILED_OUTPUT := $(BASE_NAME)_compiled.json
PROGRAM_INPUT := $(BASE_NAME)_input.json
PUBLIC_INPUT := $(BASE_NAME)_public_input.json
PRIVATE_INPUT := $(BASE_NAME)_private_input.json
TRACE_FILE := $(BASE_NAME)_trace.bin
MEMORY_FILE := $(BASE_NAME)_memory.bin
PROOF_FILE := $(BASE_NAME)_proof.json
COMPILED_OUTPUT := $(OUTPUT_BASE_NAME)_compiled.json
PROGRAM_INPUT := $(INPUT_BASE_NAME)_input.json
PUBLIC_INPUT := $(OUTPUT_BASE_NAME)_public_input.json
PRIVATE_INPUT := $(OUTPUT_BASE_NAME)_private_input.json
TRACE_FILE := $(OUTPUT_BASE_NAME)_trace.bin
MEMORY_FILE := $(OUTPUT_BASE_NAME)_memory.bin
PROOF_FILE := $(OUTPUT_BASE_NAME)_proof.json
CAIRO_PIE_OUTPUT := $(BASE_NAME)_pie.zip
PROVER_CONFIG := $(DIR_NAME)cpu_air_prover_config.json
PARAM_FILE := $(DIR_NAME)cpu_air_params.json
CPU_AIR_PROVER := ./dependencies/stone-prover/cpu_air_prover
PROVER_CONFIG := $(INPUT_BASE_NAME)_cpu_air_prover_config.json
PARAM_FILE := $(INPUT_BASE_NAME)_cpu_air_params.json


# Phony targets
.PHONY: all compile run prove clean
Expand All @@ -41,7 +46,10 @@ endif

# Compile the program
compile: check_program_set
$(activate_env) cairo-compile $(CAIRO_PROGRAM) --output $(COMPILED_OUTPUT) --proof_mode
mkdir -p $(OUTPUT_DIR)
$(activate_env) cairo-compile $(CAIRO_PROGRAM) \
--output $(COMPILED_OUTPUT) \
--proof_mode


# Generate the pie output
Expand Down Expand Up @@ -84,7 +92,7 @@ run_bootloader: compile
node format.js $(PUBLIC_INPUT)

# Generate the proof
prove_with_bootloader: run_bootloader
proove_with_bootloader: run_bootloader
$(CPU_AIR_PROVER) \
--generate-annotations \
--out_file=$(PROOF_FILE) \
Expand All @@ -94,7 +102,7 @@ prove_with_bootloader: run_bootloader
--parameter_file=$(PARAM_FILE)

# Generate the proof
prove_with_program: run
proove_with_program: run
$(CPU_AIR_PROVER) \
--generate-annotations \
--out_file=$(PROOF_FILE) \
Expand All @@ -112,6 +120,8 @@ clean: check_program_set
print-config:
@echo "Current configuration:"
@echo "CAIRO_PROGRAM: $(CAIRO_PROGRAM)"
@echo "DIR_NAME: $(DIR_NAME)"
@echo "OUTPUT_DIR: $(OUTPUT_DIR)"
@echo "BASE_NAME: $(BASE_NAME)"
@echo "COMPILED_OUTPUT: $(COMPILED_OUTPUT)"
@echo "PUBLIC_INPUT: $(PUBLIC_INPUT)"
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Proof Generator
A proof generator for cairo programs.
A proof generator for cairo programs. This repository uses [stone-prover](https://github.com/starkware-libs/stone-prover) under the hood to generate proofs and uses [cairo-vm](https://github.com/lambdaclass/cairo-vm) to run, compile and bootload the programs.

## Overview
You can genrate proofs for cairo programs here. Check out the Makefile to see what commands are available.
You can genrate proofs for cairo programs here. The commands available are documented here.
There are 2 ways to genrate proofs:
1. First bootloading the program and then proving the execution of the bootloader. This is the recommended way and generates smaller proofs.
1. First bootloading the program and then proving the execution of the bootloader. This is the recommended way and generates smaller proofs. Check out a simple bootloader [here](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/cairo/bootloaders/simple_bootloader/simple_bootloader.cairo_)
2. Proving the execution of the program directly.


Expand All @@ -15,6 +15,18 @@ Run the following command to install the dependencies:
cargo build
```

## Files
`compiled.json`: The compiled Cairo program.
`input.json`: Input data for the Cairo program.
`public_input.json`: Public inputs for the proof generation.
`private_input.json`: Private inputs for the proof generation.
`trace.bin`: Execution trace of the Cairo program.
`memory.bin`: Memory dump of the Cairo program execution.
`proof.json`: The generated STARK proof.
`pie.zip`: Cairo PIE (Program Indepedent Executable) that can be generated by running the program and can be used re run the file in standardised way without inputs.
`cpu_air_prover_config.json`: Configuration file for the CPU AIR prover(stone-prover).
`cpu_air_params.json`: Parameters file for the CPU AIR prover(stone-prover).

## Preparing a program
To checkout an example, check out the `examples` directory.
1. Create a new cairo program to proove, e.g. `dummy_snos.cairo`.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c14a612

Please sign in to comment.