28 releases (7 breaking)

0.21.0 Mar 12, 2024
0.20.1 Feb 1, 2024
0.20.0-rc.1 Dec 19, 2023
0.19.1 Nov 9, 2023
0.14.0 Mar 29, 2023

#150 in Hardware support

Download history 303/week @ 2023-12-23 776/week @ 2023-12-30 1629/week @ 2024-01-06 1325/week @ 2024-01-13 1589/week @ 2024-01-20 1357/week @ 2024-01-27 1079/week @ 2024-02-03 1501/week @ 2024-02-10 1787/week @ 2024-02-17 1940/week @ 2024-02-24 1847/week @ 2024-03-02 2426/week @ 2024-03-09 2036/week @ 2024-03-16 2797/week @ 2024-03-23 2159/week @ 2024-03-30 1535/week @ 2024-04-06

8,969 downloads per month

Apache-2.0 and LGPL-3.0-or-later

1MB
5K SLoC

cargo-risczero

Cargo extension to help create, manage, and test RISC Zero projects. The default template generated from the cargo risczero new command supports both local and remote proving. Refer to the README in the rust-starter template for more information.

Installation

To install this Cargo subcommand, first you'll want to install Rust and then you'll execute:

cargo install cargo-binstall
cargo binstall cargo-risczero

## Installing from local source. Note: this can be very slow.
cargo install --path risc0/cargo-risczero

After that you can verify it works via:

cargo risczero --version

Docker

In order to use the build command, you will need docker available in your PATH. For developer machines, this is simple with Docker Desktop.

install

The install command installs the latest RISC Zero toolchain. This toolchain is needed to compile guest programs into ELF binaries that the zkVM can execute.

cargo risczero install

You can verify it was installed correctly by running:

rustup toolchain list --verbose | grep risc0

Note that the following pre-built host targets are available:

  • aarch64-apple-darwin
  • x86_64-apple-darwin
  • x86_64-unknown-linux-gnu

If you'd like to install the toolchain on a host not listed above, you can use the build-toolchain command to build the toolchain locally.

new

The new command will create a new project from an existing template. It defaults to the rust-starter template but can be used with other templates locally or hosted on github.

Examples

# Create a project from the main template
cargo risczero new my_project

# Create a project with 'std' support in the guest
cargo risczero new my_project --std

# Disable git initialization
cargo risczero new my_project --no-git

# Create from github template
cargo risczero new my_project --template https://github.com/risc0/risc0-rust-starter

build-toolchain

Use the build-toolchain command to build the toolchain locally for your host. Warning: this may take a long time. The resulting toolchain will be automatically installed via rustup toolchain link.

build

Use the build command to build guest code for the zkVM target riscv32im-risc0-zkvm-elf deterministically.

The compiled ELF is saved in: ./target/riscv-guest/riscv32im-risc0-zkvm-elf/docker/

With this containerized build process, we ensure that all builds of your guest code, regardless of the machine or local environment, will produce the same ImageID. The ImageID, and its importance to security, is explained in more detail in our developer FAQ.

Note: The build command requires the docker CLI installed and in your PATH.

Example

# Build the zkVM's test examples
cargo risczero build --manifest-path risc0/zkvm/methods/guest/Cargo.toml

ELFs ready at:
ImageID: 417778745b43c82a20db33a55c2b1d6e0805e0fa7eec80c9654e7321121e97af - "target/riscv-guest/riscv32im-risc0-zkvm-elf/docker/risc0_zkvm_methods_guest/multi_test"
ImageID: c7c399c25ecf26b79e987ed060efce1f0836a594ad1059b138b6ed2f123dad38 - "target/riscv-guest/riscv32im-risc0-zkvm-elf/docker/risc0_zkvm_methods_guest/hello_commit"
ImageID: a51a4b747f18b7e5f36a016bdd6f885e8293dbfca2759d6667a6df8edd5f2489 - "target/riscv-guest/riscv32im-risc0-zkvm-elf/docker/risc0_zkvm_methods_guest/slice_io"

Dependencies

~49–77MB
~1.5M SLoC