(
&self,
function_index: usize,
query_record: &QueryRecord,
io_buffer: &IOBuffer,
)
| 72 | #[derive(Clone, Copy)] |
| 73 | struct TraceContext<'a> { |
| 74 | function_index: G, |
| 75 | multiplicity: G, |
| 76 | inputs: &'a [G], |
| 77 | output: &'a [G], |
| 78 | query_record: &'a QueryRecord, |
| 79 | } |
| 80 | |
| 81 | impl 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 | }; |
no test coverage detected