A complete, production-ready Zero-Knowledge Proof (ZKP) system using Noir and Barretenberg, implementing age verification for voting eligibility.
Demonstrate how someone can prove they're 18+ years old without revealing their actual age or birth year - using a complete Zero-Knowledge Proof system with cryptographic proof generation and verification.
zkp-voting-demo/
└── age_verification/ # Main ZKP project
├── src/main.nr # The ZKP circuit (Noir code)
├── Prover.toml # Prover inputs (private + public)
├── Verifier.toml # Verifier inputs (public only)
├── COMMANDS.md # Complete command reference
├── README.md # Usage guide
├── QUICKSTART.md # Quick start guide
├── ARCHITECTURE.md # System architecture & concepts
├── ACIR_ANALYSIS.md # Advanced: ACIR format analysis
└── ZKP_TRUST_MODEL.md # Understanding security and trust
cd age_verification
# See all available commands
cat COMMANDS.md
# Run the complete workflow
nargo test && nargo compile && nargo execute && \
bb prove --scheme ultra_honk -b ./target/age_verification.json -w ./target/age_verification.gz -o ./target/ && \
bb write_vk -b ./target/age_verification.json -o ./target/ && \
bb verify -k ./target/vk -p ./target/proof1. Usage Guide
Start here to learn:
- Installation (Noir + Barretenberg)
- Running the complete workflow
- Testing the circuit
- Modifying inputs
- Understanding the output
Complete command reference:
- Step-by-step commands
- File flow diagrams
- Command summary tables
- Quick reference
Deep dive into:
- System architecture diagrams
- Front-end vs Back-end
- Key ZKP concepts explained
- Circuit design principles
- Data flow visualization
- Barretenberg integration
4. ACIR Analysis (Advanced)
Understanding the compiled circuit:
- ACIR file structure
- How Noir code becomes arithmetic gates
- Barretenberg's usage of ACIR
- Circuit complexity analysis
Understanding security and trust:
- Why proofs cannot be tampered
- How server trusts client-generated proofs
- Comparison with biometric authentication
- Real-world ZKP applications
- Read the Usage Guide
- Review Commands Reference
- Experiment with different inputs in
Prover.toml
- Study the circuit code:
src/main.nr - Read Architecture Guide
- Modify the circuit to add new constraints
- Run
nargo testto verify your changes
- Understand ACIR output:
target/age_verification.json(see ACIR_ANALYSIS.md) - Analyze cryptographic proofs and verification keys
- Deploy to blockchain platforms with Solidity verifiers
- Build your own ZKP circuits
| Concept | Description | Where to Learn |
|---|---|---|
| Circuit | Mathematical representation of the problem | src/main.nr |
| Arithmetization | Converting logic to math constraints | ARCHITECTURE.md |
| Witness | Private + public inputs that satisfy constraints | Prover.toml |
| ACIR | Intermediate Representation (backend-agnostic) | target/*.json |
| Front-End | Circuit definition (Noir DSL) | src/main.nr |
| Back-End | Proof generation & verification (Barretenberg) | ARCHITECTURE.md |
| Proof | Cryptographic proof of correct computation | target/proof |
| Verification Key | Public key for verifying proofs | target/vk |
# Install noirup
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
# Reload your shell
source ~/.zshrc # or source ~/.bashrc
# Install Noir (stable version)
noirup -v 1.0.0-beta.3
# Verify installation
nargo --version# Install bbup
curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/heads/master/barretenberg/bbup/install | bash
# Reload your shell
source ~/.zshrc # or source ~/.bashrc
# Install Barretenberg (auto-detects compatible version)
bbup
# Verify installation
bb --versionNote: bbup automatically detects your Noir version and installs the compatible Barretenberg version.
- Solidity: For blockchain verifiers
- Web3 tools: For blockchain integration
Beyond age verification, this pattern can be used for:
-
Anonymous Voting
- Prove eligibility without revealing identity
- Our example shows age verification
-
Private Credentials
- Prove qualifications without revealing details
- E.g., "I have a degree" without showing which one
-
Compliance Proofs
- Prove regulatory compliance
- Without revealing sensitive business data
-
Income Verification
- Prove income range (e.g., $50k-$100k)
- Without revealing exact salary
-
Credit Scores
- Prove score > 700
- Without revealing exact score
┌──────────────────────────────────────────────────┐
│ FRONT-END (Circuit Definition) │
│ Noir │
│ Noir DSL → Arithmetization → Circuit → ACIR │
│ ↓ ↓ ↓ ↓ │
│ main.nr Constraints main() func .json │
└────────────────────┬─────────────────────────────┘
│
│ ACIR (Intermediate Representation)
│
┌────────────────────┴─────────────────────────────┐
│ BACK-END (Proving System) │
│ Barretenberg │
│ Witness → Proof Generation → Verification │
│ ↓ ↓ ↓ │
│ Inputs ZK Proof Valid/Invalid │
│ (~14KB) (< 1 second) │
└──────────────────────────────────────────────────┘
This is a complete system with:
- ✅ Circuit definition (Noir)
- ✅ Cryptographic proof generation (Barretenberg)
- ✅ Proof verification (Barretenberg)
- ✅ Production-ready
See ARCHITECTURE.md for detailed diagrams!
cd age_verification
# Run all tests
nargo test
# Test specific scenarios
# Edit src/main.nr to uncomment failure cases
nargo testTest cases included:
- Valid voter (30 years old)
- Exactly 18 years old
- Edge case (100 years old)
- Under 18 (failure test - commented)
- Future birth year (failure test - commented)
| Metric | Value |
|---|---|
| Circuit Complexity | Simple (17 ACIR opcodes, 2778 gates) |
| Constraints | 3 main assertions |
| Test Cases | 3 passing + 3 failure examples |
| Lines of Code | ~100 (heavily commented) |
| Proof Size | ~14KB |
| Verification Key Size | ~1.8KB |
| Proof Generation Time | ~15 seconds |
| Verification Time | < 1 second |
| Learning Time | 1-2 hours |
After working through this project, you'll understand:
-
ZKP Fundamentals
- What are Zero-Knowledge Proofs?
- How do they maintain privacy?
- When to use them?
-
Circuit Design
- How to define constraints
- Private vs public inputs
- Arithmetization process
-
Noir Language
- Syntax and structure
- Testing circuits
- Compilation to ACIR
-
System Architecture
- Front-end vs Back-end separation
- Role of Intermediate Representation
- Proof generation workflow
- Barretenberg proving system
-
Practical Application
- Complete cryptographic proof lifecycle
- Real-world use cases
- Integration patterns
- Production deployment
- Circom: Alternative ZKP DSL
- Cairo: StarkNet's language
- ZoKrates: Ethereum-focused toolkit
This is an educational project. Contributions welcome:
- Improve documentation
- Add more examples
- Create tutorials
- Fix issues
Educational project for learning Zero-Knowledge Proofs.
- Noir Team: For the amazing DSL
- Aztec: For ZKP infrastructure
- ZKP Community: For advancing privacy technology
cd age_verification
# See available commands
cat COMMANDS.md
# Run complete workflow
nargo test && nargo compile && nargo execute && \
bb prove --scheme ultra_honk -b ./target/age_verification.json -w ./target/age_verification.gz -o ./target/ && \
bb write_vk -b ./target/age_verification.json -o ./target/ && \
bb verify -k ./target/vk -p ./target/proofDocumentation:
- Usage Guide - How to use
- Commands Reference - Complete command guide
- Architecture Guide - How it works