Noir Verifier
Requirements (read carefully to avoid 99% of issues!)
Garaga CLI Python package version 0.18.1 (install with
pip install garaga==0.18.1Noir 1.0.0-beta.5 (install with
noirup --version 1.0.0-beta.5ornpm i @noir-lang/noir_js@1.0.0-beta.5)Barretenberg 0.87.4-starknet.1 (install with
bbup --version 0.87.4-starknet.1ornpm i @aztec/bb.js@0.87.4-starknet.1)
To install noirup and bbup, follow the quickstart guide from aztec.
Generate a Starknet smart contract for your Noir program
Supported barretenberg flavours
Supported Flavors Overview
ultra_keccak_honk
Keccak
No
Cheaper on EVM
ultra_keccak_zk_honk
Keccak
Yes
Cheaper on EVM
ultra_starknet_honk
Starknet Poseidon
No
Cheaper on Starknet
ultra_starknet_zk_honk
Starknet Poseidon
Yes
Cheaper on Starknet
1. Verification Key Generation (Same for All Flavors)
bb write_vk --scheme ultra_honk -b target/program.json -o target/vkThis creates the binary verification key file vk in target/vk.
2. Smart Contract Generation (Different per Flavor)
ultra_keccak_honk
garaga gen --system ultra_keccak_honk --vk target/vk
ultra_keccak_zk_honk
garaga gen --system ultra_keccak_zk_honk --vk target/vk
ultra_starknet_honk
garaga gen --system ultra_starknet_honk --vk target/vk
ultra_starknet_zk_honk
garaga gen --system ultra_starknet_zk_honk --vk target/vk
3. Proof Generation & Calldata Generation
bb prove --scheme ultra_honk --oracle_hash keccak
garaga calldata --system ultra_keccak_honk
bb prove --scheme ultra_honk --oracle_hash keccak --zk
garaga calldata --system ultra_keccak_zk_honk
bb prove --scheme ultra_honk --oracle_hash starknet
garaga calldata --system ultra_starknet_honk
bb prove --scheme ultra_honk --oracle_hash starknet --zk
garaga calldata --system ultra_starknet_zk_honk
4. BB.js Integration
{ keccak: true }
getHonkCallData()
HonkFlavor.KECCAK
ultra_keccak_honk
{ keccakZK: true }
getZKHonkCallData()
HonkFlavor.KECCAK
ultra_keccak_zk_honk
{ starknet: true }
getHonkCallData()
HonkFlavor.STARKNET
ultra_starknet_honk
{ starknetZK: true }
getZKHonkCallData()
HonkFlavor.STARKNET
ultra_starknet_zk_honk
First, create a new Noir project and compile it with nargo build.
nargo new hello
cd hello
nargo buildThis will create a json file in hello/target/hello.json
Now, generate the corresponding verifying key vkusing barretenberg :
bb write_vk --scheme ultra_honk --oracle_hash keccak -b target/hello.json -o targetFinally, generate a smart contract from the verifying key using the garaga CLI.
garaga gen --system ultra_keccak_zk_honk --vk target/vkThis will create a smart contract folder with the following structure.
Generating Smart Contract project for ProofSystem.UltraKeccakZKHonk using vk...
Done!
Smart Contract project created:
/noir/hello/my_project/
├── .tools-versions
├── Scarb.toml
└── src/
├── honk_verifier.cairo
├── honk_verifier_circuits.cairo
├── honk_verifier_constants.cairo
└── lib.cairoThe main function of interest is located in honk_verifier.cairo
The contract interface will be
#[starknet::interface]
trait IUltraKeccakZKHonkVerifier<TContractState> {
fn verify_ultra_keccak_zk_honk_proof(
self: @TContractState, full_proof_with_hints: Span<felt252>,
) -> Option<Span<u256>>; // Returns the public inputs in case of success.
}In order to interact with the endpoint, we need to generate the full_proof_with_hintsarray.
To do so, we need a specific proof for your program. But first, Noir requires to specify the inputs of the program in hello/Prover.toml
// The "hello" program simply prove that x!=y, with x being private and y public.
x = "1"
y = "2"Now, generate a proof with barretenberg, after running the program (notice that the --zkflag that occurs only in the proving part, not in the verifying key generation) :
nargo execute witness
bb prove -s ultra_honk --oracle_hash keccak --zk -b target/hello.json -w target/witness.gz -o target/Generating the calldata (full_proof_with_hints array)
full_proof_with_hints array)Finalizing the above CLI example, you can obtain the full_proof_with_hints array using the garaga CLI. From within the "target" directory:
garaga calldata --system ultra_keccak_zk_honk --proof proof --vk vkAdd the Rust Crate to your project using the same release tag as the version of pip package that generated the verifier.
use garaga_rs::calldata::full_proof_with_hints::{
honk::{get_honk_calldata, HonkFlavor, HonkProof, HonkVerificationKey},
zk_honk::{get_zk_honk_calldata, ZKHonkProof},
};
use std::fs::File;
use std::io::Read;
// 1. Add the Rust Crate to your project using the same release tag as the version of pip
// package that generated the verifier.
// 2. Load your verification key
let mut vk_file = File::open("path/to/vk.bin")?;
let mut vk_bytes = vec![];
vk_file.read_to_end(&mut vk_bytes)?;
let vk = HonkVerificationKey::from_bytes(&vk_bytes)?;
// 3. Load the proof and generate the calldata
// For Honk proofs
let mut proof_file = File::open("path/to/proof.bin")?;
let mut proof_bytes = vec![];
proof_file.read_to_end(&mut proof_bytes)?;
let proof = HonkProof::from_bytes(&proof_bytes)?;
let calldata = get_honk_calldata(&proof, &vk, HonkFlavor::KECCAK)?;
// For ZK Honk proofs
let mut zk_proof_file = File::open("path/to/zk_proof.bin")?;
let mut zk_proof_bytes = vec![];
zk_proof_file.read_to_end(&mut zk_proof_bytes)?;
let zk_proof = ZKHonkProof::from_bytes(&zk_proof_bytes)?;
let zk_calldata = get_zk_honk_calldata(&zk_proof, &vk, HonkFlavor::KECCAK)?;Using the garaga Npm package
import { getHonkCallData, getZKHonkCallData } from '@garaga/honk';
import { HonkFlavor } from '@garaga/honk/starknet/honkContractGenerator/parsingUtils';
import { readFile } from 'fs/promises';
// 1. Add the NPM package to your project using the same release tag as the version of pip
// package that generated the verifier.
// 2. Load your proof and verification key as Uint8Array
const vk: Uint8Array = await readFile('path/to/vk.bin');
const proof: Uint8Array = await readFile('path/to/proof.bin');
// For Honk proofs (Keccak flavor)
const calldata = getHonkCallData(
proof,
vk,
HonkFlavor.KECCAK // or HonkFlavor.STARKNET for Starknet flavor
);
// For ZK Honk proofs (Keccak flavor)
const zkCalldata = getZKHonkCallData(
proof,
vk,
HonkFlavor.KECCAK // or HonkFlavor.STARKNET for Starknet flavor
);
// The functions return bigint[]Using thegaraga Python package
from pathlib import Path
from garaga.definitions import ProofSystem
from garaga.precompiled_circuits.honk import (
HonkVk,
honk_proof_from_bytes
)
from garaga.starknet.honk_contract_generator.calldata import (
get_ultra_flavor_honk_calldata_from_vk_and_proof
)
# 1. Add the pip package to your project using the same release tag as the version that
# generated the verifier.
# 2. Load your proof and verification key
vk_path = Path('path/to/vk.bin')
proof_path = Path('path/to/proof.bin')
# Read the verification key
with open(vk_path, 'rb') as f:
vk_bytes = f.read()
vk = HonkVk.from_bytes(vk_bytes)
# Read and parse the proof
with open(proof_path, 'rb') as f:
proof_bytes = f.read()
# The proof will be parsed according to the system type
# Available proof systems:
# - ProofSystem.UltraKeccakHonk # Regular Honk with Keccak
# - ProofSystem.UltraStarknetHonk # Regular Honk with Starknet hash
# - ProofSystem.UltraKeccakZKHonk # ZK Honk with Keccak
# - ProofSystem.UltraStarknetZKHonk # ZK Honk with Starknet hash
proof = honk_proof_from_bytes(proof_bytes, vk, system=ProofSystem.UltraKeccakHonk)
calldata: list[int] = get_ultra_flavor_honk_calldata_from_vk_and_proof(
vk=vk,
proof=proof, # Can be either HonkProof or ZKHonkProof
system=ProofSystem.UltraKeccakHonk, # Or any other supported system
)The UltraStarknet Flavour
The Ultra Starknet flavour replaces the Keccak hash function by Starknet's Poseidon hash, which is better suited in the context of Starknet and Cairo contracts. Using it will both optimize on-chain verification costs and verifier contract bytecode sizes.
You can follow the previous tutorial using the starknet flavours of Supported barretenberg flavours :
--oracle_hash starknetin bb commands--system ultra_starknet_honkor--system ultra_starknet_zk_honkin garaga CLIetc. in the other python, rust, npm tooling.
Complete dApp Tutorial
Follow the Scaffold‑Garaga repository. This starter kit combines Noir, Garaga, and Starknet with in‑browser proving to help you ship a privacy‑preserving dApp fast.
What you'll learn
Generate & deploy an UltraHonk proof verifier to a local Starknet devnet.
Add on‑chain state to your privacy‑preserving app.
Connect a wallet and deploy to a public testnet.
Need Support ?
Last updated
Was this helpful?