Skip to main content

p3_binary_pcs/
proof.rs

1//! Proof types produced by the commit-fold-query pipeline.
2
3use alloc::vec::Vec;
4
5use p3_commit::Mmcs;
6use p3_field::Field;
7use p3_multilinear_util::poly::Poly;
8use p3_sumcheck::{OpeningEvals, SumcheckData};
9use serde::{Deserialize, Serialize};
10
11/// One intermediate fold batch: the commitment to that round's folded codeword, and its
12/// query openings.
13#[derive(Clone, Serialize, Deserialize)]
14#[serde(bound(
15    serialize = "MX::Commitment: Serialize, MX::MultiProof: Serialize",
16    deserialize = "MX::Commitment: Deserialize<'de>, MX::MultiProof: Deserialize<'de>"
17))]
18pub struct RoundProof<EF: Field, MX: Mmcs<EF>> {
19    /// Merkle root of this round's folded codeword.
20    pub commitment: MX::Commitment,
21    /// Every symbol of each queried coset, one width-1 row per symbol. Coset width is
22    /// `2^arity` for the next fold batch, derived from the verifier's configuration.
23    /// Cosets follow sampled query order; symbols inside a coset are ascending.
24    pub opened_values: Vec<Vec<EF>>,
25    /// One multiproof authenticating every opened row of this round together.
26    pub multi_proof: MX::MultiProof,
27}
28
29/// A full opening proof.
30///
31/// The last fold batch has no round entry.
32/// Its codeword has already shrunk to `2^log_inv_rate` symbols, so it is sent in full.
33///
34/// A Merkle path over it would only repeat what the verifier can already read.
35/// Every earlier batch is committed and opened at every coset position a query needs.
36///
37/// The base commitment holds the committed alphabet, every folded one the challenge field.
38/// The first fold of the schedule is what crosses between the two.
39#[derive(Clone, Serialize, Deserialize)]
40#[serde(bound(
41    serialize = "MT::Commitment: Serialize, MT::MultiProof: Serialize, MX::Commitment: Serialize, MX::MultiProof: Serialize",
42    deserialize = "MT::Commitment: Deserialize<'de>, MT::MultiProof: Deserialize<'de>, MX::Commitment: Deserialize<'de>, MX::MultiProof: Deserialize<'de>"
43))]
44pub struct BinaryPcsProof<F: Field, EF: Field, MT: Mmcs<F>, MX: Mmcs<EF>> {
45    /// Every sumcheck round message, in round order.
46    pub sumcheck: SumcheckData<F, EF>,
47    /// One entry per intermediate fold batch, excluding the final batch.
48    pub rounds: Vec<RoundProof<EF, MX>>,
49    /// All symbols of the sampled base cosets, in query order with ascending coset offsets.
50    /// The first batch's arity determines the number of width-1 rows per query.
51    pub base_opened_values: Vec<Vec<F>>,
52    /// Multiproof for the base commitment's queried rows.
53    pub base_multi_proof: MT::MultiProof,
54    /// The final folded codeword, sent in full and absorbed before query grinding/sampling.
55    pub final_codeword: Poly<EF>,
56    /// Witness for the single grind before the query phase.
57    pub pow_witness: F,
58    /// Claimed evaluations, in the opening protocol's own schedule order.
59    ///
60    /// One batch per protocol entry.
61    /// Each batch holds the current-point values separately from the successor-point ones.
62    pub evals: Vec<OpeningEvals<EF>>,
63}