zkkit setup:groth
Perform Groth16 trusted setup ceremony
Description
The setup:groth command wraps snarkjs groth16 setup to perform Phase 2 of the trusted setup, generating circuit-specific proving and verification keys for the Groth16 proving system.
Under the hood: This command runs snarkjs operations:
snarkjs groth16 setup [r1cs] [ptau] circuit_0000.zkeysnarkjs zkey export verificationkey
Usage
bash
zkkit setup:groth [circuit-name]Options
--ptauPath to powers of tau file--contributionsNumber of contributions (default: 1)
Examples
Run Groth16 setup for a circuit:
bash
zkkit setup:groth multiplierSpecify custom powers of tau:
bash
zkkit setup:groth multiplier --ptau powersOfTau28_hez_final_15.ptauOutput Files
circuit_final.zkey- Final proving keyverification_key.json- Verification key
About Groth16
Groth16 is one of the most efficient zero-knowledge proof systems, producing very small proofs with fast verification times. However, it requires a circuit-specific trusted setup.
Implementation
View how this command works under the hood:
src/commands/groth.js
import { run } from "../utils/exec.js";
export default async function groth(opts = {}) {
const { verification = "verification_key.json" } = opts;
await run(
"snarkjs groth16 setup outputs/schema.r1cs pot12_final.ptau circuit_0000.zkey"
);
await run(
`snarkjs zkey export verificationkey circuit_0000.zkey ${verification}`
);
console.log("✔ Groth16 setup completed");
}What it does:
- Accepts verification key output filename (defaults to
verification_key.json) - Step 1: Performs Groth16-specific setup using R1CS and Powers of Tau
- Step 2: Generates the proving key (
circuit_0000.zkey) - Step 3: Exports the verification key from the zkey file
- Creates circuit-specific keys required for proof generation and verification