kimchi_visu/
witness.rs

1use ark_ff::Field;
2use kimchi::circuits::polynomial::COLUMNS;
3use serde::Serialize;
4use serde_with::serde_as;
5use std::array;
6
7/// The type that represents the execution trace.
8/// It represents a table of [COLUMNS] columns, with `n` rows.
9/// `n` being the maximum size of the circuit, and the size of the domain.
10#[serde_as]
11#[derive(Debug, Serialize)]
12pub struct Witness<F>
13where
14    F: Field,
15{
16    #[serde_as(as = "[Vec<o1_utils::serialization::SerdeAs>; COLUMNS]")]
17    inner: [Vec<F>; COLUMNS],
18}
19
20impl<F> Witness<F>
21where
22    F: Field,
23{
24    /// Creates a new witness with `rows` rows.
25    // TODO: deprecate this
26    pub fn new(rows: usize) -> Self {
27        Witness {
28            inner: array::from_fn(|_| vec![F::zero(); rows]),
29        }
30    }
31
32    /// Returns the inner witness.
33    // TODO: deprecate this
34    pub fn inner(self) -> [Vec<F>; COLUMNS] {
35        self.inner
36    }
37}
38
39impl<F> From<[Vec<F>; COLUMNS]> for Witness<F>
40where
41    F: Field,
42{
43    fn from(inner: [Vec<F>; COLUMNS]) -> Self {
44        Witness { inner }
45    }
46}