proof-aggregation/workflow
M Alghazwi 0e09c7549d add bench results 2024-11-14 13:23:34 +01:00
..
benches fix benchmarks 2024-11-14 12:26:37 +01:00
src/bin update readme and refactor 2024-11-14 10:31:32 +01:00
.gitignore re-arrange code and refactor 2024-11-08 12:23:55 +01:00
BENCHMARKS.md add bench results 2024-11-14 13:23:34 +01:00
Cargo.toml fix benchmarks 2024-11-14 12:26:37 +01:00
README.md update readme and refactor 2024-11-14 10:31:32 +01:00
build_circuit.sh update readme and refactor 2024-11-14 10:31:32 +01:00
circ_params.sh update readme and refactor 2024-11-14 10:31:32 +01:00
gen_input.sh update readme and refactor 2024-11-14 10:31:32 +01:00
input.json update readme and refactor 2024-11-14 10:31:32 +01:00
params.sh add ceiling_log2 and refactor 2024-11-12 13:06:28 +01:00
prove.sh update readme and refactor 2024-11-14 10:31:32 +01:00
prove_and_verify.sh update readme and refactor 2024-11-14 10:31:32 +01:00

README.md

Workflow of the Storage Proof Circuits

WARNING: This is a work-in-progress prototype, and has not received careful code review. This implementation is NOT ready for production use.

This crate guides you through generating the circuit input, exporting it to a JSON file, importing from a JSON file, running the circuits to generate a proof, and finally verify the proof.

This crate can be used to:

  • Generate circuit input from fake data with given params.
  • Build the plonky2 codex storage proof circuits.
  • Generate a proof with given proof input in JSON file.
  • Verify the proof.

Code organization

  • gen_input contains the main function to generated input with the given params as environment variables.

  • build_circ contains the main function to generated input with the given params as environment variables.

  • prove contains the main function to generated input with the given params as environment variables.

  • prove_and_verify contains the main function to generated input with the given params as environment variables.

Usage

Prerequisites

  • Rust Toolchain: Ensure you have Rust installed. If not, install it from rustup.rs.

  • Rust nightly:: This crate requires the Rust nightly compiler. To install the nightly toolchain, use rustup:

rustup install nightly

To ensure that the nightly toolchain is used when building this crate, you can set the override in the project directory:

rustup override set nightly

Generate Circuit Input

The steps to generate circuit input with fake data are the following:

Step 1: Setting Up Parameters

Parameters for generating the circuit input can be defined in params.sh. You can customize the test parameters by setting the following environment variables:

export MAXDEPTH=32        # Maximum depth of the slot tree
export MAXSLOTS=256       # Maximum number of slots
export CELLSIZE=2048      # Cell size in bytes
export BLOCKSIZE=65536    # Block size in bytes
export NSAMPLES=5         # Number of samples to prove

export ENTROPY=1234567    # External randomness
export SEED=12345         # Seed for creating fake data

export NSLOTS=11          # Number of slots in the dataset
export SLOTINDEX=3        # Which slot to prove (0..NSLOTS-1)
export NCELLS=512         # Number of cells in this slot

Alternatively, for testing you can just use the default parameters as follows:

use proof_input::params::TestParams;

fn main() {
    let params = TestParams::<F,D>::default();
}

Step 2: Run the Script

Once the params are set, you can run the script to generate the JSON file.

sudo bash ./gen_input.sh

Build the Circuit

To build the circuit and measure the time to build, you can simply run the script:

sudo bash ./build_circuit.sh

To see the source code of how to build the circuit, see build_circ.

Generate the Proof

After generating the circuit input (in a JSON file), you can run the circuits to generate the proofs. First make sure you have the JSON file, then follow the steps:

Step 1: Setting Up Circuit Parameters

Parameters for the circuit can be defined in circ_params.sh. You can customize the test parameters by setting the following environment variables:

export MAX_DEPTH=32        # maximum depth of the slot tree
export MAX_LOG2_N_SLOTS=8 # Depth of the dataset tree = ceiling_log2(max_slots)
export BLOCK_TREE_DEPTH=5 # depth of the mini tree (block tree)
export N_FIELD_ELEMS_PER_CELL=272 # number of field elements per cell
export N_SAMPLES=5 # number of samples to prove

Step 2: Run the Script

Once the params are set, you can run the script to generate the proof. You can also see the time taken to generate the proof.

sudo bash ./prove.sh

Build, Prove, and Verify

To automate the whole process, you can run the following script the script builds the circuit, loads the JSON circuit input, generates the proof, and verifies it. It also shows the time taken for each step. Make sure that you generate the circuit input prior to this so that you have the JSON input file and set the circ_params.sh.

sudo bash ./prove_and_verify.sh

To inspect the source code, see prove_and_verify.