risc0-zkp
Therisc0-zkp crate provides the core zero-knowledge proof system primitives used by RISC Zero, including field arithmetic, hash functions, and the FRI-based STARK protocol implementation.
Installation
Overview
This is a low-level crate that implements the cryptographic foundations of the RISC Zero proof system. Most users should use the higher-levelrisc0-zkvm crate instead.
Feature Flags
Enables proof generation functionality.
- Implies:
std - Enables: Prover, HAL traits, and proof generation
Enables CUDA GPU acceleration.
- Implies:
prove - Requirements: CUDA toolkit
Enables Metal GPU acceleration (macOS).
- Implies:
prove
Enables Rust standard library support.
Enables circuit debugging features.
Core Modules
field
Finite field implementations.Baby Bear Field:
- Prime: 2^31 - 2^27 + 1
- 4-element extension field for FRI protocol
core::digest
256-bit cryptographic digest.Constants:
DIGEST_WORDS: usize = 8DIGEST_SHORTS: usize = 16DIGEST_BYTES: usize = 32
hal
Hardware Abstraction Layer for different compute backends.Implementations:
- CPU (default)
- CUDA (with
cudafeature) - Metal (with
metalfeature)
Proof System Constants
Minimum power of 2 for cycle count.
Maximum power of 2 for cycle count.
Number of FRI queries for security.
Inverse of Reed-Solomon expansion rate.
FRI folding factor.
Verification
VerificationError
Errors that can occur during verification.
verify
Verification functions and traits.
Adapter
Circuit adapter traits and implementations.
Layout
Memory layout definitions for proof generation.
Prove
Proof generation (available with
prove feature).Taps
Register tap definitions for constraint systems.
Merkle
Merkle tree implementations.
Examples
Using Digest
Field Arithmetic
HAL Usage
Performance
Therisc0-zkp crate is optimized for performance:
- CPU: Vectorized operations using AVX2/AVX512
- GPU (CUDA): Parallel FFT and field operations
- GPU (Metal): Optimized for Apple Silicon
Benchmarking
Security
The RISC Zero proof system provides:- Conjectured Security: 97 bits (with 50 FRI queries)
- Zero-Knowledge: Proofs reveal nothing about private inputs
- Soundness: Unforgeable proofs assuming computational hardness