From 665e6faff7b052ef8c64584e062fcc0c86fc8794 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 19 Jan 2024 18:51:36 +0800 Subject: [PATCH] Add `RowIndex`, `ColumnIndex` custom types in crypto doc --- specs/_features/eip7594/das-core.md | 8 +++----- specs/_features/eip7594/p2p-interface.md | 20 +++++++++---------- .../polynomial-commitments-sampling.md | 12 ++++++----- .../test_polynomial_commitments.py | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/specs/_features/eip7594/das-core.md b/specs/_features/eip7594/das-core.md index 635fa35f1..dfe9833b4 100644 --- a/specs/_features/eip7594/das-core.md +++ b/specs/_features/eip7594/das-core.md @@ -45,7 +45,6 @@ We define the following Python custom types for type hinting and readability: | `DataColumn` | `List[Cell, MAX_BLOBS_PER_BLOCK]` | The data of each column in EIP7594 | | `ExtendedMatrix` | `List[Cell, MAX_BLOBS_PER_BLOCK * NUMBER_OF_COLUMNS]` | The full data with blobs and one-dimensional erasure coding extension | | `FlatExtendedMatrix` | `List[BLSFieldElement, MAX_BLOBS_PER_BLOCK * FIELD_ELEMENTS_PER_BLOB * NUMBER_OF_COLUMNS]` | The flattened format of `ExtendedMatrix` | -| `LineIndex` | `uint64` | The index of the rows or columns in `FlatExtendedMatrix` matrix | ## Configuration @@ -68,11 +67,10 @@ We define the following Python custom types for type hinting and readability: #### `get_custody_lines` ```python -def get_custody_lines(node_id: NodeID, custody_size: uint64) -> Sequence[LineIndex]: +def get_custody_lines(node_id: NodeID, custody_size: uint64) -> Sequence[ColumnIndex]: assert custody_size <= NUMBER_OF_COLUMNS - all_items = list(range(NUMBER_OF_COLUMNS)) - line_index = node_id % NUMBER_OF_COLUMNS - return [LineIndex(all_items[(line_index + i) % len(all_items)]) for i in range(custody_size)] + column_index = node_id % NUMBER_OF_COLUMNS + return [ColumnIndex((column_index + i) % NUMBER_OF_COLUMNS) for i in range(custody_size)] ``` #### `compute_extended_data` diff --git a/specs/_features/eip7594/p2p-interface.md b/specs/_features/eip7594/p2p-interface.md index 4d55a69ef..fd39516bd 100644 --- a/specs/_features/eip7594/p2p-interface.md +++ b/specs/_features/eip7594/p2p-interface.md @@ -13,7 +13,7 @@ - [Configuration](#configuration) - [Containers](#containers) - [`DataColumnSidecar`](#datacolumnsidecar) - - [`DataColumnIdentifier`](#datacolumnidentifier) + - [`DataColumnIndexentifier`](#dataColumnIndexentifier) - [Helpers](#helpers) - [`verify_data_column_sidecar_kzg_proof`](#verify_data_column_sidecar_kzg_proof) - [`verify_data_column_sidecar_inclusion_proof`](#verify_data_column_sidecar_inclusion_proof) @@ -49,7 +49,7 @@ ```python class DataColumnSidecar(Container): - index: LineIndex # Index of column in extended matrix + index: ColumnIndex # Index of column in extended matrix column: DataColumn kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK] kzg_proofs: List[KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK] @@ -57,12 +57,12 @@ class DataColumnSidecar(Container): kzg_commitments_inclusion_proof: Vector[Bytes32, KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH] ``` -#### `DataColumnIdentifier` +#### `DataColumnIndexentifier` ```python -class DataColumnIdentifier(Container): +class DataColumnIndexentifier(Container): block_root: Root - index: LineIndex + index: ColumnIndex ``` ### Helpers @@ -74,14 +74,14 @@ def verify_data_column_sidecar_kzg_proof(sidecar: DataColumnSidecar) -> bool: """ Verify if the proofs are correct """ - row_ids = [LineIndex(i) for i in range(len(sidecar.column))] + row_ids = [RowIndex(i) for i in range(len(sidecar.column))] assert len(sidecar.column) == len(sidecar.kzg_commitments) == len(sidecar.kzg_proofs) # KZG batch verifies that the cells match the corresponding commitments and proofs return verify_cell_proof_batch( row_commitments=sidecar.kzg_commitments, - row_ids=row_ids, # all rows - column_ids=[sidecar.index], + row_indices=row_ids, # all rows + column_indices=[sidecar.index], datas=sidecar.column, proofs=sidecar.kzg_proofs, ) @@ -107,7 +107,7 @@ def verify_data_column_sidecar_inclusion_proof(sidecar: DataColumnSidecar) -> bo ##### `compute_subnet_for_data_column_sidecar` ```python -def compute_subnet_for_data_column_sidecar(column_index: LineIndex) -> SubnetID: +def compute_subnet_for_data_column_sidecar(column_index: ColumnIndex) -> SubnetID: return SubnetID(column_index % DATA_COLUMN_SIDECAR_SUBNET_COUNT) ``` @@ -167,7 +167,7 @@ Request Content: ``` ( - DataColumnIdentifier + DataColumnIndexentifier ) ``` diff --git a/specs/_features/eip7594/polynomial-commitments-sampling.md b/specs/_features/eip7594/polynomial-commitments-sampling.md index e09888a31..e1cb2e85b 100644 --- a/specs/_features/eip7594/polynomial-commitments-sampling.md +++ b/specs/_features/eip7594/polynomial-commitments-sampling.md @@ -60,6 +60,8 @@ Public functions MUST accept raw bytes as input and perform the required cryptog | `PolynomialCoeff` | `List[BLSFieldElement, 2 * FIELD_ELEMENTS_PER_BLOB]` | A polynomial in coefficient form | | `Cell` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_CELL]` | The unit of blob data that can come with their own KZG proofs | | `CellID` | `uint64` | Cell identifier | +| `RowIndex` | `uint64` | Row identifier | +| `ColumnIndex` | `uint64` | Column identifier | ## Constants @@ -415,8 +417,8 @@ def verify_cell_proof(commitment: KZGCommitment, ```python def verify_cell_proof_batch(row_commitments: Sequence[KZGCommitment], - row_ids: Sequence[int], - column_ids: Sequence[int], + row_indices: Sequence[RowIndex], + column_indices: Sequence[ColumnIndex], cells: Sequence[Cell], proofs: Sequence[KZGProof]) -> bool: """ @@ -432,11 +434,11 @@ def verify_cell_proof_batch(row_commitments: Sequence[KZGCommitment], """ # Get commitments via row IDs - commitments = [row_commitments[row_id] for row_id in row_ids] + commitments = [row_commitments[row_index] for row_index in row_indices] return all( - verify_kzg_proof_multi_impl(commitment, coset_for_cell(column_id), cell, proof) - for commitment, column_id, cell, proof in zip(commitments, column_ids, cells, proofs) + verify_kzg_proof_multi_impl(commitment, coset_for_cell(column_index), cell, proof) + for commitment, column_index, cell, proof in zip(commitments, column_indices, cells, proofs) ) ``` 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 d3e848772..9affe5dfa 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 @@ -50,8 +50,8 @@ def test_verify_cell_proof_batch(spec): assert spec.verify_cell_proof_batch( row_commitments=[commitment], - row_ids=[0], - column_ids=[0, 1], + row_indices=[0], + column_indices=[0, 1], cells=cells[0:1], proofs=proofs, )