Skip to content

Commit e3b83d5

Browse files
committed
Add defensive asserts in recover_polynomial()
1 parent d60580b commit e3b83d5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

specs/_features/eip7594/polynomial-commitments-sampling.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,16 @@ def recover_polynomial(cell_ids: Sequence[CellID],
598598
Public method.
599599
"""
600600
assert len(cell_ids) == len(cells_bytes)
601+
# Check we have enough cells to be able to perform the reconstruction
602+
assert CELLS_PER_BLOB / 2 <= len(cell_ids) <= CELLS_PER_BLOB
603+
# Check for duplicates
604+
assert len(cell_ids) == len(set(cell_ids))
601605

602606
# Get the extended domain
603607
roots_of_unity_extended = compute_roots_of_unity(2 * FIELD_ELEMENTS_PER_BLOB)
604608

605609
# Convert from bytes to cells
606610
cells = [bytes_to_cell(cell_bytes) for cell_bytes in cells_bytes]
607-
assert len(cells) >= CELLS_PER_BLOB // 2
608611

609612
missing_cell_ids = [cell_id for cell_id in range(CELLS_PER_BLOB) if cell_id not in cell_ids]
610613
zero_poly_coeff, zero_poly_eval, zero_poly_eval_brp = construct_vanishing_polynomial(missing_cell_ids)

0 commit comments

Comments
 (0)