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 edge case in expand_root_of_unity #375

Merged
merged 1 commit into from Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/c_kzg_4844.c
Expand Up @@ -1557,13 +1557,16 @@ static C_KZG_RET bit_reversal_permutation(
static C_KZG_RET expand_root_of_unity(
fr_t *out, const fr_t *root, uint64_t width
) {
uint64_t i;
CHECK(width >= 2);
out[0] = FR_ONE;
out[1] = *root;

for (uint64_t i = 2; !fr_is_one(&out[i - 1]); i++) {
CHECK(i <= width);
for (i = 2; i <= width; i++) {
blst_fr_mul(&out[i], &out[i - 1], root);
if (fr_is_one(&out[i])) break;
}
CHECK(i == width);
CHECK(fr_is_one(&out[width]));

return C_KZG_OK;
Expand Down