zkkit verify
Verify a zero-knowledge proof using the verification key
Description
The verify command wraps snarkjs groth16 verify to verify a zero-knowledge proof. snarkjs performs the cryptographic verification using the verification key and public inputs.
Under the hood: This command runs snarkjs groth16 verify [verification_key] [public] [proof]
Usage
bash
zkkit verify [circuit-name]Options
--proofPath to proof file (default: proof.json)--publicPath to public signals file (default: public.json)--vkeyPath to verification key (default: verification_key.json)
Examples
Verify a proof with default files:
bash
zkkit verify multiplierVerify with custom file paths:
bash
zkkit verify multiplier --proof my_proof.json --public my_public.jsonOutput
The command will output either:
- ✓ Proof is valid - Verification successful
- ✗ Proof is invalid - Verification failed
Implementation
View how this command works under the hood:
src/commands/verify.js
import { run } from "../utils/exec.js";
export default async function verify(opts = {}) {
const {
verification = "verification_key.json",
output = "public.json",
proof = "proof.json",
} = opts;
const result = await run(
`snarkjs groth16 verify ${verification} ${output} ${proof}`
);
console.log(
result.includes("OK") ? "✔ Proof verified" : "✘ Verification failed"
);
}What it does:
- Accepts verification key filename (defaults to
verification_key.json) - Accepts public signals filename (defaults to
public.json) - Accepts proof filename (defaults to
proof.json) - Uses Groth16 verification algorithm to check proof validity
- Checks if the output contains "OK" to determine success
- Returns verification status without accessing private inputs
- Verification is fast and can be done by anyone with the public files
Note
Verification is fast and can be performed by anyone with the verification key and public signals, without needing access to the private inputs (witness).