Skip to content

Commit 005c223

Browse files
committed
packing for DotProductFootprint (unused for now)
1 parent 39f0b71 commit 005c223

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

crates/lean_prover/src/common.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl SumcheckComputationPacked<EF> for PrecompileFootprint {
221221
}
222222

223223
fn eval_packed_base(&self, point: &[PFPacking<EF>], _: &[EF]) -> EFPacking<EF> {
224-
self.air_eval::<PFPacking<EF>, EFPacking<EF>>(point, |p, c| EFPacking::<EF>::from(p) * c)
224+
self.air_eval(point, |p, c| EFPacking::<EF>::from(p) * c)
225225
}
226226
}
227227

@@ -230,6 +230,25 @@ pub struct DotProductFootprint {
230230
pub dot_product_challenge: [EF; 6],
231231
}
232232

233+
impl DotProductFootprint {
234+
fn air_eval<
235+
PointF: PrimeCharacteristicRing + Copy,
236+
ResultF: Algebra<EF> + Algebra<PointF> + Copy,
237+
>(
238+
&self,
239+
point: &[PointF],
240+
mul_point_f_and_ef: impl Fn(PointF, EF) -> ResultF,
241+
) -> ResultF {
242+
(mul_point_f_and_ef(point[2], self.dot_product_challenge[2])
243+
+ mul_point_f_and_ef(point[3], self.dot_product_challenge[3])
244+
+ mul_point_f_and_ef(point[4], self.dot_product_challenge[4])
245+
+ mul_point_f_and_ef(point[1], self.dot_product_challenge[5]))
246+
* point[0]
247+
+ self.dot_product_challenge[1]
248+
+ self.global_challenge
249+
}
250+
}
251+
233252
impl<N: ExtensionField<PF<EF>>> SumcheckComputation<N, EF> for DotProductFootprint
234253
where
235254
EF: ExtensionField<N>,
@@ -239,13 +258,7 @@ where
239258
}
240259

241260
fn eval(&self, point: &[N], _: &[EF]) -> EF {
242-
self.global_challenge
243-
+ self.dot_product_challenge[1]
244-
+ (self.dot_product_challenge[2] * point[2]
245-
+ self.dot_product_challenge[3] * point[3]
246-
+ self.dot_product_challenge[4] * point[4]
247-
+ self.dot_product_challenge[5] * point[1])
248-
* point[0]
261+
self.air_eval(point, |p, c| c * p)
249262
}
250263
}
251264

@@ -254,10 +267,10 @@ impl SumcheckComputationPacked<EF> for DotProductFootprint {
254267
2
255268
}
256269

257-
fn eval_packed_extension(&self, _point: &[EFPacking<EF>], _: &[EF]) -> EFPacking<EF> {
258-
todo!()
270+
fn eval_packed_extension(&self, point: &[EFPacking<EF>], _: &[EF]) -> EFPacking<EF> {
271+
self.air_eval(point, |p, c| p * c)
259272
}
260-
fn eval_packed_base(&self, _point: &[utils::PFPacking<EF>], _: &[EF]) -> EFPacking<EF> {
261-
todo!()
273+
fn eval_packed_base(&self, point: &[utils::PFPacking<EF>], _: &[EF]) -> EFPacking<EF> {
274+
self.air_eval(point, |p, c| EFPacking::<EF>::from(p) * c)
262275
}
263276
}

crates/lean_prover/src/prove_execution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,13 @@ pub fn prove_execution(
410410
_,
411411
) = info_span!("Grand product sumcheck for Dot Product").in_scope(|| {
412412
sumcheck::prove(
413-
1, // TODO univariate skip?
413+
1,
414414
MleGroupRef::Extension(
415415
dot_product_columns[..5]
416416
.iter()
417417
.map(|c| c.as_slice())
418418
.collect::<Vec<_>>(),
419-
), // TODO packing
419+
), // we do not use packing here beacause it's slower in practice (this sumcheck is small)
420420
&dot_product_footprint_computation,
421421
&dot_product_footprint_computation,
422422
&[],

0 commit comments

Comments
 (0)