Skip to content

Commit

Permalink
Skip verifyAggregateKzgProof is empty blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Nov 26, 2022
1 parent e5d6f4f commit 37f3387
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/beacon-node/src/chain/validation/blobsSidecar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,23 @@ export function validateBlobsSidecar(
);
}

// assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
let isProofValid: boolean;
try {
isProofValid = verifyAggregateKzgProof(blobs, expectedKzgCommitments, kzgAggregatedProof);
} catch (e) {
// TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here
(e as Error).message = `Error on verifyAggregateKzgProof: ${(e as Error).message}`;
throw e;
}
// No need to verify the aggregate proof of zero blobs. Also c-kzg throws.
// https://github.com/dankrad/c-kzg/pull/12/files#r1025851956
if (blobs.length > 0) {
// assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
let isProofValid: boolean;
try {
isProofValid = verifyAggregateKzgProof(blobs, expectedKzgCommitments, kzgAggregatedProof);
} catch (e) {
// TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here
(e as Error).message = `Error on verifyAggregateKzgProof: ${(e as Error).message}`;
throw e;
}

// TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here
if (!isProofValid) {
throw Error("Invalid AggregateKzgProof");
// TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here
if (!isProofValid) {
throw Error("Invalid AggregateKzgProof");
}
}
}

Expand Down

0 comments on commit 37f3387

Please sign in to comment.