Skip to main content

Usage

zisk-verifier verifies ZisK STARK proofs natively, without the prover. This page covers adding the crate, verifying a proof saved by cargo-zisk prove, verifying proofs from custom setups and aggregates under their own key, and verifying a proof inside a ZisK guest.

Overview​

The crate verifies vadcop_final proofs and their compressed (--minimal) form, for every hash family: Poseidon1, Poseidon2 and blake3. The proof names its family and stage, and the crate picks the verifier.

It does not verify final SNARK proofs (pilfflonk or PLONK). Verify those with Proof::verify from the SDK, or on-chain with the Solidity verifier.

A crate version verifies the proofs of the ZisK release of the same version: version 1.4.0-alpha carries the 1.4.0-alpha release keys. A proof is never verified under the key it carries.

Cargo.toml
[dependencies]
# no_std by default; enable `std` on a host if you want it
zisk-verifier = { version = "1.4.0-alpha", features = ["std"] }
FeatureDefaultEffect
stdoffEnables std in the underlying proofman-verifier.

The SDK also uses this crate: Proof::verify runs the same acceptance checks for Vadcop proofs.


Verify a proof​

The common case is a proof saved by cargo-zisk prove (or Proof::save), from a release setup, for a program you expect:

// The program you expect: its 4-word ROM root. From the SDK,
// `PROGRAM.vk()?.vk`; from a file of 4 little-endian u64 words,
// `zisk_verifier::decode_vk(&bytes)?`.
let program_vk: [u64; 4] = PROGRAM.vk()?.vk.try_into().unwrap();

let proof_bytes = std::fs::read("proof.bin")?;
let verified = zisk_verifier::verify_saved(&proof_bytes, Some(&program_vk))?;

// The 64 public outputs, as the guest committed them
let outputs: [u32; 64] = verified.outputs_u32().unwrap();

verify_saved checks the proof's shape, then that it is the expected program's, before the STARK runs. A proof for another program fails with VerifyError::ProgramMismatch without paying for a full verification. Pass None to accept any program, and read verified.program_vk yourself.


Custom setups and aggregates​

These verify under their own key, which verify_saved does not know. Decode the proof and pass the key to verify (or verify_saved_words):

ProofKey
Leaf from a self-built setupThe setup's vadcop_final.verkey.bin, or vadcop_final_compressed.verkey.bin for a compressed proof, under ~/.zisk/provingKey/zisk/<stage>/.
Aggregate (recurser fold)The recurser's own key: recurser_aggregator.verkey.bin under ~/.zisk/recurser/provingKey/recurser/<recurser_id>/, or AGG.vk()?.vk from the SDK.
let key = zisk_verifier::decode_vk(&std::fs::read("vadcop_final.verkey.bin")?)?;
let saved = zisk_verifier::decode_saved(&std::fs::read("proof.bin")?)?;
let verified = zisk_verifier::verify(&saved.proof, &key)?;
assert_eq!(verified.program_vk, expected_program_vk);

For an aggregate, verify also checks that the proof declares the recurser's key as its recursion domain (verified.program_vk == key), and fails with AggregateDomainMismatch otherwise. This is what extends the recurser's leaf allow-list over the whole fold tree: a subtree folded by a different recurser is refused. See Aggregating proofs.


In-guest verification​

A ZisK guest verifies a proof with verify_zisk_proof from ziskos::zisklib, which calls verify_saved_words on the words in place:

pub fn verify_zisk_proof(
zisk_proof: &[u64],
expected_setup_vk: &[u64],
expected_program_vk: &[u64],
) -> bool
ParameterDescription
zisk_proofThe proof in the flat layout, without the seed trailer.
expected_setup_vkThe 4-word STARK key: a release key from zisk_verifier::keys, a custom setup's, or a recurser's.
expected_program_vkThe 4-word program VK you expect: a ROM root, or the recurser's key for an aggregate.

It returns false for a malformed proof, a key that is not 4 words, a proof for another program, or a proof that does not verify. The hash family is read from the proof's tag, so the guest needs no build-time configuration.

Both keys must be guest constants

expected_setup_vk and expected_program_vk MUST be compile-time constants of the guest, never read from its input. Otherwise the verification is self-keyed and authenticates nothing. For an aggregate, both are the recurser's own key.

The guest refuses a proof that ends with the seed trailer, so the host must strip it. Pass the bytes from Proof::to_bytes_without_seed_trailer() (or get_proof_bytes()), not the saved file:

host
let proof = Proof::load("inner.proof")?;
let stdin = ZiskStdin::new();
stdin.write_slice(&proof.to_bytes_without_seed_trailer()?);

ziskos does not re-export zisk-verifier, so to use the release keys in zisk_verifier::keys the guest needs its own no_std dependency on the crate:

guest/Cargo.toml
[dependencies]
zisk-verifier = { version = "1.4.0-alpha", default-features = false }
guest
use ziskos::zisklib::verify_zisk_proof;

// The inner program's ROM root, fixed at build time
const INNER_PROGRAM_VK: [u64; 4] = [/* … */];
const SETUP_VK: [u64; 4] = zisk_verifier::keys::VADCOP_FINAL_VK_BLAKE3;

let bytes: &[u8] = ziskos::io::read_slice();
let words: Vec<u64> = bytes
.chunks_exact(8)
.map(|c| u64::from_le_bytes(c.try_into().unwrap()))
.collect();
assert!(verify_zisk_proof(&words, &SETUP_VK, &INNER_PROGRAM_VK));

A C-ABI wrapper, verify_zisk_proof_c(proof, proof_len, setup_vk, setup_vk_len, program_vk, program_vk_len) -> bool, takes byte pointers. Every buffer must be 8-byte aligned and a multiple of 8 bytes long, or it returns false.