From fdeff744ffc74074bd0a444228b9d546a0f68667 Mon Sep 17 00:00:00 2001 From: George Kadianakis Date: Tue, 14 May 2024 17:18:14 +0300 Subject: [PATCH] EIP-7594: Add a missing check and a missing test vector (#3765) --- .../eip7594/polynomial-commitments-sampling.md | 3 +++ tests/generators/kzg_7594/main.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/specs/_features/eip7594/polynomial-commitments-sampling.md b/specs/_features/eip7594/polynomial-commitments-sampling.md index 08a414c41..3a0bd8a77 100644 --- a/specs/_features/eip7594/polynomial-commitments-sampling.md +++ b/specs/_features/eip7594/polynomial-commitments-sampling.md @@ -683,6 +683,9 @@ def recover_all_cells(cell_ids: Sequence[CellID], cells: Sequence[Cell]) -> Sequ # Check that each cell is the correct length for cell in cells: assert len(cell) == BYTES_PER_CELL + # Check that the cell ids are within bounds + for cell_id in cell_ids: + assert cell_id < CELLS_PER_EXT_BLOB # Get the extended domain roots_of_unity_extended = compute_roots_of_unity(FIELD_ELEMENTS_PER_EXT_BLOB) diff --git a/tests/generators/kzg_7594/main.py b/tests/generators/kzg_7594/main.py index a780f289c..ef412805a 100644 --- a/tests/generators/kzg_7594/main.py +++ b/tests/generators/kzg_7594/main.py @@ -710,6 +710,21 @@ def case05_recover_all_cells(): 'output': None } + # Edge case: More cells provided than CELLS_PER_EXT_BLOB + blob = BLOB_RANDOM_VALID2 + cells = spec.compute_cells(blob) + cell_ids = list(range(spec.CELLS_PER_EXT_BLOB)) + [0] + partial_cells = [cells[cell_id] for cell_id in cell_ids] + expect_exception(spec.recover_all_cells, cell_ids, partial_cells) + identifier = make_id(cell_ids, partial_cells) + yield f'recover_all_cells_case_invalid_more_cells_than_cells_per_ext_blob_{identifier}', { + 'input': { + 'cell_ids': cell_ids, + 'cells': encode_hex_list(partial_cells), + }, + 'output': None + } + # Edge case: Invalid cell_id blob = BLOB_RANDOM_VALID1 cells = spec.compute_cells(blob)