network

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

This package contains utilities for setting up a network of consensus nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPubFromList

func GetPubFromList(pBytes sig.PubKeyBytes, pubs []sig.Pub) sig.Pub

func ParInfoListToPubList

func ParInfoListToPubList(pr []*ParticipantInfo, pubKeys sig.PubList) []sig.Pub

Types

type BlsSharedMarshalIndex

type BlsSharedMarshalIndex struct {
	KeyIndex  int
	Idx       int
	BlsShared *bls.BlsSharedMarshal
}

BlsSharedMarshalIndex is used as the reply to the rpc call to ParticipantRegister.GetBlsShared.

type NetworkPropagationSetup

type NetworkPropagationSetup struct {
	NPT                   types.NetworkPropagationType // The type of network propagation used.
	FanOut                int                          // The number of nodes a node sends/fowards its messages to (only used for P2p or Random)
	AdditionalP2PNetworks int                          // Generate additional P2P connection networks
}

NetworkPropagationSetup describes how the messages will be propagated for an experiment.

type ParRegClientInterface

type ParRegClientInterface interface {
	GenBlsShared(id, idx, numThresh int) error
	GetBlsShared(id, idx int) (*BlsSharedMarshalIndex, error)
	GenDSSShared(id, numNonMembers, numThresh int) error
	GetDSSShared(id int) (*ed.CoinSharedMarshaled, error)
	RegisterParticipant(id int, parInfo *ParticipantInfo) error
	GetParticipants(id int, pub sig.PubKeyStr) (pi [][]*ParticipantInfo, err error)
	GetAllParticipants(id int) (pi []*ParticipantInfo, err error)
	Close() (err error)
}

type ParticipantInfo

type ParticipantInfo struct {
	RegisterCount int                           // The index of the pub key
	Pub           sig.PubKeyStr                 // The public key of the participant
	ConInfo       []channelinterface.NetConInfo // The addresses that the participant is listening on.
	ExtraInfo     []byte                        // Any extra information to register
}

ParticipantInfo describes a participant that will take place in an experiment.

type ParticipantRegister

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

ParticipantRegister is used during tests to track the nodes that will participate to initialize an experiment. Each node will register itself with the ParticipantRegister, then request the list of other participants. Once enough nodes have registered, the ParticipantRegister will let all nodes know the other participants and who they will connect to based on the NetworkPropagationSetup. It is not meant to be secure, anyone can register. The operations are concurrent safe.

func NewParReg

func NewParReg(connType NetworkPropagationSetup, count int) (pr *ParticipantRegister)

NewParReg generates a new participant register for the given network propagation setup and count expected participants

func (*ParticipantRegister) GenBlsShared

func (pr *ParticipantRegister) GenBlsShared(idx int, numThresh int) error

GenBlsShared generates a shared bls threshold key object for the given threshold. This is not safe since it is centralized.

func (*ParticipantRegister) GenDSSShared

func (pr *ParticipantRegister) GenDSSShared(numNonNumbers, numThresh int) error

GenDSSShared generates a shared threshold key object for the given threshold. This is not safe since it is centralized.

func (*ParticipantRegister) GetAllParticipants

func (pr *ParticipantRegister) GetAllParticipants() ([]*ParticipantInfo, error)

GetAllParticipants returns the list of all registered participants. It will block until enough participants have registered. Note that the list is not expected to be sorted, the nodes have to sort the public keys on their own.

func (*ParticipantRegister) GetBlsShared

func (pr *ParticipantRegister) GetBlsShared(idx int) (index int, blsShared *bls.BlsSharedMarshal)

GetBlsShared returns the index of the request to GetBlsShared and the blsShared object This is not safe since it returns all private keys.

func (*ParticipantRegister) GetDSSShared

func (pr *ParticipantRegister) GetDSSShared() ed.CoinSharedMarshaled

GetDSSShared returns the CoinSharedMarshaled object generated by GenDSSShared.

func (*ParticipantRegister) GetParticipants

func (pr *ParticipantRegister) GetParticipants(pub sig.PubKeyStr) ([][]*ParticipantInfo, error)

GetParticipants takes an existing partcipant as input, then returns the set of participants it should connect to based on the network setup. The function block until enough participants have registered.

func (*ParticipantRegister) RegisterParticipant

func (pr *ParticipantRegister) RegisterParticipant(parInfo *ParticipantInfo) error

RegisterParticipant registers a participant for consensus. It can be called multiple times for the same public key, this will not count as a new participant, but will update the object (in case the connections have changed).

type PregInterface

type PregInterface interface {
	GenBlsShared(idx, numThresh int) error
	GetBlsShared(idx int) (index int, blsShared *bls.BlsSharedMarshal)
	GenDSSShared(numNonNumbers, numThresh int) error
	GetDSSShared() ed.CoinSharedMarshaled
	//RegisterThrshKey(key sig.PubKeyStr, index int) error
	//GetAllThrshKey() sig.PubKeyStrList
	RegisterParticipant(parInfo *ParticipantInfo) error
	GetParticipants(pub sig.PubKeyStr) ([][]*ParticipantInfo, error)
	GetAllParticipants() ([]*ParticipantInfo, error)
}

type SortParInfo

type SortParInfo []*ParticipantInfo

SortPub is uses to create a sorted list of public keys

func (SortParInfo) Len

func (a SortParInfo) Len() int

func (SortParInfo) Less

func (a SortParInfo) Less(i, j int) bool

func (SortParInfo) Swap

func (a SortParInfo) Swap(i, j int)

Jump to

Keyboard shortcuts

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