Skip to content

Commit 176a6eb

Browse files
committed
Apply comments
1 parent 7936fab commit 176a6eb

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

recursion/src/recursive_challenger.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ pub trait RecursiveChallenger<F: Field> {
3535
(0..count).map(|_| self.sample(circuit)).collect()
3636
}
3737

38-
fn sample_bits(
38+
/// Samples a challenge from the current challenger state and decomposes it into `total_num_bits` (public input) bits.
39+
/// Returns the first `num_bits` bits.
40+
fn sample_public_bits(
3941
&mut self,
4042
circuit: &mut CircuitBuilder<F>,
4143
total_num_bits: usize,
@@ -49,16 +51,16 @@ pub trait RecursiveChallenger<F: Field> {
4951
bits[..num_bits].to_vec()
5052
}
5153

54+
/// Checks a PoW witness.
5255
fn check_witness(
5356
&mut self,
5457
circuit: &mut CircuitBuilder<F>,
5558
witness_bits: usize,
5659
witness: Target,
5760
total_num_bits: usize,
5861
) {
59-
// TODO: Replace `sample_bits` with a specific method that only gets returns the final bits: the first ones are all 0.
6062
self.observe(circuit, witness);
61-
let bits = self.sample_bits(circuit, total_num_bits, witness_bits);
63+
let bits = self.sample_public_bits(circuit, total_num_bits, witness_bits);
6264
for bit in bits {
6365
circuit.assert_zero(bit);
6466
}

recursion/src/recursive_generation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ where
250250
// Check PoW witness.
251251
challenger.observe(opening_proof.pow_witness);
252252

253-
// Sample bits, and add the nonzero bits to the challenges.
253+
// Sample a challenge and decompose it into bits. Add the nonzero bits to the challenges.
254254
let rand_f: Val<SC> = challenger.sample();
255255
let rand_usize = rand_f.as_canonical_biguint().to_u64_digits()[0] as usize;
256256
// Get the bits. The total number of bits is the number of bits in a base field element.

recursion/src/recursive_pcs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ where
638638
// Observe final polynomial coefficients
639639
challenger.observe_slice(circuit, &fri_proof.final_poly);
640640

641-
// TODO: Use sample_bits and check that the output is 0.
641+
// Check PoW witness.
642642
challenger.check_witness(
643643
circuit,
644644
params.pow_bits,

recursion/tests/fri.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -464,22 +464,16 @@ fn run_fri_test(setup: FriSetup, build_only: bool) {
464464
builder.pop_scope();
465465

466466
// 4) Wire the arithmetic-only FRI verifier
467-
let verif_res =
468-
verify_fri_circuit::<F, Challenge, RecExt, RecVal, RecWitness<F>, p3_recursion::Target>(
469-
&mut builder,
470-
&fri_targets,
471-
alpha_t,
472-
&betas_t,
473-
&index_bits_t_per_query,
474-
&commitments_with_opening_points_targets,
475-
log_blowup,
476-
);
477-
478-
assert!(
479-
verif_res.is_ok(),
480-
"FRI verification failed: {:?}",
481-
verif_res
482-
);
467+
verify_fri_circuit::<F, Challenge, RecExt, RecVal, RecWitness<F>, p3_recursion::Target>(
468+
&mut builder,
469+
&fri_targets,
470+
alpha_t,
471+
&betas_t,
472+
&index_bits_t_per_query,
473+
&commitments_with_opening_points_targets,
474+
log_blowup,
475+
)
476+
.unwrap();
483477

484478
builder.dump_allocation_log();
485479
let circuit = builder.build().unwrap();

0 commit comments

Comments
 (0)