Quarks-ZK
Rust implementation of Quarks zkSNARKs (Lakonia, Kopis, Xiphos) with pluggable polynomial commitment schemes.
[]
= "0.1.2"
Overview
This library implements the Quarks proof system from Quarks: Quadruple-efficient transparent zkSNARKs (Setty, Lee).
Provided constructions:
- Lakonia, Kopis, Xiphos SNARKs
- Kopis-PC and Dory-PC polynomial commitment schemes
- Generic
PolynomialCommitmentSchemetrait for backend interchangeability
SNARKs
| SNARK | Prover | Verifier | Proof Size |
|---|---|---|---|
| Lakonia | O(n log n) | O(n) | O(log n) |
| Kopis | O(n log n) | O(√n) | O(√n) |
| Xiphos | O(n log n) | O(log n) | O(log n) |
Polynomial Commitment Schemes
| PCS | Commitment | Proof Size | Verify |
|---|---|---|---|
| Kopis-PC | O(1) | O(√n) | O(√n) |
| Dory-PC | O(1) | O(log n) | O(log n) |
Requirements
- Rust 1.70+
- Cargo
Build
# Clone
# Build
# Build with all features
Tests
# Run all tests
# Run specific test module
# Run tests with output
# Run integration tests
Benchmarks
# Run all benchmarks
# Run specific benchmark
# Available benchmarks:
# - pcs_comparison : Compare Kopis-PC vs Dory-PC
# - snark_end_to_end : Full SNARK pipeline
# - kopis_pc : Kopis-PC operations
# - commitments : Commitment schemes
# - polynomial : Polynomial operations
# - sumcheck : Sumcheck protocol
# - r1cs : R1CS operations
Benchmark Results
| Operation | Kopis-PC | Dory-PC |
|---|---|---|
| Setup (vars=10) | 511 µs | 124 ms |
| Prove (n=256) | 108 ms | 78 ms |
Installation
Add to your Cargo.toml:
[]
= "0.1.4"
Usage
use ;
use thread_rng;
Generic PCS
use PolynomialCommitmentScheme;
use ;
use Fr;
Project Structure
quarks-zk/
├── src/
│ ├── lib.rs # Public API
│ ├── traits/pcs.rs # PolynomialCommitmentScheme trait
│ ├── snark/
│ │ ├── lakonia.rs # Lakonia SNARK
│ │ ├── kopis.rs # Kopis SNARK
│ │ └── xiphos.rs # Xiphos SNARK
│ ├── kopis_pc/ # Kopis-PC (O(√n) verify)
│ ├── dory_pc/ # Dory-PC (O(log n) verify)
│ ├── commitments/ # BIPP, IPP, Pedersen
│ ├── r1cs/ # R1CS constraint system
│ ├── sumcheck/ # Sumcheck protocol
│ └── polynomial/ # Multilinear polynomials
├── benches/ # Criterion benchmarks
├── examples/ # Usage examples
├── tests/ # Integration tests
└── research/ # Paper reference
API Documentation
Core Traits
PolynomialCommitmentScheme
Generic trait for polynomial commitment schemes:
Dory-PC Rerandomization (v0.1.2+)
Support for zero-knowledge commitment reuse (Vega paper):
use ;
// Setup includes h_gt generator for rerandomization
let params = setup;
// Original commitment
let commitment = commit;
// Rerandomize for unlinkable reuse
let r_delta = rand;
let rerandomized = commitment.rerandomize;
// Both commit to same value, but are unlinkable
assert_ne!;
SNARK APIs
Lakonia SNARK
use ;
let snark = setup;
let proof = snark.prove;
assert!;
Kopis SNARK (with preprocessing)
use KopisSnark;
let snark = setup;
let computation_commit = snark.preprocess;
let proof = snark.prove;
assert!;
Xiphos SNARK (Quadruple-efficient)
use ;
// With Dory-PC for O(log n) verification
let snark = setup;
let computation_commit = snark.preprocess;
let proof = snark.prove;
assert!;
Examples
# Run proof generation example
References
- Quarks: Quadruple-efficient transparent zkSNARKs - Setty, Lee
- Dory: Efficient, Transparent arguments for Generalised Inner Products - Lee
- Spartan: Efficient and general-purpose zkSNARKs - Setty
See research/PAPER.md for the complete paper reference.
Disclaimer
This is research software. It has not been audited and should not be used in production environments. The implementation is provided for educational and research purposes only.
- No security audit has been performed
- The code may contain bugs or vulnerabilities
- APIs may change without notice
- Use at your own risk
If you require production-ready cryptographic software, consider using audited implementations.
License
MIT - See LICENSE