From 8fb52362fc4ffbb3d7d0a996ea8c7124168de0be Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Wed, 25 Sep 2024 13:29:59 +0300 Subject: [PATCH] SP1 instructions added --- README.md | 3 + sp1/README.md | 40 ++------ sp1/mem_alloc_vec_test/README.md | 92 ------------------- sp1/mem_alloc_vec_test/program/src/main.rs | 3 - sp1/simple_arithmetic_test/README.md | 92 ------------------- .../program/src/main.rs | 3 - 6 files changed, 12 insertions(+), 221 deletions(-) delete mode 100644 sp1/mem_alloc_vec_test/README.md delete mode 100644 sp1/simple_arithmetic_test/README.md diff --git a/README.md b/README.md index 4db76c8..b7518ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # nescience-zkvm-testing This repo reflects the tests conducted by Nescience Team on selected zkVMs. +All tests are Rust-based, so be sure to install it, for example according to [this](https://rustup.rs/). + # How to run tests To run test, corresponding to zkVM of choise read @@ -8,3 +10,4 @@ To run test, corresponding to zkVM of choise read - [zkWASM](./zkwasm/README.md) - [zkMIPS](./zkmips/README.md) - [Valida](./valida/README.md) +- [SP1](./sp1/README.md) diff --git a/sp1/README.md b/sp1/README.md index bbb2235..1e7d7ad 100644 --- a/sp1/README.md +++ b/sp1/README.md @@ -1,39 +1,17 @@ # Test run instructions -To run corresponding tests in `Valida` some preparations have to be done. +Firstly there is requirements -We assume, that one is in `valida` folder. +- [SP1](https://docs.succinct.xyz/getting-started/install.html) -Firstly, move into [scripts_and_tools](./scripts_and_tools/) directory. +Next, we assume, that one is in `sp1` folder. -Next, run +To prove execution we need to build one of the tests, let`s use [simple_arithmetic_test](./tests/simple_arithmetic_test/) as an example. + +To generate a proof, run the following commands: ```sh -./valida_setup.sh -``` - -This will fetch all necessary components to build Rist code in `Valida`. - -Next, to prove execution we need to build one of the tests, let`s use [simple_arithmetic_test](./tests/simple_arithmetic_test/) as an example. - -Run - -```sh -./build-rust.sh simple_arithmetic_test -``` - -If run is succsessfull then you will see `simple_arithmetic_test`, `simple_arithmetic_test.ll`, `simple_arithmetic_test.o` files in the scripts directory. - -Next, we need prove execution, to do so run - -```sh -./valida_prove.sh simple_arithmetic_test -``` - -If proof succsessfull, you will see `simple_arithmetic_test.proof` file in scripts derectory. - -If needed, proof can be verified as follows - -```sh -./valida_verify.sh simple_arithmetic_test +cd simple_arithmetic_test +cd script +cargo run --release -- --prove ``` \ No newline at end of file diff --git a/sp1/mem_alloc_vec_test/README.md b/sp1/mem_alloc_vec_test/README.md deleted file mode 100644 index 295787d..0000000 --- a/sp1/mem_alloc_vec_test/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# SP1 Project Template - -This is a template for creating an end-to-end [SP1](https://github.com/succinctlabs/sp1) project -that can generate a proof of any RISC-V program. - -## Requirements - -- [Rust](https://rustup.rs/) -- [SP1](https://docs.succinct.xyz/getting-started/install.html) - -## Running the Project - -There are four main ways to run this project: build a program, execute a program, generate a core proof, and -generate an EVM-compatible proof. - -### Build the Program - -To build the program, run the following command: - -```sh -cd program -cargo prove build -``` - -### Execute the Program - -To run the program without generating a proof: - -```sh -cd script -cargo run --release -- --execute -``` - -This will execute the program and display the output. - -### Generate a Core Proof - -To generate a core proof for your program: - -```sh -cd script -cargo run --release -- --prove -``` - -### Generate an EVM-Compatible Proof - -> [!WARNING] -> You will need at least 128GB RAM to generate a PLONK or Groth16 proof. - -To generate a proof that is small enough to be verified on-chain and verifiable by the EVM: - -```sh -cd script -cargo run --release --bin evm -- --system plonk -``` - -this will generate a PLONK proof. If you want to generate a Groth16 proof, run the following command: - -```sh -cargo run --release --bin evm -- --system groth16 -``` - -These commands will also generate fixtures that can be used to test the verification of SP1 zkVM proofs -inside Solidity. - -### Retrieve the Verification Key - -To retrieve your `programVKey` for your on-chain contract, run the following command: - -```sh -cargo prove vkey --elf elf/riscv32im-succinct-zkvm-elf -``` - -## Using the Prover Network - -We highly recommend using the Succinct prover network for any non-trivial programs or benchmarking purposes. For more information, see the [setup guide](https://docs.succinct.xyz/prover-network/setup.html). - -To get started, copy the example environment file: - -```sh -cp .env.example .env -``` - -Then, set the `SP1_PROVER` environment variable to `network` and set the `SP1_PRIVATE_KEY` -environment variable to your whitelisted private key. - -For example, to generate an EVM-compatible proof using the prover network, run the following -command: - -```sh -SP1_PROVER=network SP1_PRIVATE_KEY=... cargo run --release --bin evm -``` diff --git a/sp1/mem_alloc_vec_test/program/src/main.rs b/sp1/mem_alloc_vec_test/program/src/main.rs index cb31543..a09cb24 100644 --- a/sp1/mem_alloc_vec_test/program/src/main.rs +++ b/sp1/mem_alloc_vec_test/program/src/main.rs @@ -1,6 +1,3 @@ -//! A simple program that takes a number `n` as input, and writes the `n-1`th and `n`th fibonacci -//! number as an output. - // These two lines are necessary for the program to properly compile. // // Under the hood, we wrap your main function with some extra code so that it behaves properly diff --git a/sp1/simple_arithmetic_test/README.md b/sp1/simple_arithmetic_test/README.md deleted file mode 100644 index 295787d..0000000 --- a/sp1/simple_arithmetic_test/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# SP1 Project Template - -This is a template for creating an end-to-end [SP1](https://github.com/succinctlabs/sp1) project -that can generate a proof of any RISC-V program. - -## Requirements - -- [Rust](https://rustup.rs/) -- [SP1](https://docs.succinct.xyz/getting-started/install.html) - -## Running the Project - -There are four main ways to run this project: build a program, execute a program, generate a core proof, and -generate an EVM-compatible proof. - -### Build the Program - -To build the program, run the following command: - -```sh -cd program -cargo prove build -``` - -### Execute the Program - -To run the program without generating a proof: - -```sh -cd script -cargo run --release -- --execute -``` - -This will execute the program and display the output. - -### Generate a Core Proof - -To generate a core proof for your program: - -```sh -cd script -cargo run --release -- --prove -``` - -### Generate an EVM-Compatible Proof - -> [!WARNING] -> You will need at least 128GB RAM to generate a PLONK or Groth16 proof. - -To generate a proof that is small enough to be verified on-chain and verifiable by the EVM: - -```sh -cd script -cargo run --release --bin evm -- --system plonk -``` - -this will generate a PLONK proof. If you want to generate a Groth16 proof, run the following command: - -```sh -cargo run --release --bin evm -- --system groth16 -``` - -These commands will also generate fixtures that can be used to test the verification of SP1 zkVM proofs -inside Solidity. - -### Retrieve the Verification Key - -To retrieve your `programVKey` for your on-chain contract, run the following command: - -```sh -cargo prove vkey --elf elf/riscv32im-succinct-zkvm-elf -``` - -## Using the Prover Network - -We highly recommend using the Succinct prover network for any non-trivial programs or benchmarking purposes. For more information, see the [setup guide](https://docs.succinct.xyz/prover-network/setup.html). - -To get started, copy the example environment file: - -```sh -cp .env.example .env -``` - -Then, set the `SP1_PROVER` environment variable to `network` and set the `SP1_PRIVATE_KEY` -environment variable to your whitelisted private key. - -For example, to generate an EVM-compatible proof using the prover network, run the following -command: - -```sh -SP1_PROVER=network SP1_PRIVATE_KEY=... cargo run --release --bin evm -``` diff --git a/sp1/simple_arithmetic_test/program/src/main.rs b/sp1/simple_arithmetic_test/program/src/main.rs index 1a624b3..06d657a 100644 --- a/sp1/simple_arithmetic_test/program/src/main.rs +++ b/sp1/simple_arithmetic_test/program/src/main.rs @@ -1,6 +1,3 @@ -//! A simple program that takes a number `n` as input, and writes the `n-1`th and `n`th fibonacci -//! number as an output. - // These two lines are necessary for the program to properly compile. // // Under the hood, we wrap your main function with some extra code so that it behaves properly