daserver

package
v0.0.0-...-001b6a2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const TxDataVersion1 = 1

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.

View Source
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 DAServer

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

func NewDAServer

func NewDAServer(host string, port int, store KVStore) *DAServer

func (*DAServer) Endpoint

func (d *DAServer) Endpoint() string

func (*DAServer) HandleGet

func (d *DAServer) HandleGet(w http.ResponseWriter, r *http.Request)

func (*DAServer) HandlePut

func (d *DAServer) HandlePut(w http.ResponseWriter, r *http.Request)

func (*DAServer) Start

func (d *DAServer) Start() error

func (*DAServer) Stop

func (d *DAServer) Stop() error

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 KVStore

type KVStore interface {
	// Get retrieves the given key if it's present in the key-value data store.
	Get(ctx context.Context, key []byte) ([]byte, error)
	// Put inserts the given value into the key-value data store.
	Put(ctx context.Context, key []byte, value []byte) error
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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