Skip to content

Repository files navigation

Garaga Workshop

A garaga workshop, featuring Groth16 proof generation and on-chain verification and a small ui. Features complete circuit compilation, client-side proving, and onchain verify

resources link: https://hackmd.io/@IrxgNBpSQKSNBTpimFhtYA/ByEsI1Kjll

Quick Setup Commands

# 1. Install dependencies
pnpm install

# 2. Setup Python environment
~/.pyenv/versions/3.10.12/bin/python -m venv .venv
source .venv/bin/activate
pip install garaga python-dotenv

# 3. Build circuits
pnpm setup:circuits

# 4. Generate verifiers
pnpm generate:verifiers

# 5. Deploy to Sepolia (requires .secrets file)
pnpm deploy:sepolia

# 6. Start app
pnpm dev

Prerequisites

Required Tools:

# Node.js tools for circuit compilation
npm install -g circom snarkjs

# Starknet development tools
curl https://get.starkli.sh | sh && starkliup
curl -L https://docs.swmansion.com/scarb/install.sh | bash

# Python 3.10 + Garaga for verifier generation
curl https://pyenv.run | bash
pyenv install 3.10.12 && pyenv local 3.10.12
pip install garaga

Sepolia Deployment (Optional):

Create .secrets file with your Sepolia credentials:

SEPOLIA_ACCOUNT_ADDRESS=0x...
SEPOLIA_PRIVATE_KEY=0x...
SEPOLIA_RPC_URL=https://starknet-sepolia.g.alchemy.com/...

Circuit Implementation

Age Verification Circuit (circuits/circom/age_verification.circom)

Private Inputs: age, salt
Public Outputs: hash
Constraints:
  - age >= 18
  - hash = Poseidon(age, salt)

Features:

  • Hash Function: Poseidon for cryptographic security
  • Privacy: Age remains private, only hash is public
  • Verification: Prove you're 18+ without revealing exact age
  • Randomness: Salt prevents hash table attacks

📁 Project Structure

├── apps/web/                    # React frontend
│   ├── src/
│   │   ├── components/          # UI components
│   │   ├── context/             # Starknet wallet context
│   │   └── config/              # Contract addresses
│   └── public/circom/           # Circuit artifacts (WASM, zkey, vkey)
├── circuits/circom/             # Age verification circuit
├── verifiers/                   # Garaga-generated Cairo contracts
├── scripts/                     # Automation scripts
└── setup-fresh-clone.sh         # Complete setup script

🛠 Available Scripts

# Setup and building
pnpm setup:circuits              # Build circuits with all artifacts
pnpm circuits:copy               # Copy verification key to frontend
pnpm generate:verifiers          # Generate Garaga Cairo contracts

# Deployment
pnpm deploy:sepolia             # Deploy to Sepolia testnet
pnpm deploy:devnet              # Deploy to local devnet
pnpm deploy:mainnet             # Deploy to mainnet

# Development
pnpm dev                        # Start development server
pnpm build                      # Build for production
pnpm clean                      # Clean all artifacts and restart

How to Use:

  1. Open: Visit http://localhost:5174 (after running setup)
  2. Input: Enter age (≥18) and salt for privacy
  3. Generate Proof: Click to create ZK proof (takes 2-5 seconds)
  4. Connect Wallet: Use Argent X or Braavos wallet on Sepolia
  5. Verify: Submit proof to Starknet for on-chain verification
  6. Result: View transaction hash and verification status

some stuff

1. snarkjs.groth16.fullProve() → Standard Groth16 proof
2. snarkJsProofIntoGaraga() → Convert to Garaga format
3. garaga.getGroth16CallData() → Generate massive calldata (~2000 entries)

Circuit Compilation

Circom → R1CS + WASM + Witness → Powers of Tau → zkey → Verification Key

Error Messages

  • "Garaga unreachable": Run pnpm circuits:copy to copy verification key
  • "Verification failed": Ensure deployed verifier matches frontend verification key
  • "Transaction failed": Check wallet is connected to correct network (Sepolia)

📚 Resources

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages