zkkit proof
Generate a zero-knowledge proof from witness and proving key
Description
The proof command wraps snarkjs groth16 prove to generate a zero-knowledge proof. snarkjs performs the cryptographic operations using the witness and proving key.
Under the hood: This command runs snarkjs groth16 prove circuit_0000.zkey outputs/[witness] [proof] [public]
Usage
bash
zkkit proof [circuit-name]Options
--witnessPath to witness file (default: witness.wtns)--zkeyPath to proving key file-o, --outputOutput file path (default: proof.json)
Examples
Generate proof for a circuit:
bash
zkkit proof multiplierSpecify custom witness and output files:
bash
zkkit proof multiplier --witness custom_witness.wtns -o my_proof.jsonOutput
This command generates two files:
proof.json- The zero-knowledge proofpublic.json- Public signals/inputs
Implementation
View how this command works under the hood:
src/commands/proof.js
import { run } from "../utils/exec.js";
export default async function proof(opts = {}) {
const {
witness = "witness.wtns",
proof = "proof.json",
output = "public.json",
} = opts;
await run(
`snarkjs groth16 prove circuit_0000.zkey outputs/${witness} ${proof} ${output}`
);
console.log("✔ Proof generated: proof.json, public.json");
}What it does:
- Accepts witness filename (defaults to
witness.wtns) - Accepts proof output filename (defaults to
proof.json) - Accepts public signals filename (defaults to
public.json) - Uses Groth16 protocol to generate zero-knowledge proof from witness and proving key
- Outputs both the proof and public inputs/outputs as separate JSON files
- The proof is succinct and can be verified quickly without revealing private inputs