Skip to content

Commit db585cc

Browse files
committed
wip13
1 parent b6f9c54 commit db585cc

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

extensions/native/circuit/src/sumcheck/air.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ impl<AB: InteractionBuilder> Air<AB> for NativeSumcheckAir {
6767
logup_row,
6868
is_end,
6969

70+
prod_continued,
71+
logup_continued,
7072
// What type of evaluation is performed
7173
// mainly for reducing constraint degree
7274
prod_in_round_evaluation,
@@ -116,6 +118,12 @@ impl<AB: InteractionBuilder> Air<AB> for NativeSumcheckAir {
116118
let next_enabled = next.header_row + next.prod_row + next.logup_row;
117119
builder.assert_bool(enabled.clone());
118120

121+
builder
122+
.when_transition()
123+
.assert_eq(prod_row * next.prod_row, prod_continued);
124+
builder
125+
.when_transition()
126+
.assert_eq(logup_row * next.logup_row, logup_continued);
119127
// TODO: handle last row properly
120128

121129
builder.when_transition().assert_eq::<AB::Expr, AB::Expr>(
@@ -251,12 +259,11 @@ impl<AB: InteractionBuilder> Air<AB> for NativeSumcheckAir {
251259
);
252260
assert_array_eq::<_, _, _, { EXT_DEG }>(&mut builder.when(header_row), alpha, alpha1);
253261
let prod_next_alpha = FieldExtension::multiply(alpha1, alpha);
254-
// TODO: reduce the degree
255-
// assert_array_eq::<_, _, _, { EXT_DEG }>(
256-
// &mut builder.when(and(prod_row, next.prod_row)),
257-
// prod_next_alpha,
258-
// next_alpha1,
259-
// );
262+
assert_array_eq::<_, _, _, { EXT_DEG }>(
263+
&mut builder.when(prod_continued),
264+
prod_next_alpha,
265+
next_alpha1,
266+
);
260267
// alpha1 = alpha_numerator, alpha2 = alpha_denominator for logup row
261268
let alpha_denominator = FieldExtension::multiply(alpha1, alpha);
262269
assert_array_eq::<_, _, _, { EXT_DEG }>(
@@ -265,12 +272,11 @@ impl<AB: InteractionBuilder> Air<AB> for NativeSumcheckAir {
265272
alpha2,
266273
);
267274
let logup_next_alpha = FieldExtension::multiply(alpha2, alpha);
268-
// TODO: reduce the degree
269-
// assert_array_eq::<_, _, _, { EXT_DEG }>(
270-
// &mut builder.when(and(logup_row, next.logup_row)),
271-
// logup_next_alpha,
272-
// next_alpha1,
273-
// );
275+
assert_array_eq::<_, _, _, { EXT_DEG }>(
276+
&mut builder.when(logup_continued),
277+
logup_next_alpha,
278+
next_alpha1,
279+
);
274280

275281
///////////////////////////////////////
276282
// Header

extensions/native/circuit/src/sumcheck/chip.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ where
239239
prod_row.specific[..ProdSpecificCols::<F>::width()].borrow_mut();
240240

241241
prod_row.prod_row = F::ONE;
242+
prod_row.prod_continued = if i < (num_prod_spec - 1) as usize {
243+
F::ONE
244+
} else {
245+
F::ZERO
246+
};
242247
prod_row.curr_prod_n = F::from_canonical_usize(i + 1); // curr_prod_n starts from 1
243248
prod_row.start_timestamp = F::from_canonical_u32(cur_timestamp);
244249

@@ -327,6 +332,11 @@ where
327332
logup_row.specific[..LogupSpecificCols::<F>::width()].borrow_mut();
328333

329334
logup_row.logup_row = F::ONE;
335+
logup_row.logup_continued = if i < (num_logup_spec - 1) as usize {
336+
F::ONE
337+
} else {
338+
F::ZERO
339+
};
330340
logup_row.curr_logup_n = F::from_canonical_usize(i + 1); // curr_logup_n starts from 1
331341
logup_row.start_timestamp = F::from_canonical_u32(cur_timestamp);
332342

extensions/native/circuit/src/sumcheck/columns.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ pub struct NativeSumcheckCols<T> {
1919
/// Indicates that this row is the end of the entire layer sum operation
2020
pub is_end: T,
2121

22+
pub prod_continued: T,
23+
pub logup_continued: T,
24+
2225
/// Indicates what type of evaluation constraints should be applied
2326
pub prod_in_round_evaluation: T,
2427
pub prod_next_round_evaluation: T,

0 commit comments

Comments
 (0)