Zero-Knowledge Proofs
Tenzro uses Groth16 SNARKs on BN254 for efficient zero-knowledge proofs, with GPU-accelerated proving and hybrid ZK-in-TEE execution for maximum verifiability.
ZK Proof System
- Groth16: Succinct SNARKs with constant-size proofs (~128 bytes)
- BN254 Curve: ~128-bit security level, efficient pairing operations
- GPU Acceleration: 10-100x faster proof generation with CUDA/Metal
- Hybrid ZK-in-TEE: Combine cryptographic proofs with hardware attestation
Pre-Built Circuits
InferenceVerificationCircuit
Proves that AI inference was computed correctly without revealing model weights or input data.
Public inputs: model_hash, input_hash, output_hash
Private inputs: model_weights, input_data, computation_trace
Private inputs: model_weights, input_data, computation_trace
SettlementProofCircuit
Proves payment settlement occurred correctly with proper fee calculation.
Public inputs: settlement_id, amount, fee
Private inputs: payer_signature, payee_address, timestamp
Private inputs: payer_signature, payee_address, timestamp
IdentityProofCircuit
Proves identity ownership without revealing private keys or full DID document.
Public inputs: did_hash, credential_hash
Private inputs: private_key, credential_proof
Private inputs: private_key, credential_proof
Proof Generation
Basic Proof
use tenzro_zk::{CircuitType, ProofSystem, PublicInputs};
// Setup (one-time, generates proving/verifying keys)
let proof_system = ProofSystem::setup(
CircuitType::InferenceVerification,
)?;
// Generate proof
let public_inputs = PublicInputs {
model_hash: vec![0x12, 0x34, ...],
input_hash: vec![0x56, 0x78, ...],
output_hash: vec![0xAB, 0xCD, ...],
};
let witness = /* private computation trace */;
let proof = proof_system.prove(
&public_inputs,
&witness,
).await?;
// Proof is ~128 bytes (constant size)
GPU-Accelerated Proving
use tenzro_zk::{GpuProvingEngine, CompressionLevel};
let engine = GpuProvingEngine::new()?;
// Batch proof generation (up to 100 proofs)
let proofs = engine.batch_prove(
circuit_type,
&public_inputs_batch,
&witnesses_batch,
CompressionLevel::Medium,
).await?;
// Performance:
// - CPU: ~1 proof/second
// - GPU (NVIDIA H100): ~100 proofs/second
// - Compression reduces proof size by 30-70%
Proof Verification
// Verify proof on-chain or via API
let is_valid = proof_system.verify(
&proof,
&public_inputs,
).await?;
if is_valid {
println!("✓ Proof verified");
// Release escrow, accept inference result, etc.
} else {
println!("✗ Proof invalid");
// Reject result, slash provider, etc.
}
Hybrid ZK-in-TEE
Combine ZK proofs with TEE attestation for maximum security and verifiability:
use tenzro_zk::HybridZkTee;
use tenzro_tee::IntelTdxProvider;
// Generate proof inside TEE
let hybrid_system = HybridZkTee::new(
proof_system,
IntelTdxProvider::new()?,
);
let (proof, tee_attestation) = hybrid_system
.prove_in_tee(
circuit_type,
&public_inputs,
&witness,
)
.await?;
// Verifier checks:
// 1. ZK proof is cryptographically valid
// 2. TEE attestation confirms proof was generated in genuine TEE
// 3. TEE measurements match expected values
let valid = hybrid_system.verify_hybrid(
&proof,
&tee_attestation,
&public_inputs,
).await?;
Benefits of ZK-in-TEE
- Dual Verification: Both cryptographic proof and hardware attestation
- Protected Setup: Proving keys generated and stored in TEE
- Confidential Computation: Witness data never leaves TEE
- Auditability: TEE measurements prove correct prover software
Proof Compression
GPU proving engine supports multi-level compression for bandwidth-constrained environments:
enum CompressionLevel {
None, // ~128 bytes, no compression
Light, // ~90 bytes, 30% reduction, minimal CPU overhead
Medium, // ~65 bytes, 50% reduction, balanced
Heavy, // ~40 bytes, 70% reduction, higher CPU cost
}
// Example: compress 100 proofs
let compressed_proofs = engine.batch_prove(
circuit_type,
&inputs,
&witnesses,
CompressionLevel::Heavy,
).await?;
// Result: 40 bytes * 100 = 4 KB (vs 128 bytes * 100 = 12.8 KB uncompressed)
// Verification time: +10-20% vs uncompressed
Proof Types
Tenzro supports multiple proof systems (with Groth16 as the default):
Groth16 (Default)
- Constant-size proofs (~128 bytes)
- Fast verification (~1-5ms)
- Requires trusted setup (per circuit)
PlonK (Experimental)
- Universal setup (same parameters for all circuits)
- Larger proofs (~400-800 bytes)
- Slower verification (~10-20ms)
Halo2 (Experimental)
- No trusted setup required
- Recursive proof composition
- Higher proving cost
STARK
- Transparent (no trusted setup)
- Post-quantum secure
- Large proof size (~100-200 KB)
Use Cases
1. Verifiable AI Inference
// Provider generates inference + proof
let (result, proof) = model_provider.infer_with_proof(
model_id,
input,
).await?;
// User verifies before accepting result
let valid = zk_system.verify(
CircuitType::InferenceVerification,
&proof,
&PublicInputs {
model_hash: model.hash(),
input_hash: hash(&input),
output_hash: hash(&result),
},
).await?;
if valid {
// Accept result, release payment
} else {
// Reject result, slash provider
}
2. Private Transactions
// Prove transaction validity without revealing amounts
let proof = zk_system.prove(
CircuitType::PrivateTransfer,
&PublicInputs {
sender_commitment: commit(&sender),
receiver_commitment: commit(&receiver),
nullifier: nullify(&prev_state),
},
&Witness {
sender_private_key,
amount,
receiver_address,
},
).await?;
// Validators verify without knowing sender, receiver, or amount
3. Credential Verification
// Prove KYC tier without revealing full identity
let proof = zk_system.prove(
CircuitType::IdentityProof,
&PublicInputs {
min_kyc_tier: 2,
age_requirement: 18,
},
&Witness {
did: "did:tenzro:human:...",
kyc_tier: 3,
age: 25,
credential_proof,
},
).await?;
// Service provider verifies requirements met without seeing full DID
Web Verification API
# Verify ZK proof via HTTP
curl -X POST http://localhost:8080/api/verify/zk-proof \
-H "Content-Type: application/json" \
-d '{
"proof": "0xabc123...",
"public_inputs": ["0x123", "0x456"],
"circuit_type": "InferenceVerification"
}'
# Response
{
"valid": true,
"circuit_type": "InferenceVerification",
"verification_time_ms": 45
}
Performance Benchmarks
Circuit: InferenceVerificationCircuit
Constraints: 1,000,000
CPU Proving (Intel Xeon):
- Single proof: 1.2s
- Batch (10): 12s
GPU Proving (NVIDIA H100):
- Single proof: 120ms (10x faster)
- Batch (100): 1.5s (80x faster)
Verification:
- CPU: 3-5ms
- Proof size: 128 bytes (uncompressed)
- Proof size: 40 bytes (heavy compression)