risc0_zkp/
lib.rs

1// Copyright 2025 RISC Zero, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![doc = include_str!("../README.md")]
16#![cfg_attr(not(feature = "std"), no_std)]
17#![deny(rustdoc::broken_intra_doc_links)]
18#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
19
20extern crate alloc;
21
22pub mod adapter;
23pub mod core;
24#[cfg(feature = "prove")]
25pub mod hal;
26pub mod layout;
27mod merkle;
28#[cfg(feature = "prove")]
29pub mod prove;
30pub mod taps;
31pub mod verify;
32
33pub use risc0_core::field;
34
35pub const MIN_CYCLES_PO2: usize = 13;
36pub const MIN_CYCLES: usize = 1 << MIN_CYCLES_PO2; // 8K
37pub const MAX_CYCLES_PO2: usize = 24;
38pub const MAX_CYCLES: usize = 1 << MAX_CYCLES_PO2; // 16M
39
40/// 50 FRI queries is sufficient to achieve our security target of 97 bits (conjectured security)
41pub const QUERIES: usize = 50;
42pub const ZK_CYCLES: usize = 1024; // TODO: Ideally we'd compute ZK_CYCLES programmatically
43pub const MIN_PO2: usize = core::log2_ceil(1 + ZK_CYCLES);
44
45/// Inverse of Reed-Solomon Expansion Rate
46pub const INV_RATE: usize = 4;
47
48const FRI_FOLD_PO2: usize = 4;
49
50/// FRI folding factor is 2 ^ FRI_FOLD_PO2
51pub const FRI_FOLD: usize = 1 << FRI_FOLD_PO2;
52
53/// FRI continues until the degree of the FRI polynomial reaches FRI_MIN_DEGREE
54const FRI_MIN_DEGREE: usize = 256;