Submit a Noir Ultraplonk Proof
In this tutorial, we will walk through the process of submitting a Ultraplonk proof generated by Noir.
Note: Recursive proofs are not supported at this time.
Requirements
Before starting, ensure you have the following tools installed:
noirup
: Follow the installation instructions here.bb
: Follow in the installation instructions herenoir-cli
tool.(Note: This may take 20-25 mins when running for the first time)git clone https://github.com/HorizenLabs/ultraplonk_verifier
cargo install --features bins --path .
Setting the Nargo Version
To set the correct version of nargo
, run:
noirup -v <version>
Verify the version with:
nargo --version
Make sure to select a bb
version compatible with the selected nargo
one.
Noir v0.30.0
Create a New Noir Project
Refer to the Noir documentation for instructions on creating a new project and generating proving artifacts.
Generating the Solidity Verifier Contract
Generate the Solidity verifier contract by running:
nargo codegen-verifier
This will create a file named plonk_vk.sol
in the ./contract/hello_world
directory and a proof file named hello_world.proof
in the ./target
directory. Your project structure should look like this:
$ tree
.
├── Nargo.toml
├── Prover.toml
├── Verifier.toml
├── contract
│ └── hello_world
│ └── plonk_vk.sol
├── proofs
│ └── hello_world.proof
└── src
└── main.nr
Creating the Proof Data JSON File
Create a new file named proof.json
in your project’s root directory with the following content:
{
"proof": "0x...",
"verifyInputs": ["0x..."]
}
Replace the proof
and verifyInputs
fields with the values from the hello_world.proof
and Verifier.toml
files, respectively.
Generating Proving Artifacts
To generate the proving artifacts, execute the following commands:
noir-cli key --input ./contract/hello_world/plonk_vk.sol --output ./target/vk.bin
noir-cli proof-data --input-json ./proof.json --output-proof ./target/proof.bin --output-pubs ./target/pubs.bin
To get also the vk
in hexadecimal format, run:
noir-cli key-to-hex --input <input_vk_path> --output <output_vk_hex_path>
To make sure the proving artifacts are generated correctly, run:
noir-cli verify --key ./target/vk.bin --proof ./target/proof.bin --pubs ./target/pubs.bin
These commands will generate the necessary files for submitting the Ultraplonk proof.
Noir v0.31.0
Starting from Noir 0.31.0
the nargo
toolchain has been slightly modified and the Barretenberg
backend has been exposed as a separate CLI (bb
) and used for the process of proof creation and verification; moreover, bb
also allows to explicitly export the verification key. This makes the process of getting the proving artifacts less contrived with respect to the previous version.
Refer to the Noir documentation for instructions on creating a new project and generating proving artifacts.
Once you get the proof
and vk
files from nargo
and bb
, execute the following commands:
noir-cli proof-datav2 -n <num_public_inputs> --input-proof <proof_path> --output-proof <out_proof_path> --output-pubs <out_pubs_path>
This command will provide the proof
and public_input
files in binary format. The same files in hexadecimal format are also generated, for ease of submission to zkVerify
.
To get also the vk
in hexadecimal format, run:
noir-cli key-to-hex --input <input_vk_path> --output <output_vk_hex_path>
To make sure that everything works correctly, run:
noir-cli verify --key <vk_bin_path> --proof <proof_bin_path> --pubs <pubs_bin_path>
Submitting the Proof
Submit the proof by using polkadot.js.org
frontend like on the image below: