From b9e7b031b5f2c18d76143007ea779a32b5505155 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Mon, 8 Jul 2024 09:00:14 -0500 Subject: [PATCH] Update algorithm & remove check --- .../eip7594/polynomial-commitments-sampling.md | 6 +----- .../test_polynomial_commitments.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/specs/_features/eip7594/polynomial-commitments-sampling.md b/specs/_features/eip7594/polynomial-commitments-sampling.md index b2c34a484..999e5ef34 100644 --- a/specs/_features/eip7594/polynomial-commitments-sampling.md +++ b/specs/_features/eip7594/polynomial-commitments-sampling.md @@ -511,10 +511,6 @@ def verify_cell_kzg_proof_batch_impl(row_commitments: Sequence[KZGCommitment], n = FIELD_ELEMENTS_PER_CELL num_rows = len(row_commitments) - # Given zero cells, the result is true - if num_cells == 0: - return True - # Step 1: Compute a challenge r and its powers r^0, ..., r^{num_cells-1} r = compute_verify_cell_kzg_proof_batch_challenge( row_commitments, @@ -544,7 +540,7 @@ def verify_cell_kzg_proof_batch_impl(row_commitments: Sequence[KZGCommitment], # Step 4.2: Compute RLI = [sum_k r^k interpolation_poly_k(s)] # Note: an efficient implementation would use the IDFT based method explained in the blog post - sum_interp_polys_coeff = [0] + sum_interp_polys_coeff = [0] * n for k in range(num_cells): interp_poly_coeff = interpolate_polynomialcoeff(coset_for_cell(column_indices[k]), cosets_evals[k]) interp_poly_scaled_coeff = multiply_polynomialcoeff([r_powers[k]], interp_poly_coeff) 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 dd5aece3f..dcb43f4fa 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 @@ -122,6 +122,20 @@ def test_verify_cell_kzg_proof(spec): assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index]) +@with_eip7594_and_later +@spec_test +@single_phase +def test_verify_cell_kzg_proof_batch_zero_cells(spec): + # Verify with zero cells should return true + assert spec.verify_cell_kzg_proof_batch( + row_commitments_bytes=[], + row_indices=[], + column_indices=[], + cells=[], + proofs_bytes=[], + ) + + @with_eip7594_and_later @spec_test @single_phase