preimage

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hint

type Hint interface {
	Hint() string
}

Hint is an interface to enable any program type to function as a hint, when passed to the Hinter interface, returning a string representation of what data the host should prepare pre-images for.

type HintReader

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

HintReader reads the hints of HintWriter and passes them to a router for preparation of the requested pre-images. Onchain the written hints are no-op.

func NewHintReader

func NewHintReader(r io.Reader) *HintReader

func (*HintReader) NextHint

func (hr *HintReader) NextHint(router func(hint string) error) error

type HintWriter

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

HintWriter writes hints to an io.Writer (e.g. a special file descriptor, or a debug log), for a pre-image oracle service to prepare specific pre-images.

func NewHintWriter

func NewHintWriter(w io.Writer) *HintWriter

func (*HintWriter) Hint

func (hw *HintWriter) Hint(v Hint)

type Hinter

type Hinter interface {
	Hint(v Hint)
}

Hinter is an interface to write hints to the host. This may be implemented as a no-op or logging hinter if the program is executing in a read-only environment where the host is expected to have all pre-images ready.

type HinterFn

type HinterFn func(v Hint)

func (HinterFn) Hint

func (fn HinterFn) Hint(v Hint)

type Keccak256Key

type Keccak256Key common.Hash

Keccak256Key wraps a keccak256 hash to use it as a typed pre-image key.

func (Keccak256Key) PreimageKey

func (k Keccak256Key) PreimageKey() (out common.Hash)

type Key

type Key interface {
	// PreimageKey changes the Key commitment into a
	// 32-byte type-prefixed preimage key.
	PreimageKey() common.Hash
}

type KeyType

type KeyType byte

KeyType is the key-type of a pre-image, used to prefix the pre-image key with.

const (

	// LocalKeyType is for input-type pre-images, specific to the local program instance.
	LocalKeyType KeyType = 1
	// Keccak25Key6Type is for keccak256 pre-images, for any global shared pre-images.
	Keccak25Key6Type KeyType = 2
)

type LocalIndexKey

type LocalIndexKey uint64

LocalIndexKey is a key local to the program, indexing a special program input.

func (LocalIndexKey) PreimageKey

func (k LocalIndexKey) PreimageKey() (out common.Hash)

type Oracle

type Oracle interface {
	// Get the full pre-image of a given pre-image key.
	// This returns no error: the client state-transition
	// is invalid if there is any missing pre-image data.
	Get(key Key) []byte
}

type OracleClient

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

OracleClient implements the Oracle by writing the pre-image key to the given stream, and reading back a length-prefixed value.

func NewOracleClient

func NewOracleClient(rw io.ReadWriter) *OracleClient

func (*OracleClient) Get

func (o *OracleClient) Get(key Key) []byte

type OracleFn

type OracleFn func(key Key) []byte

func (OracleFn) Get

func (fn OracleFn) Get(key Key) []byte

type OracleServer

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

OracleServer serves the pre-image requests of the OracleClient, implementing the same protocol as the onchain VM.

func NewOracleServer

func NewOracleServer(rw io.ReadWriter) *OracleServer

func (*OracleServer) NextPreimageRequest

func (o *OracleServer) NextPreimageRequest(getPreimage func(key common.Hash) ([]byte, error)) error

Jump to

Keyboard shortcuts

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