- This repo is the experimental repo to test the integrations with the
OpenBanking.nr
library:openbanking.nr-circuit
: https://github.com/attested-frontiers/openbanking.nr-circuitopenbanking.nr-server
(API server forOpenBanking API
): https://github.com/attested-frontiers/openbanking.nr-server
cd circuits
sh sh circuit_test.sh
A comprehensive boilerplate that seamlessly integrates Noir zero-knowledge circuits with Hardhat for Ethereum smart contract development. This template provides everything you need to build, test, and deploy ZK applications with enterprise-grade CI/CD pipelines.
- π Zero-Knowledge Circuit Development - Write and test Noir circuits with full TypeScript integration
- β‘ Hardhat Integration - Leverage Hardhat's powerful development environment for smart contracts
- π§ͺ Comprehensive Testing - TypeScript tests for both circuits and smart contracts with dynamic proof generation
- π CI/CD Pipeline - Automated testing, building, and validation
- π¦ Multiple Proof Formats - Handle proofs in JSON and binary
- π Deployment Ready - Hardhat Ignition integration for seamless deployment
- π Code Quality - ESLint, Solhint, Prettier, Commitlint + Husky for comprehensive code standards
This template demonstrates a complete SimpleCounter example that showcases:
- Circuit Development: Create a Noir circuit that verifies arithmetic operations
- Proof Generation: Generate zero-knowledge proofs using the
bb
proving system - Smart Contract Verification: Verify proofs on-chain using auto-generated Solidity verifiers
- Full-Stack Integration: TypeScript tests that create, verify, and submit proofs dynamically
- Production Deployment: Deploy and interact with your ZK application on Ethereum testnets
Before getting started, ensure you have:
- Node.js (v18 or later) and Yarn
- Noir toolchain - Install via noirup
- Barretenberg (
bb
) - Usually installed with Noir, or install separately - Git for version control
# Install Noir toolchain
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup
# Verify installations
nargo --version
bb --version
-
Clone and Install
git clone <repository-url> cd noir-hardhat-template yarn install
-
Build the Circuit
yarn circuit:build
-
Test Everything
# Test the Noir circuit yarn circuit:test # Test smart contracts with proof verification yarn contracts:test
-
Generate and Verify Proofs
# Generate witness and verification key yarn circuit:witness yarn circuit:vk # Create and verify a proof yarn circuit:prove yarn circuit:verify
noir-hardhat-template/
βββ circuit/ # Noir circuit source code
β βββ src/main.nr # Main circuit logic (SimpleCounter)
β βββ Nargo.toml # Circuit configuration
β βββ Prover.toml # Proving parameters
β βββ target/ # Compiled circuit artifacts
βββ contracts/ # Solidity smart contracts
β βββ SimpleCounter.sol # Main contract with ZK verification
β βββ VerifierKeccak.sol # Auto-generated proof verifier
βββ test/ # TypeScript test suites
β βββ SimpleCounter.ts # Comprehensive integration tests
βββ ignition/ # Hardhat Ignition deployment modules
β βββ modules/
β βββ SimpleCounter.ts # Deployment configuration
βββ .github/workflows/ # CI/CD pipeline configuration
βββ hardhat.config.ts # Hardhat configuration
yarn circuit:build # Compile Noir circuit
yarn circuit:test # Run circuit tests
yarn circuit:witness # Generate witness from inputs
yarn circuit:vk # Generate verification key
yarn circuit:prove # Generate zero-knowledge proof
yarn circuit:verify # Verify generated proof
yarn circuit:solidity_verifier # Generate Solidity verifier contract
yarn contracts:compile # Compile Solidity contracts
yarn contracts:test # Run smart contract tests
yarn contracts:deploy # Deploy to Sepolia testnet
yarn commitlint # Validate commit messages
yarn commitlint:last # Check last commit message
yarn lint # Run ESLint on TypeScript files
yarn lint:fix # Auto-fix ESLint issues
yarn format # Format code with Prettier
yarn format:check # Check formatting without changes
yarn lint:all # Run linting and format check
This template includes comprehensive linting and formatting tools to maintain code quality:
- Configured with TypeScript-specific rules and best practices
- Integrates with Prettier for consistent formatting
- Catches potential bugs and enforces coding standards
- Run with
yarn lint
or auto-fix withyarn lint:fix
- Enforces Solidity best practices and security patterns
- Configured with recommended rules for modern Solidity development
- Run with
npx hardhat check
- Auto-generated verifier contracts are excluded from linting
- Ensures consistent code style across TypeScript, Solidity, JSON, and Markdown
- Configured with sensible defaults for each file type
- Run with
yarn format
or check withyarn format:check
- Automatically runs linting and formatting on staged files
- Prevents committing code that doesn't meet quality standards
- Powered by Husky and lint-staged
The CI pipeline includes dedicated jobs for:
- TypeScript linting
- Solidity linting
- Formatting verification
- Commit message validation
Currently, there are no dedicated linting tools for Noir. However:
- VSCode users can install the
vscode-noir
extension for syntax highlighting and LSP support - NeoVim users can use the
noir-nvim
plugin - The Language Server Protocol (LSP) provides basic error checking via
nargo lsp
Our GitHub Actions pipeline ensures code quality and functionality across all components:
- π Commit Validation - Enforces conventional commit standards on all PRs and pushes
- β¨ TypeScript Linting - ESLint checks for code quality and potential bugs
- π Solidity Linting - Solhint enforces best practices and security patterns
- π¨ Format Check - Prettier ensures consistent code formatting
- π§ Circuit Build - Compiles Noir circuits and caches artifacts
- π§ͺ Circuit Testing - Runs all circuit tests with Noir toolchain
- π Proof Generation & Verification - Full prove/verify cycle validation
- π Contract Compilation - Compiles Solidity contracts with optimizations
- β‘ Integration Testing - End-to-end tests with proof verification on contracts
The SimpleCounter demonstrates a complete ZK application workflow:
fn main(x: Field, y: pub Field, z: pub Field) {
assert((x != y) & (y != z));
}
#[test]
fn test_main() {
main(1, 2, 1);
}
This circuit implements a uniqueness constraint verification:
- Private Input (
x
): A secret value known only to the prover - Public Inputs (
y
,z
): Values that are publicly known and verified - Constraint: Proves that
x
is different fromy
ANDy
is different fromz
- Use Case: Demonstrates how to prove knowledge of a unique value without revealing it
- Stores a counter value on-chain
- Accepts zero-knowledge proofs of uniqueness constraints
- Verifies proofs using the auto-generated Solidity verifier
- Increments the counter only when valid proofs are submitted
- Dynamically generates proofs with different combinations of
x
,y
,z
values - Demonstrates proof format conversion (binary β JSON)
- Verifies end-to-end integration between uniqueness circuits and smart contracts
- Shows how private values can remain hidden while proving constraints
Configure your deployment environment:
# Set your private key and RPC URL
npx hardhat vars set SEPOLIA_PRIVATE_KEY
npx hardhat vars set SEPOLIA_URL_RPC
npx hardhat vars set ETHERSCAN_API_KEY
yarn contracts:deploy
The deployment uses Hardhat Ignition for:
- β Reproducible deployments
- β Automatic verification on Etherscan
- Write your circuit in
circuit/src/main.nr
- Test circuit logic with
yarn circuit:test
- Generate verifier contract with
yarn circuit:solidity_verifier
- Write smart contract tests in TypeScript
- Run full test suite with
yarn contracts:test
- Deploy and verify on testnet
- Noir Documentation - Learn zero-knowledge circuit development
- Hardhat Documentation - Master Ethereum development
- Barretenberg - Understanding the proving system
Contributions are welcome! Please ensure:
- Follow conventional commit standards (enforced by our CI)
- Add tests for new features
- Update documentation as needed
- All CI checks pass
This project is licensed under the MIT License. See LICENSE for details.
Built with β€οΈ for the Noir and Ethereum communities