Skip to content

Commit d137553

Browse files
committed
Rename CellID to CellIndex
1 parent 5ace424 commit d137553

File tree

7 files changed

+205
-204
lines changed

7 files changed

+205
-204
lines changed

specs/_features/eip7594/das-core.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ def compute_extended_matrix(blobs: Sequence[Blob]) -> List[MatrixEntry, MAX_CELL
151151
extended_matrix = []
152152
for blob_index, blob in enumerate(blobs):
153153
cells, proofs = compute_cells_and_kzg_proofs(blob)
154-
for cell_id, (cell, proof) in enumerate(zip(cells, proofs)):
154+
for cell_index, (cell, proof) in enumerate(zip(cells, proofs)):
155155
extended_matrix.append(MatrixEntry(
156156
cell=cell,
157157
kzg_proof=proof,
158158
row_index=blob_index,
159-
column_index=cell_id,
159+
column_index=cell_index,
160160
))
161161
return extended_matrix
162162
```
@@ -174,17 +174,17 @@ def recover_matrix(partial_matrix: Sequence[MatrixEntry],
174174
"""
175175
extended_matrix = []
176176
for blob_index in range(blob_count):
177-
cell_ids = [e.column_index for e in partial_matrix if e.row_index == blob_index]
177+
cell_indices = [e.column_index for e in partial_matrix if e.row_index == blob_index]
178178
cells = [e.cell for e in partial_matrix if e.row_index == blob_index]
179179
proofs = [e.kzg_proof for e in partial_matrix if e.row_index == blob_index]
180180

181-
recovered_cells, recovered_proofs = recover_cells_and_kzg_proofs(cell_ids, cells, proofs)
182-
for cell_id, (cell, proof) in enumerate(zip(recovered_cells, recovered_proofs)):
181+
recovered_cells, recovered_proofs = recover_cells_and_kzg_proofs(cell_indices, cells, proofs)
182+
for cell_index, (cell, proof) in enumerate(zip(recovered_cells, recovered_proofs)):
183183
extended_matrix.append(MatrixEntry(
184184
cell=cell,
185185
kzg_proof=proof,
186186
row_index=blob_index,
187-
column_index=cell_id,
187+
column_index=cell_index,
188188
))
189189
return extended_matrix
190190
```

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

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Public functions MUST accept raw bytes as input and perform the required cryptog
6767
| `Coset` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_CELL]` | The evaluation domain of a cell |
6868
| `CosetEvals` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_CELL]` | The internal representation of a cell (the evaluations over its Coset) |
6969
| `Cell` | `ByteVector[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_CELL]` | The unit of blob data that can come with its own KZG proof |
70-
| `CellID` | `uint64` | Validation: `x < CELLS_PER_EXT_BLOB` |
70+
| `CellIndex` | `uint64` | Validation: `x < CELLS_PER_EXT_BLOB` |
7171

7272
## Constants
7373

