ephemeral

package
v0.0.0-...-7ce9f83 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 29 Imported by: 2

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-2023 - 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-2023 - 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-2023 - 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

This section is empty.

Functions

func DefaultCastorTupleStreamerFactory

func DefaultCastorTupleStreamerFactory(l *zap.SugaredLogger, tt castor.TupleType, conf *SPDZEngineTypedConfig, playerDataDir string, gameID uuid.UUID, threadNr int) (TupleStreamer, error)

DefaultCastorTupleStreamerFactory default implementation of TupleStreamerFactory creating new io.CastorTupleStreamer

func NewTopicFromPlayerID

func NewTopicFromPlayerID(ctx *CtxConfig) string

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

func NewTransportClientFromDiverseConfigs

func NewTransportClientFromDiverseConfigs(dcConf *DiscoveryClientTypedConfig, ctx *CtxConfig, 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()
	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()
	History() *fsm.History
}

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, errCh chan error, 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, stateTimeout time.Duration, computationTimeout time.Duration, me MPCEngine, playerParams *PlayerParams, errCh chan error, 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()

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, dcConf *DiscoveryClientTypedConfig, pod string, spdz MPCEngine, stateTimeout time.Duration, computationTimeout time.Duration, errCh chan error, logger *zap.SugaredLogger) (*PlayerWithIO, error)

NewPlayerWithIO returns a new instance of PlayerWithIO.

func (*PlayerWithIO) History

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

History returns the fsm.History of the game's statemachine.

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, error)

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 and returns the number of threads declared by the program.

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. Also sets the CtxConfig to the request

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 TupleStreamerFactory

type TupleStreamerFactory func(l *zap.SugaredLogger, tt castor.TupleType, conf *SPDZEngineTypedConfig, playerDataDir string, gameID uuid.UUID, threadNr int) (TupleStreamer, error)

TupleStreamerFactory is a factory method to create new io.TupleStreamer.

It accepts a logger, the type of tuples it provides, the spdz config, path to the player data base directory, the game ID, as well as the thread it serves. It either returns a pointer to the new TupleStreamer or an error if creation failed.

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