From d137553f96c525279a595ff29ade8e617346ee3f Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Tue, 11 Jun 2024 07:41:52 -0500 Subject: [PATCH] Rename CellID to CellIndex --- specs/_features/eip7594/das-core.md | 12 +- .../polynomial-commitments-sampling.md | 81 ++--- .../test_polynomial_commitments.py | 20 +- .../kzg_7594/recover_cells_and_kzg_proofs.md | 6 +- .../formats/kzg_7594/verify_cell_kzg_proof.md | 6 +- .../kzg_7594/verify_cell_kzg_proof_batch.md | 2 +- tests/generators/kzg_7594/main.py | 282 +++++++++--------- 7 files changed, 205 insertions(+), 204 deletions(-) diff --git a/specs/_features/eip7594/das-core.md b/specs/_features/eip7594/das-core.md index 67719ad0f3..9faf77b9ab 100644 --- a/specs/_features/eip7594/das-core.md +++ b/specs/_features/eip7594/das-core.md @@ -151,12 +151,12 @@ def compute_extended_matrix(blobs: Sequence[Blob]) -> List[MatrixEntry, MAX_CELL extended_matrix = [] for blob_index, blob in enumerate(blobs): cells, proofs = compute_cells_and_kzg_proofs(blob) - for cell_id, (cell, proof) in enumerate(zip(cells, proofs)): + for cell_index, (cell, proof) in enumerate(zip(cells, proofs)): extended_matrix.append(MatrixEntry( cell=cell, kzg_proof=proof, row_index=blob_index, - column_index=cell_id, + column_index=cell_index, )) return extended_matrix ``` @@ -174,17 +174,17 @@ def recover_matrix(partial_matrix: Sequence[MatrixEntry], """ extended_matrix = [] for blob_index in range(blob_count): - cell_ids = [e.column_index for e in partial_matrix if e.row_index == blob_index] + cell_indices = [e.column_index for e in partial_matrix if e.row_index == blob_index] cells = [e.cell for e in partial_matrix if e.row_index == blob_index] proofs = [e.kzg_proof for e in partial_matrix if e.row_index == blob_index] - recovered_cells, recovered_proofs = recover_cells_and_kzg_proofs(cell_ids, cells, proofs) - for cell_id, (cell, proof) in enumerate(zip(recovered_cells, recovered_proofs)): + recovered_cells, recovered_proofs = recover_cells_and_kzg_proofs(cell_indices, cells, proofs) + for cell_index, (cell, proof) in enumerate(zip(recovered_cells, recovered_proofs)): extended_matrix.append(MatrixEntry( cell=cell, kzg_proof=proof, row_index=blob_index, - column_index=cell_id, + column_index=cell_index, )) return extended_matrix ``` diff --git a/specs/_features/eip7594/polynomial-commitments-sampling.md b/specs/_features/eip7594/polynomial-commitments-sampling.md index acf4ffc627..a79e5eed9a 100644 --- a/specs/_features/eip7594/polynomial-commitments-sampling.md +++ b/specs/_features/eip7594/polynomial-commitments-sampling.md @@ -67,7 +67,7 @@ Public functions MUST accept raw bytes as input and perform the required cryptog | `Coset` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_CELL]` | The evaluation domain of a cell | | `CosetEvals` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_CELL]` | The internal representation of a cell (the evaluations over its Coset) | | `Cell` | `ByteVector[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_CELL]` | The unit of blob data that can come with its own KZG proof | -| `CellID` | `uint64` | Validation: `x < CELLS_PER_EXT_BLOB` | +| `CellIndex` | `uint64` | Validation: `x < CELLS_PER_EXT_BLOB` | ## Constants @@ -402,15 +402,15 @@ def verify_kzg_proof_multi_impl(commitment: KZGCommitment, #### `coset_for_cell` ```python -def coset_for_cell(cell_id: CellID) -> Coset: +def coset_for_cell(cell_index: CellIndex) -> Coset: """ - Get the coset for a given ``cell_id`` + Get the coset for a given ``cell_index``. """ - assert cell_id < CELLS_PER_EXT_BLOB + assert cell_index < CELLS_PER_EXT_BLOB roots_of_unity_brp = bit_reversal_permutation( compute_roots_of_unity(FIELD_ELEMENTS_PER_EXT_BLOB) ) - return Coset(roots_of_unity_brp[FIELD_ELEMENTS_PER_CELL * cell_id:FIELD_ELEMENTS_PER_CELL * (cell_id + 1)]) + return Coset(roots_of_unity_brp[FIELD_ELEMENTS_PER_CELL * cell_index:FIELD_ELEMENTS_PER_CELL * (cell_index + 1)]) ``` ## Cells @@ -439,7 +439,7 @@ def compute_cells_and_kzg_proofs(blob: Blob) -> Tuple[ proofs = [] for i in range(CELLS_PER_EXT_BLOB): - coset = coset_for_cell(CellID(i)) + coset = coset_for_cell(CellIndex(i)) proof, ys = compute_kzg_proof_multi_impl(polynomial_coeff, coset) cells.append(coset_evals_to_cell(ys)) proofs.append(proof) @@ -465,9 +465,9 @@ def compute_cells(blob: Blob) -> Vector[Cell, CELLS_PER_EXT_BLOB]: compute_roots_of_unity(FIELD_ELEMENTS_PER_EXT_BLOB)) extended_data_rbo = bit_reversal_permutation(extended_data) cells = [] - for cell_id in range(CELLS_PER_EXT_BLOB): - start = cell_id * FIELD_ELEMENTS_PER_CELL - end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL + for cell_index in range(CELLS_PER_EXT_BLOB): + start = cell_index * FIELD_ELEMENTS_PER_CELL + end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL cells.append(coset_evals_to_cell(CosetEvals(extended_data_rbo[start:end]))) return cells ``` @@ -478,7 +478,7 @@ def compute_cells(blob: Blob) -> Vector[Cell, CELLS_PER_EXT_BLOB]: ```python def verify_cell_kzg_proof(commitment_bytes: Bytes48, - cell_id: CellID, + cell_index: CellIndex, cell: Cell, proof_bytes: Bytes48) -> bool: """ @@ -487,11 +487,11 @@ def verify_cell_kzg_proof(commitment_bytes: Bytes48, Public method. """ assert len(commitment_bytes) == BYTES_PER_COMMITMENT - assert cell_id < CELLS_PER_EXT_BLOB + assert cell_index < CELLS_PER_EXT_BLOB assert len(cell) == BYTES_PER_CELL assert len(proof_bytes) == BYTES_PER_PROOF - coset = coset_for_cell(cell_id) + coset = coset_for_cell(cell_index) return verify_kzg_proof_multi_impl( bytes_to_kzg_commitment(commitment_bytes), @@ -553,7 +553,7 @@ def verify_cell_kzg_proof_batch(row_commitments_bytes: Sequence[Bytes48], ### `construct_vanishing_polynomial` ```python -def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[ +def construct_vanishing_polynomial(missing_cell_indices: Sequence[CellIndex]) -> Tuple[ Sequence[BLSFieldElement], Sequence[BLSFieldElement]]: """ @@ -565,8 +565,8 @@ def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[ # Compute polynomial that vanishes at all the missing cells (over the small domain) short_zero_poly = vanishing_polynomialcoeff([ - roots_of_unity_reduced[reverse_bits(missing_cell_id, CELLS_PER_EXT_BLOB)] - for missing_cell_id in missing_cell_ids + roots_of_unity_reduced[reverse_bits(missing_cell_index, CELLS_PER_EXT_BLOB)] + for missing_cell_index in missing_cell_indices ]) # Extend vanishing polynomial to full domain using the closed form of the vanishing polynomial over a coset @@ -580,12 +580,12 @@ def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[ zero_poly_eval_brp = bit_reversal_permutation(zero_poly_eval) # Sanity check - for cell_id in range(CELLS_PER_EXT_BLOB): - start = cell_id * FIELD_ELEMENTS_PER_CELL - end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL - if cell_id in missing_cell_ids: + for cell_index in range(CELLS_PER_EXT_BLOB): + start = cell_index * FIELD_ELEMENTS_PER_CELL + end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL + if cell_index in missing_cell_indices: assert all(a == 0 for a in zero_poly_eval_brp[start:end]) - else: # cell_id in cell_ids + else: # cell_index in cell_indices assert all(a != 0 for a in zero_poly_eval_brp[start:end]) return zero_poly_coeff, zero_poly_eval @@ -594,7 +594,7 @@ def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[ ### `recover_shifted_data` ```python -def recover_shifted_data(cell_ids: Sequence[CellID], +def recover_shifted_data(cell_indices: Sequence[CellIndex], cells: Sequence[Cell], zero_poly_eval: Sequence[BLSFieldElement], zero_poly_coeff: Sequence[BLSFieldElement], @@ -609,9 +609,9 @@ def recover_shifted_data(cell_ids: Sequence[CellID], shift_inv = div(BLSFieldElement(1), shift_factor) extended_evaluation_rbo = [0] * FIELD_ELEMENTS_PER_EXT_BLOB - for cell_id, cell in zip(cell_ids, cells): - start = cell_id * FIELD_ELEMENTS_PER_CELL - end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL + for cell_index, cell in zip(cell_indices, cells): + start = cell_index * FIELD_ELEMENTS_PER_CELL + end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL extended_evaluation_rbo[start:end] = cell extended_evaluation = bit_reversal_permutation(extended_evaluation_rbo) @@ -661,7 +661,7 @@ def recover_original_data(eval_shifted_extended_evaluation: Sequence[BLSFieldEle ### `recover_cells_and_kzg_proofs` ```python -def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID], +def recover_cells_and_kzg_proofs(cell_indices: Sequence[CellIndex], cells: Sequence[Cell], proofs_bytes: Sequence[Bytes48]) -> Tuple[ Vector[Cell, CELLS_PER_EXT_BLOB], @@ -677,14 +677,14 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID], Public method. """ - assert len(cell_ids) == len(cells) == len(proofs_bytes) + assert len(cell_indices) == len(cells) == len(proofs_bytes) # Check we have enough cells to be able to perform the reconstruction - assert CELLS_PER_EXT_BLOB / 2 <= len(cell_ids) <= CELLS_PER_EXT_BLOB + assert CELLS_PER_EXT_BLOB / 2 <= len(cell_indices) <= CELLS_PER_EXT_BLOB # Check for duplicates - assert len(cell_ids) == len(set(cell_ids)) - # Check that the cell ids are within bounds - for cell_id in cell_ids: - assert cell_id < CELLS_PER_EXT_BLOB + assert len(cell_indices) == len(set(cell_indices)) + # Check that the cell indices are within bounds + for cell_index in cell_indices: + assert cell_index < CELLS_PER_EXT_BLOB # Check that each cell is the correct length for cell in cells: assert len(cell) == BYTES_PER_CELL @@ -698,11 +698,12 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID], # Convert cells to coset evals cosets_evals = [cell_to_coset_evals(cell) for cell in cells] - missing_cell_ids = [CellID(cell_id) for cell_id in range(CELLS_PER_EXT_BLOB) if cell_id not in cell_ids] - zero_poly_coeff, zero_poly_eval = construct_vanishing_polynomial(missing_cell_ids) + missing_cell_indices = [CellIndex(cell_index) for cell_index in range(CELLS_PER_EXT_BLOB) + if cell_index not in cell_indices] + zero_poly_coeff, zero_poly_eval = construct_vanishing_polynomial(missing_cell_indices) eval_shifted_extended_evaluation, eval_shifted_zero_poly, shift_inv = recover_shifted_data( - cell_ids, + cell_indices, cosets_evals, zero_poly_eval, zero_poly_coeff, @@ -716,9 +717,9 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID], roots_of_unity_extended, ) - for cell_id, coset_evals in zip(cell_ids, cosets_evals): - start = cell_id * FIELD_ELEMENTS_PER_CELL - end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL + for cell_index, coset_evals in zip(cell_indices, cosets_evals): + start = cell_index * FIELD_ELEMENTS_PER_CELL + end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL assert reconstructed_data[start:end] == coset_evals recovered_cells = [ @@ -728,11 +729,11 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID], polynomial_eval = reconstructed_data[:FIELD_ELEMENTS_PER_BLOB] polynomial_coeff = polynomial_eval_to_coeff(polynomial_eval) recovered_proofs = [None] * CELLS_PER_EXT_BLOB - for i, cell_id in enumerate(cell_ids): - recovered_proofs[cell_id] = bytes_to_kzg_proof(proofs_bytes[i]) + for i, cell_index in enumerate(cell_indices): + recovered_proofs[cell_index] = bytes_to_kzg_proof(proofs_bytes[i]) for i in range(CELLS_PER_EXT_BLOB): if recovered_proofs[i] is None: - coset = coset_for_cell(CellID(i)) + coset = coset_for_cell(CellIndex(i)) proof, ys = compute_kzg_proof_multi_impl(polynomial_coeff, coset) assert coset_evals_to_cell(ys) == recovered_cells[i] recovered_proofs[i] = proof diff --git a/tests/core/pyspec/eth2spec/test/eip7594/unittests/polynomial_commitments/test_polynomial_commitments.py b/tests/core/pyspec/eth2spec/test/eip7594/unittests/polynomial_commitments/test_polynomial_commitments.py index 215f8f3e6f..ec54db661f 100644 --- a/tests/core/pyspec/eth2spec/test/eip7594/unittests/polynomial_commitments/test_polynomial_commitments.py +++ b/tests/core/pyspec/eth2spec/test/eip7594/unittests/polynomial_commitments/test_polynomial_commitments.py @@ -36,10 +36,10 @@ def test_verify_cell_kzg_proof(spec): commitment = spec.blob_to_kzg_commitment(blob) cells, proofs = spec.compute_cells_and_kzg_proofs(blob) - cell_id = 0 - assert spec.verify_cell_kzg_proof(commitment, cell_id, cells[cell_id], proofs[cell_id]) - cell_id = 1 - assert spec.verify_cell_kzg_proof(commitment, cell_id, cells[cell_id], proofs[cell_id]) + cell_index = 0 + assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index]) + cell_index = 1 + assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index]) @with_eip7594_and_later @@ -77,19 +77,19 @@ def test_recover_cells_and_kzg_proofs(spec): cells, proofs = spec.compute_cells_and_kzg_proofs(blob) # Compute the cells we will be recovering from - cell_ids = [] + cell_indices = [] # First figure out just the indices of the cells for i in range(N_SAMPLES): j = rng.randint(0, spec.CELLS_PER_EXT_BLOB - 1) - while j in cell_ids: + while j in cell_indices: j = rng.randint(0, spec.CELLS_PER_EXT_BLOB - 1) - cell_ids.append(j) + cell_indices.append(j) # Now the cells/proofs themselves - known_cells = [cells[cell_id] for cell_id in cell_ids] - known_proofs = [proofs[cell_id] for cell_id in cell_ids] + known_cells = [cells[cell_index] for cell_index in cell_indices] + known_proofs = [proofs[cell_index] for cell_index in cell_indices] # Recover the missing cells and proofs - recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_ids, known_cells, known_proofs) + recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_indices, known_cells, known_proofs) recovered_data = [x for xs in recovered_cells for x in xs] # Check that the original data match the non-extended portion of the recovered data diff --git a/tests/formats/kzg_7594/recover_cells_and_kzg_proofs.md b/tests/formats/kzg_7594/recover_cells_and_kzg_proofs.md index 8967664128..4e839c8ff4 100644 --- a/tests/formats/kzg_7594/recover_cells_and_kzg_proofs.md +++ b/tests/formats/kzg_7594/recover_cells_and_kzg_proofs.md @@ -8,12 +8,12 @@ The test data is declared in a `data.yaml` file: ```yaml input: - cell_ids: List[CellID] -- the cell identifier for each cell + cell_indices: List[CellIndex] -- the cell indices cells: List[Cell] -- the partial collection of cells output: Tuple[List[Cell], List[KZGProof]] -- all cells and proofs ``` -- `CellID` is an unsigned 64-bit integer. +- `CellIndex` is an unsigned 64-bit integer. - `Cell` is a 2048-byte hexadecimal string, prefixed with `0x`. - `KZGProof` is a 48-byte hexadecimal string, prefixed with `0x`. @@ -21,4 +21,4 @@ All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with ` ## Condition -The `recover_cells_and_kzg_proofs` handler should recover missing cells and proofs, and the result should match the expected `output`. If any cell is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), any proof is invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), or any `cell_id` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`. +The `recover_cells_and_kzg_proofs` handler should recover missing cells and proofs, and the result should match the expected `output`. If any cell is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), any proof is invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), or any `cell_index` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`. diff --git a/tests/formats/kzg_7594/verify_cell_kzg_proof.md b/tests/formats/kzg_7594/verify_cell_kzg_proof.md index 5ab3ad0739..3d5f33b524 100644 --- a/tests/formats/kzg_7594/verify_cell_kzg_proof.md +++ b/tests/formats/kzg_7594/verify_cell_kzg_proof.md @@ -9,18 +9,18 @@ The test data is declared in a `data.yaml` file: ```yaml input: commitment: Bytes48 -- the KZG commitment - cell_id: CellID -- the identifier for the cell + cell_index: CellIndex -- the cell index cell: Cell -- the cell proof: Bytes48 -- the KZG proof for the cell output: bool -- true (correct proof) or false (incorrect proof) ``` - `Bytes48` is a 48-byte hexadecimal string, prefixed with `0x`. -- `CellID` is an unsigned 64-bit integer. +- `CellIndex` is an unsigned 64-bit integer. - `Cell` is a 2048-byte hexadecimal string, prefixed with `0x`. All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`. ## Condition -The `verify_cell_kzg_proof` handler should verify that `commitment` is a correct KZG commitment to `cell` by using the cell KZG proof `proof`, and the result should match the expected `output`. If the commitment or proof is invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), `cell` is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), or `cell_id` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`. +The `verify_cell_kzg_proof` handler should verify that `commitment` is a correct KZG commitment to `cell` by using the cell KZG proof `proof`, and the result should match the expected `output`. If the commitment or proof is invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), `cell` is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), or `cell_index` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`. diff --git a/tests/formats/kzg_7594/verify_cell_kzg_proof_batch.md b/tests/formats/kzg_7594/verify_cell_kzg_proof_batch.md index 9761b55032..439d1e25ae 100644 --- a/tests/formats/kzg_7594/verify_cell_kzg_proof_batch.md +++ b/tests/formats/kzg_7594/verify_cell_kzg_proof_batch.md @@ -25,4 +25,4 @@ All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with ` ## Condition -The `verify_cell_kzg_proof_batch` handler should verify that `row_commitments` are correct KZG commitments to `cells` by using the cell KZG proofs `proofs`, and the result should match the expected `output`. If any of the commitments or proofs are invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), any cell is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), or any `cell_id` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`. +The `verify_cell_kzg_proof_batch` handler should verify that `row_commitments` are correct KZG commitments to `cells` by using the cell KZG proofs `proofs`, and the result should match the expected `output`. If any of the commitments or proofs are invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), any cell is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), or any `cell_index` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`. diff --git a/tests/generators/kzg_7594/main.py b/tests/generators/kzg_7594/main.py index fd9d28727c..be343795e7 100644 --- a/tests/generators/kzg_7594/main.py +++ b/tests/generators/kzg_7594/main.py @@ -96,15 +96,15 @@ def case03_verify_cell_kzg_proof(): for i in range(len(VALID_BLOBS)): cells, proofs = VALID_CELLS_AND_PROOFS[i] commitment = VALID_COMMITMENTS[i] - cell_id = (2 ** i - 1) % spec.CELLS_PER_EXT_BLOB - cell = cells[cell_id] - proof = proofs[cell_id] - assert spec.verify_cell_kzg_proof(commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + cell_index = (2 ** i - 1) % spec.CELLS_PER_EXT_BLOB + cell = cells[cell_index] + proof = proofs[cell_index] + assert spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_valid_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -115,15 +115,15 @@ def case03_verify_cell_kzg_proof(): for i in range(len(VALID_BLOBS)): cells, proofs = VALID_CELLS_AND_PROOFS[i] commitment = bls_add_one(VALID_COMMITMENTS[i]) - cell_id = 99 % spec.CELLS_PER_EXT_BLOB - cell = cells[cell_id] - proof = proofs[cell_id] - assert not spec.verify_cell_kzg_proof(commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + cell_index = 99 % spec.CELLS_PER_EXT_BLOB + cell = cells[cell_index] + proof = proofs[cell_index] + assert not spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_incorrect_commitment_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -132,17 +132,17 @@ def case03_verify_cell_kzg_proof(): # Incorrect cell for i in range(len(VALID_INDIVIDUAL_RANDOM_CELL_BYTES)): - cell_id = 16 % spec.CELLS_PER_EXT_BLOB + cell_index = 16 % spec.CELLS_PER_EXT_BLOB commitment = VALID_COMMITMENTS[i] cells, proofs = VALID_CELLS_AND_PROOFS[i] cell = VALID_INDIVIDUAL_RANDOM_CELL_BYTES[i] - proof = proofs[cell_id] - assert not spec.verify_cell_kzg_proof(commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + proof = proofs[cell_index] + assert not spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_incorrect_cell_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -151,17 +151,17 @@ def case03_verify_cell_kzg_proof(): # Incorrect proof for i in range(len(VALID_BLOBS)): - cell_id = 91 % spec.CELLS_PER_EXT_BLOB + cell_index = 91 % spec.CELLS_PER_EXT_BLOB commitment = VALID_COMMITMENTS[i] cells, proofs = VALID_CELLS_AND_PROOFS[i] - cell = cells[cell_id] - proof = bls_add_one(proofs[cell_id]) - assert not spec.verify_cell_kzg_proof(commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + cell = cells[cell_index] + proof = bls_add_one(proofs[cell_index]) + assert not spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_incorrect_proof_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -171,33 +171,33 @@ def case03_verify_cell_kzg_proof(): # Edge case: Invalid commitment for commitment in INVALID_G1_POINTS: cells, proofs = VALID_CELLS_AND_PROOFS[0] - cell_id = 81 % spec.CELLS_PER_EXT_BLOB - cell = cells[cell_id] - proof = proofs[cell_id] - expect_exception(spec.verify_cell_kzg_proof, commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + cell_index = 81 % spec.CELLS_PER_EXT_BLOB + cell = cells[cell_index] + proof = proofs[cell_index] + expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_invalid_commitment_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, 'output': None } - # Edge case: Invalid cell_id - for cell_id in [spec.CELLS_PER_EXT_BLOB, spec.CELLS_PER_EXT_BLOB + 1]: + # Edge case: Invalid cell_index + for cell_index in [spec.CELLS_PER_EXT_BLOB, spec.CELLS_PER_EXT_BLOB + 1]: cells, proofs = VALID_CELLS_AND_PROOFS[1] commitment = VALID_COMMITMENTS[1] cell = cells[0] proof = proofs[0] - expect_exception(spec.verify_cell_kzg_proof, commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) - yield f'verify_cell_kzg_proof_case_invalid_cell_id_{identifier}', { + expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) + yield f'verify_cell_kzg_proof_case_invalid_cell_index_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -206,16 +206,16 @@ def case03_verify_cell_kzg_proof(): # Edge case: Invalid cell for cell in INVALID_INDIVIDUAL_CELL_BYTES: - cell_id = 32 % spec.CELLS_PER_EXT_BLOB + cell_index = 32 % spec.CELLS_PER_EXT_BLOB commitment = VALID_COMMITMENTS[2] cells, proofs = VALID_CELLS_AND_PROOFS[2] - proof = proofs[cell_id] - expect_exception(spec.verify_cell_kzg_proof, commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + proof = proofs[cell_index] + expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_invalid_cell_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -226,14 +226,14 @@ def case03_verify_cell_kzg_proof(): for proof in INVALID_G1_POINTS: cells, _ = VALID_CELLS_AND_PROOFS[3] commitment = VALID_COMMITMENTS[3] - cell_id = 36 % spec.CELLS_PER_EXT_BLOB - cell = cells[cell_id] - expect_exception(spec.verify_cell_kzg_proof, commitment, cell_id, cell, proof) - identifier = make_id(commitment, cell_id, cell, proof) + cell_index = 36 % spec.CELLS_PER_EXT_BLOB + cell = cells[cell_index] + expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof) + identifier = make_id(commitment, cell_index, cell, proof) yield f'verify_cell_kzg_proof_case_invalid_proof_{identifier}', { 'input': { 'commitment': encode_hex(commitment), - 'cell_id': cell_id, + 'cell_index': cell_index, 'cell': encode_hex(cell), 'proof': encode_hex(proof), }, @@ -620,14 +620,14 @@ def case04_verify_cell_kzg_proof_batch(): def case05_recover_cells_and_kzg_proofs(): # Valid: No missing cells cells, proofs = VALID_CELLS_AND_PROOFS[0] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB)) - recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_ids, cells, proofs) + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB)) + recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_indices, cells, proofs) assert recovered_cells == cells assert recovered_proofs == proofs - identifier = make_id(cell_ids, cells, proofs) + identifier = make_id(cell_indices, cells, proofs) yield f'recover_cells_and_kzg_proofs_case_valid_no_missing_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(cells), 'proofs': encode_hex_list(proofs), }, @@ -636,16 +636,16 @@ def case05_recover_cells_and_kzg_proofs(): # Valid: Half missing cells (every other cell) cells, proofs = VALID_CELLS_AND_PROOFS[1] - cell_ids = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_ids, partial_cells, partial_proofs) + cell_indices = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_indices, partial_cells, partial_proofs) assert recovered_cells == cells assert recovered_proofs == proofs - identifier = make_id(cell_ids, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) yield f'recover_cells_and_kzg_proofs_case_valid_half_missing_every_other_cell_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -654,16 +654,16 @@ def case05_recover_cells_and_kzg_proofs(): # Valid: Half missing cells (first half) cells, proofs = VALID_CELLS_AND_PROOFS[2] - cell_ids = list(range(0, spec.CELLS_PER_EXT_BLOB // 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_ids, partial_cells, partial_proofs) + cell_indices = list(range(0, spec.CELLS_PER_EXT_BLOB // 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_indices, partial_cells, partial_proofs) assert recovered_cells == cells assert recovered_proofs == proofs - identifier = make_id(cell_ids, partial_cells) + identifier = make_id(cell_indices, partial_cells) yield f'recover_cells_and_kzg_proofs_case_valid_half_missing_first_half_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -672,16 +672,16 @@ def case05_recover_cells_and_kzg_proofs(): # Valid: Half missing cells (second half) cells, proofs = VALID_CELLS_AND_PROOFS[3] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB // 2, spec.CELLS_PER_EXT_BLOB)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_ids, partial_cells, partial_proofs) + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB // 2, spec.CELLS_PER_EXT_BLOB)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_indices, partial_cells, partial_proofs) assert recovered_cells == cells assert recovered_proofs == proofs - identifier = make_id(cell_ids, partial_cells) + identifier = make_id(cell_indices, partial_cells) yield f'recover_cells_and_kzg_proofs_case_valid_half_missing_second_half_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -689,12 +689,12 @@ def case05_recover_cells_and_kzg_proofs(): } # Edge case: All cells are missing - cell_ids, partial_cells = [], [] - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells) - identifier = make_id(cell_ids, partial_cells) + cell_indices, partial_cells = [], [] + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells) + identifier = make_id(cell_indices, partial_cells) yield f'recover_cells_and_kzg_proofs_case_invalid_all_cells_are_missing_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -703,14 +703,14 @@ def case05_recover_cells_and_kzg_proofs(): # Edge case: More than half missing cells, proofs = VALID_CELLS_AND_PROOFS[4] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB // 2 - 1)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB // 2 - 1)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) yield f'recover_cells_and_kzg_proofs_case_invalid_more_than_half_missing_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -719,32 +719,32 @@ def case05_recover_cells_and_kzg_proofs(): # Edge case: More cells provided than CELLS_PER_EXT_BLOB cells, proofs = VALID_CELLS_AND_PROOFS[5] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB)) + [0] - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB)) + [0] + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) yield f'recover_cells_and_kzg_proofs_case_invalid_more_cells_than_cells_per_ext_blob_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, 'output': None } - # Edge case: Invalid cell_id + # Edge case: Invalid cell_index cells, proofs = VALID_CELLS_AND_PROOFS[6] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB // 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - # Replace first cell_id with an invalid value - cell_ids[0] = spec.CELLS_PER_EXT_BLOB - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) - yield f'recover_cells_and_kzg_proofs_case_invalid_cell_id_{identifier}', { + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB // 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + # Replace first cell_index with an invalid value + cell_indices[0] = spec.CELLS_PER_EXT_BLOB + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) + yield f'recover_cells_and_kzg_proofs_case_invalid_cell_index_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -754,16 +754,16 @@ def case05_recover_cells_and_kzg_proofs(): # Edge case: Invalid cell for cell in INVALID_INDIVIDUAL_CELL_BYTES: cells, proofs = VALID_CELLS_AND_PROOFS[6] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB // 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB // 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] # Replace first cell with an invalid value partial_cells[0] = cell - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) yield f'recover_cells_and_kzg_proofs_case_invalid_cell_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, @@ -773,93 +773,93 @@ def case05_recover_cells_and_kzg_proofs(): # Edge case: Invalid proof for proof in INVALID_G1_POINTS: cells, proofs = VALID_CELLS_AND_PROOFS[0] - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB // 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB // 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] # Replace first proof with an invalid value partial_proofs[0] = proof - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) yield f'recover_cells_and_kzg_proofs_case_invalid_proof_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, 'output': None } - # Edge case: More cell_ids than cells + # Edge case: More cell_indices than cells cells, proofs = VALID_CELLS_AND_PROOFS[0] - cell_ids = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - # Add another cell_id - cell_ids.append(spec.CELLS_PER_EXT_BLOB - 1) - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) - yield f'recover_cells_and_kzg_proofs_case_invalid_more_cell_ids_than_cells_{identifier}', { + cell_indices = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + # Add another cell_index + cell_indices.append(spec.CELLS_PER_EXT_BLOB - 1) + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) + yield f'recover_cells_and_kzg_proofs_case_invalid_more_cell_indices_than_cells_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, 'output': None } - # Edge case: More cells than cell_ids + # Edge case: More cells than cell_indices cells, proofs = VALID_CELLS_AND_PROOFS[1] - cell_ids = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] + cell_indices = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] # Add another cell partial_cells.append(CELL_RANDOM_VALID1) - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) - yield f'recover_cells_and_kzg_proofs_case_invalid_more_cells_than_cell_ids_{identifier}', { + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) + yield f'recover_cells_and_kzg_proofs_case_invalid_more_cells_than_cell_indices_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, 'output': None } - # Edge case: More proofs than cell_ids + # Edge case: More proofs than cell_indices cells, proofs = VALID_CELLS_AND_PROOFS[1] - cell_ids = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] + cell_indices = list(range(0, spec.CELLS_PER_EXT_BLOB, 2)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] # Add another proof partial_proofs.append(G1) - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) - yield f'recover_cells_and_kzg_proofs_case_invalid_more_proofs_than_cell_ids_{identifier}', { + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) + yield f'recover_cells_and_kzg_proofs_case_invalid_more_proofs_than_cell_indices_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), }, 'output': None } - # Edge case: Duplicate cell_id + # Edge case: Duplicate cell_index cells, proofs = VALID_CELLS_AND_PROOFS[2] # There will be 65 cells, where 64 are unique and 1 is a duplicate. # Depending on the implementation, 63 & 1 might not fail for the right # reason. For example, if the implementation assigns cells in an array # via index, this would result in 63 cells and the test would fail due # to insufficient cell count, not because of a duplicate cell. - cell_ids = list(range(spec.CELLS_PER_EXT_BLOB // 2 + 1)) - partial_cells = [cells[cell_id] for cell_id in cell_ids] - partial_proofs = [proofs[cell_id] for cell_id in cell_ids] - # Replace first cell_id with the second cell_id - cell_ids[0] = cell_ids[1] - expect_exception(spec.recover_cells_and_kzg_proofs, cell_ids, partial_cells, partial_proofs) - identifier = make_id(cell_ids, partial_cells, partial_proofs) - yield f'recover_cells_and_kzg_proofs_case_invalid_duplicate_cell_id_{identifier}', { + cell_indices = list(range(spec.CELLS_PER_EXT_BLOB // 2 + 1)) + partial_cells = [cells[cell_index] for cell_index in cell_indices] + partial_proofs = [proofs[cell_index] for cell_index in cell_indices] + # Replace first cell_index with the second cell_index + cell_indices[0] = cell_indices[1] + expect_exception(spec.recover_cells_and_kzg_proofs, cell_indices, partial_cells, partial_proofs) + identifier = make_id(cell_indices, partial_cells, partial_proofs) + yield f'recover_cells_and_kzg_proofs_case_invalid_duplicate_cell_index_{identifier}', { 'input': { - 'cell_ids': cell_ids, + 'cell_indices': cell_indices, 'cells': encode_hex_list(partial_cells), 'proofs': encode_hex_list(partial_proofs), },