PeerDAS cryptography: Add a missing check and a missing test vector (coverage report of test vectors) #3765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I spent some time checking which parts of c-kzg are not tested by the test vectors. I did this by exporting coverage information of the C code of c-kzg when the test vectors are tested through the Rust bindings. I was forced to go through the Rust bindings because only the bindings run the test vectors at the moment (and IMO that's fine).
For what it's worth, I used the cargo-llvm-cov project and the following command:
CC=clang LLVM_COV=llvm-cov LLVM_PROFDATA=llvm-profdata cargo llvm-cov --include-ffi --html
.In case you are curious, I attach a zip file (c_kzg_coverage.zip) with the coverage report of c-kzg (commit
f5e4b030f
) when running the tests of the Rust bindings.All in all, the coverage results were very good (i.e. the test vectors are well thought out!).
In this PR, I fix some minor issues found during the above procedure:
cell_id
range check inrecover_all_cells()
(which was actually tested by the test vectors)recover_all_cells()
which represents the right side of the spec assertion:assert CELLS_PER_EXT_BLOB / 2 <= len(cell_ids) <= CELLS_PER_EXT_BLOB
. The test vector is sorta rendundant because the combination of the duplicate cell_id check and the cell_id range check would have caught this edge case, but still worth checking explicitly since it's not trivial (and it shows up in the coverage as well).Some more notes: