Documentation ¶
Index ¶
- Constants
- Variables
- func CreateBidirectionalChannel() (FileChannel, FileChannel, error)
- func Keccak256(v []byte) (out [32]byte)
- type BlobKey
- type FileChannel
- type FilePoller
- type Hint
- type HintHandler
- type HintReader
- type HintWriter
- type Hinter
- type HinterFn
- type Keccak256Key
- type Key
- type KeyType
- type LocalIndexKey
- type Oracle
- type OracleClient
- type OracleFn
- type OracleServer
- type PrecompileKey
- type PreimageGetter
- type ReadWritePair
- type Sha256Key
Constants ¶
const ( HClientRFd = 3 HClientWFd = 4 PClientRFd = 5 PClientWFd = 6 )
Variables ¶
var ( ErrIncorrectData = errors.New("incorrect data") ErrUnsupportedKeyType = errors.New("unsupported key type") )
Functions ¶
func CreateBidirectionalChannel ¶
func CreateBidirectionalChannel() (FileChannel, FileChannel, error)
CreateBidirectionalChannel creates a pair of FileChannels that are connected to each other.
Types ¶
type BlobKey ¶
type BlobKey [32]byte
BlobKey is the hash of a blob commitment and `z` value to use as a preimage key for `y`.
func (BlobKey) PreimageKey ¶
func (BlobKey) TerminalString ¶
type FileChannel ¶
type FileChannel interface { io.ReadWriteCloser // Reader returns the file that is used for reading. Reader() *os.File // Writer returns the file that is used for writing. Writer() *os.File }
FileChannel is a unidirectional channel for file I/O
type FilePoller ¶
type FilePoller struct { File FileChannel // contains filtered or unexported fields }
FilePoller is a ReadWriteCloser that polls the underlying file channel for reads and writes until its context is done. This is useful to detect when the other end of a blocking pre-image channel is no longer available.
func NewFilePoller ¶
func NewFilePoller(ctx context.Context, f FileChannel, pollTimeout time.Duration) *FilePoller
NewFilePoller returns a FilePoller that polls the underlying file channel for reads and writes until the provided ctx is done. The poll timeout is the maximum amount of time to wait for I/O before the operation is halted and the context is checked for cancellation.
func (*FilePoller) Close ¶
func (p *FilePoller) Close() error
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 HintHandler ¶
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(rw io.ReadWriter) *HintReader
func (*HintReader) NextHint ¶
func (hr *HintReader) NextHint(router HintHandler) 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(rw io.ReadWriter) *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 Keccak256Key ¶
type Keccak256Key [32]byte
Keccak256Key wraps a keccak256 hash to use it as a typed pre-image key.
func (Keccak256Key) PreimageKey ¶
func (k Keccak256Key) PreimageKey() (out [32]byte)
func (Keccak256Key) String ¶
func (k Keccak256Key) String() string
func (Keccak256Key) TerminalString ¶
func (k Keccak256Key) TerminalString() string
type Key ¶
type Key interface { // PreimageKey changes the Key commitment into a // 32-byte type-prefixed preimage key. PreimageKey() [32]byte }
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 // Keccak256KeyType is for keccak256 pre-images, for any global shared pre-images. Keccak256KeyType KeyType = 2 // GlobalGenericKeyType is a reserved key type for generic global data. GlobalGenericKeyType KeyType = 3 // Sha256KeyType is for sha256 pre-images, for any global shared pre-images. Sha256KeyType KeyType = 4 // BlobKeyType is for blob point pre-images. BlobKeyType KeyType = 5 // PrecompileKeyType is for precompile result pre-images. PrecompileKeyType KeyType = 6 )
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 [32]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 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 PreimageGetter) error
type PrecompileKey ¶
type PrecompileKey [32]byte
PrecompileKey is the hash of precompile address and its input data
func (PrecompileKey) PreimageKey ¶
func (k PrecompileKey) PreimageKey() (out [32]byte)
func (PrecompileKey) String ¶
func (k PrecompileKey) String() string
func (PrecompileKey) TerminalString ¶
func (k PrecompileKey) TerminalString() string
type PreimageGetter ¶
func WithVerification ¶
func WithVerification(source PreimageGetter) PreimageGetter
WithVerification wraps the supplied source to verify that the returned data is a valid pre-image for the key.
type ReadWritePair ¶
type ReadWritePair struct {
// contains filtered or unexported fields
}
func ClientHinterChannel ¶
func ClientHinterChannel() *ReadWritePair
func ClientPreimageChannel ¶
func ClientPreimageChannel() *ReadWritePair
ClientPreimageChannel returns a FileChannel for the preimage oracle in a detached context
func NewReadWritePair ¶
func NewReadWritePair(r *os.File, w *os.File) *ReadWritePair
NewReadWritePair creates a new FileChannel that uses the given files
func (*ReadWritePair) Close ¶
func (rw *ReadWritePair) Close() error
func (*ReadWritePair) Reader ¶
func (rw *ReadWritePair) Reader() *os.File
func (*ReadWritePair) Writer ¶
func (rw *ReadWritePair) Writer() *os.File
type Sha256Key ¶
type Sha256Key [32]byte
Sha256Key wraps a sha256 hash to use it as a typed pre-image key.hash