zinc_piop/combined_poly_resolver/
structs.rs1use crypto_primitives::PrimeField;
2use zinc_transcript::traits::{ConstTranscribable, GenTranscribable, Transcribable};
3use zinc_utils::add;
4
5use crate::combined_poly_resolver::CombinedPolyResolverError;
6
7#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct Proof<F: PrimeField> {
13 pub up_evals: Vec<F>,
15 pub down_evals: Vec<F>,
18}
19
20impl<F: PrimeField> GenTranscribable for Proof<F>
21where
22 F::Inner: ConstTranscribable,
23 F::Modulus: ConstTranscribable,
24{
25 fn read_transcription_bytes_exact(bytes: &[u8]) -> Self {
26 let (up_evals, bytes) = Vec::<F>::read_transcription_bytes_subset(bytes);
27 let (down_evals, bytes) = Vec::<F>::read_transcription_bytes_subset(bytes);
28 assert!(bytes.is_empty(), "All bytes should be consumed");
29 Self {
30 up_evals,
31 down_evals,
32 }
33 }
34
35 fn write_transcription_bytes_exact(&self, buf: &mut [u8]) {
36 let buf = self.up_evals.write_transcription_bytes_subset(buf);
37 let buf = self.down_evals.write_transcription_bytes_subset(buf);
38 assert!(buf.is_empty(), "Entire buffer should be used");
39 }
40}
41
42impl<F: PrimeField> Transcribable for Proof<F>
43where
44 F::Inner: ConstTranscribable,
45 F::Modulus: ConstTranscribable,
46{
47 fn get_num_bytes(&self) -> usize {
48 add!(
49 2 * u32::NUM_BYTES,
50 add!(
51 self.up_evals.get_num_bytes(),
52 self.down_evals.get_num_bytes()
53 )
54 )
55 }
56}
57
58impl<F: PrimeField> Proof<F> {
59 pub fn validate_evaluation_sizes(
61 &self,
62 num_cols: usize,
63 num_down_cols: usize,
64 ) -> Result<(), CombinedPolyResolverError<F>> {
65 if self.up_evals.len() != num_cols {
66 return Err(CombinedPolyResolverError::WrongUpEvalsNumber {
67 got: self.up_evals.len(),
68 expected: num_cols,
69 });
70 }
71
72 if self.down_evals.len() != num_down_cols {
73 return Err(CombinedPolyResolverError::WrongDownEvalsNumber {
74 got: self.down_evals.len(),
75 expected: num_down_cols,
76 });
77 }
78
79 Ok(())
80 }
81}
82
83pub struct ProverState<F: PrimeField> {
84 pub evaluation_point: Vec<F>,
86}
87
88pub struct CprProverAncillary {
92 pub num_cols: usize,
94 pub num_down_cols: usize,
96 pub num_vars: usize,
98}
99
100pub struct CprVerifierAncillary<F: PrimeField> {
104 pub folding_challenge_powers: Vec<F>,
106 pub ic_evaluation_point: Vec<F>,
108 pub num_vars: usize,
110}
111
112#[derive(Clone, Debug)]
116pub struct VerifierSubclaim<F: PrimeField> {
117 pub evaluation_point: Vec<F>,
119 pub up_evals: Vec<F>,
121 pub down_evals: Vec<F>,
123}