Skip to main content

Results & Outputs

Every .run() on a request builder (except UploadRequest::run()) returns a Result<JobHandle<T>> where T is one of the result types. The result types are thin newtypes that carry an optional remote JobId and Deref into their underlying *Output so all backend accessors are reachable in one step.

Overview

Every .run() returns a Result<JobHandle<T>> where T is one of the result types below. Awaiting the handle resolves to Result<T>.

The result types are thin newtypes over the prover backend's output types. Each wraps an optional JobId (populated on remote runs, None on embedded runs) and Derefs to its inner *Output so all the backend accessors are reachable through the result without an extra step.


Result types

Every result is a thin newtype that surfaces an identifier and Derefs into an *Output carrying the actual data.

ResultIdentifierDeref target
SetupResultjob_id() -> Option<&JobId>
UploadResultjob_id() -> Option<&JobId>
ExecuteResultjob_id() -> Option<&JobId>ExecuteOutput
ProveResultjob_id() -> Option<&JobId>ProveOutput
VerifyConstraintsResultjob_id() -> Option<&JobId>VerifyConstraintsOutput
// Every Output-side method is reachable through the Deref:
let result = client.prove(&PROGRAM, stdin).run()?.await?;

result.save_proof("./proof.bin")?;
let proof: &Proof = result.get_proof();
let publics: &PublicValues = result.get_publics();
result.verify()?;

Output types

The *Output types live in zisk_prover_backend and are re-exported at the top level of zisk_sdk. They are the direct result of a prover run; you don't construct them — you receive them via the Deref from the corresponding *Result.

Shared: publics access

All three output types (ProveOutput, ExecuteOutput, VerifyConstraintsOutput) expose the same four methods for reading the public inputs the guest committed:

MethodReturnsDescription
get_publics()&PublicValuesBorrow the public inputs/outputs of the run.
get_public_values::<T>()Result<T>Typed deserialise via serde.
get_public_values_abi::<T>()Result<T>Typed deserialise via Solidity ABI rules.
get_public_values_slice(&mut [u8])()Copy raw public-input bytes into the slice.

The sections below cover what each output type adds on top.

ProveOutput

pub struct ProveOutput { /* ... */ }

Proof access

MethodReturnsDescription
get_proof()&ProofBorrow the underlying proof.
get_proof_bytes()Result<Vec<u8>>Serialised proof bytes (varies by ProofKind).
get_proof_u64()Result<Vec<u64>>Serialised proof as u64 words.
get_program_vk()&ProgramVKBorrow the program verification key.
save_proof(path: impl AsRef<Path>)Result<()>Persist the inner Proof to path.

Verification

MethodReturnsDescription
verify()Result<()>Verify the proof against the embedded publics and program VK.
with_publics(&PublicValues)ZiskVerifyBuilderBegin a verify chain with overridden publics.
with_program_vk(&ProgramVK)ZiskVerifyBuilderBegin a verify chain with an overridden program VK.

The two with_* methods return a ZiskVerifyBuilder you can keep chaining (.with_publics(...).with_program_vk(...).verify()); verify() is the all-defaults shortcut.

Statistics

MethodReturnsDescription
get_proving_time()u64Total proving time in milliseconds.
get_execution_steps()u64Number of guest steps executed.
get_execution_cost()u64Aggregated execution cost (in cost units).
let out = client.prove(&PROGRAM, stdin).run()?.await?;

// Save to disk
out.save_proof("./proofs/run-42.bin")?;

// Decode publics into a typed value
let digest: [u8; 32] = out.get_public_values()?;

// Verify with the publics already embedded in the proof
out.verify()?;

// Verify with an externally-held program VK
let vk = PROGRAM.vk()?;
out.with_program_vk(&vk).verify()?;

ExecuteOutput

pub struct ExecuteOutput { /* ... */ }

Carries no proof — that's the whole point of execute. Adds only a few execution statistics on top of the shared publics surface.

Statistics

MethodReturnsDescription
get_execution_steps()u64Number of guest steps executed.
get_execution_cost()u64Aggregated execution cost (in cost units).
get_execution_time()u64Execution time in milliseconds.

VerifyConstraintsOutput

pub struct VerifyConstraintsOutput { /* ... */ }

The constraint checker's per-run summary — not a proof object. If the constraints fail the underlying job errors out instead of returning an output, so receiving one of these means the constraints passed.

Statistics

MethodReturnsDescription
get_execution_steps()u64Number of guest steps executed.
get_execution_total_cost()u64Total cost across all constraint phases.
get_executor_time()&ZiskExecutorTimePer-phase executor timing.
get_execution_cost_per_type()&StatsCostPerTypePer-component cost breakdown.
get_duration()u64Total constraint-check duration in milliseconds.