Skip to content

Commit c39ce01

Browse files
chore(whir_zk): clippy + signature cleanup post-pruned-NTT
Reviewer flagged that `f_hat_witness: &mut` in `ood_stir_and_rounds`, `gamma_check`, and `prove_blinded_polynomial` is no longer accurate — the partial-encode path never mutates the witness. Switch to `&` and drop the now-redundant `&*` reborrows. Misleading `&mut` could mask future bugs where the witness is unintentionally mutated. Also applies the smaller clippy/fmt nits the reviewer surfaced: - ntt_partial: allow(dead_code) (kept pub for external callers; the hot path uses ntt_partial_with_plan_into) - PartialNttPlan::size: const fn - ntt_partial_with_plan_into: allow(significant_drop_tightening); the roots-table RwLockReadGuard is intentionally held across all DIT stages, mirroring ntt_dispatch - assertion comparison form: `> n` instead of `>= n + 1` - cargo fmt `cargo clippy -- -D warnings` is now clean; 155 lib tests still pass.
1 parent d4ad1fb commit c39ce01

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/algebra/ntt/cooley_tukey.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ impl<F: Field> NttEngine<F> {
370370
/// `O(size * log(size))` for a full NTT.
371371
///
372372
/// `size` must be a power of two.
373+
#[allow(dead_code)] // public single-shot entry; batched callers use the plan-based path
373374
pub fn ntt_partial(&self, values: &[F], size: usize, indices: &[usize]) -> Vec<F> {
374375
let plan = PartialNttPlan::new(size, indices);
375376
let mut out = vec![F::ZERO; indices.len()];
@@ -383,6 +384,7 @@ impl<F: Field> NttEngine<F> {
383384
///
384385
/// Sharing a single plan across many NTTs with the same `(size, indices)`
385386
/// avoids re-running the O(size · log size) mask construction per call.
387+
#[allow(clippy::significant_drop_tightening)] // roots guard intentionally held across DIT stages
386388
pub fn ntt_partial_with_plan_into(
387389
&self,
388390
values: &[F],
@@ -397,7 +399,7 @@ impl<F: Field> NttEngine<F> {
397399
return;
398400
}
399401
assert!(
400-
out.len() >= (indices.len() - 1) * stride + 1,
402+
out.len() > (indices.len() - 1) * stride,
401403
"output buffer too small for stride"
402404
);
403405
if size == 1 {
@@ -507,7 +509,7 @@ impl PartialNttPlan {
507509
}
508510
}
509511

510-
pub fn size(&self) -> usize {
512+
pub const fn size(&self) -> usize {
511513
self.size
512514
}
513515

src/protocols/whir_zk/prover.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ where
327327
alpha_coeffs: &[F],
328328
rho: F,
329329
folding_randomness: MultilinearPoint<F>,
330-
f_hat_witness: &mut irs_commit::Witness<F, F>,
330+
f_hat_witness: &irs_commit::Witness<F, F>,
331331
f_hat_polys: &[Vec<F>],
332332
masking_polys: &[Vec<F>],
333333
g_polys: &[Vec<F>],
@@ -353,7 +353,7 @@ where
353353
.open_from_coeffs(
354354
self.prover_state,
355355
&[&f_hat_refs],
356-
&[&*f_hat_witness],
356+
&[f_hat_witness],
357357
);
358358

359359
let r_bar = folding_randomness.0;
@@ -454,7 +454,7 @@ where
454454
/// codeword matrix is never materialised.
455455
fn gamma_check(
456456
&mut self,
457-
f_hat_witness: &mut irs_commit::Witness<F, F>,
457+
f_hat_witness: &irs_commit::Witness<F, F>,
458458
f_hat_polys: &[Vec<F>],
459459
masking_coeffs_all: &[Vec<F>],
460460
g_i_coeffs: &[Vec<F>],
@@ -474,7 +474,7 @@ where
474474
.open_at_indices_from_coeffs(
475475
self.prover_state,
476476
&[&f_hat_refs],
477-
&[&*f_hat_witness],
477+
&[f_hat_witness],
478478
&gamma_f_hat_indices,
479479
);
480480

@@ -498,7 +498,7 @@ impl<F: FftField> Config<F> {
498498
&self,
499499
prover_state: &mut ProverState<H, R>,
500500
vectors: Vec<Cow<'_, [F]>>,
501-
f_hat_witness: &mut irs_commit::Witness<F, F>,
501+
f_hat_witness: &irs_commit::Witness<F, F>,
502502
f_hat_polys: &[Vec<F>],
503503
masking_polys: &[Vec<F>],
504504
g_polys: &[Vec<F>],
@@ -696,7 +696,7 @@ impl<F: FftField> Config<F> {
696696
Hash: ProverMessage<[H::U]>,
697697
{
698698
let Witness {
699-
mut f_hat_witness,
699+
f_hat_witness,
700700
mut blinding_poly_witness,
701701
f_hat_polys,
702702
secrets,
@@ -713,7 +713,7 @@ impl<F: FftField> Config<F> {
713713
let blinded = self.prove_blinded_polynomial(
714714
prover_state,
715715
vectors,
716-
&mut f_hat_witness,
716+
&f_hat_witness,
717717
&f_hat_polys,
718718
&secrets.masking_polys,
719719
&secrets.g_polys,

0 commit comments

Comments
 (0)