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

Update recovery code to match specs #459

Merged
merged 23 commits into from
Jul 20, 2024
Merged

Conversation

kevaundray
Copy link
Contributor

This updates the computation of the zero polynomial to match the specs.

src/c_kzg_4844.c Outdated Show resolved Hide resolved
Copy link
Contributor

@b-wagn b-wagn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, this is great!
Unifying the code with the spec is always good.
In this particular case, it also makes it much more readable and removes more complex functions.

I left a few comments, mostly about how to make it even more readable, how to deal with edge cases, and possibly one improvement.

Let me know what you think :)

src/test_c_kzg_4844.c Outdated Show resolved Hide resolved
src/test_c_kzg_4844.c Outdated Show resolved Hide resolved
src/test_c_kzg_4844.c Outdated Show resolved Hide resolved
src/test_c_kzg_4844.c Outdated Show resolved Hide resolved
src/test_c_kzg_4844.c Outdated Show resolved Hide resolved
* are missing indices, using a combination of direct multiplication
* (#do_zero_poly_mul_partial) and iterated multiplication via convolution
* (#reduce_partials).
* The roots of unity are chosen based on the missing cell indices. If the i'th
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the doc comment (and comments in the function itself) here is already pretty good.
One thing I would add is where to get the i'th root of unity from, as this heavily depends on the order of the roots.

If I understand correctly, it would be s->expanded_roots_of_unity[i]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I can modify that to be more explicit, and yep it is expanded_roots_of_unity (non-bit-reversed) -- note that the code has been modularized so that all of the vanishing polynomial calculations/functions do not depend on any bit reversal permutation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified it to include expanded_roots_of_unity, though feel free to push a commit to modify it further

src/c_kzg_4844.c Outdated Show resolved Hide resolved
src/c_kzg_4844.c Outdated Show resolved Hide resolved
src/c_kzg_4844.c Outdated Show resolved Hide resolved
src/c_kzg_4844.c Show resolved Hide resolved
src/c_kzg_4844.c Outdated Show resolved Hide resolved
src/test_c_kzg_4844.c Outdated Show resolved Hide resolved
src/c_kzg_4844.c Outdated Show resolved Hide resolved
src/c_kzg_4844.c Outdated Show resolved Hide resolved
src/c_kzg_4844.c Outdated Show resolved Hide resolved
* is trivial. We expect the caller to handle this case,
* and return C_KZG_BADARGS if not.
* @remark `missing_cell_indices` are assumed to be less than
* `CELLS_PER_EXT_BLOB`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `CELLS_PER_EXT_BLOB`.
* `CELLS_PER_EXT_BLOB` and at least one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous remark should be good enough.

Copy link
Contributor

@b-wagn b-wagn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kev! This is much better 😃

@jtraglia jtraglia merged commit 1b5c3c8 into ethereum:main Jul 20, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants