Generating & submitting proofs of Rust code with ZKRust

zkRust is a CLI tool to generate proofs of your rust code using a RISCV-zkVM's and submit them to Aligned to be verified with only one command. The following provers are supported:

Dependencies

To generate and submit proofs to Aligned using ZKRust, you need to have the following dependencies installed:

  • Foundry (Optional, needed only to create a local keystore to sign Ethereum transactions if you didn't already have one).

Generate & Submit proofs

To generate and submit proofs to Aligned testnet using zkRust, you can follow the steps below:

1. Install zkRust :

The zkRust executable can be installed directly via the command line via:

curl -L https://raw.githubusercontent.com/yetanotherco/zkRust/main/install_zkrust.sh | bash

or built by cloning the repo

git clone https://github.com/yetanotherco/zkRust
cd zkRust

and running the installation script:

make install

2. Generate a keystore:

You can use cast to create a local keystore. If you already have one, you can skip this step.

cast wallet new-mnemonic

Then you can import your created keystore using:

cast wallet import --interactive <path_to_keystore.json>

Make sure to send at least 0.1 Holesky ETH to the address in the keystore. You can get Holesky ETH from the faucet

3. Generate and submit the proof with zkRust:

The zkRust repo has some predefined examples that can be used to generate a proof. You can find them in zkRust/examples. For example, to generate a proof of a fibonacci program with Risc0 or SP1 and submit it to aligned, run:

cargo run --release --  prove-risc0 \
    --submit-to-aligned-with-keystore \
    <PATH_TO_KEYSTORE> \
    examples/fibonacci .

This command will generate a proof for the fibonacci example program and submit it to Aligned using the keystore provided for signing the transaction.

Take into consideration that the proof generation can take some time. Once the proof has been generated, a prompt will appear asking for the passphrase of your keystore and then send it to Aligned.

The same program can be proved using SP1 just changing the zkRust subcommand:

cargo run --release -- prove-sp1 \
    --submit-to-aligned-with-keystore <path_to_keystore> \
    examples/fibonacci .

Caveats

For the moment, the Rust code that can be proven has some limitations:

  • Programs with user Input and Output to the vm code are not supported.

Last updated