Use uint64 for some loop counters

This commit is contained in:
Ben Edgington 2021-02-05 13:46:05 +00:00
parent ddecf22708
commit 0558dbaba8
3 changed files with 10 additions and 6 deletions

View File

@ -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];
}

View File

@ -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;

View File

@ -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;
}
}