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-zkvm-platform
Therisc0-zkvm-platform crate provides low-level platform definitions, syscalls, and runtime components for the RISC Zero zkVM.
Installation
Overview
This crate contains the foundational components needed for both guest and host code to interact with the zkVM platform. It defines syscalls, memory layout, and provides optional runtime components.This is a low-level crate. Most users should use
risc0-zkvm instead.Feature Flags
Builds a Rust runtime for guest programs.
- Implies:
export-libm,export-syscalls
Provides the
_start entrypoint for guest programs.Provides a panic handler for guest programs.
Exports syscall implementations.
Exports libm (math library) functions.
Enables getrandom implementation using
sys_random syscall.- Implies:
export-getrandom - Default: Panics when called
Exports a getrandom implementation (panics by default).
Uses embedded-alloc for heap allocation instead of the default bump allocator.
- Trade-off: Slower but reclaims freed memory
Enables the
sys_getenv syscall.Enables the
sys_argc and sys_argv syscalls.Enables unstable/experimental features.
Constants
Memory
Size of a zkVM memory page.
Size of a zkVM machine word in bytes (32-bit architecture).
File Descriptors
Standard IO file descriptors.
Functions
align_up
Aligns an address upwards to the specified alignment.Parameters:
addr: Address to alignalign: Alignment (must be a power of 2)
Syscalls
The crate provides thedeclare_syscall! macro for defining and calling syscalls.
declare_syscall!
Declares a syscall interface.
Standard Syscalls
The following syscalls are available:I/O Syscalls
I/O Syscalls
sys_read(fd: u32, buf: *mut u8, len: usize) -> usizesys_write(fd: u32, buf: *const u8, len: usize)
Memory Syscalls
Memory Syscalls
sys_alloc_words(nwords: u32) -> *mut u32sys_alloc_aligned(bytes: u32, align: u32) -> *mut u8
Cryptographic Syscalls
Cryptographic Syscalls
sys_sha_compress(digest: *mut [u32; 8], data: *const [u32; 16])sys_sha_buffer(digest: *mut [u32; 8], buf: *const u8, len: u32)sys_random(out: *mut u32, len: usize)
Control Flow Syscalls
Control Flow Syscalls
sys_halt()sys_pause()sys_verify(control_id: *const u32, claim: *const u32) -> u32
Proof-of-Work Syscalls
Proof-of-Work Syscalls
sys_povw_preflight(job_id: u64, nonce: *const u32) -> u32sys_povw_prove(job_id: u64, nonce: *const u32)sys_povw_gen_nonce(nonce: *mut u32)
Memory Module
Defines zkVM memory layout.
Heap Module
Heap allocator implementations (available with
rust-runtime feature).Allocators:- Default: Bump allocator (fast, no deallocation)
- With
heap-embedded-alloc: Linked-list allocator (slower, reuses memory)
Examples
Using Syscalls in Guest Code
Memory Alignment
Custom Runtime
You can build a custom runtime without depending onrisc0-zkvm: