Skip to content

Commit deeaeec

Browse files
authored
air: use ref for column groups in AirWitness (#27)
1 parent 2b5c779 commit deeaeec

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

crates/air/src/prove.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ fn eval_unstructured_column_groups<EF: ExtensionField<PF<EF>> + ExtensionField<I
286286
columns_batching_scalars: &[EF],
287287
) -> Vec<Vec<EF>> {
288288
let mut all_sub_evals = vec![];
289-
for group in &witnesses.column_groups {
289+
for group in witnesses.column_groups {
290290
let batched_column = multilinears_linear_combination(
291291
&witnesses.cols[group.clone()],
292292
&eval_eq(from_end(
@@ -403,7 +403,7 @@ fn open_structured_columns<EF: ExtensionField<PF<EF>> + ExtensionField<IF>, IF:
403403
let mut all_inner_sums = vec![];
404404
let mut all_batched_columns = vec![];
405405
let mut all_batched_columns_mixed = vec![];
406-
for group in &witness.column_groups {
406+
for group in witness.column_groups {
407407
let batched_column = multilinears_linear_combination(
408408
&witness.cols[group.clone()],
409409
&eval_eq(from_end(

crates/air/src/witness.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use p3_util::{log2_ceil_usize, log2_strict_usize};
1010
#[derive(Debug)]
1111
pub struct AirWitness<'a, F> {
1212
pub cols: Vec<&'a [F]>,
13-
pub column_groups: Vec<Range<usize>>,
13+
pub column_groups: &'a [Range<usize>],
1414
}
1515

1616
impl<'a, F> Deref for AirWitness<'a, F> {
@@ -21,11 +21,8 @@ impl<'a, F> Deref for AirWitness<'a, F> {
2121
}
2222

2323
impl<'a, F> AirWitness<'a, F> {
24-
pub fn new(cols: &'a [impl Borrow<[F]>], column_groups: &[Range<usize>]) -> Self {
25-
let cols = cols
26-
.iter()
27-
.map(std::borrow::Borrow::borrow)
28-
.collect::<Vec<_>>();
24+
pub fn new(cols: &'a [impl Borrow<[F]>], column_groups: &'a [Range<usize>]) -> Self {
25+
let cols = cols.iter().map(Borrow::borrow).collect::<Vec<_>>();
2926
assert!(
3027
cols.iter()
3128
.all(|col| col.len() == (1 << log2_strict_usize(cols[0].len()))),
@@ -36,7 +33,7 @@ impl<'a, F> AirWitness<'a, F> {
3633
assert!(column_groups.iter().all(|r| r.start < r.end));
3734
Self {
3835
cols,
39-
column_groups: column_groups.to_vec(),
36+
column_groups,
4037
}
4138
}
4239

crates/zk_vm/src/prove_execution.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ pub fn prove_execution(
8080
.iter()
8181
.map(Vec::as_slice),
8282
);
83-
let exec_witness = AirWitness::<PF<EF>>::new(&exec_columns, &exec_column_groups());
83+
let exec_column_groups = exec_column_groups();
84+
let exec_witness = AirWitness::new(&exec_columns, &exec_column_groups);
8485
let exec_table = AirTable::<EF, _>::new(VMAir);
8586

8687
#[cfg(test)]
@@ -96,8 +97,10 @@ pub fn prove_execution(
9697
let dot_product_table = AirTable::<EF, _>::new(DotProductAir);
9798

9899
let (p16_columns, p24_columns) = build_poseidon_columns(&poseidons_16, &poseidons_24);
99-
let p16_witness = AirWitness::new(&p16_columns, &poseidon_16_column_groups(&p16_air));
100-
let p24_witness = AirWitness::new(&p24_columns, &poseidon_24_column_groups(&p24_air));
100+
let p16_column_groups = poseidon_16_column_groups(&p16_air);
101+
let p24_column_groups = poseidon_24_column_groups(&p24_air);
102+
let p16_witness = AirWitness::new(&p16_columns, &p16_column_groups);
103+
let p24_witness = AirWitness::new(&p24_columns, &p24_column_groups);
101104

102105
let (dot_product_columns, dot_product_padding_len) = build_dot_product_columns(&dot_products);
103106
let dot_product_witness = AirWitness::new(&dot_product_columns, &DOT_PRODUCT_AIR_COLUMN_GROUPS);

0 commit comments

Comments
 (0)