Skip to content

Commit

Permalink
fix(sigmap-EDAP-01): Missing nil Checks On Parameters Of Incoming Req…
Browse files Browse the repository at this point in the history
…uests (#231)

* fix(sigmap-EDAP-01): Missing nil Checks On Parameters Of Incoming Requests

* fix(sigmap-EDAP-01): Missing nil Checks On Parameters Of Incoming Requests - check all nil fields and use proto accessors for referencing cert fields
epociask authored Jan 9, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent cc1b304 commit f34d87a
Showing 2 changed files with 40 additions and 3 deletions.
16 changes: 13 additions & 3 deletions store/generated_key/eigenda/eigenda.go
Original file line number Diff line number Diff line change
@@ -59,7 +59,12 @@ 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)
}

decodedBlob, err := e.client.GetBlob(ctx, cert.BlobVerificationProof.BatchMetadata.BatchHeaderHash, cert.BlobVerificationProof.BlobIndex)
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.GetBatchMetadata().GetBatchHeaderHash(), cert.BlobVerificationProof.GetBlobIndex())
if err != nil {
return nil, fmt.Errorf("EigenDA client failed to retrieve decoded blob: %w", err)
}
@@ -119,7 +124,12 @@ func (e Store) Put(ctx context.Context, value []byte) ([]byte, error) {
}
cert := (*verify.Certificate)(blobInfo)

err = e.verifier.VerifyCommitment(cert.BlobHeader.Commitment, encodedBlob)
err = cert.NoNilFields()
if err != nil {
return nil, fmt.Errorf("failed to verify DA cert: %w", err)
}

err = e.verifier.VerifyCommitment(cert.BlobHeader.GetCommitment(), encodedBlob)
if err != nil {
return nil, fmt.Errorf("failed to verify commitment: %w", err)
}
@@ -158,7 +168,7 @@ func (e Store) Verify(ctx context.Context, key []byte, value []byte) error {
}

// verify kzg data commitment
err = e.verifier.VerifyCommitment(cert.BlobHeader.Commitment, encodedBlob)
err = e.verifier.VerifyCommitment(cert.BlobHeader.GetCommitment(), encodedBlob)
if err != nil {
return fmt.Errorf("failed to verify commitment: %w", err)
}
27 changes: 27 additions & 0 deletions verify/certificate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package verify

import (
"fmt"
"math/big"

"github.com/Layr-Labs/eigenda/api/grpc/disperser"
@@ -29,6 +30,32 @@ type BlobHeader struct {

type Certificate disperser.BlobInfo

// NoNilFields ... checks if any referenced fields in the certificate
// are nil and returns an error if so
func (c *Certificate) NoNilFields() error {
if c.BlobVerificationProof == nil {
return fmt.Errorf("BlobVerificationProof is nil")
}

if c.BlobVerificationProof.BatchMetadata == nil {
return fmt.Errorf("BlobVerificationProof.BatchMetadata is nil")
}

if c.BlobVerificationProof.BatchMetadata.BatchHeader == nil {
return fmt.Errorf("BlobVerificationProof.BatchMetadata.BatchHeader is nil")
}

if c.BlobHeader == nil {
return fmt.Errorf("BlobHeader is nil")
}

if c.BlobHeader.Commitment == nil {
return fmt.Errorf("BlobHeader.Commitment is nil")
}

return nil
}

func (c *Certificate) BlobIndex() uint32 {
return c.BlobVerificationProof.BlobIndex
}

0 comments on commit f34d87a

Please sign in to comment.