Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpwang authored Jan 20, 2025
1 parent df279c4 commit 1acaf55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions extensions/native/compiler/src/constraints/halo2/baby_bear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ impl BabyBearChip {
max_bits,
},
);
// let (_, r) = signed_div_mod(&self.range, ctx, diff, BabyBear::ORDER_U32, max_bits);
// self.gate().assert_is_const(ctx, &r, &Fr::ZERO);
debug_assert_eq!(c.to_baby_bear(), a.to_baby_bear() / b.to_baby_bear());
c
}
Expand Down Expand Up @@ -259,7 +257,7 @@ impl BabyBearChip {
[0],
);
let div = ctx.get(-2);
// Constrain that `abs(div) <= 2 ** (2 ** a_num_bits / b`).bits().
// Constrain that `abs(div) <= 2 ** (2 ** a_num_bits / b).bits()`.
let bound = (BigUint::from(1u32) << (a_num_bits as u32)) / &b;
let shifted_div =
self.range
Expand All @@ -271,7 +269,7 @@ impl BabyBearChip {
// In particular, 2 * bound + 1 has at most Fr::CAPACITY - RESERVED_HIGH_BITS - BABYBEAR_ORDER_BITS + 1 bits.
// Most notably, suppose we could fake |p * shifted_div - p * shifted_div'| < p, with both shifted_div and shifted_div'
// distinct and satisfying the range check. We note that |shifted_div-shifted_div'| < 1 << (Fr::CAPACITY - RESERVED_HIGH_BITS - BABYBEAR_ORDER_BITS + 1)
// In particular, even if we multiply by babybear, we have 0 < p * |shifted_div-shifted_div' < 1 << (Fr::CAPACITY - RESERVED_HIGH_BITS + 2)
// In particular, even if we multiply by babybear, we have 0 < p * |shifted_div-shifted_div'| < 1 << (Fr::CAPACITY - RESERVED_HIGH_BITS + 2)
// its pretty clear that this has no overlap with (-p, p), so we are safe.
self.range
.range_check(ctx, shifted_div, (bound * 2u32 + 1u32).bits() as usize);
Expand Down Expand Up @@ -321,7 +319,7 @@ where
);
let rem = ctx.get(-4);
let div = ctx.get(-2);
// Constrain that `abs(div) <= 2 ** (2 ** a_num_bits / b`).bits().
// Constrain that `abs(div) <= 2 ** (2 ** a_num_bits / b).bits()`.
let bound = (BigUint::from(1u32) << (a_num_bits as u32)) / &b;
let shifted_div = range
.gate()
Expand All @@ -332,7 +330,7 @@ where
// In particular, 2 * bound + 1 has at most Fr::CAPACITY - RESERVED_HIGH_BITS - BABYBEAR_ORDER_BITS + 1 bits.
// Most notably, suppose we could fake |p * shifted_div - p * shifted_div'| < p, with both shifted_div and shifted_div'
// distinct and satisfying the range check. We note that |shifted_div-shifted_div'| < 1 << (Fr::CAPACITY - RESERVED_HIGH_BITS - BABYBEAR_ORDER_BITS + 1)
// In particular, even if we multiply by babybear, we have 0 < p * |shifted_div-shifted_div' < 1 << (Fr::CAPACITY - RESERVED_HIGH_BITS + 2)
// In particular, even if we multiply by babybear, we have 0 < p * |shifted_div-shifted_div'| < 1 << (Fr::CAPACITY - RESERVED_HIGH_BITS + 2)
// its pretty clear that this has no overlap with (-p, p), so we are safe.
range.range_check(ctx, shifted_div, (bound * 2u32 + 1u32).bits() as usize);
// Constrain that remainder is less than divisor (i.e. `r < b`).
Expand Down
1 change: 0 additions & 1 deletion extensions/native/recursion/src/fri/two_adic_pcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ pub fn verify_two_adic_pcs<C: Config>(
builder.range(0, ps_at_z.len()).for_each(|t, builder| {
let p_at_x = builder.get(&mat_opening, t);
let p_at_z = builder.get(&ps_at_z, t);
// let quotient = (p_at_z - p_at_x) / (z - x);

builder.assign(&n, cur_alpha_pow * (p_at_z - p_at_x) + n);
builder.assign(&cur_alpha_pow, cur_alpha_pow * alpha);
Expand Down

0 comments on commit 1acaf55

Please sign in to comment.