diff --git a/src/fft_g1.c b/src/fft_g1.c index cfe08a0..ec13255 100644 --- a/src/fft_g1.c +++ b/src/fft_g1.c @@ -198,4 +198,4 @@ TEST_LIST = { {NULL, NULL} /* zero record marks the end of the list */ }; -#endif // KZGTEST \ No newline at end of file +#endif // KZGTEST diff --git a/src/fk20_proofs.c b/src/fk20_proofs.c index b692de7..c373caa 100644 --- a/src/fk20_proofs.c +++ b/src/fk20_proofs.c @@ -485,7 +485,7 @@ void fk_single(void) { FFTSettings fs; KZGSettings ks; FK20SingleSettings fk; - uint64_t secrets_len = n_len + 1; + uint64_t secrets_len = n_len; g1_t s1[secrets_len]; g2_t s2[secrets_len]; poly p; @@ -558,7 +558,7 @@ void fk_single_strided(void) { FFTSettings fs; KZGSettings ks; FK20SingleSettings fk; - uint64_t secrets_len = n_len + 1; + uint64_t secrets_len = n_len; g1_t s1[secrets_len]; g2_t s2[secrets_len]; poly p; @@ -606,7 +606,7 @@ void fk_multi_settings(void) { KZGSettings ks; FK20MultiSettings fk; uint64_t n = 5; - uint64_t secrets_len = 33; + uint64_t secrets_len = 32; g1_t s1[secrets_len]; g2_t s2[secrets_len]; @@ -764,4 +764,4 @@ TEST_LIST = { {NULL, NULL} /* zero record marks the end of the list */ }; -#endif \ No newline at end of file +#endif diff --git a/src/kzg_proofs.c b/src/kzg_proofs.c index aa5a087..faf89e4 100644 --- a/src/kzg_proofs.c +++ b/src/kzg_proofs.c @@ -248,7 +248,7 @@ void proof_single(void) { // Our polynomial: degree 15, 16 coefficients uint64_t coeffs[] = {1, 2, 3, 4, 7, 7, 7, 7, 13, 13, 13, 13, 13, 13, 13, 13}; int poly_len = sizeof coeffs / sizeof coeffs[0]; - uint64_t secrets_len = poly_len + 1; + uint64_t secrets_len = poly_len; FFTSettings fs; KZGSettings ks; @@ -296,8 +296,8 @@ void proof_multi(void) { uint64_t coeffs[] = {1, 2, 3, 4, 7, 7, 7, 7, 13, 13, 13, 13, 13, 13, 13, 13}; int poly_len = sizeof coeffs / sizeof coeffs[0]; - FFTSettings fs1, fs2; - KZGSettings ks1, ks2; + FFTSettings fs; + KZGSettings ks; poly p; g1_t commitment, proof; fr_t x, tmp; @@ -307,7 +307,7 @@ void proof_multi(void) { int coset_scale = 3, coset_len = (1 << coset_scale); fr_t y[coset_len]; - uint64_t secrets_len = poly_len > coset_len ? poly_len + 1 : coset_len + 1; + uint64_t secrets_len = poly_len > coset_len ? poly_len : coset_len; g1_t s1[secrets_len]; g2_t s2[secrets_len]; @@ -319,38 +319,34 @@ void proof_multi(void) { // Initialise the secrets and data structures generate_trusted_setup(s1, s2, &secret, secrets_len); - TEST_CHECK(C_KZG_OK == new_fft_settings(&fs1, 4)); // ln_2 of poly_len - TEST_CHECK(C_KZG_OK == new_kzg_settings(&ks1, s1, s2, secrets_len, &fs1)); + TEST_CHECK(C_KZG_OK == new_fft_settings(&fs, 4)); // ln_2 of poly_len + TEST_CHECK(C_KZG_OK == new_kzg_settings(&ks, s1, s2, secrets_len, &fs)); // Commit to the polynomial - TEST_CHECK(C_KZG_OK == commit_to_poly(&commitment, &p, &ks1)); - - TEST_CHECK(C_KZG_OK == new_fft_settings(&fs2, coset_scale)); - TEST_CHECK(C_KZG_OK == new_kzg_settings(&ks2, s1, s2, secrets_len, &fs2)); + TEST_CHECK(C_KZG_OK == commit_to_poly(&commitment, &p, &ks)); // Compute proof at the points [x * root_i] 0 <= i < coset_len fr_from_uint64(&x, 5431); - TEST_CHECK(C_KZG_OK == compute_proof_multi(&proof, &p, &x, coset_len, &ks2)); + TEST_CHECK(C_KZG_OK == compute_proof_multi(&proof, &p, &x, coset_len, &ks)); // y_i is the value of the polynomial at each x_i + uint64_t stride = secrets_len / coset_len; for (int i = 0; i < coset_len; i++) { - fr_mul(&tmp, &x, &ks2.fs->expanded_roots_of_unity[i]); + fr_mul(&tmp, &x, &fs.expanded_roots_of_unity[i * stride]); eval_poly(&y[i], &p, &tmp); } // Verify the proof that the (unknown) polynomial has value y_i at x_i - TEST_CHECK(C_KZG_OK == check_proof_multi(&result, &commitment, &proof, &x, y, coset_len, &ks2)); + TEST_CHECK(C_KZG_OK == check_proof_multi(&result, &commitment, &proof, &x, y, coset_len, &ks)); TEST_CHECK(true == result); // Change a value and check that the proof fails fr_add(y + coset_len / 2, y + coset_len / 2, &fr_one); - TEST_CHECK(C_KZG_OK == check_proof_multi(&result, &commitment, &proof, &x, y, coset_len, &ks2)); + TEST_CHECK(C_KZG_OK == check_proof_multi(&result, &commitment, &proof, &x, y, coset_len, &ks)); TEST_CHECK(false == result); - free_fft_settings(&fs1); - free_fft_settings(&fs2); - free_kzg_settings(&ks1); - free_kzg_settings(&ks2); + free_fft_settings(&fs); + free_kzg_settings(&ks); free_poly(&p); } diff --git a/src/poly.c b/src/poly.c index 9d06607..dbe1808 100644 --- a/src/poly.c +++ b/src/poly.c @@ -978,4 +978,4 @@ TEST_LIST = { {NULL, NULL} /* zero record marks the end of the list */ }; -#endif // KZGTEST \ No newline at end of file +#endif // KZGTEST