spawn_zk_snarks/
lib.rs

1//! # spawn-zk-snarks
2//! 
3//! A Rust library that provides a robust implementation of Zero-Knowledge Proofs (ZKPs) 
4//! using the Groth16 proving system. Built on top of the arkworks ecosystem, it offers 
5//! both high performance and EVM compatibility.
6//! 
7//! ## Features
8//! 
9//! - **Groth16 Proving System**
10//!   - Generate proving and verification keys
11//!   - Create verifiable proofs for given witnesses
12//!   - Verify proofs with the generated verification keys
13//!   - Efficient constraint system implementation
14//! 
15//! - **Circuit Implementation**
16//!   - Arithmetic circuit support
17//!   - Constraint generation
18//!   - Witness computation
19//!   - Flexible circuit configuration
20//! 
21//! ## Quick Start
22//! 
23//! ```rust
24//! use spawn_zk_snarks::{Groth16Setup, ArithmeticCircuit};
25//! use ark_bn254::Fr;
26//! use ark_ff::One;
27//! 
28//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
29//! // Setup phase
30//! let setup = Groth16Setup::new(3, 2)?;
31//! 
32//! // Generate proof
33//! let inputs = vec![Fr::one()];
34//! let witness = vec![Fr::one(), Fr::one()];
35//! let proof = setup.prove(&inputs, &witness)?;
36//! 
37//! // Verify proof
38//! let is_valid = setup.verify(&proof, &inputs)?;
39//! assert!(result);
40//! # Ok(())
41//! # }
42//! ```
43//! 
44//! ## Performance
45//! 
46//! Based on benchmark results:
47//! 
48//! ```text
49//! proof generation    time:   [1.3244 ms 1.3519 ms 1.3931 ms]
50//! proof verification  time:   [760.30 µs 762.93 µs 765.25 µs]
51//! evm conversion     time:   [289.96 ns 291.12 ns 292.43 ns]
52//! ```
53//! 
54//! For detailed benchmark results, see [BENCHMARKS.md](BENCHMARKS.md).
55//! 
56//! ## Security Considerations
57//! 
58//! - Uses the battle-tested Groth16 proving system
59//! - Built on the arkworks cryptographic library
60//! - Constant-time operations for core cryptographic functions
61//! - Regular security audits recommended before production use
62
63#![cfg_attr(docsrs, feature(doc_cfg))]
64#![deny(missing_docs)]
65#![deny(rustdoc::broken_intra_doc_links)]
66
67mod circuits;
68mod groth16;
69mod evm;
70
71pub use circuits::{ArithmeticCircuit, CircuitError};
72pub use groth16::{Groth16Setup, Groth16Error};
73pub use evm::{proof_to_calldata, generate_verifier_contract};
74
75#[cfg(test)]
76mod tests;