Skip to content

Commit

Permalink
Merge branch 'main' into epociask--fix-EDAP-06
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask authored Jan 9, 2025
2 parents 70f2782 + f34d87a commit 79a1360
Show file tree
Hide file tree
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
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 79a1360

Please sign in to comment.