Skip to content

KliverAi/Privacy

Repository files navigation

Kliver Privacy

Zero-knowledge proof system for Starknet: Complete toolkit for generating, verifying, and deploying ZK proofs using Noir circuits, Barretenberg, and Garaga.

Noir Barretenberg Starknet


Table of Contents


Overview

Kliver Privacy is a complete zero-knowledge proof infrastructure for Starknet that enables privacy-preserving session validation on-chain.

What it does:

  • Generates zero-knowledge proofs using Noir circuits
  • Deploys UltraHonk verifier contracts to Starknet
  • Verifies proofs on-chain with real transactions
  • Complete end-to-end workflow from circuit to verification

Successful deployment example:

  • Sepolia Contract: 0x06a65b053fc92038862083f38d95898c3018d7860840e5548ec0cfcc2358128a
  • Explorer: View on Starkscan
  • Status: Deployed & Verified

Architecture

Workflow Pipeline

📁 Noir Circuit (circuits/generate-proof/)
    ↓ (generates proof + public inputs)
📄 Proof Files (target/proof, target/vk, target/public_inputs)
    ↓ (Garaga formats for Starknet)
🔗 Calldata (proof_calldata.txt)
    ↓ (sncast calls contract)
🏛️ Starknet Verifier Contract
    ↓ (returns verification result)
✅ On-Chain Verification Success!

Technology Stack

Component Technology Version
Circuit Compiler Noir 1.0.0-beta.6
Proof System Barretenberg (UltraHonk) 0.86.0-starknet.1
Contract Language Cairo 2.x
Verifier Generator Garaga Latest
Deployment Starknet Foundry Latest
Package Manager Poetry Latest

Quick Start

Installation

Automated Installation (Recommended)

# Install all required tools
python deploy_contract.py install-all

# Include local devnet (optional)
python deploy_contract.py install-all --with-devnet

Manual Installation

python deploy_contract.py install-poetry     # Install Poetry
python deploy_contract.py install-python     # Install Python dependencies
python deploy_contract.py install-noir       # Install Noir v1.0.0-beta.6
python deploy_contract.py install-bb         # Install Barretenberg v0.86.0-starknet.1
python deploy_contract.py install-scarb      # Install Scarb (Cairo)
python deploy_contract.py install-foundry    # Install Starknet Foundry

Requirements: Python 3.10+ and internet access.


Deployment

Complete Workflow

The easiest way to deploy everything:

# Deploy contract + generate proof + verify on-chain
poetry run python deploy_contract.py deploy --environment qa --contract verifier

# Test complete verification workflow
poetry run python deploy_contract.py test-verification --environment qa

This will:

  • Build and execute the Noir circuit
  • Generate zero-knowledge proof
  • Deploy verifier contract to Sepolia
  • Generate calldata and verify on-chain
  • Show successful verification results

Pipeline Commands

For more control, use pipeline commands that group related steps:

# 1. Circuit & Proof Generation (Steps 1-4)
poetry run python deploy_contract.py build-proof-pipeline

# 2. Contract Deployment (Steps 5-7)
poetry run python deploy_contract.py deploy-verifier-pipeline --environment qa

# 3. On-Chain Verification (Steps 8-10)
poetry run python deploy_contract.py verify-pipeline --environment qa --use-invoke

Step-by-Step Process

If you want to execute each step individually:

A. Circuit & Proof Generation

# Step 1: Build the Noir circuit
poetry run python deploy_contract.py build-circuit

# Step 2: Execute circuit (generate witness)
poetry run python deploy_contract.py exec-circuit

# Step 3: Generate zero-knowledge proof
poetry run python deploy_contract.py prove-circuit

# Step 4: Generate verification key
poetry run python deploy_contract.py gen-vk

B. Contract Deployment

# Step 5: Generate verifier contract
poetry run python deploy_contract.py gen-verifier

# Step 6: Compile verifier contract
poetry run python deploy_contract.py build-verifier

# Step 7: Deploy to Starknet
poetry run python deploy_contract.py deploy --environment qa --contract verifier

C. On-Chain Verification

# Step 8: Generate calldata for proof
poetry run python deploy_contract.py generate-calldata

# Step 9a: Verify proof on-chain (read-only call)
poetry run python deploy_contract.py verify-onchain --environment qa

# Step 9b: Execute proof verification transaction (creates TX on blockchain)
poetry run python deploy_contract.py invoke-onchain --environment qa

# Step 10: Complete verification test
poetry run python deploy_contract.py test-verification --environment qa

Deployment Options

