circuits_lib::work_only

Function work_only_circuit

Source
pub fn work_only_circuit(guest: &impl ZkvmGuest)
Expand description

Executes the “work-only” zkVM circuit, verifying the total work value and committing it as a structured output.

§Parameters

  • guest: A reference to an object implementing ZkvmGuest.

§Functionality

  1. Reads WorkOnlyCircuitInput from the guest.
  2. Ensures the method_id matches HEADER_CHAIN_METHOD_ID.
  3. Serializes and verifies the header chain circuit output using env::verify().
  4. Converts total_work (from bytes) into a 128-bit integer (U128).
  5. Breaks down the 128-bit integer into four 32-bit words.
  6. Commits the resulting WorkOnlyCircuitOutput to the guest.

§Panics

  • If method_id does not match HEADER_CHAIN_METHOD_ID.
  • If serialization (borsh::to_vec()) or verification (env::verify()) fails.
  • If total_work conversion or chunk processing fails.