zkHub Documentation

Complete guide to building privacy-preserving applications on Solana with zero-knowledge proofs.

Quick Start

Installation

Install the zkHub SDK via npm:

npm install @zkhub/sdk

Basic Setup

Initialize the zkHub client in your application:

import { ZkHub } from '@zkhub/sdk';

const zkHub = new ZkHub({
  network: 'devnet',
  rpcUrl: 'https://api.devnet.solana.com'
});

Core Modules

zkID Module

Privacy-Preserving Identity Verification

Verify identity attributes without revealing personal data. Perfect for age verification, citizenship proofs, and credential checks with on-chain SBT generation for verified results.

Key Features:

  • Proof of Personhood - Verify unique human without identity exposure
  • Proof of Age - Confirm minimum age without revealing birthdate
  • Proof of Country - Verify citizenship without disclosing which country
  • On-chain SBT Generator - Soulbound tokens for verification results

Use Cases:

Anonymous Voting

Governance without identity exposure

Anti-Sybil Airdrops

One person, one airdrop

Age-Restricted Access

18+ compliance for marketplaces

Example Code:

// Prove user is over 18
const ageProof = await zkHub.zkID.proveAge({
  minimumAge: 18,
  privateData: userBirthdate
});

// Verify on-chain and mint SBT
const result = await zkHub.verify(ageProof);
if (result.valid) {
  const sbt = await zkHub.zkID.mintSBT(result);
  console.log('SBT minted:', sbt.address);
}

zkCompliance Module

Financial Privacy & Regulatory Compliance

Enable compliant DeFi applications without compromising user privacy. Prove KYC status and blacklist clearance without exposing personal information to smart contracts.

Key Features:

  • KYC Proof - Verify user completed KYC without revealing identity
  • Blacklist Verification - Prove user not on sanctions lists
  • Anti-Fraud Protection - Detect fraudulent activity with privacy

Example Code:

// Prove KYC compliance
const kycProof = await zkHub.zkCompliance.proveKYC({
  provider: 'kyc-provider-id',
  userData: encryptedUserData
});

// Prove not on blacklist
const blacklistProof = await zkHub.zkCompliance.proveNotBlacklisted({
  checkLists: ['OFAC', 'EU-Sanctions']
});

// Combine proofs for compliance
const combined = await zkHub.aggregate([kycProof, blacklistProof]);
Revolutionary

zkTrading Module

First-of-Its-Kind on Solana

Revolutionary private trading infrastructure for DEXs and trading bots. Execute trades without exposing positions, protect against MEV, and maintain privacy while ensuring solvency.

Revolutionary Features:

  • Proof of Solvency - Prove sufficient balance without exposing amount
  • Private Limit Orders - Submit orders with encrypted price/amount (only hash visible)
  • Off-Chain Compute - Heavy computation off-chain, ZK verification on-chain
  • MEV Resistance - Anti-front-running through zero-knowledge proofs
Game Changer: This module brings institutional-grade privacy to Solana DeFi, enabling use cases previously impossible on public blockchains.

Example Code:

// Create private limit order
const order = await zkHub.zkTrading.createPrivateOrder({
  tokenPair: ['SOL', 'USDC'],
  amount: 1000, // encrypted
  price: 150,   // encrypted
  side: 'buy'
});

// Prove solvency without exposing balance
const solvencyProof = await zkHub.zkTrading.proveSolvency({
  requiredAmount: order.amount,
  privateBalance: userBalance
});

// Submit order with solvency proof
await zkHub.zkTrading.submitOrder(order, solvencyProof);
Future-Proof

zkAI Module

Verifiable AI Computation

Prove AI inference correctness without revealing the model or input data. A rare and future-proof solution for trustless AI on Solana.

Key Capabilities:

  • Verify AI output came from specific model without revealing the model
  • Private inference - compute on sensitive data without exposure
  • On-chain AI agents with verifiable decision-making
  • Game AI fairness - prove AI isn't cheating