Flag Description Required
--environment Environment (qa/dev/prod) Yes
--contract Contract name (verifier) For deploy
--skip-circuit Skip circuit build/prove steps No
--skip-vk Skip verification key generation No
--rpc-url Custom RPC URL No
--contract-address Specific contract address For verification
--use-invoke Create real transaction For verify-pipeline
--regenerate-proof Rebuild proof before test For test-verification

Configuration

Edit deployment_config.yml for environment settings:

environments:
  qa:
    name: "Quality Assurance"
    network: "sepolia"
    rpc_url: "https://starknet-sepolia.public.blastapi.io/rpc/v0_8"
    account: "qa"

  prod:
    name: "Production"
    network: "mainnet"
    rpc_url: "https://starknet-mainnet.public.blastapi.io/rpc/v0_8"
    account: "kliver"

Call vs Invoke

  • verify-onchain: Read-only call, doesn't create transaction, free, instant response
  • invoke-onchain: Creates real transaction on blockchain, costs gas, permanently recorded, returns TX hash

Circuit Logic

The Noir circuit implements session validation with zero-knowledge proofs.

Located in: circuits/generate-proof/src/main.nr

What it validates

  • Session Data: Verifies session with up to 40 interactions
  • Hash Computation: Uses Poseidon2 to hash session interactions
  • Range Validation: Ensures random keys are 10-digit numbers (1000000000-9999999999)

Public Inputs

  • random_key: 64-bit random number (10 digits)
  • expected_interactions_hash: Hash of session interactions

Session Structure

struct SessionInteraction {
    id: Field,
    sender: u8,           // 0 or 1
    message: Field,
}

struct SessionData {
    session_id: Field,
    interactions: [SessionInteraction; 40],
}

Verification Flow

  1. Validate random key is in valid range (10 digits)
  2. Compute Poseidon2 hash of all session interactions
  3. Verify computed hash matches expected hash
  4. Generate proof that above constraints hold

Understanding Verification Results

When verification succeeds, you'll see a response array:

Response: [0x0, 0x2, 0x3b9aca17, 0x0, 0x158a0b5b978d173ae46a249d400aef26, ...]

Decoded:

  • [0] 0x0 - Padding
  • [1] 0x2 - Number of public inputs
  • [2] 0x3b9aca17 = 1000000023 - Your random key
  • [3] 0x0 - Padding
  • [4-5] - Expected interactions hash (256-bit split into two 128-bit values)

Development

Local Development Network

# Start local Starknet devnet
make devnet

# Setup accounts
poetry run python deploy_contract.py prepare-accounts

Frontend Application

cd app
bun install && bun run dev

Command Reference

Installation Commands

poetry run python deploy_contract.py install-all [--with-devnet]
poetry run python deploy_contract.py install-poetry
poetry run python deploy_contract.py install-python
poetry run python deploy_contract.py install-noir
poetry run python deploy_contract.py install-bb
poetry run python deploy_contract.py install-scarb
poetry run python deploy_contract.py install-foundry

Pipeline Commands (Recommended)

poetry run python deploy_contract.py build-proof-pipeline
poetry run python deploy_contract.py deploy-pipeline --environment qa
poetry run python deploy_contract.py deploy-verifier-pipeline --environment qa
poetry run python deploy_contract.py verify-pipeline --environment qa
poetry run python deploy_contract.py verify-pipeline --environment qa --use-invoke

Individual Step Commands

# Circuit & Proof
poetry run python deploy_contract.py build-circuit
poetry run python deploy_contract.py exec-circuit
poetry run python deploy_contract.py prove-circuit
poetry run python deploy_contract.py gen-vk

# Contract Deployment
poetry run python deploy_contract.py gen-verifier
poetry run python deploy_contract.py build-verifier
poetry run python deploy_contract.py declare-verifier --environment qa
poetry run python deploy_contract.py deploy --environment qa --contract verifier

# Verification
poetry run python deploy_contract.py generate-calldata
poetry run python deploy_contract.py verify-onchain --environment qa
poetry run python deploy_contract.py invoke-onchain --environment qa
poetry run python deploy_contract.py test-verification --environment qa

Troubleshooting

Common Issues

Missing proof files

# Generate proof first
poetry run python deploy_contract.py prove-circuit

No contract address found

# Deploy contract first
poetry run python deploy_contract.py deploy --environment qa --contract verifier

Transaction fails with gas issues

# Add max-fee parameter
poetry run python deploy_contract.py invoke-onchain --environment qa --max-fee 1000000000000000

Prerequisites missing

# Check what's missing
poetry run python deploy_contract.py deploy --environment qa --contract verifier

# Install missing tools
python deploy_contract.py install-all

Useful Links


More Information

To learn more about Kliver and our platform, visit:

kliver.ai


Built with Noir, Barretenberg, Garaga, and Starknet

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors