diff --git a/store/generated_key/eigenda/eigenda.go b/store/generated_key/eigenda/eigenda.go index b67ce1d..9922b32 100644 --- a/store/generated_key/eigenda/eigenda.go +++ b/store/generated_key/eigenda/eigenda.go @@ -59,6 +59,11 @@ func (e Store) Get(ctx context.Context, key []byte) ([]byte, error) { return nil, fmt.Errorf("failed to decode DA cert to RLP format: %w", err) } + err = cert.NoNilFields() + if err != nil { + return nil, fmt.Errorf("failed to verify DA cert: %w", err) + } + decodedBlob, err := e.client.GetBlob(ctx, cert.BlobVerificationProof.BatchMetadata.BatchHeaderHash, cert.BlobVerificationProof.BlobIndex) if err != nil { return nil, fmt.Errorf("EigenDA client failed to retrieve decoded blob: %w", err) @@ -119,6 +124,11 @@ func (e Store) Put(ctx context.Context, value []byte) ([]byte, error) { } cert := (*verify.Certificate)(blobInfo) + err = cert.NoNilFields() + if err != nil { + return nil, fmt.Errorf("failed to verify DA cert: %w", err) + } + err = e.verifier.VerifyCommitment(cert.BlobHeader.Commitment, encodedBlob) if err != nil { return nil, fmt.Errorf("failed to verify commitment: %w", err) diff --git a/verify/certificate.go b/verify/certificate.go index 9defd89..ee68ef0 100644 --- a/verify/certificate.go +++ b/verify/certificate.go @@ -1,6 +1,7 @@ package verify import ( + "fmt" "math/big" "github.com/Layr-Labs/eigenda/api/grpc/disperser" @@ -29,6 +30,19 @@ type BlobHeader struct { type Certificate disperser.BlobInfo +// NoNilFields ... check if struct pointer fields are nil +func (c *Certificate) NoNilFields() error { + if c.BlobVerificationProof == nil { + return fmt.Errorf("BlobVerificationProof is nil") + } + + if c.BlobHeader == nil { + return fmt.Errorf("BlobHeader is nil") + } + + return nil +} + func (c *Certificate) BlobIndex() uint32 { return c.BlobVerificationProof.BlobIndex }