Generating proofs for Aligned
Last updated
Last updated
This guide assumes that:
sp1 prover installed (instructions )
sp1 project to generate the proofs (instructions )
aligned installed (instructions )
Aligned only verifies SP1 in a compressed version. You can check you are using compressed by opening script/src/main.rs and check that the proof is generated with
client.prove_compressed
instead ofclient.prove
.
First, open a terminal and navigate to the script folder in the sp1 project directory
Then, run the following command to generate a proof:
After generating the proof, you will have to find two different files:
proof file: usually found under script
directory, with the name proof.json
or similar
elf file: usually found under program/elf/
directory
Then, you can send the proof to the Aligned network by running the following command
Where proof_path
is the path to the proof file, vm_program_path
is the path to the ELF file. proof_generator_addr
is an optional parameter that works as a helper for some applications where you can be frontrunned.
This guide assumes that:
Gnark library is installed. If not, install it using the following command inside your Go module:
Open a terminal and navigate to the Gnark project directory. Then, run the following command to generate the proof:
After generating the proof, you will have to have three different files:
proof file
verification key file
public input file
Then, you can send the proof to the Aligned network by running the following command
Where proof path is the path to the proof file, public_input_path
is the path to the public input file,
and verification_key_path
is the path to the verification key file.
This guide assumes that:
First, open the risc0 host file and add the following code to export proof, image id & public input needed by Aligned.
Note that METHOD_ID will be imported from guest, but it will be under a different name.
Then run the following command to generate the proof:
After generating the proof, you will have to find three different files:
Proof file
Image id file
Public input file
Then, you can send the proof to the Aligned network by running the following command
zkRust
is a CLI tool maintained by Aligned that aims to simplify the developing applications in Rust using zkVM's such as SP1 or Risc0.
zkRust can be installed directly by downloading the latest release binaries:
Then, to get started you can create a workspace for your project in zkRust by running:
It is that simple.
To use zkRust, users specify a fn main()
whose execution is proven within the zkVM. This function must be defined in a main.rs
file in a directory with the following structure:
For using more complex programs you can import a separate lib/ crate into the PROGRAM_DIRECTORY
The user may also define a input()
and output()
functions in addition to main()
, that define code that runs outside of the zkVM, before and after the VM executes
The input()
function executes before the zkVM code is executed and allows the user to define inputs passed to the vm such as a deserialized Tx or data fetched from an external source at runtime.
Within the main()
(guest) function the user may write information from the computation performed in the zkVM to an output buffer to be used after proof generation.
The output()
defines code that allows the user to read the information written to that buffer of the and perform post-processing of that data.
The user may specify inputs into the VM (guest) code using zk_rust_io::write()
as long on the type of rust object they are writing implements Serializable
.
Within the main()
function (guest) the user may read in the inputs by specifying zk_rust_io::read()
and output data computed during the execution phase of the code within the VM (guest) program by specifying zk_rust_io::commit()
.
To read the output of the output of the VM (guest) program you declare zk_rust_io::out()
. The zk_rust_io
crate defines function headers that are not inlined and are purely used as compile time symbols to ensure a user can compile their rust code before running it within one of the zkVMs available in zkRust.
To use the I/O imports import the zk_rust_io
crate by adding the following to the Cargo.toml
in your project directory.
To generate a proof of the execution of your code run the following:
Sp1:
Risc0:
For more instructions on how to submit proofs, check the .
Gnark project to generate the proofs' instructions
For a detailed guide on how to generate those files, refer to our .
For more instructions on how to submit proofs, check the .
Risc0 toolchain installed (instructions )
Risc0 project to generate the proofs (instructions )
Aligned installed (instructions )
For more instructions on how to submit proofs, check the .
Make sure to have installed with version v2.0.0
. Running Risc0 on macOS enable acceleration by default and may need to be installed it needed.
For additional information on using zkRust and using it to submit proofs to Aligned see the Github Repository.