Fix edge case in expand_root_of_unity (#375)
This commit is contained in:
parent
456c3d8fab
commit
f3fffecd1c
|
@ -1557,13 +1557,16 @@ static C_KZG_RET bit_reversal_permutation(
|
||||||
static C_KZG_RET expand_root_of_unity(
|
static C_KZG_RET expand_root_of_unity(
|
||||||
fr_t *out, const fr_t *root, uint64_t width
|
fr_t *out, const fr_t *root, uint64_t width
|
||||||
) {
|
) {
|
||||||
|
uint64_t i;
|
||||||
|
CHECK(width >= 2);
|
||||||
out[0] = FR_ONE;
|
out[0] = FR_ONE;
|
||||||
out[1] = *root;
|
out[1] = *root;
|
||||||
|
|
||||||
for (uint64_t i = 2; !fr_is_one(&out[i - 1]); i++) {
|
for (i = 2; i <= width; i++) {
|
||||||
CHECK(i <= width);
|
|
||||||
blst_fr_mul(&out[i], &out[i - 1], root);
|
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]));
|
CHECK(fr_is_one(&out[width]));
|
||||||
|
|
||||||
return C_KZG_OK;
|
return C_KZG_OK;
|
||||||
|
|
Loading…
Reference in New Issue