remainder/mle/verifier_mle.rs
1use serde::{Deserialize, Serialize};
2use shared_types::Field;
3
4use crate::layer::LayerId;
5
6use super::MleIndex;
7
8/// A version of [crate::mle::dense::DenseMle] used by the Verifier.
9/// A [VerifierMle] stores a fully bound MLE along with its evaluation.
10/// It is used to represent the leaves of an `Expression<F, VerifierExpr>`.
11#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Hash)]
12#[serde(bound = "F: Field")]
13pub struct VerifierMle<F: Field> {
14 /// Layer whose data this MLE is a subset of.
15 layer_id: LayerId,
16
17 /// A list of bound indices.
18 var_indices: Vec<MleIndex<F>>,
19
20 /// The evaluation of this MLE when variables are bound according
21 /// `var_indices`.
22 eval: F,
23}
24
25impl<F: Field> VerifierMle<F> {
26 /// Constructor for the [VerifierMle] using layer_id and the
27 /// MLE indices that will go into this MLE. Additionally includes
28 /// the eval, which is the evaluation of the fully bound MLE.
29 pub fn new(layer_id: LayerId, var_indices: Vec<MleIndex<F>>, eval: F) -> Self {
30 Self {
31 layer_id,
32 var_indices,
33 eval,
34 }
35 }
36
37 /// Returns the layer_id of this MLE.
38 pub fn layer_id(&self) -> LayerId {
39 self.layer_id
40 }
41
42 /// Returns the num_vars of this MLE.
43 pub fn num_vars(&self) -> usize {
44 self.var_indices.len()
45 }
46
47 /// Returns the MLE indices of this MLE.
48 pub fn var_indices(&self) -> &[MleIndex<F>] {
49 &self.var_indices
50 }
51
52 /// Returns the fully bound value of this MLE.
53 pub fn value(&self) -> F {
54 self.eval
55 }
56}