diff --git a/src/fft_common.c b/src/fft_common.c index 6727266..ad2bf15 100644 --- a/src/fft_common.c +++ b/src/fft_common.c @@ -28,7 +28,7 @@ C_KZG_RET expand_root_of_unity(blst_fr *roots, const blst_fr *root_of_unity, con roots[0] = fr_one; roots[1] = *root_of_unity; - for (int i = 2; !fr_is_one(&roots[i - 1]); i++) { + for (uint64_t i = 2; !fr_is_one(&roots[i - 1]); i++) { ASSERT(i <= width, C_KZG_ERROR); blst_fr_mul(&roots[i], &roots[i - 1], root_of_unity); } @@ -40,7 +40,7 @@ C_KZG_RET expand_root_of_unity(blst_fr *roots, const blst_fr *root_of_unity, con // Create a reversed list of Fr provided // `width` is one less than the length of `roots` C_KZG_RET reverse(blst_fr *out, const blst_fr *roots, const uint64_t width) { - for (int i = 0; i <= width; i++) { + for (uint64_t i = 0; i <= width; i++) { out[i] = roots[width - i]; } diff --git a/src/fft_common_test.c b/src/fft_common_test.c index 57c4a60..772f50b 100644 --- a/src/fft_common_test.c +++ b/src/fft_common_test.c @@ -30,9 +30,9 @@ void roots_of_unity_is_the_expected_size(void) { void roots_of_unity_are_plausible(void) { blst_fr r; - for (unsigned int i = 0; i < NUM_ROOTS; i++) { + for (int i = 0; i < NUM_ROOTS; i++) { blst_fr_from_uint64(&r, scale2_root_of_unity[i]); - for (unsigned int j = 0; j < i; j++) { + for (int j = 0; j < i; j++) { blst_fr_sqr(&r, &r); } TEST_CHECK(true == fr_is_one(&r)); @@ -83,7 +83,7 @@ void expand_roots_is_plausible(void) { void new_fft_settings_is_plausible(void) { // Just test one (largeish) value of scale - unsigned int scale = 21; + int scale = 21; unsigned int width = 1 << scale; blst_fr prod; FFTSettings s; diff --git a/src/poly.c b/src/poly.c index 46acee1..0f18dc9 100644 --- a/src/poly.c +++ b/src/poly.c @@ -32,6 +32,7 @@ void poly_free(poly p) { void poly_eval(blst_fr *out, const poly *p, const blst_fr *x) { blst_fr tmp; + uint64_t i; if (p->length == 0) { fr_from_uint64(out, 0); @@ -42,9 +43,12 @@ void poly_eval(blst_fr *out, const poly *p, const blst_fr *x) { // Horner's method *out = p->coeffs[p->length - 1]; - for (int i = p->length - 2; i >= 0; i--) { // needs to be uint64_t? + i = p->length - 2; + while (true) { blst_fr_mul(&tmp, out, x); blst_fr_add(out, &tmp, &p->coeffs[i]); + if (i == 0) break; + --i; } }