Documentation Index
Fetch the complete documentation index at: https://mintlify.com/risc0/risc0/llms.txt
Use this file to discover all available pages before exploring further.
risc0-circuit-rv32im
Therisc0-circuit-rv32im crate implements the RISC-V RV32IM constraint system circuit used by the RISC Zero zkVM to prove correct execution of guest programs.
Installation
Overview
This crate provides the core circuit that validates RV32IM (RISC-V 32-bit with integer multiplication/division) instruction execution within the zkVM. It’s a low-level component typically used indirectly throughrisc0-zkvm.
This is a low-level circuit implementation. Most users should use
risc0-zkvm instead.Feature Flags
Enables proof generation functionality.
- Implies:
execute,std
Enables execution and witness generation.
- Implies:
std
Enables CUDA GPU acceleration.
- Implies:
prove
Enables standard library support.
Enables witness generation debugging.
Enables block tracker debugging for performance analysis.
Constants
Version of the seal format for rv32im circuit.
Maximum instruction rows for bigint programs.
Maximum instruction rows for smaller power-of-2 sizes (< 15).
Types
Claim
Represents a claim about program execution.Fields:
po2: Power of 2 for segment sizepre_state: State before executionpost_state: State after executionoutput: Output digest (if terminated)terminate_state: Termination informationpovw_nonce: Proof-of-work nonce
Decode a claim from a segment seal.Parameters:
seal: Raw seal data from a segment
Extract the exit code from the claim.Returns: Exit code (Halted, Paused, or SystemSplit)
TerminateState
State when a segment terminates.Fields:
a0: Register a0 value (exit code and halt type)a1: Register a1 value
EcallKind
Types of environment calls (syscalls).
BlockType
Types of execution blocks in the circuit.Variants: Execution blocks, memory operations, control flow, etc.
Circuit Implementation
The RV32IM circuit implementation.Implements the constraint system for validating RV32IM execution.
Verification
Verify a segment seal.Parameters:
seal: Segment seal to verifyimage_id: Expected program image ID
Trace
Execution trace recording and callbacks.
Execution (with execute feature)
execute Module
Program execution and witness generation.Provides an executor that runs RISC-V programs and generates execution traces for proving.
Proving (with prove feature)
prove Module
Proof generation for RV32IM execution.Implements the prover for the RV32IM circuit constraint system.
Examples
Decoding a Segment Seal
Verifying a Segment
Trace Callback
Proof-of-Work
Extract proof-of-work nonce from a segment seal.Example:
Performance
The RV32IM circuit is optimized for:- Throughput: Millions of cycles per second on CPU
- GPU Acceleration: 10-100x speedup with CUDA
- Memory Efficiency: Streaming witness generation
Benchmarking
Circuit Architecture
The RV32IM circuit validates:- Instruction Decoding: Correct instruction fetch and decode
- ALU Operations: Integer arithmetic and logic
- Memory Access: Load/store operations
- Control Flow: Branches and jumps
- Multiply/Divide: M extension operations
- Syscalls: Environment calls