Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bn): limbs limit in assign_sum #94

Merged
merged 1 commit into from
Jan 10, 2024
Merged

Conversation

cyphersnake
Copy link
Collaborator

There was a bug if exactly limbs_count of elements was obtained while calculating the sum, then panic on split_at would fall. Now this check for zero tail is optional.

@cyphersnake cyphersnake requested a review from chaosma January 9, 2024 14:16
@cyphersnake cyphersnake self-assigned this Jan 9, 2024
@cyphersnake cyphersnake force-pushed the bn-fix-sum-limbs-limit branch from 6f83509 to 4c35bf7 Compare January 9, 2024 14:33
@cyphersnake cyphersnake enabled auto-merge (rebase) January 9, 2024 20:32
@@ -150,20 +150,24 @@ impl<F: ff::PrimeField> BigUintMulModChip<F> {
big_uint::nat_to_f::<F>(&big_uint::get_big_int_with_n_ones(self.limb_width.get()))
.unwrap_or_default();

let (rhs_cells, rhs_tail) = rhs_cells.split_at(self.limbs_count_limit.get());
if rhs_cells.len() > self.limbs_count_limit.get() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why previous will panic at split_at? Do you mean rhs_tail.iter() will panic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic here

Len of sum result is less, then limbs limit & panic because of that

@cyphersnake cyphersnake requested a review from chaosma January 10, 2024 10:29
There was a bug if exactly limbs_count of elements was obtained while calculating the sum, then panic on `split_at` would fall. Now this check for zero tail is optional.
@cyphersnake cyphersnake force-pushed the bn-fix-sum-limbs-limit branch from 4c35bf7 to 5879d9d Compare January 10, 2024 14:47
@cyphersnake cyphersnake merged commit 67f2741 into main Jan 10, 2024
1 check passed
@cyphersnake cyphersnake deleted the bn-fix-sum-limbs-limit branch January 10, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants