From 8280337dfb42b044df99b1a476c58d2a95980b7b Mon Sep 17 00:00:00 2001 From: Victor Graf Date: Fri, 6 Dec 2024 08:35:30 -0800 Subject: [PATCH] fix up links and minor edits to content --- README.md | 67 +++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index ed7f2a5c..f0f2ea9d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # RISC Zero Foundry Template -> Prove computation with the [RISC Zero zkVM] and verify the results in your Ethereum contract. +> Prove computation with the [RISC Zero zkVM][docs-zkvm] and verify the results in your Ethereum contract. -This repository implements an example application on Ethereum utilizing RISC Zero as a [coprocessor] to the smart contract application. +This repository implements an example application on Ethereum utilizing RISC Zero as a [coprocessor][blog-coprocessor] to the smart contract application. It provides a starting point for building powerful new applications on Ethereum that offload work that is computationally intensive (i.e. gas expensive), or difficult to implement in Solidity (e.g. ed25519 signature verification, or HTML parsing). @@ -10,18 +10,18 @@ Integrate with [Steel][steel-repo] to execute view calls and simulate transactio ## Overview -Here is a simplified overview of how devs can integrate RISC Zero, with [Bonsai] proving, into their Ethereum smart contracts: +Here is a simplified overview of how devs can integrate RISC Zero, including with [Bonsai][docs-bonsai] proving, into their Ethereum smart contracts: ![RISC Zero Foundry Template Diagram](images/risc0-foundry-template.png) -1. Run your application logic in the [RISC Zero zkVM]. The provided [publisher] app sends an off-chain proof request to the [Bonsai] proving service. -2. [Bonsai] generates the program result, written to the [journal], and a SNARK proof of its correctness. -3. The [publisher] app submits this proof and journal on-chain to your app contract for validation. -4. Your app contract calls the [RISC Zero Verifier] to validate the proof. If the verification is successful, the journal is deemed trustworthy and can be safely used. +1. Run your application logic in the [RISC Zero zkVM][docs-zkvm]. The provided [publisher](./apps) app sends an off-chain proof request to the [Bonsai] proving service. +2. [Bonsai][docs-bonsai] generates the program result, written to the [journal][term-journal], and a SNARK proof of its correctness. +3. The [publisher](./apps) app submits this proof and journal on-chain to your app contract for validation. +4. Your app contract calls the [RISC Zero Verifier][docs-verifier] to validate the proof. If the verification is successful, the journal is deemed trustworthy and can be safely used. ## Dependencies -First, [install Rust] and [Foundry], and then restart your terminal. +First, [install Rust][install-rust] and [Foundry][install-foundry], and then restart your terminal. ```sh # Install Rust @@ -41,7 +41,7 @@ curl -L https://risczero.com/install | bash Next we can install the RISC Zero toolchain by running `rzup`: ```sh -rzup +rzup install ``` You can verify the installation was successful by running: @@ -50,7 +50,7 @@ You can verify the installation was successful by running: cargo risczero --version ``` -Now you have all the tools you need to develop and deploy an application with [RISC Zero]. +Now you have all the tools you need to develop and deploy an application with [RISC Zero][homepage-risczero]. ## Quick Start @@ -59,16 +59,16 @@ First, install the RISC Zero toolchain using the [instructions above](#dependenc Now, you can initialize a new RISC Zero project at a location of your choosing: ```sh -forge init -t risc0/bonsai-foundry-template ./my-project +forge init -t risc0/risc0-foundry-template ./my-project ``` Congratulations! You've just started your first RISC Zero project. Your new project consists of: -- a [zkVM program] (written in Rust), which specifies a computation that will be proven; -- a [app contract] (written in Solidity), which uses the proven results; -- a [publisher] which makes proving requests to [Bonsai] and posts the proof to Ethereum. +- a [zkVM program](./methods) (written in Rust), which specifies a computation that will be proven; +- a [app contract](./contracts) (written in Solidity), which uses the proven results; +- a [publisher](./apps) which makes proving requests to [Bonsai][docs-bonsai] and posts the proof to Ethereum. We provide an example implementation, but your dApp interface or application servers could act as the publisher. ### Build the Code @@ -113,7 +113,8 @@ Your new project consists of: RISC0_DEV_MODE=false forge test -vvv ``` - Producing the [Groth16 SNARK proofs][Groth16] for this test requires running on an x86 machine with [Docker] installed, or using [Bonsai](#configuring-bonsai). Apple silicon is currently unsupported for local proving, you can find out more info in the relevant issues [here](https://github.com/risc0/risc0/issues/1520) and [here](https://github.com/risc0/risc0/issues/1749). + Producing the [Groth16 SNARK proofs][groth16] for this test requires running on an x86 machine with [Docker][install-docker] installed, or using [Bonsai](#configuring-bonsai). + Apple silicon is currently unsupported for local proving, you can find out more info in the relevant issues [here](https://github.com/risc0/risc0/issues/1520) and [here](https://github.com/risc0/risc0/issues/1749). ## Develop Your Application @@ -121,7 +122,7 @@ To build your application using the RISC Zero Foundry Template, you’ll need to - ***Guest Code***: Write the code you want proven in the [methods/guest](./methods/guest/) folder. This code runs off-chain within the RISC Zero zkVM and performs the actual computations. For example, the provided template includes a computation to check if a given number is even and generate a proof of this computation. - ***Smart Contracts***: Write the on-chain part of your project in the [contracts](./contracts/) folder. The smart contract verifies zkVM proofs and updates the blockchain state based on the results of off-chain computations. For instance, in the [EvenNumber](./contracts/EvenNumber.sol) example, the smart contract verifies a proof that a number is even and stores that number on-chain if the proof is valid. -- ***Publisher Application***: Adjust the publisher example in the [apps](./apps/) folder. The publisher application bridges off-chain computation with on-chain verification by submitting proof requests, receiving proofs, and publishing them to the smart contract on Ethereum. +- ***Publisher Application***: Adjust the publisher example in the [apps](./apps) folder. The publisher application bridges off-chain computation with on-chain verification by submitting proof requests, receiving proofs, and publishing them to the smart contract on Ethereum. ### Configuring Bonsai @@ -144,17 +145,17 @@ RISC0_DEV_MODE=false forge test -vvv ### Deterministic Builds By setting the environment variable `RISC0_USE_DOCKER` a containerized build process via Docker will ensure that all builds of your guest code, regardless of the machine or local environment, will produce the same [image ID][image-id]. -The [image ID][image-id], and its importance to security, is explained in more detail in our [developer FAQ]. +The [image ID][image-id], and its importance to security, is explained in more detail in our [developer FAQ][faq]. ```bash RISC0_USE_DOCKER=1 cargo build ``` -> ***Note:*** *This requires having Docker installed and in your PATH. To install Docker see [Get Docker][Docker].* +> ***Note:*** *This requires having Docker installed and in your PATH. To install Docker see [Get Docker][install-docker].* ## Deploy Your Application -When you're ready, follow the [deployment guide] to get your application running on [Sepolia] or Ethereum Mainnet. +When you're ready, follow the [deployment guide](./deployment-guide.md) to get your application running on [Sepolia][sepolia] or Ethereum Mainnet. ## Project Structure @@ -187,24 +188,18 @@ Below are the primary files in the project directory └── Elf.sol // Generated contract with paths the guest program ELF files. ``` -[Bonsai]: https://dev.bonsai.xyz/ -[Foundry]: https://getfoundry.sh/ -[Docker]: https://docs.docker.com/get-docker/ -[Groth16]: https://www.risczero.com/news/on-chain-verification -[RISC Zero Verifier]: https://github.com/risc0/risc0/blob/release-0.21/bonsai/ethereum/contracts/IRiscZeroVerifier.sol -[RISC Zero installation]: https://dev.risczero.com/api/zkvm/install -[RISC Zero zkVM]: https://dev.risczero.com/zkvm -[RISC Zero]: https://www.risczero.com/ +[docs-bonsai]: https://dev.risczero.com/api/generating-proofs/remote-proving +[install-foundry]: https://getfoundry.sh/ +[install-docker]: https://docs.docker.com/get-docker/ +[groth16]: https://www.risczero.com/news/on-chain-verification +[docs-verifier]: https://dev.risczero.com/api/blockchain-integration/contracts/verifier +[docs-zkvm]: https://dev.risczero.com/zkvm +[homepage-risczero]: https://www.risczero.com/ [Sepolia]: https://www.alchemy.com/overviews/sepolia-testnet -[app contract]: ./contracts/ -[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall#cargo-binaryinstall -[coprocessor]: https://www.risczero.com/news/a-guide-to-zk-coprocessors-for-scalability -[deployment guide]: /deployment-guide.md -[developer FAQ]: https://dev.risczero.com/faq#zkvm-application-design +[blog-coprocessor]: https://www.risczero.com/news/a-guide-to-zk-coprocessors-for-scalability +[faq]: https://dev.risczero.com/faq#zkvm-application-design [image-id]: https://dev.risczero.com/terminology#image-id -[install Rust]: https://doc.rust-lang.org/cargo/getting-started/installation.html -[journal]: https://dev.risczero.com/terminology#journal -[publisher]: ./apps/README.md -[zkVM program]: ./methods/guest/ +[install-rust]: https://doc.rust-lang.org/cargo/getting-started/installation.html +[term-journal]: https://dev.risczero.com/terminology#journal [steel-repo]: https://github.com/risc0/risc0-ethereum/tree/main/steel [erc20-counter]: https://github.com/risc0/risc0-ethereum/tree/main/examples/erc20-counter