sonobe/src/utils/espresso/sum_check/structs.rs
src/utils/espresso/sum_check/structs.rsRaw
1// code forked from:
2// https://github.com/EspressoSystems/hyperplonk/tree/main/subroutines/src/poly_iop/sum_check
3//
4// Copyright (c) 2023 Espresso Systems (espressosys.com)
5// This file is part of the HyperPlonk library.
6
7// You should have received a copy of the MIT License
8// along with the HyperPlonk library. If not, see <https://mit-license.org/>.
9
10//! This module defines structs that are shared by all sub protocols.
11
12use crate::utils::virtual_polynomial::VirtualPolynomial;
13use ark_ec::CurveGroup;
14use ark_ff::PrimeField;
15use ark_serialize::CanonicalSerialize;
16
17/// An IOP proof is a collections of
18/// - messages from prover to verifier at each round through the interactive
19/// protocol.
20/// - a point that is generated by the transcript for evaluation
21#[derive(Clone, Debug, Default, PartialEq, Eq)]
22pub struct IOPProof<F: PrimeField> {
23 pub point: Vec<F>,
24 pub proofs: Vec<IOPProverMessage<F>>,
25}
26
27/// A message from the prover to the verifier at a given round
28/// is a list of evaluations.
29#[derive(Clone, Debug, Default, PartialEq, Eq, CanonicalSerialize)]
30pub struct IOPProverMessage<F: PrimeField> {
31 pub(crate) evaluations: Vec<F>,
32}
33
34/// Prover State of a PolyIOP.
35#[derive(Debug)]
36pub struct IOPProverState<C: CurveGroup> {
37 /// sampled randomness given by the verifier
38 pub challenges: Vec<C::ScalarField>,
39 /// the current round number
40 pub(crate) round: usize,
41 /// pointer to the virtual polynomial
42 pub(crate) poly: VirtualPolynomial<C::ScalarField>,
43 /// points with precomputed barycentric weights for extrapolating smaller
44 /// degree uni-polys to `max_degree + 1` evaluations.
45 #[allow(clippy::type_complexity)]
46 pub(crate) extrapolation_aux: Vec<(Vec<C::ScalarField>, Vec<C::ScalarField>)>,
47}
48
49/// Verifier State of a PolyIOP, generic over a curve group
50#[derive(Debug)]
51pub struct IOPVerifierState<C: CurveGroup> {
52 pub(crate) round: usize,
53 pub(crate) num_vars: usize,
54 pub(crate) max_degree: usize,
55 pub(crate) finished: bool,
56 /// a list storing the univariate polynomial in evaluation form sent by the
57 /// prover at each round
58 pub(crate) polynomials_received: Vec<Vec<C::ScalarField>>,
59 /// a list storing the randomness sampled by the verifier at each round
60 pub(crate) challenges: Vec<C::ScalarField>,
61}