(NOTE: This project is still IN PROGRESS)
A zero-knowledge proof system for verifying financial covenants in leaseback transactions using Noir, Garaga, and Starknet. This application allows companies to prove compliance with financial covenants without revealing sensitive financial data.
This project demonstrates a privacy-preserving financial verification system with:
- Noir Circuit: Validates financial covenants (debt-to-equity ratio, interest coverage, etc.)
- In-Browser Proving: Generate ZK proofs directly in the browser using Barretenberg
- Starknet Verification: Submit and verify proofs on Starknet blockchain
- Next.js Frontend: Modern web interface for proof generation and verification
├── circuits/ # Noir ZK circuit for financial covenant validation
├── contracts/ # Cairo smart contracts for on-chain verification
├── app/ # Next.js frontend application
└── scripts/ # Setup and utility scripts
The system verifies the following financial covenants:
- Debt-to-Equity Ratio: debt/equity ≤ 2.5
- Interest Coverage Ratio: EBITDA/interest ≥ 1.5
- Debt Service Coverage Ratio: cashflow/lease_payment ≥ 1.2
- Current Ratio: current_assets/current_liabilities ≥ 1.0
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:
If you encounter issues installing Garaga on your operating system, Docker installation is preferred. See the [Docker guide](https://www.notion.so/Steps-to-Run-the-Scaffold-Garaga-Demo-in-Docker-20e8ba8810a480eb8817f89f2168f21f?source=copy_link) for reference.
Note: We need specific versions of Noir, Barretenberg, and Garaga to work well together. If you experience issues with code generation, proving, or verification, first ensure you have the correct package versions.
### E2E Testing & On-Chain Verification
For end-to-end testing with proof generation and on-chain verification:
**Option 1: Docker (Recommended)**
```sh
# Build container (one-time)
docker build -t zk-leaseback .
# Run E2E tests in container
docker run -it -v $(pwd):/app zk-leaseback bash
cd /app/scripts && bun run e2e:devSee DOCKER_GUIDE.md for complete Docker workflow and Sepolia deployment.
Option 2: Starknet Sepolia Testnet (Local Setup)
# Follow the comprehensive guide
cat SEPOLIA_SETUP.md
# Or use the quick deployment script
cd scripts && chmod +x ../deploy.sh && bash ../deploy.shOption 3: Local Devnet
make devnet
cd scripts && bun run e2e:devSee SEPOLIA_SETUP.md for full setup instructions and DEPLOYMENT_GUIDE.md for deployment steps.
Run the automated setup script from the project root:
chmod +x scripts/setup-app.sh
./scripts/setup-app.shThis will:
- Compile the Noir circuit
- Generate the verification key
- Copy circuit artifacts to the app
- Install app dependencies
- Setup WASM files for in-browser proving
Then start the development server:
cd app
npm run devcd circuits
nargo compileThe circuit implements financial covenant validation logic. Sample inputs are in Prover.toml for testing.
bb write_vk -b ./target/leaseback.json -o ./target/cd ../app
# Install dependencies
npm install
# Copy circuit artifacts
cp ../circuits/target/leaseback.json public/circuit.json
cp ../circuits/target/vk public/vk.bin
# Copy WASM files for in-browser proving
chmod +x scripts/copy-wasm.sh
./scripts/copy-wasm.sh
# Start development server
npm run devOpen http://localhost:3000 to use the application.
For complete proof generation and on-chain verification:
# Install E2E dependencies
cd scripts
bun install
# Option A: Use Starknet Sepolia Testnet (Recommended)
cp .env.example .env
# Update VERIFIER_CONTRACT_ADDRESS in .env with your deployed contract
bun run e2e:dev
# Option B: Use Local Devnet
# First start devnet in another terminal: make devnet
bun run e2e:devFor detailed Sepolia deployment instructions, see SEPOLIA_SETUP.md.
- Scaffold Garaga - Original template
- DOCKER_GUIDE.md - Docker setup and deployment
- SEPOLIA_SETUP.md - Comprehensive Sepolia testnet setup
- DEPLOYMENT_GUIDE.md - Deployment reference guide
E2E testing and deployment infrastructure:
e2e/e2e.ts- Complete end-to-end test orchestration- Proof generation from circuit witness
- On-chain verification via Starknet RPC
- Support for both devnet and Sepolia testnet
package.json- E2E dependencies and npm scriptsdeploy.sh- Automated deployment script for SepoliaDockerfile- Complete build environment for CI/CD.env.example- Environment configuration template
- Gates: ~11,662
- Max Supported: 524,288 gates (2^19)
- Public Inputs: Financial statement root
- Public Outputs: Financial statement root + nullifier hash
- Financial data remains private (never revealed on-chain)
- Nullifier prevents double-spending/double-factoring
- Merkle tree commitment for financial statements
- Zero-knowledge proof of covenant compliance
cd circuits
nargo testAfter modifying the circuit:
# Recompile circuit
cd circuits
nargo compile
# Regenerate VK
bb write_vk -b ./target/leaseback.json -o ./target/
# Regenerate verifier contract
make gen-verifiercd app
npm run build
npm startcd app
chmod +x scripts/copy-wasm.sh
./scripts/copy-wasm.shcp circuits/target/leaseback.json app/circuits/circuit.json
cp circuits/target/vk app/circuits/vk.bin- Ensure circuit artifacts are up to date
- Check that WASM files are in
app/circuits/wasm/ - Verify input values meet covenant requirements
- Noir: Zero-knowledge proof language and compiler
- Barretenberg: Ultra Honk proof system backend
- Garaga: Starknet proof verification library
- Next.js: React framework for the frontend
- Starknet: Layer 2 blockchain for verification
- Cairo: Smart contract language for Starknete verifier contract in
contracts/verifier/based on your circuit.
In a separate terminal:
make devnetmake accounts-filemake declare-verifier
make deploy-verifierUpdate the contract address in app/src/components/LeasebackProofForm.tsx:
const contractAddress = "0x..."; // Your deployed contract address
1. Build the app with `bun run build`
1. Finally we can run the app: `bun run dev`
## Useful links
- 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/