Skip to main content

sp1_hypercube/
record.rs

1use crate::{air::SP1AirBuilder, InteractionKind};
2use hashbrown::HashMap;
3use slop_algebra::AbstractField;
4
5/// A record that can be proven by a machine.
6pub trait MachineRecord: Default + Sized + Send + Sync + Clone {
7    /// The statistics of the record.
8    fn stats(&self) -> HashMap<String, usize>;
9
10    /// Appends two records together.
11    fn append(&mut self, other: &mut Self);
12
13    /// Returns the public values of the record.
14    fn public_values<F: AbstractField>(&self) -> Vec<F>;
15
16    // /// Extracts the global cumulative sum from the public values.
17    // fn global_cumulative_sum<F: Field>(public_values: &[F]) -> SepticDigest<F>;
18
19    /// Constrains the public values of the record.
20    fn eval_public_values<AB: SP1AirBuilder>(builder: &mut AB);
21
22    /// The interaction kinds that appear in `eval_public_values`. Needed so that the shard verifier
23    /// knows how much randomness to allocate for the `LogUpGkr` `beta_seed` challenge.
24    fn interactions_in_public_values() -> Vec<InteractionKind>;
25}
26
27/// This exists only for the zerocheck unit test on `MinimalAddChip`.
28impl MachineRecord for Vec<(u32, u32, u32)> {
29    fn stats(&self) -> HashMap<String, usize> {
30        let mut map = HashMap::new();
31        map.insert("num_addi".to_string(), self.len());
32        map
33    }
34
35    fn append(&mut self, other: &mut Self) {
36        self.append(other);
37    }
38
39    fn public_values<F: AbstractField>(&self) -> Vec<F> {
40        vec![]
41    }
42
43    fn eval_public_values<AB: SP1AirBuilder>(_builder: &mut AB) {}
44
45    fn interactions_in_public_values() -> Vec<InteractionKind> {
46        vec![]
47    }
48}