Skip to content

Commit

Permalink
fix: input size for exp_reverse_bits_len
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-sun committed Jan 10, 2025
1 parent c9ce9e8 commit c760328
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions extensions/native/compiler/src/ir/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ impl<C: Config> Builder<C> {

/// Exponentiates a variable to a list of reversed bits with a given length.
///
/// Example: if power_bits = [1, 0, 1, 0] and bit_len = Const(4), then
/// the result should be x^8 * x^2 = x^10.
/// Example: if power_bits = [1, 0, 1, 0], then the result should be x^8 * x^2 = x^10.
///
/// Reference: [`openvm_stark_backend::p3_util::reverse_bits_len`]
pub fn exp_reverse_bits_len<V>(&mut self, x: V, power_bits: &Array<C, Var<C::N>>) -> V
Expand Down
1 change: 0 additions & 1 deletion extensions/native/recursion/src/challenger/duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ impl<C: Config> DuplexChallengerVariable<C> {
builder.range(nb_bits, bits.len()).for_each(|i, builder| {
builder.set(&bits, i, C::N::ZERO);
});

bits
}

Expand Down
3 changes: 2 additions & 1 deletion extensions/native/recursion/src/fri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ where
let two_adic_gen_ext = two_adic_generator_f.to_operand().symbolic();
let two_adic_generator_ef: Ext<_, _> = builder.eval(two_adic_gen_ext);

let x = builder.exp_reverse_bits_len(two_adic_generator_ef, index_bits);
let index_bits_truncated = index_bits.slice(builder, 0, log_max_height);
let x = builder.exp_reverse_bits_len(two_adic_generator_ef, &index_bits_truncated);

builder
.range(0, commit_phase_commits.len())
Expand Down
12 changes: 9 additions & 3 deletions extensions/native/recursion/src/fri/two_adic_pcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,19 @@ pub fn verify_two_adic_pcs<C: Config>(
let cur_alpha_pow = builder.get(&alpha_pow, log_height);

let bits_reduced: Usize<_> = builder.eval(log_max_height - log_height);
let index_bits_shifted = index_bits.shift(builder, bits_reduced);
let index_bits_shifted =
index_bits.shift(builder, bits_reduced.clone());

let two_adic_generator =
config.get_two_adic_generator(builder, log_height);
builder.cycle_tracker_start("exp-reverse-bits-len");
let two_adic_generator_exp = builder
.exp_reverse_bits_len(two_adic_generator, &index_bits_shifted);

let index_bits_shifted_truncated =
index_bits_shifted.slice(builder, 0, log_height);
let two_adic_generator_exp = builder.exp_reverse_bits_len(
two_adic_generator,
&index_bits_shifted_truncated,
);
builder.cycle_tracker_end("exp-reverse-bits-len");
let x: Felt<C::F> = builder.eval(two_adic_generator_exp * g);

Expand Down

0 comments on commit c760328

Please sign in to comment.