Crate spawn_zk_snarks

Crate spawn_zk_snarks 

Source
Expand description

§spawn-zk-snarks

A Rust library that provides a robust implementation of Zero-Knowledge Proofs (ZKPs) using the Groth16 proving system. Built on top of the arkworks ecosystem, it offers both high performance and EVM compatibility.

§Features

  • Groth16 Proving System

    • Generate proving and verification keys
    • Create verifiable proofs for given witnesses
    • Verify proofs with the generated verification keys
    • Efficient constraint system implementation
  • Circuit Implementation

    • Arithmetic circuit support
    • Constraint generation
    • Witness computation
    • Flexible circuit configuration

§Quick Start

use spawn_zk_snarks::{Groth16Setup, ArithmeticCircuit};
use ark_bn254::Fr;
use ark_ff::One;
 
// Setup phase
let setup = Groth16Setup::new(3, 2)?;
 
// Generate proof
let inputs = vec![Fr::one()];
let witness = vec![Fr::one(), Fr::one()];
let proof = setup.prove(&inputs, &witness)?;
 
// Verify proof
let is_valid = setup.verify(&proof, &inputs)?;
assert!(result);

§Performance

Based on benchmark results:

proof generation    time:   [1.3244 ms 1.3519 ms 1.3931 ms]
proof verification  time:   [760.30 µs 762.93 µs 765.25 µs]
evm conversion     time:   [289.96 ns 291.12 ns 292.43 ns]

For detailed benchmark results, see BENCHMARKS.md.

§Security Considerations

  • Uses the battle-tested Groth16 proving system
  • Built on the arkworks cryptographic library
  • Constant-time operations for core cryptographic functions
  • Regular security audits recommended before production use

Structs§

ArithmeticCircuit
Basic arithmetic circuit for ZKP
Groth16Setup
Contains all necessary parameters for the Groth16 proving system.

Enums§

CircuitError
Errors that can occur during circuit operations
Groth16Error
Represents all possible errors that can occur during Groth16 operations.

Functions§

generate_verifier_contract
Generates a Solidity verifier contract for the given verification key.
proof_to_calldata
Converts a Groth16 proof and public inputs into EVM-compatible calldata.