@@ -402,15 +402,15 @@ def verify_kzg_proof_multi_impl(commitment: KZGCommitment,
402402
#### `coset_for_cell`
403403

404404
```python
405-
def coset_for_cell(cell_id: CellID) -> Coset:
405+
def coset_for_cell(cell_index: CellIndex) -> Coset:
406406
"""
407-
Get the coset for a given ``cell_id``
407+
Get the coset for a given ``cell_index``.
408408
"""
409-
assert cell_id < CELLS_PER_EXT_BLOB
409+
assert cell_index < CELLS_PER_EXT_BLOB
410410
roots_of_unity_brp = bit_reversal_permutation(
411411
compute_roots_of_unity(FIELD_ELEMENTS_PER_EXT_BLOB)
412412
)
413-
return Coset(roots_of_unity_brp[FIELD_ELEMENTS_PER_CELL * cell_id:FIELD_ELEMENTS_PER_CELL * (cell_id + 1)])
413+
return Coset(roots_of_unity_brp[FIELD_ELEMENTS_PER_CELL * cell_index:FIELD_ELEMENTS_PER_CELL * (cell_index + 1)])
414414
```
415415

416416
## Cells
@@ -439,7 +439,7 @@ def compute_cells_and_kzg_proofs(blob: Blob) -> Tuple[
439439
proofs = []
440440

441441
for i in range(CELLS_PER_EXT_BLOB):
442-
coset = coset_for_cell(CellID(i))
442+
coset = coset_for_cell(CellIndex(i))
443443
proof, ys = compute_kzg_proof_multi_impl(polynomial_coeff, coset)
444444
cells.append(coset_evals_to_cell(ys))
445445
proofs.append(proof)
@@ -465,9 +465,9 @@ def compute_cells(blob: Blob) -> Vector[Cell, CELLS_PER_EXT_BLOB]:
465465
compute_roots_of_unity(FIELD_ELEMENTS_PER_EXT_BLOB))
466466
extended_data_rbo = bit_reversal_permutation(extended_data)
467467
cells = []
468-
for cell_id in range(CELLS_PER_EXT_BLOB):
469-
start = cell_id * FIELD_ELEMENTS_PER_CELL
470-
end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL
468+
for cell_index in range(CELLS_PER_EXT_BLOB):
469+
start = cell_index * FIELD_ELEMENTS_PER_CELL
470+
end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL
471471
cells.append(coset_evals_to_cell(CosetEvals(extended_data_rbo[start:end])))
472472
return cells
473473
```
@@ -478,7 +478,7 @@ def compute_cells(blob: Blob) -> Vector[Cell, CELLS_PER_EXT_BLOB]:
478478

479479
```python
480480
def verify_cell_kzg_proof(commitment_bytes: Bytes48,
481-
cell_id: CellID,
481+
cell_index: CellIndex,
482482
cell: Cell,
483483
proof_bytes: Bytes48) -> bool:
484484
"""
@@ -487,11 +487,11 @@ def verify_cell_kzg_proof(commitment_bytes: Bytes48,
487487
Public method.
488488
"""
489489
assert len(commitment_bytes) == BYTES_PER_COMMITMENT
490-
assert cell_id < CELLS_PER_EXT_BLOB
490+
assert cell_index < CELLS_PER_EXT_BLOB
491491
assert len(cell) == BYTES_PER_CELL
492492
assert len(proof_bytes) == BYTES_PER_PROOF
493493

494-
coset = coset_for_cell(cell_id)
494+
coset = coset_for_cell(cell_index)
495495

496496
return verify_kzg_proof_multi_impl(
497497
bytes_to_kzg_commitment(commitment_bytes),
@@ -553,7 +553,7 @@ def verify_cell_kzg_proof_batch(row_commitments_bytes: Sequence[Bytes48],
553553
### `construct_vanishing_polynomial`
554554

555555
```python
556-
def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[
556+
def construct_vanishing_polynomial(missing_cell_indices: Sequence[CellIndex]) -> Tuple[
557557
Sequence[BLSFieldElement],
558558
Sequence[BLSFieldElement]]:
559559
"""
@@ -565,8 +565,8 @@ def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[
565565

566566
# Compute polynomial that vanishes at all the missing cells (over the small domain)
567567
short_zero_poly = vanishing_polynomialcoeff([
568-
roots_of_unity_reduced[reverse_bits(missing_cell_id, CELLS_PER_EXT_BLOB)]
569-
for missing_cell_id in missing_cell_ids
568+
roots_of_unity_reduced[reverse_bits(missing_cell_index, CELLS_PER_EXT_BLOB)]
569+
for missing_cell_index in missing_cell_indices
570570
])
571571

572572
# 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[
580580
zero_poly_eval_brp = bit_reversal_permutation(zero_poly_eval)
581581

582582
# Sanity check
583-
for cell_id in range(CELLS_PER_EXT_BLOB):
584-
start = cell_id * FIELD_ELEMENTS_PER_CELL
585-
end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL
586-
if cell_id in missing_cell_ids:
583+
for cell_index in range(CELLS_PER_EXT_BLOB):
584+
start = cell_index * FIELD_ELEMENTS_PER_CELL
585+
end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL
586+
if cell_index in missing_cell_indices:
587587
assert all(a == 0 for a in zero_poly_eval_brp[start:end])
588-
else: # cell_id in cell_ids
588+
else: # cell_index in cell_indices
589589
assert all(a != 0 for a in zero_poly_eval_brp[start:end])
590590

591591
return zero_poly_coeff, zero_poly_eval
@@ -594,7 +594,7 @@ def construct_vanishing_polynomial(missing_cell_ids: Sequence[CellID]) -> Tuple[
594594
### `recover_shifted_data`
595595

596596
```python
597-
def recover_shifted_data(cell_ids: Sequence[CellID],
597+
def recover_shifted_data(cell_indices: Sequence[CellIndex],
598598
cells: Sequence[Cell],
599599
zero_poly_eval: Sequence[BLSFieldElement],
600600
zero_poly_coeff: Sequence[BLSFieldElement],
@@ -609,9 +609,9 @@ def recover_shifted_data(cell_ids: Sequence[CellID],
609609
shift_inv = div(BLSFieldElement(1), shift_factor)
610610

611611
extended_evaluation_rbo = [0] * FIELD_ELEMENTS_PER_EXT_BLOB
612-
for cell_id, cell in zip(cell_ids, cells):
613-
start = cell_id * FIELD_ELEMENTS_PER_CELL
614-
end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL
612+
for cell_index, cell in zip(cell_indices, cells):
613+
start = cell_index * FIELD_ELEMENTS_PER_CELL
614+
end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL
615615
extended_evaluation_rbo[start:end] = cell
616616
extended_evaluation = bit_reversal_permutation(extended_evaluation_rbo)
617617

@@ -661,7 +661,7 @@ def recover_original_data(eval_shifted_extended_evaluation: Sequence[BLSFieldEle
661661
### `recover_cells_and_kzg_proofs`
662662

663663
```python
664-
def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID],
664+
def recover_cells_and_kzg_proofs(cell_indices: Sequence[CellIndex],
665665
cells: Sequence[Cell],
666666
proofs_bytes: Sequence[Bytes48]) -> Tuple[
667667
Vector[Cell, CELLS_PER_EXT_BLOB],
@@ -677,14 +677,14 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID],
677677
678678
Public method.
679679
"""
680-
assert len(cell_ids) == len(cells) == len(proofs_bytes)
680+
assert len(cell_indices) == len(cells) == len(proofs_bytes)
681681
# Check we have enough cells to be able to perform the reconstruction
682-
assert CELLS_PER_EXT_BLOB / 2 <= len(cell_ids) <= CELLS_PER_EXT_BLOB
682+
assert CELLS_PER_EXT_BLOB / 2 <= len(cell_indices) <= CELLS_PER_EXT_BLOB
683683
# Check for duplicates
684-
assert len(cell_ids) == len(set(cell_ids))
685-
# Check that the cell ids are within bounds
686-
for cell_id in cell_ids:
687-
assert cell_id < CELLS_PER_EXT_BLOB
684+
assert len(cell_indices) == len(set(cell_indices))
685+
# Check that the cell indices are within bounds
686+
for cell_index in cell_indices:
687+
assert cell_index < CELLS_PER_EXT_BLOB
688688
# Check that each cell is the correct length
689689
for cell in cells:
690690
assert len(cell) == BYTES_PER_CELL
@@ -698,11 +698,12 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID],
698698
# Convert cells to coset evals
699699
cosets_evals = [cell_to_coset_evals(cell) for cell in cells]
700700

701-
missing_cell_ids = [CellID(cell_id) for cell_id in range(CELLS_PER_EXT_BLOB) if cell_id not in cell_ids]
702-
zero_poly_coeff, zero_poly_eval = construct_vanishing_polynomial(missing_cell_ids)
701+
missing_cell_indices = [CellIndex(cell_index) for cell_index in range(CELLS_PER_EXT_BLOB)
702+
if cell_index not in cell_indices]
703+
zero_poly_coeff, zero_poly_eval = construct_vanishing_polynomial(missing_cell_indices)
703704

704705
eval_shifted_extended_evaluation, eval_shifted_zero_poly, shift_inv = recover_shifted_data(
705-
cell_ids,
706+
cell_indices,
706707
cosets_evals,
707708
zero_poly_eval,
708709
zero_poly_coeff,
@@ -716,9 +717,9 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID],
716717
roots_of_unity_extended,
717718
)
718719

719-
for cell_id, coset_evals in zip(cell_ids, cosets_evals):
720-
start = cell_id * FIELD_ELEMENTS_PER_CELL
721-
end = (cell_id + 1) * FIELD_ELEMENTS_PER_CELL
720+
for cell_index, coset_evals in zip(cell_indices, cosets_evals):
721+
start = cell_index * FIELD_ELEMENTS_PER_CELL
722+
end = (cell_index + 1) * FIELD_ELEMENTS_PER_CELL
722723
assert reconstructed_data[start:end] == coset_evals
723724

724725
recovered_cells = [
@@ -728,11 +729,11 @@ def recover_cells_and_kzg_proofs(cell_ids: Sequence[CellID],
728729
polynomial_eval = reconstructed_data[:FIELD_ELEMENTS_PER_BLOB]
729730
polynomial_coeff = polynomial_eval_to_coeff(polynomial_eval)
730731
recovered_proofs = [None] * CELLS_PER_EXT_BLOB
731-
for i, cell_id in enumerate(cell_ids):
732-
recovered_proofs[cell_id] = bytes_to_kzg_proof(proofs_bytes[i])
732+
for i, cell_index in enumerate(cell_indices):
733+
recovered_proofs[cell_index] = bytes_to_kzg_proof(proofs_bytes[i])
733734
for i in range(CELLS_PER_EXT_BLOB):
734735
if recovered_proofs[i] is None:
735-
coset = coset_for_cell(CellID(i))
736+
coset = coset_for_cell(CellIndex(i))
736737
proof, ys = compute_kzg_proof_multi_impl(polynomial_coeff, coset)
737738
assert coset_evals_to_cell(ys) == recovered_cells[i]
738739
recovered_proofs[i] = proof

tests/core/pyspec/eth2spec/test/eip7594/unittests/polynomial_commitments/test_polynomial_commitments.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def test_verify_cell_kzg_proof(spec):
3636
commitment = spec.blob_to_kzg_commitment(blob)
3737
cells, proofs = spec.compute_cells_and_kzg_proofs(blob)
3838

39-
cell_id = 0
40-
assert spec.verify_cell_kzg_proof(commitment, cell_id, cells[cell_id], proofs[cell_id])
41-
cell_id = 1
42-
assert spec.verify_cell_kzg_proof(commitment, cell_id, cells[cell_id], proofs[cell_id])
39+
cell_index = 0
40+
assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index])
41+
cell_index = 1
42+
assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index])
4343

4444

4545
@with_eip7594_and_later
@@ -77,19 +77,19 @@ def test_recover_cells_and_kzg_proofs(spec):
7777
cells, proofs = spec.compute_cells_and_kzg_proofs(blob)
7878

7979
# Compute the cells we will be recovering from
80-
cell_ids = []
80+
cell_indices = []
8181
# First figure out just the indices of the cells
8282
for i in range(N_SAMPLES):
8383
j = rng.randint(0, spec.CELLS_PER_EXT_BLOB - 1)
84-
while j in cell_ids:
84+
while j in cell_indices:
8585
j = rng.randint(0, spec.CELLS_PER_EXT_BLOB - 1)
86-
cell_ids.append(j)
86+
cell_indices.append(j)
8787
# Now the cells/proofs themselves
88-
known_cells = [cells[cell_id] for cell_id in cell_ids]
89-
known_proofs = [proofs[cell_id] for cell_id in cell_ids]
88+
known_cells = [cells[cell_index] for cell_index in cell_indices]
89+
known_proofs = [proofs[cell_index] for cell_index in cell_indices]
9090

9191
# Recover the missing cells and proofs
92-
recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_ids, known_cells, known_proofs)
92+
recovered_cells, recovered_proofs = spec.recover_cells_and_kzg_proofs(cell_indices, known_cells, known_proofs)
9393
recovered_data = [x for xs in recovered_cells for x in xs]
9494

9595
# Check that the original data match the non-extended portion of the recovered data

tests/formats/kzg_7594/recover_cells_and_kzg_proofs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ The test data is declared in a `data.yaml` file:
88

99
```yaml
1010
input:
11-
cell_ids: List[CellID] -- the cell identifier for each cell
11+
cell_indices: List[CellIndex] -- the cell indices
1212
cells: List[Cell] -- the partial collection of cells
1313
output: Tuple[List[Cell], List[KZGProof]] -- all cells and proofs
1414
```
1515
16-
- `CellID` is an unsigned 64-bit integer.
16+
- `CellIndex` is an unsigned 64-bit integer.
1717
- `Cell` is a 2048-byte hexadecimal string, prefixed with `0x`.
1818
- `KZGProof` is a 48-byte hexadecimal string, prefixed with `0x`.
1919

2020
All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`.
2121

2222
## Condition
2323

24-
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`.
24+
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`.

tests/formats/kzg_7594/verify_cell_kzg_proof.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ The test data is declared in a `data.yaml` file:
99
```yaml
1010
input:
1111
commitment: Bytes48 -- the KZG commitment
12-
cell_id: CellID -- the identifier for the cell
12+
cell_index: CellIndex -- the cell index
1313
cell: Cell -- the cell
1414
proof: Bytes48 -- the KZG proof for the cell
1515
output: bool -- true (correct proof) or false (incorrect proof)
1616
```
1717
1818
- `Bytes48` is a 48-byte hexadecimal string, prefixed with `0x`.
19-
- `CellID` is an unsigned 64-bit integer.
19+
- `CellIndex` is an unsigned 64-bit integer.
2020
- `Cell` is a 2048-byte hexadecimal string, prefixed with `0x`.
2121

2222
All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`.
2323

2424
## Condition
2525

26-
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`.
26+
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`.

tests/formats/kzg_7594/verify_cell_kzg_proof_batch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `
2525

2626
## Condition
2727

28-
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`.
28+
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`.

0 commit comments

Comments
 (0)