Skip to content

Commit

Permalink
Replace division of constant 1 with inverse (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored May 6, 2024
1 parent 7a8baff commit 43d6f06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/flp/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ where
)?;

// Check that the elements of `input` sum to 1.
let mut sum_check = -(F::one() / F::from(F::valid_integer_try_from(num_shares)?));
let mut sum_check = -F::from(F::valid_integer_try_from(num_shares)?).inv();
for val in input.iter() {
sum_check += *val;
}
Expand Down
2 changes: 1 addition & 1 deletion src/flp/types/fixedpoint_l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ where
self.valid_call_check(input, joint_rand)?;

let f_num_shares = Field128::from(Field128::valid_integer_try_from::<usize>(num_shares)?);
let num_shares_inverse = Field128::one() / f_num_shares;
let num_shares_inverse = f_num_shares.inv();

// Ensure that all submitted field elements are either 0 or 1.
// This is done for:
Expand Down

0 comments on commit 43d6f06

Please sign in to comment.