Skip to main content

qp_plonky2_core/
lib.rs

1//! Core traits and types shared between plonky2 prover and verifier.
2//!
3//! This crate provides the foundational types and traits that both the
4//! full plonky2 prover and the lightweight verifier depend on.
5
6#![allow(clippy::too_many_arguments)]
7#![allow(clippy::needless_range_loop)]
8#![cfg_attr(not(feature = "std"), no_std)]
9
10#[cfg(not(feature = "std"))]
11pub extern crate alloc;
12
13/// Re-export of `plonky2_field` for field types.
14#[doc(inline)]
15pub use plonky2_field as field;
16
17// Core modules - order matters for dependencies
18mod arch;
19pub mod challenger;
20pub mod circuit_config;
21pub mod config;
22pub mod fri;
23pub mod fri_proof;
24pub mod fri_structure;
25pub mod fri_validate_shape;
26pub mod fri_verifier;
27pub mod hash;
28pub mod hash_types;
29pub mod hashing;
30pub mod iop;
31pub mod keccak;
32pub mod merkle_proofs;
33pub mod merkle_tree;
34pub mod plonk;
35pub mod plonk_common;
36pub mod poseidon;
37pub mod poseidon_crandall;
38pub mod poseidon_goldilocks;
39pub mod proof;
40pub mod reducing;
41pub mod selectors;
42pub mod strided_view;
43pub mod util;
44
45// Re-export key types at crate root for convenience
46pub use challenger::Challenger;
47// Circuit and FRI configuration types
48pub use circuit_config::{CircuitConfig, PolyFriZkConfig, ZkConfig, ZkMode};
49pub use config::{
50    GenericConfig, GenericHashOut, Hasher, KeccakGoldilocksConfig, PoseidonGoldilocksConfig,
51};
52pub use fri::{
53    FriBatchMaskingParams, FriChallenger, FriConfig, FriConfigObserve, FriFinalPolyLayout,
54    FriParams, FriParamsObserve, FriReductionStrategy,
55};
56// FRI proof types
57pub use fri_proof::{
58    combine_final_poly_chunks, eval_final_polys_at_point, CompressedFriProof,
59    CompressedFriQueryRounds, FriBatchMaskProof, FriBatchMaskQuery, FriFinalPolys,
60    FriInitialTreeProof, FriProof, FriQueryRound, FriQueryStep,
61};
62pub use fri_structure::{
63    FriBatchInfo, FriChallenges, FriCoefficient, FriInstanceInfo, FriOpeningBatch,
64    FriOpeningExpression, FriOpeningTerm, FriOpenings, FriOracleInfo, FriOracleLayout,
65    FriOracleRepresentation, FriPolynomialInfo,
66};
67pub use fri_validate_shape::{validate_batch_fri_proof_shape, validate_fri_proof_shape};
68pub use fri_verifier::{
69    compute_evaluation, fri_combine_initial, fri_verify_proof_of_work, verify_fri_proof,
70    PrecomputedReducedOpenings,
71};
72// Hash utilities
73pub use hash::path_compression::{compress_merkle_proofs, decompress_merkle_proofs};
74pub use hash_types::{BytesHash, HashOut, RichField, NUM_HASH_OUT_ELTS};
75pub use hashing::PlonkyPermutation;
76// IOP types
77pub use iop::{
78    flatten_target, unflatten_target, BoolTarget, ExtensionAlgebraTarget, ExtensionTarget,
79    HashOutTarget, MerkleCapTarget, Target, Wire,
80};
81pub use keccak::{KeccakHash, KeccakPermutation};
82pub use merkle_proofs::MerkleProof;
83pub use merkle_tree::{
84    capacity_up_to_mut, fill_digests_buf, fill_subtree, merkle_tree_prove, MerkleCap, MerkleTree,
85};
86pub use plonk_common::{
87    eval_l_0, eval_zero_poly, reduce_with_powers, reduce_with_powers_multi, salt_size, PlonkOracle,
88    SALT_SIZE,
89};
90pub use poseidon::{
91    Permuter, Poseidon, PoseidonHash, PoseidonPermutation, ALL_ROUND_CONSTANTS, HALF_N_FULL_ROUNDS,
92    N_FULL_ROUNDS_TOTAL, N_PARTIAL_ROUNDS, N_ROUNDS, SPONGE_CAPACITY, SPONGE_RATE, SPONGE_WIDTH,
93};
94// Proof challenge types
95pub use proof::{FriInferredElements, ProofChallenges};
96pub use selectors::{LookupSelectors, SelectorsInfo, UNUSED_SELECTOR};
97// Utility functions
98pub use util::{
99    assume, branch_hint, log2_ceil, log2_strict, reverse_bits, reverse_index_bits,
100    reverse_index_bits_in_place,
101};
102
103/// The extension degree for the field extension (D=2 provides 100-bits of security)
104pub const D: usize = 2;
105
106/// The standard Plonky2 configuration using Poseidon hash over Goldilocks field
107pub type C = PoseidonGoldilocksConfig;
108
109/// The Goldilocks prime field
110pub type F = field::goldilocks_field::GoldilocksField;