MCPcopy Create free account
hub / github.com/argumentcomputer/ix / witness_data

Method witness_data

crates/aiur/src/trace.rs:74–117  ·  view source on GitHub ↗
(
    &self,
    function_index: usize,
    query_record: &QueryRecord,
    io_buffer: &IOBuffer,
  )

Source from the content-addressed store, hash-verified

72#[derive(Clone, Copy)]
73struct TraceContext<'a> {
74 function_index: G,
75 multiplicity: G,
76 inputs: &'a [G],
77 output: &'a [G],
78 query_record: &'a QueryRecord,
79}
80
81impl Toplevel {
82 pub fn witness_data(
83 &self,
84 function_index: usize,
85 query_record: &QueryRecord,
86 io_buffer: &IOBuffer,
87 slot_arg_widths: &[usize],
88 ) -> (RowMajorMatrix<G>, LookupValues<G>) {
89 let func = &self.functions[function_index];
90 let width = func.width();
91 let unfiltered_queries = &query_record.function_queries[function_index];
92 let queries = unfiltered_queries
93 .iter()
94 .filter(|(_, res)| !res.multiplicity.is_zero())
95 .collect::<Vec<_>>();
96 let height_no_padding = queries.len();
97 // An unqueried circuit yields an EMPTY trace (not a padded height-1 one):
98 // the prover deactivates it, so it is neither committed nor opened.
99 let height = if height_no_padding == 0 {
100 0
101 } else {
102 height_no_padding.next_power_of_two()
103 };
104 let mut rows = vec![G::ZERO; height * width];
105 let rows_no_padding = &mut rows[0..height_no_padding * width];
106 // Builder rows start zeroed (`Lookup::empty()` in every slot), so padding
107 // rows need no writes at all.
108 let mut builder = LookupValues::builder(height, slot_arg_widths);
109 let mut row_writers = builder.rows_mut();
110 rows_no_padding
111 .par_chunks_mut(width)
112 .zip(row_writers[..height_no_padding].par_iter_mut())
113 .enumerate()
114 .for_each(|(i, (row, lookups))| {
115 let (inputs, result) = queries[i];
116 let index = &mut ColumnIndex {
117 auxiliary: 0,
118 // we skip the first lookup, which is reserved for return
119 lookup: 1,
120 };

Callers 2

proveMethod · 0.45
prove_ixvmMethod · 0.45

Calls 5

is_zeroMethod · 0.80
populate_rowMethod · 0.80
widthMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected