zk402-groth16
Groth16 proof system implementation for zk402 using arkworks.
Overview
This crate provides a concrete implementation of the zk402_core::ProofSystem trait using the Groth16 zero-knowledge proof system via the arkworks library ecosystem. It implements an EdDSA signature verification circuit that proves knowledge of a private key without revealing the signature itself.
Features
- Groth16 proving - Efficient, constant-size proofs
- EdDSA-in-circuit - Signature verification inside the SNARK
- BLS12-381 curve - Well-supported, production-ready elliptic curve
- Arkworks integration - Built on the arkworks zkSNARK library suite
Circuit Statement
The circuit proves knowledge of a secret key sk such that:
- The public key derived from
skmatches a known address skproduced a valid EdDSA signature over the payment data (amount, recipient, nonce, etc.)
The signature itself is never revealed, only the proof of its validity.
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
= "0.1.0"
Example:
use ;
use Groth16ProofSystem;
// Load proving and verifying keys
let pk = load_proving_key?;
let vk = load_verifying_key?;
// Create witness data
let witness = Witness ;
// Generate proof
let proof = prove?;
// Verify proof
let valid = verify?;
assert!;
Key Generation
Circuit parameters and proving/verifying keys must be generated via a trusted setup ceremony. This crate provides utilities for:
- Running a local trusted setup (for testing)
- Loading keys from binary files
- Serializing/deserializing keys
Warning: Use production trusted setup ceremonies for mainnet deployments, not local test setups.
Performance
Typical benchmarks on modern hardware:
- Proving time: ~500ms - 2s (depending on witness complexity)
- Verification time: ~5-20ms
- Proof size: 192 bytes (constant)
Security Considerations
- The circuit implements EdDSA (not ECDSA) for efficiency
- Public inputs include the sender address
from(not private in v1) - Nonce reuse is prevented by on-chain tracking
- Trusted setup parameters must come from a secure ceremony
Related Crates
zk402-core- Core types and traitszk402-prover- High-level prover interfaceark-groth16- Underlying Groth16 implementationark-ed-on-bls12-381- EdDSA curve
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.