This is a Noir+Garaga+Starknet starter with in-browser proving and a step-by-step guide how to:
- Generate and deploy UltraHonk proof verifier contract to Starknet devnet
- Add state to your privacy preserving app
- Add wallet connection and deploy to public testnet
Ensure you have node.js >= 20 installed.
Bun is used for package management, install it with:
make install-bunFor compiling Noir circuits and generating proofs we need specific versions of Aztec packages:
make install-noir
make install-barretenbergStarknet toolkit comes in a single bundle via asdf (the following command will install it if you don't have it):
make install-starknetWe also need to install a tool for spawning local Starknet chain:
make install-devnetFinally we need to install Garaga. Make sure you have Python 3.10 in your system. You may also need to start a separate Python virtual environment for this to work. You can do that with python3.10 -m venv garaga-venv && source garaga-venv/bin/activate. Then install with:
make install-garagaIf you encountered installing garaga failed in your operating system, use docker install is preferred, here's the guide for your reference(https://www.notion.so/Steps-to-Run-the-Scaffold-Garaga-Demo-in-Docker-20e8ba8810a480eb8817f89f2168f21f?source=copy_link)
Note that we need specific versions of Noir, Barretenberg, and Garaga to work well together. If you are experiencing any issues with code generation, proving, and verification — first of all ensure you have the correct package versions.
This repo is organized in layers: each app iteration is a new git branch.
Follow the steps and checkout the necessary branch:
master— in-browser proof generation and stateless proof verification in devnet1-app-logic— more involved Noir circuit logic2-app-state— extend onchain part with a storage for nullifiers3-testnet— deploy to public Starknet testnet and interact via wallet
First of all we need to build our Noir circuit:
make build-circuitSample inputs are already provided in Prover.toml, execute to generate witness:
make exec-circuitGenerate verification key:
make gen-vkNow we can generate the verifier contract in Cairo using Garaga:
make gen-verifierLet's start our local development network in other terminal instance:
make devnetYou now need to start a new terminal window. Initialize the account we will be using for deployment:
make accounts-fileFirst we need to declare out contract ("upload" contract code):
make declare-verifierNow we can instantiate the contract class we obtained (you might need to update the command in Makefile):
make deploy-verifierGreat! Now let's copy necessary artifacts:
make artifactsPrepare the app and its requirements so you can run it. Go to the app folder and:
- Update the contract address in the app code (change App.tsx).
- Make sure you have
tscinstalled. If not, you can install it withbun add -d typescript@next. - Install vite with
npm install -D vite - Build the app with
bun run build - Finally we can run the app:
bun run dev
- Noir quickstart https://noir-lang.org/docs/getting_started/quick_start
- Garaga docs https://garaga.gitbook.io/garaga/deploy-your-snark-verifier-on-starknet/noir
- Starknet.js docs https://starknetjs.com/docs/guides/intro
- Starknet quickstart https://docs.starknet.io/quick-start/overview/
- Sncast 101 https://foundry-rs.github.io/starknet-foundry/starknet/101.html
- Cairo book https://book.cairo-lang.org/