Using the zkVM
CLI Quick Start

CLI Quick Start

1. Install the Nexus zkVM

First, install Rust: Rust Install Instructions (opens in a new tab).

Also, make sure you have a working version of cmake (opens in a new tab).

Next, install the RISC-V target:

rustup target add riscv32i-unknown-none-elf

Then, install the Nexus zkVM:

cargo install --git https://github.com/nexus-xyz/nexus-zkvm cargo-nexus --tag 'v0.2.3'

Verify the installation:

cargo nexus --help

This should print the available CLI commands.

2. Create a new Nexus project

Somewhere out of the nexus-zkvm checkout, run:

cargo nexus new nexus-project

And change directory to the new project:

cd nexus-project

This will create a new Rust project with the following structure:

./nexus-project
├── Cargo.lock
├── Cargo.toml
└── src
    └── main.rs

And an example zkVM Rust program in ./src/main.rs:

#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
 
use nexus_rt::write_log;
 
#[nexus_rt::main]
fn main() {
    write_log("Hello, World!\n");
}

3. Run your program

cargo nexus run

You should see the program print:

"Hello, World!"

3. Prove your program

Generate a zero-knowledge proof for your Rust program using the Nexus zkVM.

cargo nexus prove

This will generate a proof, and store it in ./nexus-proof.

4. Verify your proof

Finally, load and verify the proof:

cargo nexus verify

You should see the program print Verifying Proof... and finally Finished when complete.