Documentation ¶
Index ¶
Constants ¶
const TxDataVersion1 = 1
Variables ¶
var ErrCommitmentMismatch = errors.New("commitment mismatch")
ErrCommitmentMismatch is returned when the commitment does not match the given input.
var ErrInvalidCommitment = errors.New("invalid commitment")
ErrInvalidCommitment is returned when the commitment cannot be parsed into a known commitment type.
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type CommitmentData ¶
type CommitmentData interface { CommitmentType() CommitmentType Encode() []byte TxData() []byte Verify(input []byte) error }
CommitmentData is the binary representation of a commitment.
func DecodeCommitmentData ¶
func DecodeCommitmentData(input []byte) (CommitmentData, error)
DecodeCommitmentData 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 NewCommitmentData ¶
func NewCommitmentData(t CommitmentType, input []byte) CommitmentData
NewCommitmentData creates a new commitment from the given input and desired type.
type CommitmentType ¶
type CommitmentType byte
CommitmentType is the commitment type prefix.
const ( Keccak256CommitmentType CommitmentType = 0 GenericCommitmentType CommitmentType = 1 )
CommitmentType describes the binary format of the commitment. KeccakCommitmentType is the default commitment type for the centralized DA storage. GenericCommitmentType indicates an opaque bytestring that the op-node never opens.
type GenericCommitment ¶
type GenericCommitment []byte
GenericCommitment is an implementation of CommitmentData that treats the commitment as an opaque bytestring.
func DecodeGenericCommitment ¶
func DecodeGenericCommitment(commitment []byte) (GenericCommitment, error)
DecodeGenericCommitment validates and casts the commitment into a GenericCommitment.
func NewGenericCommitment ¶
func NewGenericCommitment(input []byte) GenericCommitment
NewGenericCommitment creates a new commitment from the given input.
func (GenericCommitment) CommitmentType ¶
func (c GenericCommitment) CommitmentType() CommitmentType
CommitmentType returns the commitment type of Generic Commitment.
func (GenericCommitment) Encode ¶
func (c GenericCommitment) Encode() []byte
Encode adds a commitment type prefix self describing the commitment.
func (GenericCommitment) TxData ¶
func (c GenericCommitment) TxData() []byte
TxData adds an extra version byte to signal it's a commitment.
func (GenericCommitment) Verify ¶
func (c GenericCommitment) Verify(input []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 CommitmentData that uses Keccak256 as the commitment function.
func DecodeKeccak256 ¶
func DecodeKeccak256(commitment []byte) (Keccak256Commitment, error)
DecodeKeccak256 validates and casts the commitment into a Keccak256Commitment.
func NewKeccak256Commitment ¶
func NewKeccak256Commitment(input []byte) Keccak256Commitment
NewKeccak256Commitment creates a new commitment from the given input.
func (Keccak256Commitment) CommitmentType ¶
func (c Keccak256Commitment) CommitmentType() CommitmentType
CommitmentType returns the commitment type of Keccak256.
func (Keccak256Commitment) Encode ¶
func (c Keccak256Commitment) Encode() []byte
Encode adds a commitment type prefix self describing the commitment.
func (Keccak256Commitment) TxData ¶
func (c Keccak256Commitment) TxData() []byte
TxData adds an extra version byte to signal it's a commitment.
func (Keccak256Commitment) Verify ¶
func (c Keccak256Commitment) Verify(input []byte) error
Verify checks if the commitment matches the given input.