Improve test_verify_cell_proof_batch()

This commit is contained in:
George Kadianakis 2024-01-17 17:20:36 +02:00
parent 66798602dd
commit 2000a4f307
2 changed files with 12 additions and 6 deletions

View File

@ -438,7 +438,10 @@ def verify_cell_proof_batch(row_commitments_bytes: Sequence[Bytes48],
cells_bytes: Sequence[Vector[Bytes32, FIELD_ELEMENTS_PER_CELL]],
proofs_bytes: Sequence[Bytes48]) -> bool:
"""
Check multiple cell proofs. This function implements the naive algorithm of checking every cell
Verify a set of cells, given their corresponding proofs and their coordinates (row_id, column_id) in the blob
matrix. The list of all commitments is also provided in row_commitments_bytes.
This function implements the naive algorithm of checking every cell
individually; an efficient algorithm can be found here:
https://ethresear.ch/t/a-universal-verification-equation-for-data-availability-sampling/13240
@ -448,6 +451,8 @@ def verify_cell_proof_batch(row_commitments_bytes: Sequence[Bytes48],
Public method.
"""
assert len(cells_bytes) == len(proofs_bytes) == len(row_ids) == len(column_ids)
# Get commitments via row IDs
commitments_bytes = [row_commitments_bytes[row_id] for row_id in row_ids]

View File

@ -54,15 +54,16 @@ def test_verify_cell_proof_batch(spec):
blob = get_sample_blob(spec)
commitment = spec.blob_to_kzg_commitment(blob)
cells, proofs = spec.compute_cells_and_proofs(blob)
cells_bytes = [[field_element_bytes(element) for element in cell] for cell in cells]
assert len(cells) == len(proofs)
assert spec.verify_cell_proof_batch(
row_commitments_bytes=[commitment],
row_ids=[0],
column_ids=[0, 1],
cells_bytes=cells_bytes[0:1],
proofs_bytes=proofs,
row_ids=[0, 0],
column_ids=[0, 4],
cells_bytes=[cells_bytes[0], cells_bytes[4]],
proofs_bytes=[proofs[0], proofs[4]],
)