diff --git a/src/kzg_single_proofs.c b/src/kzg_single_proofs.c index f4da450..a6cad77 100644 --- a/src/kzg_single_proofs.c +++ b/src/kzg_single_proofs.c @@ -32,7 +32,7 @@ void compute_proof_single(blst_p1 *out, const KZGSettings *ks, poly *p, const ui divisor.coeffs[1] = one; // Calculate q = p / (x - x0) - init_poly(&q, poly_long_div_length(p->length, 2)); + init_poly(&q, poly_quotient_length(p, &divisor)); poly_long_div(&q, p, &divisor); linear_combination_g1(out, ks->secret_g1, q.coeffs, q.length); diff --git a/src/poly.c b/src/poly.c index 5cacc37..986c849 100644 --- a/src/poly.c +++ b/src/poly.c @@ -47,8 +47,8 @@ void eval_poly_at(blst_fr *out, const poly *p, const blst_fr *x) { } // Call this to find out how much space to allocate for the result -uint64_t poly_long_div_length(const uint64_t len_dividend, const uint64_t len_divisor) { - return len_dividend - len_divisor + 1; +uint64_t poly_quotient_length(const poly *dividend, const poly *divisor) { + return dividend->length - divisor->length + 1; } // `out` must have been pre-allocated to the correct size, and the length is provided diff --git a/src/poly.h b/src/poly.h index 5a755c8..3e8edfb 100644 --- a/src/poly.h +++ b/src/poly.h @@ -26,5 +26,5 @@ typedef struct { void init_poly(poly *out, const uint64_t length); void free_poly(poly p); void eval_poly_at(blst_fr *out, const poly *p, const blst_fr *x); -uint64_t poly_long_div_length(const uint64_t len_dividend, const uint64_t len_divisor); +uint64_t poly_quotient_length(const poly *dividend, const poly *divisor); C_KZG_RET poly_long_div(poly *out, const poly *dividend, const poly *divisor); diff --git a/src/poly_test.c b/src/poly_test.c index 6bb43cf..bcc7f07 100644 --- a/src/poly_test.c +++ b/src/poly_test.c @@ -18,8 +18,13 @@ #include "debug_util.h" #include "poly.h" +void title(void) {;} + void poly_div_length(void) { - TEST_CHECK(3 == poly_long_div_length(4, 2)); + poly a, b; + init_poly(&a, 17); + init_poly(&b, 5); + TEST_CHECK(13 == poly_quotient_length(&a, &b)); } void poly_div_0(void) { @@ -113,6 +118,7 @@ void eval_poly(void) { TEST_LIST = { + {"POLY_TEST", title}, {"poly_div_length", poly_div_length}, {"poly_div_0", poly_div_0}, {"poly_div_1", poly_div_1},