Skip to content

Commit

Permalink
fix: avoid potential panic in two_complement (#2081)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Jul 28, 2023
1 parent 0164a92 commit 63c4da0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ impl GeneratedAcir {
) -> Expression {
let max_power_of_two =
FieldElement::from(2_i128).pow(&FieldElement::from(max_bit_size as i128 - 1));
let inter = &(&Expression::from_field(max_power_of_two) - lhs) * &leading.into();
lhs.add_mul(FieldElement::from(2_i128), &inter.unwrap())

let intermediate =
self.mul_with_witness(&(&Expression::from(max_power_of_two) - lhs), &leading.into());

lhs.add_mul(FieldElement::from(2_i128), &intermediate)
}

/// Returns an expression which represents `lhs * rhs`
Expand Down

0 comments on commit 63c4da0

Please sign in to comment.