45 releases (16 breaking)

1.0.0-rc.2 Dec 3, 2022
0.20.1 Feb 1, 2024
0.20.0 Jan 29, 2024
0.20.0-rc.1 Dec 19, 2023
0.10.0 Jun 24, 2022

#1949 in Cryptography

Download history 1023/week @ 2023-10-27 839/week @ 2023-11-03 1132/week @ 2023-11-10 642/week @ 2023-11-17 675/week @ 2023-11-24 546/week @ 2023-12-01 632/week @ 2023-12-08 868/week @ 2023-12-15 661/week @ 2023-12-22 470/week @ 2023-12-29 984/week @ 2024-01-05 726/week @ 2024-01-12 633/week @ 2024-01-19 852/week @ 2024-01-26 681/week @ 2024-02-02 802/week @ 2024-02-09

3,136 downloads per month
Used in 2 crates

Apache-2.0 and LGPL-3.0-or-later

173K SLoC

C++ 103K SLoC // 0.4% comments Rust 42K SLoC // 0.1% comments CUDA 14K SLoC // 0.0% comments Metal Shading Language 14K SLoC // 0.0% comments GNU Style Assembly 370 SLoC // 0.5% comments

Build RISC Zero zkVM guest code and provide handles to the host side.

In order for the host to execute guest code in the RISC Zero zkVM, the host must be provided a compiled RISC-V ELF file and the corresponding ImageID. This crate contains the functions needed to take zkVM guest code, build a corresponding ELF file and ImageID, and make the ImageID and a path to the ELF file available for the host to use.

Using risc0-build to build guest methods

Using this crate can be a bit delicate, so we encourage you to follow along in our RISC Zero Rust Starter repository. In that repository, risc0-build is used in the methods directory.

Guest methods are embedded for the host to use by calling embed_methods (or embed_methods_with_options) in a build script. An example build.rs file would look like

fn main() {

This requires including risc0-build as a build dependency. You will also need add a [package.metadata.risc0] section to your cargo file. In this section, put a methods field with a list of relative paths containing the guest code. For example, if your guest code is in the guest directory, then Cargo.toml might include

risc0-build = "0.17"

methods = ["guest"]

This builds a file methods.rs in your cargo output directory which you must then include for the host to use. For example, you might make a file src/lib.rs containing

include!(concat!(env!("OUT_DIR"), "/methods.rs"));

This process will generate an image ID (*_ID) and the contents of an ELF file (*_ELF). The names will be derived from the name of the ELF binary, which will be converted to ALL_CAPS to comply with Rust naming conventions. Thus, if a method binary is named multiply, the image ID will be named methods::MULTIPLY_ID and the contents of the ELF file will be named methods::MULTIPLY_ELF. These are included at the beginning of the host-side code:



~545K SLoC