Skip to content

Commit

Permalink
fix(boojum): compute the correct number of PoW seed challenges (#43)
Browse files Browse the repository at this point in the history
This PR fixes a bug in PoW seed challenge count calculation.
  • Loading branch information
robik75 authored Nov 18, 2024
1 parent 9ecb5cd commit 8d2f5f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions crates/boojum/src/cs/implementations/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2111,11 +2111,9 @@ impl<

let now = std::time::Instant::now();

const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / F::CHAR_BITS;
if num_challenges % F::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(F::CHAR_BITS) / F::CHAR_BITS;
let challenges = transcript.get_multiple_challenges(num_challenges);
let pow_challenge = POW::run_from_field_elements(challenges, new_pow_bits, worker);

Expand Down
6 changes: 2 additions & 4 deletions crates/boojum/src/cs/implementations/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,11 +1958,9 @@ impl<F: SmallField, EXT: FieldExtension<2, BaseField = F>> Verifier<F, EXT> {
log!("Doing PoW verification for {} bits", new_pow_bits);
log!("Prover gave challenge 0x{:016x}", proof.pow_challenge);

const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / F::CHAR_BITS;
if num_challenges % F::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(F::CHAR_BITS) / F::CHAR_BITS;
let challenges = transcript.get_multiple_challenges(num_challenges);
let pow_challenge = proof.pow_challenge;

Expand Down
6 changes: 2 additions & 4 deletions crates/boojum/src/gadgets/recursion/recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,11 +1493,9 @@ impl<F: SmallField, EXT: FieldExtension<2, BaseField = F>, CS: ConstraintSystem<
log!("Doing PoW verification for {} bits", new_pow_bits);
// log!("Prover gave challenge 0x{:016x}", proof.pow_challenge);

const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / F::CHAR_BITS;
if num_challenges % F::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(F::CHAR_BITS) / F::CHAR_BITS;
let _challenges: Vec<_> = transcript.get_multiple_challenges(cs, num_challenges);

todo!()
Expand Down

0 comments on commit 8d2f5f7

Please sign in to comment.