comm

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package comm consists of set of helper communication related functions used by both client and server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleVks

func HandleVks(log *logging.Logger,
	vks []*coconut.VerificationKey,
	pp *coconut.PolynomialPoints,
	threshold int,
) ([]*coconut.VerificationKey, *coconut.PolynomialPoints, error)

FIXME: nolint: gocyclo

func LogAndReturnError

func LogAndReturnError(log *logging.Logger, fmtString string, a ...interface{}) error

func ParseVerificationKeyResponses

func ParseVerificationKeyResponses(responses []*ServerResponse,
	isThreshold bool,
	log *logging.Logger,
) ([]*coconut.VerificationKey, *coconut.PolynomialPoints)

ParseVerificationKeyResponses takes a slice containing ServerResponses with marshalled verification keys and processes it accordingly to threshold system parameter.

func ReadPacketFromConn

func ReadPacketFromConn(conn net.Conn) (*packet.Packet, error)

ReadPacketFromConn reads all data from a given connection and unmarshals it into a packet instance.

func ResolveServerRequest

func ResolveServerRequest(cmd commands.Command,
	resCh chan *commands.Response,
	log *logging.Logger,
	requestTimeout int,
	provReady bool,
) proto.Message

ResolveServerRequest awaits for a response from a cryptoworker and acts on it appropriately adding relevant metadata. nolint: gocyclo TODO: FIXME: currently it is only used by an outdated (and without actual support for new functions) grpclistener

func SendServerRequests

func SendServerRequests(ctx context.Context,
	responseCh chan<- *ServerResponse,
	maxReqs int,
	log *logging.Logger,
	connectionTimeout time.Duration,
) chan<- *ServerRequest

SendServerRequests starts set of goroutines sending requests on TCP sockets to particular servers. Number of goroutines is limited by maxReqs argument. It returns the channel to write the requests to. errcheck is ignored to make it not complain about not checking for err in conn.Close() nolint: errcheck

func ValidateIDs

func ValidateIDs(log *logging.Logger, pp *coconut.PolynomialPoints, isThreshold bool) (map[int]bool, error)

func WaitForServerResponses

func WaitForServerResponses(ctx context.Context,
	responseCh <-chan *ServerResponse,
	responses []*ServerResponse,
	log *logging.Logger,
)

WaitForServerResponses is responsible for keeping track of request statuses and possible timeouts if some requests fail to resolve in given time period. TODO: return error on timeout

Types

type RequestParams

type RequestParams struct {
	MarshaledPacket   []byte
	MaxRequests       int
	ConnectionTimeout time.Duration
	ServerAddresses   []string
}

RequestParams encapsulates all information required by GetServerResponses including server addresses and all timeout values.

type ServerMetadata

type ServerMetadata struct {
	Address string
}

ServerMetadata encapsulates all server-related information passed in each request and response.

type ServerRequest

type ServerRequest struct {
	MarshaledData  []byte // it's just a marshalled packet, but is kept generic in case the implementation changes
	ServerMetadata *ServerMetadata
}

ServerRequest represents raw data sent to a particular server as well as the associated metadata when the request is sent on a TCP socket.

type ServerRequestGrpc

type ServerRequestGrpc struct {
	Message        proto.Message
	ServerMetadata *ServerMetadata
}

ServerRequestGrpc represents raw data sent to a particular server as well as the associated metadata when the request is sent as a gRPC request.

type ServerResponse

type ServerResponse struct {
	MarshaledData  []byte
	ServerMetadata *ServerMetadata
}

ServerResponse represents raw data returned from a particular server as well as the associated metadata when the request was sent on a TCP socket.

func GetServerResponses

func GetServerResponses(ctx context.Context, requestParams *RequestParams, log *logging.Logger) []*ServerResponse

GetServerResponses writes requests to all server specified in the params according to the set params. func GetServerResponses(packet []byte, maxR int, connT int, reqT int, addrs []string, ids []int) []*ServerResponse { TODO: return error on timeout

type ServerResponseGrpc

type ServerResponseGrpc struct {
	Message        proto.Message
	ServerMetadata *ServerMetadata
}

ServerResponseGrpc represents raw data returned from a particular server as well as the associated metadata when the request was sent as a gRPC request.

Directories

Path Synopsis
Package commands define command types used by coconut server.
Package commands define command types used by coconut server.
Package packet defines packet structure that is sent on the wire between multiple entities
Package packet defines packet structure that is sent on the wire between multiple entities

Jump to

Keyboard shortcuts

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