Rename success return code
This commit is contained in:
parent
60a6d33f73
commit
8538d74298
|
@ -18,7 +18,7 @@
|
|||
#define C_KZG_H
|
||||
|
||||
typedef enum {
|
||||
C_KZG_SUCCESS = 0,
|
||||
C_KZG_OK = 0,
|
||||
C_KZG_BADARGS,
|
||||
C_KZG_ERROR,
|
||||
} C_KZG_RET;
|
||||
|
|
|
@ -34,7 +34,7 @@ C_KZG_RET expand_root_of_unity(blst_fr *roots, const blst_fr *root_of_unity, con
|
|||
}
|
||||
ASSERT(fr_is_one(&roots[width]), C_KZG_ERROR);
|
||||
|
||||
return C_KZG_SUCCESS;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
||||
// Create a reversed list of Fr provided
|
||||
|
@ -44,7 +44,7 @@ C_KZG_RET reverse(blst_fr *out, const blst_fr *roots, const uint64_t width) {
|
|||
out[i] = roots[width - i];
|
||||
}
|
||||
|
||||
return C_KZG_SUCCESS;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
||||
C_KZG_RET new_fft_settings(FFTSettings *fs, const unsigned int max_scale) {
|
||||
|
@ -55,7 +55,7 @@ C_KZG_RET new_fft_settings(FFTSettings *fs, const unsigned int max_scale) {
|
|||
fs->reverse_roots_of_unity = malloc((fs->max_width + 1) * sizeof(blst_fr));
|
||||
|
||||
ret = expand_root_of_unity(fs->expanded_roots_of_unity, &fs->root_of_unity, fs->max_width);
|
||||
if (ret != C_KZG_SUCCESS) return ret;
|
||||
if (ret != C_KZG_OK) return ret;
|
||||
ret = reverse(fs->reverse_roots_of_unity, fs->expanded_roots_of_unity, fs->max_width);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void reverse_works(void) {
|
|||
}
|
||||
|
||||
// Reverse
|
||||
TEST_CHECK(reverse(rev, arr, n) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(reverse(rev, arr, n) == C_KZG_OK);
|
||||
|
||||
// Verify - decreasing values
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
@ -70,7 +70,7 @@ void expand_roots_is_plausible(void) {
|
|||
|
||||
// Initialise
|
||||
blst_fr_from_uint64(&root, scale2_root_of_unity[scale]);
|
||||
TEST_CHECK(expand_root_of_unity(expanded, &root, width) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(expand_root_of_unity(expanded, &root, width) == C_KZG_OK);
|
||||
|
||||
// Verify - each pair should multiply to one
|
||||
TEST_CHECK(true == fr_is_one(expanded + 0));
|
||||
|
@ -88,7 +88,7 @@ void new_fft_settings_is_plausible(void) {
|
|||
blst_fr prod;
|
||||
FFTSettings s;
|
||||
|
||||
TEST_CHECK(new_fft_settings(&s, scale) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(new_fft_settings(&s, scale) == C_KZG_OK);
|
||||
|
||||
// Verify - each pair should multiply to one
|
||||
for (unsigned int i = 1; i <= width; i++) {
|
||||
|
|
|
@ -66,5 +66,5 @@ C_KZG_RET fft_fr (blst_fr *out, blst_fr *in, FFTSettings *fs, bool inv, uint64_t
|
|||
} else {
|
||||
fft_fr_fast(out, in, 1, fs->expanded_roots_of_unity, stride, fs->max_width);
|
||||
}
|
||||
return C_KZG_SUCCESS;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ void compare_sft_fft(void) {
|
|||
// Initialise: ascending values of i (could be anything), and arbitrary size
|
||||
unsigned int size = 12;
|
||||
FFTSettings fs;
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_OK);
|
||||
blst_fr data[fs.max_width], out0[fs.max_width], out1[fs.max_width];
|
||||
for (int i = 0; i < fs.max_width; i++) {
|
||||
fr_from_uint64(data + i, i);
|
||||
|
@ -67,15 +67,15 @@ void roundtrip_fft(void) {
|
|||
// Initialise: ascending values of i, and arbitrary size
|
||||
unsigned int size = 12;
|
||||
FFTSettings fs;
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_OK);
|
||||
blst_fr data[fs.max_width], coeffs[fs.max_width];
|
||||
for (int i = 0; i < fs.max_width; i++) {
|
||||
fr_from_uint64(data + i, i);
|
||||
}
|
||||
|
||||
// Forward and reverse FFT
|
||||
TEST_CHECK(fft_fr(coeffs, data, &fs, false, fs.max_width) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(fft_fr(data, coeffs, &fs, true, fs.max_width) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(fft_fr(coeffs, data, &fs, false, fs.max_width) == C_KZG_OK);
|
||||
TEST_CHECK(fft_fr(data, coeffs, &fs, true, fs.max_width) == C_KZG_OK);
|
||||
|
||||
// Verify that the result is still ascending values of i
|
||||
for (int i = 0; i < fs.max_width; i++) {
|
||||
|
@ -90,14 +90,14 @@ void roundtrip_fft(void) {
|
|||
void inverse_fft(void) {
|
||||
// Initialise: ascending values of i
|
||||
FFTSettings fs;
|
||||
TEST_CHECK(new_fft_settings(&fs, 4) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(new_fft_settings(&fs, 4) == C_KZG_OK);
|
||||
blst_fr data[fs.max_width], out[fs.max_width];
|
||||
for (int i = 0; i < fs.max_width; i++) {
|
||||
fr_from_uint64(&data[i], i);
|
||||
}
|
||||
|
||||
// Inverst FFT
|
||||
TEST_CHECK(fft_fr(out, data, &fs, true, fs.max_width) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(fft_fr(out, data, &fs, true, fs.max_width) == C_KZG_OK);
|
||||
|
||||
// Verify against the known result, `inv_fft_expected`
|
||||
int n = sizeof(inv_fft_expected) / sizeof(inv_fft_expected[0]);
|
||||
|
|
|
@ -67,5 +67,5 @@ C_KZG_RET fft_g1 (blst_p1 *out, blst_p1 *in, FFTSettings *fs, bool inv, uint64_t
|
|||
} else {
|
||||
fft_g1_fast(out, in, 1, fs->expanded_roots_of_unity, stride, fs->max_width);
|
||||
}
|
||||
return C_KZG_SUCCESS;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void compare_sft_fft(void) {
|
|||
// Initialise: arbitrary size
|
||||
unsigned int size = 6;
|
||||
FFTSettings fs;
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_OK);
|
||||
blst_p1 data[fs.max_width], slow[fs.max_width], fast[fs.max_width];
|
||||
make_data(data, fs.max_width);
|
||||
|
||||
|
@ -53,14 +53,14 @@ void roundtrip_fft(void) {
|
|||
// Initialise: arbitrary size
|
||||
unsigned int size = 10;
|
||||
FFTSettings fs;
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(new_fft_settings(&fs, size) == C_KZG_OK);
|
||||
blst_p1 expected[fs.max_width], data[fs.max_width], coeffs[fs.max_width];
|
||||
make_data(expected, fs.max_width);
|
||||
make_data(data, fs.max_width);
|
||||
|
||||
// Forward and reverse FFT
|
||||
TEST_CHECK(fft_g1(coeffs, data, &fs, false, fs.max_width) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(fft_g1(data, coeffs, &fs, true, fs.max_width) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(fft_g1(coeffs, data, &fs, false, fs.max_width) == C_KZG_OK);
|
||||
TEST_CHECK(fft_g1(data, coeffs, &fs, true, fs.max_width) == C_KZG_OK);
|
||||
|
||||
// Verify that the result is still ascending values of i
|
||||
for (int i = 0; i < fs.max_width; i++) {
|
||||
|
|
|
@ -24,5 +24,5 @@ C_KZG_RET new_kzg_settings(KZGSettings *ks, FFTSettings *fs, blst_p1 *secret_g1,
|
|||
ks->extended_secret_g1 = NULL;
|
||||
ks->secret_g2 = secret_g2;
|
||||
ks->length = length;
|
||||
return C_KZG_SUCCESS;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
|
|
@ -78,5 +78,5 @@ C_KZG_RET poly_long_div(poly *out, const poly *dividend, const poly *divisor) {
|
|||
--a_pos;
|
||||
}
|
||||
|
||||
return C_KZG_SUCCESS;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ void poly_div_0(void) {
|
|||
actual.length = 2;
|
||||
actual.coeffs = c;
|
||||
|
||||
TEST_CHECK(poly_long_div(&actual, ÷nd, &divisor) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(poly_long_div(&actual, ÷nd, &divisor) == C_KZG_OK);
|
||||
TEST_CHECK(fr_equal(&expected[0], &actual.coeffs[0]));
|
||||
TEST_CHECK(fr_equal(&expected[1], &actual.coeffs[1]));
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void poly_div_1(void) {
|
|||
actual.length = 3;
|
||||
actual.coeffs = c;
|
||||
|
||||
TEST_CHECK(poly_long_div(&actual, ÷nd, &divisor) == C_KZG_SUCCESS);
|
||||
TEST_CHECK(poly_long_div(&actual, ÷nd, &divisor) == C_KZG_OK);
|
||||
TEST_CHECK(fr_equal(&expected[0], &actual.coeffs[0]));
|
||||
TEST_CHECK(fr_equal(&expected[1], &actual.coeffs[1]));
|
||||
TEST_CHECK(fr_equal(&expected[2], &actual.coeffs[2]));
|
||||
|
|
Loading…
Reference in New Issue