zkkit setup:trusted
Perform trusted setup ceremony for PLONK or other proving systems
Description
The setup:trusted command wraps snarkjs powersoftau commands to perform the Powers of Tau ceremony (Phase 1 of trusted setup). This generates common reference parameters used by multiple circuits.
Under the hood: This command orchestrates multiple snarkjs operations:
snarkjs powersoftau new bn128 12 pot12_0000.ptausnarkjs powersoftau contributesnarkjs powersoftau prepare phase2snarkjs powersoftau verify
Usage
bash
zkkit setup:trusted [circuit-name]Options
--protocolSpecify protocol (plonk, fflonk) - default: plonk--ptauPath to powers of tau file
Examples
Run trusted setup for a circuit:
bash
zkkit setup:trusted multiplierUse FFLONK protocol:
bash
zkkit setup:trusted multiplier --protocol fflonkOutput Files
proving_key.zkey- Key for generating proofsverification_key.json- Key for verifying proofs
Implementation
View how this command works under the hood:
src/commands/trustedSetup.js
import { run } from "../utils/exec.js";
export default async function trustedSetup(
entropy = "default-random-entropy-" + Date.now()
) {
console.log("running trusted setup");
await run("snarkjs powersoftau new bn128 12 pot12_0000.ptau");
await run(
"snarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau",
entropy + "\n" // Entropy sent to stdin
);
await run(
"snarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau"
);
await run("snarkjs powersoftau verify pot12_final.ptau");
console.log("✔ Trusted setup completed");
}What it does:
- Accepts entropy string parameter (auto-generates if not provided)
- Step 1: Creates initial Powers of Tau file using BN128 curve with size 12
- Step 2: Contributes entropy to the ceremony for randomness
- Step 3: Prepares the final Powers of Tau file for Phase 2
- Step 4: Verifies the trusted setup parameters are valid
- Uses snarkjs commands to perform the multi-step ceremony