zk-mini is a minimal zero-knowledge proof (ZKP) framework implemented in Rust, designed to demonstrate the basic principles behind zero-knowledge proofs. This project includes custom implementations for circuits and constraint systems and supports simple examples such as addition, multiplication, and Merkle tree proofs.
Features Circuit Components: Support for addition, multiplication, and hash gates. Merkle Tree Proofs: Demonstrates how ZKPs can verify membership in a Merkle tree. Modular Hashing: Allows custom hash functions to be injected into the circuit. Serialization: Saves proofs and circuits to .bin files for inspection. Installation To get started, clone the repository and build the project with Rust’s package manager, cargo.
bash Copy code
git clone https://github.com/yourusername/zk-mini.git cd zk-mini
cargo build --release Usage The project includes a main program that demonstrates generating and verifying ZK proofs for various examples, including addition, multiplication, and Merkle tree membership.
To run the examples:
bash Copy code cargo run --release Running Examples Running cargo run --release will generate proof files for each example:
Addition Proof: Generates an addition proof and saves it to addition_proof.bin. Multiplication Proof: Generates a multiplication proof and saves it to multiplication_proof.bin. Custom Hashing Proof: Demonstrates custom hash functions, saved to custom_hash_proof.bin. Merkle Tree Proof: Verifies a transaction in a Merkle tree and saves the proof to merkle_proof.bin. Viewing Proof Files The .bin files generated by the program contain serialized proof data. To inspect these files:
Hex Editor: Open the files in a hex editor (like Hex Fiend for macOS). Rust Deserialization: Use the provided Rust code to deserialize and print the contents of these files for easier inspection. File Structure src/ main.rs: Entry point, demonstrating usage of the framework. circuit.rs: Circuit component with modular gates and customizable hash functions. r1cs.rs: Defines the constraint system and checks if constraints are satisfied. merkle.rs: Provides Merkle tree functionality. hash_functions.rs: Allows defining custom hash functions to be used within the circuit.