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.1
Noir 1.0.0-beta.4 (install with
noirup --version 1.0.0-beta.4
ornpm i @noir-lang/noir_js@1.0.0-beta.4
)Barretenberg 0.87.4-starknet.1 (install with
bbup --version 0.87.4-starknet.1
ornpm 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/vk
This 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 build
This will create a json file in hello/target/hello.json
Now, generate the corresponding verifying key vk
using barretenberg :
bb write_vk --scheme ultra_honk --oracle_hash keccak -b target/hello.json -o target
Finally, generate a smart contract from the verifying key using the garaga CLI.
garaga gen --system ultra_keccak_zk_honk --vk target/vk
This 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.cairo
The 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_hints
array.
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 --zk
flag 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 vk
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 starknet
in bb commands--system ultra_starknet_honk
or--system ultra_starknet_zk_honk
in 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?