Welcome to my first project using Noir for generating zero knowledge proofs!
This project demonstrates a complete workflow for building, compiling, and verifying zero knowledge circuits using Noir. It serves as both a learning resource and a practical example for beginners.
- Language: Noir (
.nrfile extension) - Proving Backend: Barretenberg
- Proving Scheme: ultra_honk
- Project Type: Binary crate
- Creator: Aztec Network
fn main(x: Field, y: pub Field) {
assert(x != y);
}
#[test]
fn test_circuit() {
main(1, 2);
}This circuit proves that you know a private value (x) that is not equal to a public value (y), without revealing x.
- Private Input
x: Only known to the prover - Public Input
y: Known to both prover and verifier - Assertion:
assert(x != y)creates a constraint - Proof: Generates a zero knowledge proof that the constraint is satisfied
simple_circuit/
βββ README.MD # This file - Project overview
βββ Basics.MD # Detailed guide to Noir basics & concepts
βββ NOIR_GUIDE.md # Complete guide to Noir language
βββ Nargo.toml # Project manifest
βββ Prover.toml # Input values for testing
βββ src/
β βββ main.nr # Main circuit entry point
βββ 0. Installation/
β βββ README.MD # Installation & setup guide for macOS/Windows
βββ target/
βββ simple_circuit.json # Compiled circuit bytecode
βββ simple_circuit.gz # Witness file
βββ vk # Verification key
βββ proof # Generated proof
βββ public_inputs # Public inputs
Follow the Installation Guide for:
- macOS or Windows setup
- Rust, Nargo, and Barretenberg installation
- Verification of all tools
Read Basics.MD to learn:
- Variable types in Noir
- Input visibility (private vs public)
- Testing functions
- Complete workflow (check β compile β execute β prove β verify)
Check NOIR_GUIDE.md for:
- Language features and syntax
- Common patterns
- Best practices
- Resources and documentation
# 1. Check circuit structure
nargo check
# 2. Compile to ACIR
nargo compile
# 3. Execute to generate witness
nargo execute
# 4. Generate verification key
bb write_vk -b ./target/simple_circuit.json -o ./target
# 5. Generate proof
bb prove -b ./target/simple_circuit.json -w ./target/simple_circuit.gz -o ./target
# 6. Verify proof
bb verify -k ./target/vk -p ./target/proof| File | Purpose |
|---|---|
| README.MD (this file) | Project overview and quick start |
| Basics.MD | Detailed Noir basics, types, and workflow |
| NOIR_GUIDE.md | Comprehensive Noir language guide |
| 0. Installation/README.MD | Step-by-step installation for macOS & Windows |
- Validates circuit structure
- Creates
Prover.tomlfor inputs
- Compiles Noir to ACIR (Arithmetic Circuit IR)
- Creates circuit bytecode
- Executes circuit with test inputs
- Generates witness file (
simple_circuit.gz) - Stores witness in
/target
- Generates verification key from circuit
- Creates
vkfile for proof verification
- Uses Barretenberg to create proof
- Combines circuit + witness
- Outputs
proofandpublic_inputs
- Verifies proof off-chain
- Uses verification key
- Confirms proof validity without executing circuit
- DSL for ZKPs: Designed specifically for zero knowledge proofs
- Rust-like Syntax: Familiar to modern programmers
- Type-Safe: Strong type system prevents errors
- Backend Agnostic: Can compile to different proving systems
- Private vs Public: Control input visibility
- Assertions: Create constraints that must be satisfied
- Witness: The satisfying assignment that proves the constraint
- Proof: Cryptographic evidence without revealing witness
- Ultra-Honk Scheme: Modern proving system
- High Performance: Optimized for production use
- Multi-threaded: Uses parallel processing for efficiency
- Aztec-Built: Developed by Aztec for their privacy network
[package]
name = "simple_circuit"
type = "bin"
authors = ["Your Name"]
compiler_version = "0.21.0"- Type:
binmeans binary crate (executable) - Dependencies: Add libraries here as needed
x = "1"
y = "2"- Private Inputs: Values for
x,z, etc. - Public Inputs: Values for
pubparameters - Updated after each
nargo execute
fn main(x: Field, y: pub Field) {
assert(x != y);
}- Entry Point: Main circuit logic
- Functions: Define circuit behavior
- Tests: Validate circuit logic
- Noir Book: https://noir-lang.org/docs/
- Aztec Network: https://aztec.network/
- GitHub Repository: https://github.com/noir-lang/noir
- Discord: Aztec Network community
- GitHub Discussions: Ask questions
- Forum: https://forum.aztec.network/
- β Understand basic circuit structure
- β Learn input visibility (private vs public)
- β Generate your first proof
- π² Write custom constraints
- π² Build more complex circuits
- π² Use cryptographic functions (SHA256, ECDSA)
- π² Create reusable code patterns
- π² Optimize circuit size
- π² Build library crates
- π² Integrate with smart contracts
- π² Create proving backends
- π² Contribute to Noir ecosystem
This is a learning project for exploring:
- Zero knowledge proof fundamentals
- Noir programming language
- Barretenberg proving system
- ZK circuit development workflow
Feel free to fork, modify, and learn!
- All examples use the BN254 elliptic curve (Barretenberg default)
- Proofs are verified using ultra_honk scheme
- Generated proofs are non-interactive and publicly verifiable
- This project uses test inputs for demonstration
Last Updated: October 2025
For detailed guides, see: