1use derivative::Derivative;
2use serde::{Deserialize, Serialize};
34use crate::config::{Com, PcsProof, RapPhaseSeqPartialProof, StarkGenericConfig, Val};
56/// The full proof for multiple RAPs where trace matrices are committed into
7/// multiple commitments, where each commitment is multi-matrix.
8///
9/// Includes the quotient commitments and FRI opening proofs for the constraints as well.
10#[derive(Serialize, Deserialize, Derivative)]
11#[serde(bound = "")]
12#[derivative(Clone(bound = "Com<SC>: Clone"))]
13pub struct Proof<SC: StarkGenericConfig> {
14/// The PCS commitments
15pub commitments: Commitments<Com<SC>>,
16/// Opening proofs separated by partition, but this may change
17pub opening: OpeningProof<PcsProof<SC>, SC::Challenge>,
18/// Proof data for each AIR
19pub per_air: Vec<AirProofData<Val<SC>, SC::Challenge>>,
20/// Partial proof for rap phase if it exists
21pub rap_phase_seq_proof: Option<RapPhaseSeqPartialProof<SC>>,
22}
2324impl<SC: StarkGenericConfig> Proof<SC> {
25pub fn get_air_ids(&self) -> Vec<usize> {
26self.per_air.iter().map(|p| p.air_id).collect()
27 }
28pub fn get_public_values(&self) -> Vec<Vec<Val<SC>>> {
29self.per_air
30 .iter()
31 .map(|p| p.public_values.clone())
32 .collect()
33 }
34}
3536/// All commitments to a multi-matrix STARK that are not preprocessed.
37#[derive(Clone, Serialize, Deserialize)]
38pub struct Commitments<Com> {
39/// Multiple commitments for the main trace.
40 /// For each RAP, each part of a partitioned matrix trace matrix
41 /// must belong to one of these commitments.
42pub main_trace: Vec<Com>,
43/// One shared commitment for all trace matrices across all RAPs
44 /// in a single challenge phase `i` after observing the commits to
45 /// `preprocessed`, `main_trace`, and `after_challenge[..i]`
46pub after_challenge: Vec<Com>,
47/// Shared commitment for all quotient polynomial evaluations
48pub quotient: Com,
49}
5051/// PCS opening proof with opened values for multi-matrix AIR.
52#[derive(Clone, Serialize, Deserialize)]
53pub struct OpeningProof<PcsProof, Challenge> {
54pub proof: PcsProof,
55pub values: OpenedValues<Challenge>,
56}
5758#[derive(Clone, Serialize, Deserialize)]
59pub struct OpenedValues<Challenge> {
60/// For each preprocessed trace commitment, the opened values
61pub preprocessed: Vec<AdjacentOpenedValues<Challenge>>,
62/// For each main trace commitment, for each matrix in commitment, the
63 /// opened values
64pub main: Vec<Vec<AdjacentOpenedValues<Challenge>>>,
65/// For each phase after challenge, there is shared commitment.
66 /// For each commitment, if any, for each matrix in the commitment, the opened values,
67pub after_challenge: Vec<Vec<AdjacentOpenedValues<Challenge>>>,
68/// For each RAP, for each quotient chunk in quotient poly, the opened values
69pub quotient: Vec<Vec<Vec<Challenge>>>,
70}
7172#[derive(Clone, Serialize, Deserialize)]
73pub struct AdjacentOpenedValues<Challenge> {
74pub local: Vec<Challenge>,
75pub next: Vec<Challenge>,
76}
7778#[derive(Clone, Serialize, Deserialize)]
79pub struct AirProofData<Val, Challenge> {
80pub air_id: usize,
81/// height of trace matrix.
82pub degree: usize,
83/// For each challenge phase with trace, the values to expose to the verifier in that phase
84pub exposed_values_after_challenge: Vec<Vec<Challenge>>,
85// The public values to expose to the verifier
86pub public_values: Vec<Val>,
87}