Skip to content

Commit

Permalink
Add utility function to call verifyBlobV2 (#1107)
Browse files Browse the repository at this point in the history
Signed-off-by: litt3 <102969658+litt3@users.noreply.github.com>
  • Loading branch information
litt3 authored Jan 16, 2025
1 parent 4e7fa36 commit f591a1f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
38 changes: 36 additions & 2 deletions api/clients/v2/verification/blob_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

commonv2 "github.com/Layr-Labs/eigenda/api/grpc/common/v2"
"github.com/Layr-Labs/eigenda/common"

disperser "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
Expand Down Expand Up @@ -43,8 +44,6 @@ func NewBlobVerifier(
// VerifyBlobV2FromSignedBatch calls the verifyBlobV2FromSignedBatch view function on the EigenDABlobVerifier contract
//
// This method returns nil if the blob is successfully verified. Otherwise, it returns an error.
//
// It is the responsibility of the caller to configure a timeout on the ctx, if a timeout is required.
func (v *BlobVerifier) VerifyBlobV2FromSignedBatch(
ctx context.Context,
// The signed batch that contains the blob being verified. This is obtained from the disperser, and is used
Expand Down Expand Up @@ -74,3 +73,38 @@ func (v *BlobVerifier) VerifyBlobV2FromSignedBatch(

return nil
}

// VerifyBlobV2 calls the VerifyBlobV2 view function on the EigenDABlobVerifier contract
//
// This method returns nil if the blob is successfully verified. Otherwise, it returns an error.
func (v *BlobVerifier) VerifyBlobV2(
ctx context.Context,
// The header of the batch that the blob is contained in
batchHeader *commonv2.BatchHeader,
// Contains data pertaining to the blob's inclusion in the batch
blobVerificationProof *disperser.BlobVerificationInfo,
// Contains data that can be used to verify that the blob actually exists in the claimed batch
nonSignerStakesAndSignature verifierBindings.NonSignerStakesAndSignature,
) error {
convertedBatchHeader, err := verifierBindings.ConvertBatchHeader(batchHeader)
if err != nil {
return fmt.Errorf("convert batch header: %s", err)
}

convertedBlobVerificationProof, err := verifierBindings.ConvertVerificationProof(blobVerificationProof)
if err != nil {
return fmt.Errorf("convert blob verification proof: %s", err)
}

err = v.blobVerifierCaller.VerifyBlobV2(
&bind.CallOpts{Context: ctx},
*convertedBatchHeader,
*convertedBlobVerificationProof,
nonSignerStakesAndSignature)

if err != nil {
return fmt.Errorf("verify blob v2: %s", err)
}

return nil
}
4 changes: 2 additions & 2 deletions contracts/bindings/EigenDABlobVerifier/conversion_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func ConvertSignedBatch(inputBatch *disperserv2.SignedBatch) (*SignedBatch, error) {
convertedBatchHeader, err := convertBatchHeader(inputBatch.GetHeader())
convertedBatchHeader, err := ConvertBatchHeader(inputBatch.GetHeader())
if err != nil {
return nil, fmt.Errorf("convert batch header: %s", err)
}
Expand All @@ -31,7 +31,7 @@ func ConvertSignedBatch(inputBatch *disperserv2.SignedBatch) (*SignedBatch, erro
return outputSignedBatch, nil
}

func convertBatchHeader(inputHeader *commonv2.BatchHeader) (*BatchHeaderV2, error) {
func ConvertBatchHeader(inputHeader *commonv2.BatchHeader) (*BatchHeaderV2, error) {
var outputBatchRoot [32]byte

inputBatchRoot := inputHeader.GetBatchRoot()
Expand Down

0 comments on commit f591a1f

Please sign in to comment.