Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not rely on calloc zeroing out allocations #474

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/eip7594/eip7594.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ C_KZG_RET compute_cells_and_kzg_proofs(
ret = poly_lagrange_to_monomial(poly_monomial, poly_lagrange, FIELD_ELEMENTS_PER_BLOB, s);
if (ret != C_KZG_OK) goto out;

/* Ensure the upper half of the fields are zero */
jtraglia marked this conversation as resolved.
Show resolved Hide resolved
for (size_t i = FIELD_ELEMENTS_PER_BLOB; i < FIELD_ELEMENTS_PER_EXT_BLOB; i++) {
poly_monomial[i] = FR_ZERO;
}

if (cells != NULL) {
/* Allocate space for our data points */
ret = new_fr_array(&data_fr, FIELD_ELEMENTS_PER_EXT_BLOB);
Expand Down
10 changes: 6 additions & 4 deletions src/eip7594/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ static C_KZG_RET vanishing_polynomial_for_missing_cells(
);
if (ret != C_KZG_OK) goto out;

/* Zero out all the coefficients */
for (size_t i = 0; i < FIELD_ELEMENTS_PER_EXT_BLOB; i++) {
vanishing_poly[i] = FR_ZERO;
}

/*
* For each root \omega^i in `short_vanishing_poly`, we compute a polynomial that has roots at
*
Expand Down Expand Up @@ -246,10 +251,7 @@ C_KZG_RET recover_cells(
for (size_t i = 0; i < CELLS_PER_EXT_BLOB; i++) {
/* Iterate over each cell index and check if we have received it */
if (!is_in_array(cell_indices, num_cells, i)) {
/*
* If the cell is missing, bit reverse the index and add it to the
* missing array.
*/
/* If the cell is missing, bit reverse the index and add it to the missing array */
uint32_t brp_i = reverse_bits_limited(CELLS_PER_EXT_BLOB, i);
missing_cell_indices[len_missing++] = brp_i;
}
Expand Down
Loading