node

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFinishRealtimeStreamHeader

func GetFinishRealtimeStreamHeader(stream pb.Node_FinishRealtimeServer) (*pb.RoundInfo, error)

GetFinishRealtimeStreamHeader gets the header in the metadata from the server stream and converts it to a mixmessages.RoundInfo message.

func GetPostPhaseStreamHeader

func GetPostPhaseStreamHeader(stream pb.Node_StreamPostPhaseServer) (*pb.BatchInfo, error)

Gets the header in the metadata from the server stream and returns it or an error if it fails.

func GetPrecompTestBatchStreamHeader

func GetPrecompTestBatchStreamHeader(stream pb.Node_PrecompTestBatchServer) (*pb.RoundInfo, error)

GetPrecompTestBatchStreamHeader gets the header in the metadata from the server stream and converts it to a mixmessages.RoundInfo message.

func GetUnmixedBatchStreamHeader

func GetUnmixedBatchStreamHeader(stream pb.Node_UploadUnmixedBatchServer) (*pb.BatchInfo, error)

GetUnmixedBatchStreamHeader gets the header in the metadata from the server stream and returns it or an error if it fails.

Types

type Comms

type Comms struct {
	*connect.ProtoComms

	*mixmessages.UnimplementedNodeServer
	*messages.UnimplementedGenericServer
	// contains filtered or unexported fields
}

Server object used to implement endpoints and top-level comms functionality

func StartNode

func StartNode(id *id.ID, localServer string, interconnectPort int, handler Handler,
	certPEMblock, keyPEMblock []byte) *Comms

Starts a new server on the address:port specified by listeningAddr and a callback interface for server operations with given path to public and private key for TLS connection

func (*Comms) AskOnline

