miden_lifted_stark/pcs/deep/proof.rs
1//! DEEP transcript data structures.
2
3use alloc::vec::Vec;
4
5use miden_stark_transcript::{Channel, TranscriptError, VerifierChannel};
6use p3_field::{ExtensionField, Field, TwoAdicField};
7use p3_matrix::dense::RowMajorMatrix;
8
9use crate::pcs::deep::{DeepParams, read_eval_matrices};
10
11/// Opened evaluations grouped by commitment group and matrix.
12///
13/// `opened[g][m]` is a `RowMajorMatrix<EF>` with one row per evaluation point,
14/// where `g` is the commitment group index and `m` the matrix index within that group.
15pub type OpenedValues<EF> = Vec<Vec<RowMajorMatrix<EF>>>;
16
17/// Structured transcript view for the DEEP interaction.
18///
19/// This records the prover's PoW witness and the two challenges sampled
20/// from the Fiat-Shamir transcript after observing evaluations.
21///
22/// `evals[g][m]` is a `RowMajorMatrix<EF>` with `num_eval_points` rows for
23/// commitment group `g`, matrix `m`. Widths include alignment padding (matching
24/// the committed rows).
25pub struct DeepTranscript<F: Field, EF: ExtensionField<F>> {
26 /// `evals[g][m]` is a `RowMajorMatrix` with `num_eval_points` rows.
27 pub evals: OpenedValues<EF>,
28 /// Proof-of-work witness sampled before DEEP challenges.
29 pub pow_witness: F,
30 /// Challenge `α` for batching columns into `f_reduced`.
31 pub challenge_columns: EF,
32 /// Challenge `β` for batching opening points.
33 pub challenge_points: EF,
34}
35
36impl<F, EF> DeepTranscript<F, EF>
37where
38 F: TwoAdicField,
39 EF: ExtensionField<F>,
40{
41 /// Parse DEEP transcript data from a verifier channel.
42 ///
43 /// Reads OOD evaluations, verifies the PoW witness, and samples batching
44 /// challenges. Does not verify the DEEP quotient itself; that validation
45 /// happens in the DEEP verifier. Commitment widths must match the
46 /// committed rows (including any alignment padding).
47 pub fn from_verifier_channel<Ch>(
48 params: &DeepParams,
49 commitments: &[(<Ch as Channel>::Commitment, Vec<usize>)],
50 num_eval_points: usize,
51 channel: &mut Ch,
52 ) -> Result<Self, TranscriptError>
53 where
54 Ch: VerifierChannel<F = F>,
55 {
56 let group_widths: Vec<&[usize]> = commitments.iter().map(|(_, gw)| gw.as_slice()).collect();
57 let evals = read_eval_matrices::<F, EF, Ch>(&group_widths, num_eval_points, channel)?;
58
59 let pow_witness = channel.grind(params.deep_pow_bits)?;
60 let challenge_columns: EF = channel.sample_algebra_element();
61 let challenge_points: EF = channel.sample_algebra_element();
62
63 Ok(Self {
64 evals,
65 pow_witness,
66 challenge_columns,
67 challenge_points,
68 })
69 }
70}