From b239ce9808d59d471bcdc99162886a08f0c337aa Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Thu, 3 Oct 2024 00:40:49 +0530 Subject: [PATCH] fix verification logic --- beacon_chain/spec/eip7594_helpers.nim | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/beacon_chain/spec/eip7594_helpers.nim b/beacon_chain/spec/eip7594_helpers.nim index 7b87ed462..4957df363 100644 --- a/beacon_chain/spec/eip7594_helpers.nim +++ b/beacon_chain/spec/eip7594_helpers.nim @@ -382,31 +382,34 @@ proc validate_data_column_sidecar*( ok() # https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/p2p-interface.md#verify_data_column_sidecar_kzg_proofs -proc verify_data_column_sidecar_kzg_proofs*(sidecar: DataColumnSidecar): Result[void, string] = - # Verifying if the KZG proofs are correct - +proc verify_data_column_sidecar_kzg_proofs*(sidecar: DataColumnSidecar): + Result[void, cstring] = + ## Verify if the KZG Proofs consisting in the `DataColumnSidecar` + ## is valid or not. + # Check if the data column sidecar index < NUMBER_OF_COLUMNS if not (sidecar.index < NUMBER_OF_COLUMNS): - return err("EIP7594: Data column sidecar index exceeds the NUMBER_OF_COLUMNS") + return err("Data column sidecar index exceeds the NUMBER_OF_COLUMNS") - # Check is the sidecar column length == sidecar.kzg_commitments length == sidecar.kzg_proofs mixInLength + # Check is the sidecar column length = sidecar.kzg_commitments length + # and sidecar.kzg_commitments length = sidecar.kzg_proofs length if not (sidecar.column.len == sidecar.kzg_commitments.len): - return err("EIP7594: Data column sidecar length is not equal to the kzg_commitments length") + return err("Data column sidecar length is not equal to the kzg_commitments length") if not (sidecar.kzg_commitments.len == sidecar.kzg_proofs.len): - return err("EIP7594: Data column sidecar kzg_commitments length is not equal to the kzg_proofs length") + return err("Sidecar kzg_commitments length is not equal to the kzg_proofs length") # Iterate through the cell indices - var cellIndices: seq[CellIndex] + var cellIndices = + newSeq[CellIndex](MAX_BLOB_COMMITMENTS_PER_BLOCK) for _ in 0..