commitments

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Keccak256CommitmentType OPCommitmentType = 0
	GenericCommitmentType   OPCommitmentType = 1
	KeccakCommitmentString  string           = "KeccakCommitment"
	GenericCommitmentString string           = "GenericCommitment"
)

CommitmentType describes the binary format of the commitment. KeccakCommitmentStringType is the default commitment type for the centralized DA storage. GenericCommitmentType indicates an opaque bytestring that the op-node never opens.

Variables

View Source
var ErrCommitmentMismatch = errors.New("commitment mismatch")

ErrCommitmentMismatch is returned when the commitment does not match the given input.

View Source
var ErrInvalidCommitment = errors.New("invalid commitment")

ErrInvalidCommitment is returned when the commitment cannot be parsed into a known commitment type.

Functions

func EncodeCommitment added in v1.3.0

func EncodeCommitment(
	bytes []byte,
	commitmentMode CommitmentMode,
	commitmentType EigenDACommitmentType,
) ([]byte, error)

Types

type CertCommitment added in v1.3.0

type CertCommitment interface {
	CommitmentType() EigenDACommitmentType
	Encode() []byte
	Verify(input []byte) error
}

CertCommitment is the binary representation of a commitment.

type CommitmentMeta added in v1.5.0

type CommitmentMeta struct {
	Mode CommitmentMode
	// version is shared for all modes and denotes version of the EigenDA certificate
	Version EigenDACommitmentType
}

type CommitmentMode added in v1.3.0

type CommitmentMode string
const (
	OptimismKeccak  CommitmentMode = "optimism_keccak256"
	OptimismGeneric CommitmentMode = "optimism_generic"
	Standard        CommitmentMode = "standard"
)

func StringToCommitmentMode added in v1.3.0

func StringToCommitmentMode(s string) (CommitmentMode, error)

type DAServiceOPCommitmentType

type DAServiceOPCommitmentType byte
const (
	EigenDAOPCommitmentType DAServiceOPCommitmentType = 0
)

type DaSvcCommitment added in v1.3.0

type DaSvcCommitment interface {
	CommitmentType() DAServiceOPCommitmentType
	Encode() []byte
	Verify(input []byte) error
}

OPCommitment is the binary representation of a commitment.

type EigenDACommitment

type EigenDACommitment struct {
	// contains filtered or unexported fields
}

func NewEigenDACommitment added in v1.7.0

func NewEigenDACommitment(input []byte, commitmentType EigenDACommitmentType) EigenDACommitment

NewEigenDACommitment creates a new commitment from the given input.

func (EigenDACommitment) CommitmentType added in v1.7.0

func (c EigenDACommitment) CommitmentType() EigenDACommitmentType

CommitmentType returns the commitment type of EigenDACommitment.

func (EigenDACommitment) Encode added in v1.7.0

func (c EigenDACommitment) Encode() []byte

Encode adds a commitment type prefix self describing the commitment.

type EigenDACommitmentType added in v1.3.0

type EigenDACommitmentType byte
const (
	// EigenDA V1
	CertV0 EigenDACommitmentType = iota
	// EigenDA V2
	CertV1
)

type EigenDASvcCommitment added in v1.3.0

type EigenDASvcCommitment []byte

func DecodeEigenDASvcCommitment added in v1.3.0

func DecodeEigenDASvcCommitment(commitment []byte) (EigenDASvcCommitment, error)

DecodeEigenDASvcCommitment validates and casts the commitment into a Keccak256Commitment.

func NewEigenDASvcCommitment added in v1.3.0

func NewEigenDASvcCommitment(input []byte) EigenDASvcCommitment

NewEigenDASvcCommitment creates a new commitment from the given input.

func (EigenDASvcCommitment) CommitmentType added in v1.3.0

CommitmentType returns the commitment type of Keccak256.

func (EigenDASvcCommitment) Encode added in v1.3.0

func (c EigenDASvcCommitment) Encode() []byte

Encode adds a commitment type prefix self describing the commitment.

type GenericCommitment

type GenericCommitment []byte

GenericCommitment is an implementation of OPCommitment that treats the commitment as an opaque bytestring.

func DecodeGenericCommitment added in v1.3.0

func DecodeGenericCommitment(commitment []byte) (GenericCommitment, error)

DecodeGenericCommitment validates and casts the commitment into a GenericCommitment.

func NewGenericCommitment added in v1.3.0

func NewGenericCommitment(input []byte) GenericCommitment

NewGenericCommitment creates a new commitment from the given input.

func (GenericCommitment) CommitmentType added in v1.3.0

func (c GenericCommitment) CommitmentType() OPCommitmentType

CommitmentType returns the commitment type of Generic Commitment.

func (GenericCommitment) Encode added in v1.3.0

func (c GenericCommitment) Encode() []byte

Encode adds a commitment type prefix self describing the commitment.

func (GenericCommitment) Verify added in v1.3.0

func (c GenericCommitment) Verify(_ []byte) error

Verify always returns true for GenericCommitment because the DA Server must validate the data before returning it to the op-node.

type Keccak256Commitment

type Keccak256Commitment []byte

Keccak256Commitment is an implementation of OPCommitment that uses Keccak256 as the commitment function.

func DecodeKeccak256 added in v1.3.0

func DecodeKeccak256(commitment []byte) (Keccak256Commitment, error)

DecodeKeccak256 validates and casts the commitment into a Keccak256Commitment.

func NewKeccak256Commitment added in v1.3.0

func NewKeccak256Commitment(input []byte) Keccak256Commitment

NewKeccak256Commitment creates a new commitment from the given input.

func (Keccak256Commitment) CommitmentType added in v1.3.0

func (c Keccak256Commitment) CommitmentType() OPCommitmentType

CommitmentType returns the commitment type of Keccak256.

func (Keccak256Commitment) Encode added in v1.3.0

func (c Keccak256Commitment) Encode() []byte

Encode adds a commitment type prefix self describing the commitment.

func (Keccak256Commitment) Verify added in v1.3.0

func (c Keccak256Commitment) Verify(input []byte) error

Verify checks if the commitment matches the given input.

type OPCommitment

type OPCommitment interface {
	CommitmentType() OPCommitmentType
	Encode() []byte
	Verify(input []byte) error
}

OPCommitment is the binary representation of a commitment.

func DecodeOPCommitment added in v1.3.0

func DecodeOPCommitment(input []byte) (OPCommitment, error)

DecodeOPCommitment parses the commitment into a known commitment type. The input type is determined by the first byte of the raw data. The input type is discarded and the commitment is passed to the appropriate constructor.

func NewOPCommitment added in v1.3.0

func NewOPCommitment(t OPCommitmentType, input []byte) OPCommitment

NewOPCommitment creates a new commitment from the given input and desired type.

type OPCommitmentType

type OPCommitmentType byte

OPCommitmentType is the commitment type prefix.

func CommitmentTypeFromString added in v1.3.0

func CommitmentTypeFromString(s string) (OPCommitmentType, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL