Skip to content

Commit

Permalink
Merge pull request #11 from Layr-Labs/epociask--fix-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask authored May 18, 2024
2 parents df0fc93 + 2165a28 commit 1b50ef2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)

// ErrCommitmentLength is returned when the commitment length is invalid.
var ErrCommitmentLength = errors.New("invalid commitment length")

// ErrInvalidCommitment is returned when the commitment cannot be parsed into a known commitment type.
var ErrInvalidCommitment = errors.New("invalid commitment")

Expand All @@ -18,8 +21,8 @@ type CommitmentType byte

const (
// default commitment type for the DA storage.
Keccak256CommitmentType CommitmentType = 0x00
DaService CommitmentType = 0x01
Keccak256CommitmentType CommitmentType = 0
GenericCommitment CommitmentType = 1
)

type ExtDAType byte
Expand Down Expand Up @@ -75,11 +78,10 @@ func DecodeKeccak256(commitment []byte) (Keccak256Commitment, error) {
return c, nil
}

// NOTE - This logic will need to be migrated into layr-labs/op-stack directly
type EigenDACommitment []byte

func (c EigenDACommitment) Encode() []byte {
return append([]byte{byte(DaService), byte(EigenDA), byte(EigenV0)}, c...)
return append([]byte{byte(EigenDA), byte(EigenV0)}, c...)
}

func (c EigenDACommitment) TxData() []byte {
Expand All @@ -88,9 +90,9 @@ func (c EigenDACommitment) TxData() []byte {

func DecodeEigenDACommitment(commitment []byte) (EigenDACommitment, error) {
if len(commitment) <= 3 {
return nil, ErrInvalidCommitment
return nil, ErrCommitmentLength
}
if commitment[0] != byte(DaService) {
if commitment[0] != byte(GenericCommitment) {
return nil, ErrInvalidCommitment
}

Expand Down

0 comments on commit 1b50ef2

Please sign in to comment.