func (s *Comms) AskOnline(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Handle a Broadcasted Ask Online event

func (*Comms) AuthenticateToken

func (s *Comms) AuthenticateToken(ctx context.Context,
	msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Handles validation of reverse-authentication tokens

func (*Comms) CreateNewRound

func (s *Comms) CreateNewRound(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Handle a NewRound event

func (*Comms) DownloadMixedBatch

func (s *Comms) DownloadMixedBatch(authMsg *messages.AuthenticatedMessage,
	stream pb.Node_DownloadMixedBatchServer) error

DownloadMixedBatch streams the slots in the completed batch to the gateway

func (*Comms) FinishRealtime

func (s *Comms) FinishRealtime(stream pb.Node_FinishRealtimeServer) error

FinishRealtime broadcasts to all nodes when the realtime is completed

func (*Comms) GetMeasure

func (s *Comms) GetMeasure(ctx context.Context, msg *messages.AuthenticatedMessage) (*pb.RoundMetrics, error)

func (*Comms) GetPermissioningAddress

func (s *Comms) GetPermissioningAddress(context.Context, *messages.Ping) (*pb.StrAddress, error)

Server -> Gateway permissioning address

func (*Comms) GetPostPhaseStreamClient

func (s *Comms) GetPostPhaseStreamClient(host *connect.Host,
	header pb.BatchInfo) (pb.Node_StreamPostPhaseClient, context.CancelFunc, error)

GetPostPhaseStreamClient gets the streaming client using a header and returns the stream and the cancel context if there are no connection errors

func (*Comms) GetRoundBufferInfo

func (s *Comms) GetRoundBufferInfo(ctx context.Context,
	msg *messages.AuthenticatedMessage) (
	*pb.RoundBufferInfo, error)

GetBufferInfo returns buffer size (number of completed precomputations)

func (*Comms) Poll

Gateway -> Server unified polling

func (*Comms) PostPhase

func (s *Comms) PostPhase(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack,
	error)

Handle a Phase event

func (*Comms) PostPrecompResult

func (s *Comms) PostPrecompResult(ctx context.Context,
	msg *messages.AuthenticatedMessage) (*messages.Ack, error)

PostPrecompResult sends final Message and AD precomputations.

func (*Comms) PrecompTestBatch

func (s *Comms) PrecompTestBatch(stream pb.Node_PrecompTestBatchServer) error

PrecompTestBatch is the reception handler for StreamPrecompTestBatch.

func (*Comms) RequestClientKey

func (s *Comms) RequestClientKey(ctx context.Context,
	msg *messages.AuthenticatedMessage) (*pb.SignedKeyResponse, error)

Handles Registration Nonce Communication

func (*Comms) RequestToken

func (s *Comms) RequestToken(context.Context, *messages.Ping) (*messages.AssignToken, error)

Handles reception of reverse-authentication token requests

func (*Comms) RoundError

func (s *Comms) RoundError(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

func (*Comms) RoundTripPing

func (s *Comms) RoundTripPing(host *connect.Host, rtPing *pb.RoundTripPing) (*messages.Ack, error)

Server -> Server Send Function

func (*Comms) SendAskOnline

func (s *Comms) SendAskOnline(host *connect.Host) (*messages.Ack, error)

Server -> Server Send Function

func (*Comms) SendAuthorizerAuth

func (s *Comms) SendAuthorizerAuth(host *connect.Host,
	message *pb.AuthorizerAuth) (*messages.Ack, error)

Server -> Authorizer Send Function

func (*Comms) SendFinalKey

func (s *Comms) SendFinalKey(host *connect.Host, sharedPiece *pb.SharePiece) (*messages.Ack, error)

Server -> Server sending multi-party round DH final key

func (*Comms) SendFinishRealtime

func (s *Comms) SendFinishRealtime(host *connect.Host,
	roundInfo *pb.RoundInfo, batch *pb.CompletedBatch) (*messages.Ack, error)

SendFinishRealtime is a node to node comm which streams a completed batch to all nodes within a round.

func (*Comms) SendGetMeasure

func (s *Comms) SendGetMeasure(host *connect.Host,
	message *pb.RoundInfo) (*pb.RoundMetrics, error)

Server -> Server Send Function

func (*Comms) SendNewRound

func (s *Comms) SendNewRound(host *connect.Host,
	message *pb.RoundInfo) (*messages.Ack, error)

Server -> Server Send Function

func (*Comms) SendNodeRegistration

func (s *Comms) SendNodeRegistration(host *connect.Host,
	message *pb.NodeRegistration) error

Server -> Registration Send Function

func (*Comms) SendPoll

func (s *Comms) SendPoll(host *connect.Host,
	message *pb.PermissioningPoll) (*pb.PermissionPollResponse, error)

Server -> Registration Send Function

func (*Comms) SendPostPhase

func (s *Comms) SendPostPhase(host *connect.Host,
	message *pb.Batch) (*messages.Ack, error)

Server -> Server Send Function

func (*Comms) SendPostPrecompResult

func (s *Comms) SendPostPrecompResult(host *connect.Host,
	roundID uint64, numSlots uint32) (*messages.Ack, error)

Server -> Server Send Function

func (*Comms) SendRegistrationCheck

func (s *Comms) SendRegistrationCheck(host *connect.Host,
	message *pb.RegisteredNodeCheck) (*pb.RegisteredNodeConfirmation, error)

Server -> Registration Send Function

func (*Comms) SendRoundError

func (s *Comms) SendRoundError(host *connect.Host, message *pb.RoundError) (*messages.Ack, error)

Server -> Server error function

func (*Comms) SendRoundTripPing

func (s *Comms) SendRoundTripPing(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

func (*Comms) SendSharePhase

func (s *Comms) SendSharePhase(host *connect.Host, sharedPiece *pb.SharePiece) (*messages.Ack, error)

Server -> Server sending multi-party round DH key piece

func (*Comms) SendStartSharePhase

func (s *Comms) SendStartSharePhase(host *connect.Host, ri *pb.RoundInfo) (*messages.Ack, error)

Server -> Server initiating multi-party round DH key generation

func (*Comms) ShareFinalKey

func (s *Comms) ShareFinalKey(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Server -> Server sending multi-party round DH final key

func (*Comms) SharePhaseRound

func (s *Comms) SharePhaseRound(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Server -> Server passing state of multi-party round DH key generation

func (*Comms) StartSharePhase

func (s *Comms) StartSharePhase(ctx context.Context, msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Server -> Server initiating multi-party round DH key generation

func (*Comms) StreamPostPhase

func (s *Comms) StreamPostPhase(server pb.Node_StreamPostPhaseServer) error

Handle a phase event using a stream server

func (*Comms) StreamPrecompTestBatch

func (s *Comms) StreamPrecompTestBatch(host *connect.Host, info *pb.RoundInfo,
	mockBatch *pb.CompletedBatch) error

StreamPrecompTestBatch is a server to server broadcast. It simulates sending the completed batch of PrecompTestBatch, testing for connectivity.

func (*Comms) UploadUnmixedBatch

func (s *Comms) UploadUnmixedBatch(server pb.Node_UploadUnmixedBatchServer) error

UploadUnmixedBatch is the handler for gateway sending a batch to its node

type Handler

type Handler interface {
	// Server interface for starting New Rounds
	CreateNewRound(message *mixmessages.RoundInfo, auth *connect.Auth) error
	// Server interface for sending a new batch
	UploadUnmixedBatch(server mixmessages.Node_UploadUnmixedBatchServer, auth *connect.Auth) error
	// Server interface for handling a mixed batch request
	DownloadMixedBatch(stream mixmessages.Node_DownloadMixedBatchServer,
		batchInfo *mixmessages.BatchReady, auth *connect.Auth) error
	// Server interface for broadcasting when realtime is complete
	FinishRealtime(message *mixmessages.RoundInfo,
		streamServer mixmessages.Node_FinishRealtimeServer, auth *connect.Auth) error
	// GetRoundBufferInfo returns # of available precomputations
	GetRoundBufferInfo(auth *connect.Auth) (int, error)

	PrecompTestBatch(stream mixmessages.Node_PrecompTestBatchServer, info *mixmessages.RoundInfo,
		auth *connect.Auth) error

	GetMeasure(message *mixmessages.RoundInfo, auth *connect.Auth) (*mixmessages.RoundMetrics, error)

	// Server Interface for all Internode Comms
	PostPhase(message *mixmessages.Batch, auth *connect.Auth) error

	StreamPostPhase(server mixmessages.Node_StreamPostPhaseServer, auth *connect.Auth) error

	// PostPrecompResult interface to finalize both payloads' precomps
	PostPrecompResult(roundID uint64, numSlots uint32, auth *connect.Auth) error

	Poll(msg *mixmessages.ServerPoll, auth *connect.Auth) (*mixmessages.ServerPollResponse, error)

	SendRoundTripPing(ping *mixmessages.RoundTripPing, auth *connect.Auth) error

	AskOnline() error

	RoundError(error *mixmessages.RoundError, auth *connect.Auth) error
	// Consensus node -> cMix node NDF request
	// NOTE: For now cMix nodes serve the NDF to the
	//  consensus nodes, but this will be reversed
	//  once consensus generates the NDF
	GetNDF() (*interconnect.NDF, error)

	// GetPermissioningAddress gets gateway the permissioning server's address
	// from server.
	GetPermissioningAddress() (string, error)

	// Server -> Server initiating multi-party round DH key generation
	StartSharePhase(ri *mixmessages.RoundInfo, auth *connect.Auth) error

	// Server -> Server passing state of multi-party round DH key generation
	SharePhaseRound(sharedPiece *mixmessages.SharePiece, auth *connect.Auth) error

	// Server -> Server sending multi-party round DH key
	ShareFinalKey(sharedPiece *mixmessages.SharePiece, auth *connect.Auth) error

	// Server interface for RequestNonceMessage
	RequestClientKey(nonceRequest *mixmessages.SignedClientKeyRequest, auth *connect.Auth) (*mixmessages.SignedKeyResponse, error)
}

type Implementation

type Implementation struct {
	Functions implementationFunctions
}

Implementation allows users of the client library to set the functions that implement the node functions

func NewImplementation

func NewImplementation() *Implementation

NewImplementation returns a Implementation struct with all of the function pointers returning nothing and printing an error.

func (*Implementation) AskOnline

func (s *Implementation) AskOnline() error

AskOnline blocks until the server is online, or returns an error

func (*Implementation) CreateNewRound

func (s *Implementation) CreateNewRound(msg *mixmessages.RoundInfo, auth *connect.Auth) error

Server Interface for starting New Rounds

func (*Implementation) DownloadMixedBatch

func (s *Implementation) DownloadMixedBatch(stream mixmessages.Node_DownloadMixedBatchServer,
	batchInfo *mixmessages.BatchReady, auth *connect.Auth) error

func (*Implementation) FinishRealtime

func (s *Implementation) FinishRealtime(message *mixmessages.RoundInfo, streamServer mixmessages.Node_FinishRealtimeServer, auth *connect.Auth) error

func (*Implementation) GetMeasure

func (s *Implementation) GetMeasure(message *mixmessages.RoundInfo, auth *connect.Auth) (*mixmessages.RoundMetrics, error)

func (*Implementation) GetNDF

func (s *Implementation) GetNDF() (*interconnect.NDF, error)

Consensus node -> cMix node NDF request NOTE: For now cMix nodes serve the NDF to the

consensus nodes, but this will be reversed
once consensus generates the NDF

func (*Implementation) GetPermissioningAddress

func (s *Implementation) GetPermissioningAddress() (string, error)

GetPermissioningAddress gets gateway the permissioning server's address from server.

func (*Implementation) GetRoundBufferInfo

func (s *Implementation) GetRoundBufferInfo(auth *connect.Auth) (int, error)

GetRoundBufferInfo returns # of completed precomputations

func (*Implementation) Poll

func (*Implementation) PostPhase

func (s *Implementation) PostPhase(m *mixmessages.Batch, auth *connect.Auth) error

Server Interface for the phase messages

func (*Implementation) PostPrecompResult

func (s *Implementation) PostPrecompResult(roundID uint64,
	numSlots uint32, auth *connect.Auth) error

PostPrecompResult interface to finalize both payloads' precomputations

func (*Implementation) PrecompTestBatch

func (s *Implementation) PrecompTestBatch(stream mixmessages.Node_PrecompTestBatchServer, message *mixmessages.RoundInfo,
	auth *connect.Auth) error

func (*Implementation) RequestClientKey

func (s *Implementation) RequestClientKey(nonceRequest *mixmessages.SignedClientKeyRequest, auth *connect.Auth) (*mixmessages.SignedKeyResponse, error)

Server interface for RequestNonceMessage

func (*Implementation) RoundError

func (s *Implementation) RoundError(err *mixmessages.RoundError, auth *connect.Auth) error

func (*Implementation) SendRoundTripPing

func (s *Implementation) SendRoundTripPing(ping *mixmessages.RoundTripPing, auth *connect.Auth) error

func (*Implementation) ShareFinalKey

func (s *Implementation) ShareFinalKey(sharedPiece *mixmessages.SharePiece, auth *connect.Auth) error

Server -> Server sending multi-party round DH final key

func (*Implementation) SharePhaseRound

func (s *Implementation) SharePhaseRound(sharedPiece *mixmessages.SharePiece, auth *connect.Auth) error

Server -> Server passing state of multi-party round DH key generation

func (*Implementation) StartSharePhase

func (s *Implementation) StartSharePhase(ri *mixmessages.RoundInfo, auth *connect.Auth) error

Server -> Server initiating multi-party round DH key generation

func (*Implementation) StreamPostPhase

Server Interface for streaming phase messages

func (*Implementation) UploadUnmixedBatch

func (s *Implementation) UploadUnmixedBatch(stream mixmessages.Node_UploadUnmixedBatchServer,
	auth *connect.Auth) error

type MessageInfo

type MessageInfo struct {
	SenderId       string
	Address        string
	Signature      []byte
	ValidSignature bool
}

MessageInfo contains information about a comm to be passed into every interface callback Specifically, contains sender ID and network address, signature and signature validity

Jump to

Keyboard shortcuts

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