Quick Start Guide
Get started with zkkit by building your first zero-knowledge circuit
Overview
This guide walks you through creating your first zero-knowledge proof. You'll write a circuit in Circom, and zkkit will orchestrate circom and snarkjs to compile, prove, and verify it.
π What you'll learn:
- β’ Write a Circom circuit (multiplier example)
- β’ Use zkkit to wrap circom compilation
- β’ Generate proofs with snarkjs via zkkit commands
- β’ Verify proofs cryptographically
Initialize Your Project
Start by creating a new zkkit project. This sets up the necessary directory structure and configuration files.
zkkit init my-first-zk-projectcd my-first-zk-projectπ Project Structure Created:
my-first-zk-project/ βββ circuits/ # Your circuit files go here βββ build/ # Compiled circuits output βββ zkkit.config.json # Project configuration βββ package.json # Node.js dependencies
Create Your Circuit
Create a simple multiplier circuit file in the circuits/ directory.
Create circuits/multiplier.circom:
pragma circom 2.0.0;
// This circuit proves that you know two numbers (a, b)
// that multiply to give c, without revealing a or b
template Multiplier() {
// Private inputs (secret)
signal input a;
signal input b;
// Public output
signal output c;
// Constraint: c must equal a * b
c <== a * b;
}
component main = Multiplier();π‘ What's happening here?
The circuit defines private inputs (a, b) that remain secret, and a public output (c). Anyone can verify that you know values of a and b that multiply to c, without ever seeing a or b!
Compile the Circuit
Compile your circuit into the R1CS constraint system and WASM witness generator.
zkkit compile circuits/multiplier.circomβ Files Generated:
build/multiplier.r1cs- Constraint systembuild/multiplier.wasm- Witness generatorbuild/multiplier.sym- Symbol information
Prepare Input Data
Create an input file with your secret values. Let's prove we know that 3 Γ 11 = 33.
Create input.json:
{
"a": "3",
"b": "11"
}π Privacy Note:
The values "3" and "11" are our private inputs. They will never be revealed in the proofβonly the fact that we know numbers that multiply to 33.
Generate Witness
Compute the witness by executing the circuit with your input values.
zkkit witness multiplier input.jsonβ Generated:
witness.wtns - Contains all intermediate wire values
Run Trusted Setup
Perform the trusted setup ceremony to generate proving and verification keys. We'll use Groth16 for this example.
zkkit setup:groth multiplierβ Keys Generated:
circuit_final.zkey- Proving key (used to create proofs)verification_key.json- Verification key (used to verify proofs)
β‘ One-Time Setup:
You only need to run the trusted setup once per circuit. The verification key can be shared publicly and reused for all proofs of this circuit.
Generate the Proof
Create a zero-knowledge proof using the witness and proving key.
zkkit proof multiplierβ Proof Created:
proof.json- The zero-knowledge proofpublic.json- Public signals (output: 33)
π Success!
You now have a cryptographic proof that you know two numbers that multiply to 33, without revealing what those numbers are!
Verify the Proof
Verify that the proof is valid using the verification key and public signals.
zkkit verify multiplierExpected Output:
β Proof is valid - Verification successful
π What Just Happened?
The verifier confirmed that your proof is mathematically validβyou DO know numbers that multiply to 33βwithout ever learning that those numbers are 3 and 11!
Complete Command Summary
Here's the entire workflow in one place:
# 1. Initialize project zkkit init my-first-zk-project cd my-first-zk-project # 2. Create circuit (circuits/multiplier.circom) # [Create the circuit file as shown above] # 3. Compile circuit zkkit compile circuits/multiplier.circom # 4. Create input file (input.json) # [Create the input file as shown above] # 5. Generate witness zkkit witness multiplier input.json # 6. Run trusted setup zkkit setup:groth multiplier # 7. Generate proof zkkit proof multiplier # 8. Verify proof zkkit verify multiplier
Next Steps
Now that you've completed your first zero-knowledge proof, you can:
π Explore Commands
Learn more about each zkkit command and its options
π§ Try Different Circuits
Experiment with more complex circuits like hash functions or Merkle trees
β‘ Optimize Performance
Learn about circuit optimization techniques for faster proofs
π Deploy to Production
Integrate zkkit proofs into your blockchain or web applications
Troubleshooting
Command not found?
Make sure zkkit is installed globally:
npm install -g zkkitCompilation errors?
Verify that Rust and Circom are properly installed and in your PATH
Proof generation fails?
Ensure the witness file was generated successfully before creating the proof