/fhe_risc0_zkvm

FHE in the Risc0 zkVM

Primary LanguageRustApache License 2.0Apache-2.0

FHE in Risc0 zkVM

Integration of fhe.rs, a FHE library in Rust, in Risc0 zkVM.

A small voting example is implemented, where the homomorphic addition of the ciphertexts is done in the zkVM guest. The example comes from the fhe.rs library (here). The original example has a voters max of 1000, in this repo a fixed amount of 5 voters is used to showcase the functionality.

A fork of the fhe.rs library is being used, where the Rust version aligns with the accepted Rust version in the zkVM guest (here).

Note: the current example can run with

RISC0_DEV_MODE=1 cargo run

Running it in full proving mode probably hits a hardware limit and running in Bonsai probably hits a quota limit.

Quick Start

Init and update submodule:

git submodule init
git submodule update

To build all methods and execute the method within the zkVM, run the following command:

cargo run

To run in developer mode, without generating valid proofs (much faster):

RISC0_DEV_MODE=1 cargo run

Running proofs remotely on Bonsai

If you have access to the URL and API key to Bonsai you can run your proofs remotely. To prove in Bonsai mode, invoke cargo run with two additional environment variables:

BONSAI_API_KEY="YOUR_API_KEY" BONSAI_API_URL="BONSAI_URL" cargo run