A verification-only library that validates inclusion of individual proofs within SNARKtor aggregated proofs. This library does not submit proofs to any EVM blockchain - it only verifies that specific proofs exist within SNARKtor aggregated proofs according to the SNARKtor whitepaper.
The SNARKtor protocol enables decentralized recursive proof aggregation, allowing multiple individual zero-knowledge proofs from any proving system to be combined into a single aggregated proof. This verification library provides the tools to:
- Verify that individual proofs are included in SNARKtor aggregated proofs
- Validate Merkle trees used in the proof aggregation structure
- Parse and handle various proof formats for verification
- Support verification of proofs from multiple proving systems (Groth16, PLONK, STARKs, etc.)
Important: This library is designed for verification only. It does not submit proofs to Telos EVM or any other blockchain.
The library consists of several key components:
- SnarktorVerifier.sol - Verification contract that validates proof inclusion within aggregated proofs
- SnarktorVerificationClient.js - JavaScript client for verification operations
- verification-examples.js - Example integrations showing proof inclusion verification
- Universal Proof Support: Verify inclusion of proofs from any ZK proving system (Groth16, PLONK, STARKs, Bulletproofs, etc.)
- Flexible Input Formats: Handle proofs as hex strings, JSON objects, or binary buffers
- Aggregated Proof Verification: Verify that individual proofs are included in SNARKtor aggregated proofs
- Merkle Tree Operations: Build and verify Merkle trees for proof inclusion
- Read-Only Operations: All functions are verification-only, no blockchain state changes
- Client-Side Verification: Most operations can be performed without blockchain interaction
npm install
const { SnarktorVerificationClient } = require('./src/SnarktorVerificationClient');
// Initialize verification client (read-only)
const client = new SnarktorVerificationClient(
'https://your-evm-provider.com',
contractAddress // No private key needed for verification
);
// Generate proof hash from your proof data
const proofData = { /* Groth16, PLONK, STARK, etc. */ };
const proofInfo = SnarktorVerificationClient.generateProofHash(
proofData,
publicInputs,
verificationKey
);
// Verify that your proof is included in a SNARKtor aggregated proof
const isIncluded = await client.verifyProofInclusion(
proofInfo.proofHash,
aggregatedProofHash,
merkleProof
);
console.log(`Proof included in aggregation: ${isIncluded}`);
// Build merkle tree from proof hashes
const proofHashes = ['0x123...', '0x456...', '0x789...'];
const merkleRoot = SnarktorVerificationClient.buildMerkleTree(proofHashes);
// Generate inclusion proof for specific proof
const merkleProof = SnarktorVerificationClient.generateMerkleProof(proofHashes, 1);
// Verify merkle proof client-side (no blockchain call needed)
const isValid = SnarktorVerificationClient.verifyMerkleProof(
merkleProof.path,
merkleProof.index,
merkleProof.leaf,
merkleRoot
);
The library supports verification of proofs from various systems:
// Groth16 proof verification
const groth16Proof = {
pi_a: ['0x123', '0x456'],
pi_b: [['0x789', '0x012'], ['0x345', '0x678']],
pi_c: ['0x901', '0x234']
};
// PLONK proof verification
const plonkProof = {
commitments: ['0xabc', '0xdef'],
evaluations: ['0x111', '0x222'],
opening_proof: '0x333'
};
// STARK proof verification
const starkProof = {
trace_commitment: '0xstark1',
composition_commitment: '0xstark2',
fri_proof: '0xstark3'
};
// All can be verified using the same interface
const groth16Hash = SnarktorVerificationClient.generateProofHash(groth16Proof, inputs, vk);
const plonkHash = SnarktorVerificationClient.generateProofHash(plonkProof, inputs, vk);
const starkHash = SnarktorVerificationClient.generateProofHash(starkProof, inputs, vk);
This library implements verification aspects of the SNARKtor protocol:
- Base Proofs: Individual proofs that were aggregated by SNARKtor
- Aggregated Proofs: SNARKtor-generated proofs containing multiple base proofs
- Merkle Inclusion: Cryptographic proof that a base proof exists in an aggregated proof
The library uses Merkle trees to verify inclusion of base proofs in aggregated proofs:
- Build trees from proof hashes
- Generate inclusion proofs
- Verify proofs both on-chain and client-side
verifyProofInclusion(baseHash, aggregatedHash, merkleProof)
- Verify that a base proof is included in an aggregated proofverifyMerkleRoot(merkleRoot, proofs)
- Verify Merkle root against proof setgetBaseProof(proofHash)
- Get base proof details (if available)getAggregatedProof(aggregatedHash)
- Get aggregated proof details (if available)isBaseProofAvailable(proofHash)
- Check if base proof data is availableisAggregatedProofAvailable(aggregatedHash)
- Check if aggregated proof data is available
addBaseProofData(proofHash, publicInput, verificationKey)
- Add base proof verification dataaddAggregatedProofData(aggregatedHash, merkleRoot, includedProofs)
- Add aggregated proof verification data
ProofInclusionVerified(baseProofHash, aggregatedHash, verified)
- Proof inclusion verification resultMerkleRootValidated(merkleRoot, isValid)
- Merkle root validation result
verifyProofInclusion(baseHash, aggregatedHash, merkleProof)
- Verify proof inclusionverifyMerkleRoot(merkleRoot, proofs)
- Verify Merkle rootgetBaseProof(proofHash)
- Get proof details (returns null if not available)isBaseProofAvailable(proofHash)
- Check data availabilityisAggregatedProofAvailable(aggregatedHash)
- Check data availability
parseGenericProof(proofData)
- Parse any proof formatgenerateProofHash(proofData, inputs, vk)
- Generate proof hash for verificationvalidateProofStructure(proofData)
- Validate proof structurebuildMerkleTree(proofHashes)
- Build Merkle treegenerateMerkleProof(proofs, index)
- Generate inclusion proofverifyMerkleProof(path, index, leaf, root)
- Verify inclusion proof (client-side)
Run the test suite:
npx hardhat test
The test suite includes:
- Proof inclusion verification for multiple proof types
- Merkle tree operations and validation
- Generic proof parsing and validation
- Client-side verification utilities
- Data availability checks
node examples/verification-integration.js
This example demonstrates:
- Verifying inclusion of proofs from different proving systems (Groth16, PLONK, STARKs, Bulletproofs)
- Parsing various proof formats (hex, JSON, buffers)
- Building Merkle trees from proof hashes
- Verifying proof inclusion in SNARKtor aggregated proofs
- Client-side verification without blockchain calls
The library supports verification of proofs from:
- Groth16: Most common SNARK system
- PLONK: Universal setup SNARK
- STARKs: Post-quantum secure proofs
- Bulletproofs: Range proofs and confidential transactions
- Custom formats: Any JSON or binary proof structure
The library supports configuration through environment variables:
RPC_URL
- EVM-compatible RPC endpoint for verificationCONTRACT_ADDRESS
- Deployed verification contract address
- All verification operations are read-only
- Merkle proofs are validated both on-chain and client-side
- No private keys or sensitive data are required for verification
- Proof data integrity is maintained through cryptographic hashing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details
For questions or issues, please open an issue on the GitHub repository or contact the development team.