Complete guide to building privacy-preserving applications on Solana with zero-knowledge proofs.
Install the zkHub SDK via npm:
npm install @zkhub/sdkInitialize the zkHub client in your application:
import { ZkHub } from '@zkhub/sdk';
const zkHub = new ZkHub({
network: 'devnet',
rpcUrl: 'https://api.devnet.solana.com'
});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.
Governance without identity exposure
One person, one airdrop
18+ compliance for marketplaces
// 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);
}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.
// 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]);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.
// 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);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.
// 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);GameFi & Metaverse Privacy
Build provably fair blockchain games with hidden state, verifiable randomness, and anti-cheat mechanisms powered by zero-knowledge proofs.
// 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
});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.
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.
// 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);Privacy-Preserving Wallet Operations
Secure wallet operations with zero-knowledge proofs, ensuring that transactions are verified without revealing sensitive information.
// 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);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>