scroll-tech/halo2-snark-aggregator

why subtract one in integer_chip

JohnWick2ETH opened this issue · 2 comments

why subtract one to compute v1 in the integer_chip.add_constraints_for_mul_equation_on_limb0()?

AFAIK, v1*2^2b = u1 + v0.

let u1 = v0 - one + limbs[2].value - rem.limbs_le[2].value

To avoid minus overflow when computing u0, we borrowed one from v1.
Think about
limbs[1].value < rem.limbs_le[1].value || (limbs[1].value == rem.limbs_le[1].value && limbs[0].value < rem.limbs_le[0].value)
see

+ self.helper.limb_modulus_exps[2];
,

why would it happen that u0 is negative?