Skip to content

Commit

Permalink
Assert proof is valid in validate_blobs_sidecar + update version of j…
Browse files Browse the repository at this point in the history
…c-kzg-4844 (#6708)
  • Loading branch information
StefanBratanov authored Jan 19, 2023
1 parent 348ac16 commit 9535a58
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ public boolean isMergeTransitionComplete(final BeaconState state) {
/**
* Performs data availability by validating blobs and proof from Sidecar against blobs kzg
* commitments from the block. It will also make check slot and blockRoot consistency.
*
* @param slot
* @param beaconBlockRoot
* @param kzgCommitments
* @param blobsSidecar
* @return
*/
public boolean isDataAvailable(
final UInt64 slot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package tech.pegasys.teku.spec.logic.versions.eip4844.helpers;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static tech.pegasys.teku.spec.config.SpecConfigEip4844.BLOB_TX_TYPE;
import static tech.pegasys.teku.spec.config.SpecConfigEip4844.VERSIONED_HASH_VERSION_KZG;

Expand Down Expand Up @@ -68,17 +69,19 @@ private void validateBlobSidecar(
final BlobsSidecar blobsSidecar) {
checkArgument(
slot.equals(blobsSidecar.getBeaconBlockSlot()),
"Block slot should match blobsSidecar slot");
"Block slot should match blobs sidecar slot");
checkArgument(
beaconBlockRoot.equals(blobsSidecar.getBeaconBlockRoot()),
"Block root should match blobsSidecar beacon block root");
"Block root should match blobs sidecar beacon block root");
checkArgument(
kzgCommitments.size() == blobsSidecar.getBlobs().size(),
"Number of kzgCommitments should match number of blobs");
kzg.verifyAggregateKzgProof(
blobsSidecar.getBlobs().stream().map(Blob::getBytes).collect(Collectors.toList()),
kzgCommitments,
blobsSidecar.getKZGAggregatedProof());
"Number of KZG commitments should match number of blobs");
final boolean isValidProof =
kzg.verifyAggregateKzgProof(
blobsSidecar.getBlobs().stream().map(Blob::getBytes).collect(Collectors.toList()),
kzgCommitments,
blobsSidecar.getKZGAggregatedProof());
checkState(isValidProof, "Invalid aggregate KZG proof for the given blobs and commitments");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencyManagement {

dependency 'io.libp2p:jvm-libp2p-minimal:0.10.0-RELEASE'
dependency 'tech.pegasys:jblst:0.3.10'
dependency 'tech.pegasys:jc-kzg-4844:0.2.1'
dependency 'tech.pegasys:jc-kzg-4844:0.3.0'

dependency 'org.hdrhistogram:HdrHistogram:2.1.12'

Expand Down

0 comments on commit 9535a58

Please sign in to comment.