Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compute_cells method #3796

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions specs/_features/eip7594/polynomial-commitments-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
- [Cells](#cells-1)
- [Cell computation](#cell-computation)
- [`compute_cells_and_kzg_proofs`](#compute_cells_and_kzg_proofs)
- [`compute_cells`](#compute_cells)
- [Cell verification](#cell-verification)
- [`verify_cell_kzg_proof`](#verify_cell_kzg_proof)
- [`verify_cell_kzg_proof_batch`](#verify_cell_kzg_proof_batch)
Expand All @@ -65,7 +64,6 @@ Public functions MUST accept raw bytes as input and perform the required cryptog
The following is a list of the public methods:

* [`compute_cells_and_kzg_proofs`](#compute_cells_and_kzg_proofs)
* [`compute_cells`](#compute_cells)
* [`verify_cell_kzg_proof`](#verify_cell_kzg_proof)
* [`verify_cell_kzg_proof_batch`](#verify_cell_kzg_proof_batch)
* [`recover_cells_and_kzg_proofs`](#recover_cells_and_kzg_proofs)
Expand Down Expand Up @@ -459,31 +457,6 @@ def compute_cells_and_kzg_proofs(blob: Blob) -> Tuple[
return cells, proofs
```

#### `compute_cells`

```python
def compute_cells(blob: Blob) -> Vector[Cell, CELLS_PER_EXT_BLOB]:
"""
Compute the cell data for an extended blob (without computing the proofs).

Public method.
"""
assert len(blob) == BYTES_PER_BLOB

polynomial = blob_to_polynomial(blob)
polynomial_coeff = polynomial_eval_to_coeff(polynomial)

extended_data = fft_field(polynomial_coeff + [0] * FIELD_ELEMENTS_PER_BLOB,
compute_roots_of_unity(FIELD_ELEMENTS_PER_EXT_BLOB))
extended_data_rbo = bit_reversal_permutation(extended_data)
cells = []
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
```

### Cell verification

#### `verify_cell_kzg_proof`
Expand Down
45 changes: 8 additions & 37 deletions tests/generators/kzg_7594/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,11 @@
from eth2spec.utils import bls


###############################################################################
# Test cases for compute_cells
###############################################################################

def case01_compute_cells():
# Valid cases
for blob in VALID_BLOBS:
cells = spec.compute_cells(blob)
identifier = make_id(blob)
yield f'compute_cells_case_valid_{identifier}', {
'input': {
'blob': encode_hex(blob),
},
'output': encode_hex_list(cells)
}

# Edge case: Invalid blobs
for blob in INVALID_BLOBS:
expect_exception(spec.compute_cells, blob)
identifier = make_id(blob)
yield f'compute_cells_case_invalid_blob_{identifier}', {
'input': {
'blob': encode_hex(blob)
},
'output': None
}


###############################################################################
# Test cases for compute_cells_and_kzg_proofs
###############################################################################

def case02_compute_cells_and_kzg_proofs():
def case_compute_cells_and_kzg_proofs():
# Valid cases
for blob in VALID_BLOBS:
cells, proofs = spec.compute_cells_and_kzg_proofs(blob)
Expand Down Expand Up @@ -91,7 +63,7 @@ def case02_compute_cells_and_kzg_proofs():
# Test cases for verify_cell_kzg_proof
###############################################################################

def case03_verify_cell_kzg_proof():
def case_verify_cell_kzg_proof():
# Valid cases
for i in range(len(VALID_BLOBS)):
cells, proofs = VALID_CELLS_AND_PROOFS[i]
Expand Down Expand Up @@ -245,7 +217,7 @@ def case03_verify_cell_kzg_proof():
# Test cases for verify_cell_kzg_proof_batch
###############################################################################

def case04_verify_cell_kzg_proof_batch():
def case_verify_cell_kzg_proof_batch():
# Valid cases
for i in range(len(VALID_BLOBS)):
cells, proofs = VALID_CELLS_AND_PROOFS[i]
Expand Down Expand Up @@ -617,7 +589,7 @@ def case04_verify_cell_kzg_proof_batch():
# Test cases for recover_cells_and_kzg_proofs
###############################################################################

def case05_recover_cells_and_kzg_proofs():
def case_recover_cells_and_kzg_proofs():
# Valid: No missing cells
cells, proofs = VALID_CELLS_AND_PROOFS[0]
cell_indices = list(range(spec.CELLS_PER_EXT_BLOB))
Expand Down Expand Up @@ -899,9 +871,8 @@ def cases_fn() -> Iterable[gen_typing.TestCase]:
bls.use_arkworks()
gen_runner.run_generator("kzg_7594", [
# EIP-7594
create_provider(EIP7594, 'compute_cells', case01_compute_cells),
create_provider(EIP7594, 'compute_cells_and_kzg_proofs', case02_compute_cells_and_kzg_proofs),
create_provider(EIP7594, 'verify_cell_kzg_proof', case03_verify_cell_kzg_proof),
create_provider(EIP7594, 'verify_cell_kzg_proof_batch', case04_verify_cell_kzg_proof_batch),
create_provider(EIP7594, 'recover_cells_and_kzg_proofs', case05_recover_cells_and_kzg_proofs),
create_provider(EIP7594, 'compute_cells_and_kzg_proofs', case_compute_cells_and_kzg_proofs),
create_provider(EIP7594, 'verify_cell_kzg_proof', case_verify_cell_kzg_proof),
create_provider(EIP7594, 'verify_cell_kzg_proof_batch', case_verify_cell_kzg_proof_batch),
create_provider(EIP7594, 'recover_cells_and_kzg_proofs', case_recover_cells_and_kzg_proofs),
])