Example Code:

// Run private ML inference
const inference = await zkHub.zkAI.runInference({
  model: 'fraud-detection-v2',
  privateInput: transactionData,
  publicOutput: true
});

// Generate proof of correct computation
const proof = await zkHub.zkAI.generateProof(inference);

// Verify on-chain
const verified = await zkHub.verify(proof);
console.log('AI computation verified:', verified.valid);

zkGame Module

GameFi & Metaverse Privacy

Build provably fair blockchain games with hidden state, verifiable randomness, and anti-cheat mechanisms powered by zero-knowledge proofs.

Gaming Features:

  • Private Actions - Hide player moves while proving validity
  • Fair RNG - Verifiable randomness for loot drops and outcomes
  • Anti-Cheat Proof - Prove game actions follow rules
  • Tamper-Proof Leaderboards - Scores with zero-knowledge verification

Example Code:

// Generate fair random number
const rng = await zkHub.zkGame.generateFairRNG({
  seed: playerSeed,
  commitment: gameCommitment
});

// Make private game move
const move = await zkHub.zkGame.proveValidMove({
  privateState: playerHand,
  publicState: gameState,
  action: 'attack'
});

// Submit to leaderboard with proof
await zkHub.zkGame.submitScore({
  score: 9500,
  proof: scoreProof
});
Killer Feature

zkAggregator

Unified Multi-Proof Verification

The killer feature: Aggregate multiple ZK SNARK proofs into a single unified proof. Dramatically reduce on-chain compute costs and enable complex multi-proof applications.

Why It's Revolutionary:

  • 90% Cost Reduction - Verify once instead of multiple times
  • Complex Applications - Combine identity, solvency, and compliance proofs
  • Faster Execution - Single on-chain verification transaction
  • Composable - Mix and match any zkHub module proofs
Real-World Example:

A DeFi launchpad requires: (1) age verification, (2) proof of funds, (3) whitelist eligibility. Instead of verifying 3 separate proofs on-chain, zkAggregator combines them into 1 final proof. The dApp only needs to verify once, saving 90% on compute costs and making Solana even faster.

Example Code:

// Generate multiple proofs
const ageProof = await zkHub.zkID.proveAge({ minimumAge: 18 });
const fundsProof = await zkHub.zkTrading.proveSolvency({ amount: 1000 });
const whitelistProof = await zkHub.zkID.proveWhitelist({ list: 'early-access' });

// Aggregate all proofs into one
const aggregated = await zkHub.aggregate([
  ageProof,
  fundsProof,
  whitelistProof
]);

// DApp verifies single proof - 90% cost savings!
const verified = await launchpad.verifyEligibility(aggregated);

zkWallet Module

Privacy-Preserving Wallet Operations

Secure wallet operations with zero-knowledge proofs, ensuring that transactions are verified without revealing sensitive information.

Key Features:

  • Private Transactions - Hide transaction details while proving validity
  • Secure Wallet Access - Protect wallet access with zero-knowledge proofs
  • Multi-Sig Wallet Support - Verify multi-signature transactions without revealing keys
  • Anti-Phishing Protection - Detect phishing attempts with privacy

Example Code:

// Prove wallet balance
const balanceProof = await zkHub.zkWallet.proveBalance({
  requiredAmount: 1000,
  privateBalance: userBalance
});

// Verify transaction without revealing details
const transactionProof = await zkHub.zkWallet.proveTransaction({
  transactionData: encryptedTransactionData
});

// Submit transaction with proof
await zkHub.zkWallet.submitTransaction(transactionProof);

API Reference

Core API Methods

zkHub.verify(proof)

Verify any ZK proof on-chain

Returns: Promise<{ valid: boolean, data: any }>

zkHub.aggregate(proofs[])

Combine multiple proofs into one

Returns: Promise<AggregatedProof>

zkHub.[module].generate(params)

Generate proof for specific module

Returns: Promise<Proof>

Resources