# Generating proofs for Aligned

## SP1

### Dependencies

This guide assumes that:

sp1 prover installed (instructions here)

sp1 project to generate the proofs (instructions here)

aligned installed (instructions here)

### How to generate a proof

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 of`client.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:

### How to get the proof verified by Aligned

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.

For more instructions on how to submit proofs, check the Submitting proofs guide.

## Gnark

### Dependencies

This guide assumes that:

Gnark library is installed. If not, install it using the following command inside your Go module:

Gnark project to generate the proofs' instructions here

### How to generate a proof

Open a terminal and navigate to the Gnark project directory. Then, run the following command to generate the proof:

### How to get the proof verified by Aligned

After generating the proof, you will have to have three different files:

proof file

verification key file

public input file

For a detailed guide on how to generate those files, refer to our detailed guide.

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.

For more instructions on how to submit proofs, check the Submitting proofs guide.

## Risc0

### Dependencies

This guide assumes that:

Risc0 toolchain installed (instructions here)

Risc0 project to generate the proofs (instructions here)

Aligned installed (instructions here)

### How to generate a proof

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:

### How to get the proof verified by Aligned

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

For more instructions on how to submit proofs, check the Submitting proofs guide.

## Halo2

### Dependencies

This guide assumes that:

You are using PSE fork of the Halo2 proof system.

You have a strong understanding of Halo2 circuit development and are familiar with the Halo2 proof system.

Aligned installed (instructions here).

### Import the Halo2 fork library

Aligned supports verification of Halo2 proofs using the IPA and KZG backends. To verify Halo2 proofs on Aligned a description of your Halo2 circuits constraint system must be serialized and sent over the wire to Aligned in addition to the ciruits verification parameters, verification key, and public inputs.

Aligned maintains its own fork of the PSE's Halo2 repository that provides helper methods to serialize and send Halo2 proofs to Aligned.

### How to generate a proof

Once you have developed your circuit and generated its respective, prover key, verifier key, and public input.

You can add `prove_and_serialize_kzg_circuit`

or `prove_and_serialize_ipa_circuit`

from Aligned's Halo2 fork to generate a proof for your cicuit and serialize the circuit and its public inputs to be sent to Aligned.

Then run the following command to generate the proof, parameters, and public inputs:

The files will be saved within a `proof_files/`

directory containing:

`proof.bin`

`params.bin`

`public_input.bin`

### How to get the proof verified by Aligned

After generating the proof, you can send the proof for the respective proof systems of Halo2 to the Aligned network by running one of the following commands:

For more instructions on how to submit proofs, check the Submitting proofs guide.

Last updated