ephemeral

package
v0.0.0-...-b7fd0f1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	DoneTopic = "Done"
)

Functions

func NewTopicFromPlayerID

func NewTopicFromPlayerID(ctx *CtxConfig) string

NewTopicFromPlayerID converts player ID so it can be used as topic name.

func NewTransportClientFromDiverseConfigs

func NewTransportClientFromDiverseConfigs(ioConfig *io.Config, ctx *CtxConfig, timeout time.Duration, logger *zap.SugaredLogger, ch *Wires) (*c.Client, error)

NewTransportClientFromDiverseConfigs returns a new transport client.

Types

type AbstractForwarder

type AbstractForwarder interface {
	Run() error
}

AbstractForwarder an interface for an entity that forwards events.

type AbstractPlayer

type AbstractPlayer interface {
	Init(errCh chan error)
	Stop()
	History() *fsm.History
	Bus() mb.MessageBus
	PublishEvent(name, topic string, event *pb.Event)
}

AbstractPlayer is an interface of a player.

type AbstractPlayerWithIO

type AbstractPlayerWithIO interface {
	Start()
}

AbstractPlayerWithIO is an interface type for a PlayerWithIO.

type Callbacker

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

Callbacker preserves callback functions used in Player FSM.

func NewCallbacker

func NewCallbacker(bus mb.MessageBus, playerParams *PlayerParams, logger *zap.SugaredLogger) *Callbacker

NewCallbacker returns a new instance of callbacker

type Forwarder

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

Forwarder forwards events from/out an FSM.

func NewForwarder

func NewForwarder(conf *ForwarderConf) *Forwarder

NewForwarder returns a new forwarder.

func (*Forwarder) Run

func (f *Forwarder) Run() error

Run forwards events from _in_ channel to player's internal message bus. It returns nil once the context is canceled.

type ForwarderConf

type ForwarderConf struct {
	Logger *zap.SugaredLogger
	Ctx    context.Context
	Player *Player1
	InCh   chan *pb.Event
	OutCh  chan *pb.Event
	Topic  string
}

ForwarderConf is the configuration of the event forwarder.

type MPCEngine

type MPCEngine interface {
	Execute(*pb.Event) error
}

MPCEngine is an interface for an MPC runtime that performs the computation.

type Player1

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

Player1 stores the FSM of the player, it manages the state and runs callbacks as response on internal/external events. The events are communicated via in-memory message bus with 2 topics: "discovery" topic is used to transmit events from player to discovery service. "playerN" topic name corresponds to the name of the player. And is used for events from discovery to the player and from the player to itself.

func NewPlayer

func NewPlayer(ctx context.Context, bus mb.MessageBus, timeout time.Duration, me MPCEngine, playerParams *PlayerParams, logger *zap.SugaredLogger) (*Player1, error)

NewPlayer returns an fsm based model of the MPC player.

func (*Player1) Bus

func (p *Player1) Bus() mb.MessageBus

Bus returns in internal message bus to comply with FSMWithBus interface.

func (*Player1) History

func (p *Player1) History() *fsm.History

History returns player's state and event history.

func (*Player1) Init

func (p *Player1) Init(errCh chan error)

Init starts FSM and triggers the registration of the player.

func (*Player1) PublishEvent

func (p *Player1) PublishEvent(name, topic string, event *pb.Event)

PublishEvent publishes an external event into player's state machine.

func (*Player1) Stop

func (p *Player1) Stop()

Stop unsubscribes bus listeners.

type PlayerParams

type PlayerParams struct {
	GameID            string
	Pod               string
	PlayerID, Players int32
	// Address of the frontend gateway (e.g. Istio).
	IP   string
	Name string
}

PlayerParams defines parameters of the player.

type PlayerWithIO

type PlayerWithIO struct {
	Forwarder AbstractForwarder
	Player    AbstractPlayer
	Wires     *Wires
	Client    c.TransportClient
}

PlayerWithIO contains the forwarder, player FSM, wires with input and output channels and discovery client.

func NewPlayerWithIO

func NewPlayerWithIO(ctx *CtxConfig, conf *io.Config, pod string, spdz MPCEngine, errCh chan error, logger *zap.SugaredLogger) (*PlayerWithIO, error)

NewPlayerWithIO returns a new instance of PlayerWithIO.

func (*PlayerWithIO) Start

func (p *PlayerWithIO) Start()

Start activates the state machine of the player.

type SPDZEngine

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

SPDZEngine compiles, executes, provides IO operations for SPDZ based runtimes.

func NewSPDZEngine

func NewSPDZEngine(logger *zap.SugaredLogger, cmder Executor, config *SPDZEngineTypedConfig) *SPDZEngine

NewSPDZEngine returns a new instance of SPDZ engine that knows how to compile and trigger an execution of SPDZ runtime.

func (*SPDZEngine) Activate

func (s *SPDZEngine) Activate(ctx *CtxConfig) ([]byte, error)

Activate starts a proxy, writes an IP file, start SPDZ execution, unpacks inputs parameters, sends them to the runtime and waits for the response.

func (*SPDZEngine) Compile

func (s *SPDZEngine) Compile(ctx *CtxConfig) error

Compile compiles a SPDZ application.

type SPDZWrapper

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

SPDZWrapper starts the computation and reads the output parameters. It is also used to update player's proxy configuration based on the discovery output.

func NewSPDZWrapper

func NewSPDZWrapper(ctx *CtxConfig, respCh chan []byte, errCh chan error, logger *zap.SugaredLogger, act func(*CtxConfig) ([]byte, error)) *SPDZWrapper

NewSPDZWrapper returns a new SPDZ wrapper.

func (*SPDZWrapper) Execute

func (s *SPDZWrapper) Execute(event *pb.Event) error

Execute runs the MPC computation.

type Server

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

Server is a HTTP server which wraps the handling of incoming requests that trigger the MPC computation.

func NewServer

func NewServer(compile func(*CtxConfig) error, activate func(*CtxConfig) ([]byte, error), logger *zap.SugaredLogger, config *SPDZEngineTypedConfig) *Server

NewServer returns a new server.

func (*Server) ActivationHandler

func (s *Server) ActivationHandler(writer http.ResponseWriter, req *http.Request)

ActivationHandler is the http handler starts the Player FSM.

func (*Server) BodyFilter

func (s *Server) BodyFilter(next http.Handler) http.Handler

BodyFilter verifies all necessary parameters are set in the request body.

func (*Server) CompilationHandler

func (s *Server) CompilationHandler(next http.Handler) http.Handler

CompilationHandler parses the JSON payload and adds it to the request context.

func (*Server) MethodFilter

func (s *Server) MethodFilter(next http.Handler) http.Handler

MethodFilter assures that only HTTP POST requests are able to get through.

type Wires

type Wires struct {
	In  chan *pb.Event
	Out chan *pb.Event
	Err chan error
}

Wires defines the channels used to communicate with the player.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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