Documentation ¶
Index ¶
- Constants
- Variables
- func Divmod(numerator, denominator int) (quotient, remainder int)
- func GetFreeTCPPort() int
- func GetFreeUDPPort() int
- func WriteAll(nodes []*Node, p NodeParser, uri string)
- type Allocator
- type Config
- func (c *Config) GetBinaryPath() string
- func (c *Config) GetCSVFile() string
- func (c *Config) GetMaxTimeout() time.Duration
- func (c *Config) GetMonitorAddress(ip string) string
- func (c *Config) GetResultsDir() string
- func (c *Config) GetResultsFile() string
- func (c *Config) Logger() handel.Logger
- func (c *Config) MaxNodes() int
- func (c *Config) NewAllocator() Allocator
- func (c *Config) NewConstructor() Constructor
- func (c *Config) NewEncoding() network.Encoding
- func (c *Config) NewNetwork(id handel.Identity) handel.Network
- func (c *Config) WriteTo(path string) error
- type Constructor
- type Duration
- type Generator
- type HandelConfig
- type Marshallable
- type Node
- type NodeInfo
- type NodeList
- type NodeParser
- type NodeRecord
- type Platform
- type PublicKey
- type RoundRandomOffline
- type RoundRobin
- type RunConfig
- type SecretConstructor
- type SecretKey
- type SimulConstructor
- type SyncMaster
- type SyncSlave
Constants ¶
const ( // START id START = iota // END id END // P2P id P2P )
Variables ¶
var Message = []byte("Everything that is beautiful and noble is the product of reason and calculation.")
Message that will get signed
Functions ¶
func GetFreeUDPPort ¶
func GetFreeUDPPort() int
GetFreeUDPPort returns a free usable UDP address We need to keep an history of the previous port we
allocated, we do this with this global variable.
func WriteAll ¶
func WriteAll(nodes []*Node, p NodeParser, uri string)
WriteAll writes down all the given nodes to the specified URI with the given parser.
Types ¶
type Allocator ¶
Allocator allocates *total* Handel instances on *len(plats)* platform, where *offline* instances will be set as offline.
func NewRoundRandomOffline ¶
func NewRoundRandomOffline() Allocator
NewRoundRandomOffline returns a RoundRandomOffline allocator
type Config ¶
type Config struct { // which network should we use // Valid value: "udp" (default) Network string // which "curve system" should we use // Valid value: "bn256" (default) Curve string // which encoding should we use on the network // valid value: "gob" (default) Encoding string // which allocator to use when experimenting failing nodes // valid value: "round" (default) or "random" Allocator string // which is the port to send measurements to MonitorPort int // Debug forwards the debug output if set to != 0 Debug int // which simulation are we running - // valid values: "handel" (default) or "p2p/udp" or "p2p/libp2p" Simulation string // Maximum time to wait for the whole thing to finish // string because of ugly format of TOML encoding --- MaxTimeout string // how many time should we repeat each experiment Retrials int // to which file should we write the results ResultFile string // config for each run Runs []RunConfig // contains filtered or unexported fields }
Config is read from a TOML encoded file and passed to Platform.Config and prepares the platform for specific system-wide configurations.
func LoadConfig ¶
LoadConfig looks up the given file to unmarshal a TOML encoded Config.
func (*Config) GetBinaryPath ¶
GetBinaryPath returns the binary to compile
func (*Config) GetCSVFile ¶
GetCSVFile returns a name of the CSV file
func (*Config) GetMaxTimeout ¶
GetMaxTimeout returns the global maximum timeout specified in the config
func (*Config) GetMonitorAddress ¶
GetMonitorAddress returns a full IP address composed of the given address apprended with the port from the config.
func (*Config) GetResultsDir ¶
GetResultsDir returns the directory where results will be written
func (*Config) GetResultsFile ¶
GetResultsFile returns the path where to write the resulting csv file
func (*Config) NewAllocator ¶
NewAllocator returns the allocation determined by the "Allocator" string field of the config.
func (*Config) NewConstructor ¶
func (c *Config) NewConstructor() Constructor
NewConstructor returns a Constructor that is using the curve denoted by the curve field of the config. Valid input so far is "bn256".
func (*Config) NewEncoding ¶
NewEncoding returns the corresponding network encoding
func (*Config) NewNetwork ¶
NewNetwork returns the network implementation designated by this config for this given identity
type Constructor ¶
type Constructor interface { Handel() handel.Constructor PublicKey() PublicKey SecretKey() SecretKey Signature() handel.Signature KeyPair(r io.Reader) (SecretKey, PublicKey) }
Constructor can construct a secret key on top of the regular handel constructor. This is what NEW CURVES must implement in order to be tested on a simulation.
func NewEmptyConstructor ¶
func NewEmptyConstructor() Constructor
NewEmptyConstructor returns a Constructor that construct fake secret key and fake public key that don't do anything. Useful for testing networks and the likes. Do NOT use the public / secret / signatures for anything !
func NewSimulConstructor ¶
func NewSimulConstructor(h handel.Constructor) Constructor
NewSimulConstructor returns a simulation Constructor
type Duration ¶
Duration is an alias for time.Duration
func (*Duration) MarshalText ¶
MarshalText implements the TextMarshaler interface
func (*Duration) UnmarshalText ¶
UnmarshalText implements the TextUnmarshaler interface
type HandelConfig ¶
type HandelConfig struct { // Period of the periodic update loop Period string // Number of node do we contact for each periodic update UpdateCount int // Number of node do we contact when starting level + when finishing level // XXX - maybe remove in the futur ! - NodeCount int // Timeout used to give to the LinearTimeout constructor Timeout string // UnsafeSleepTimeOnSigVerify UnsafeSleepTimeOnSigVerify int // which queue evaluator are we choosing Evaluator string }
HandelConfig is a small config that will be converted to handel.Config during the simulation
type Marshallable ¶
Marshallable represents an interface that can marshal and unmarshals itself
type Node ¶
Node is similar to a NodeRecord but decoded
func GenerateNode ¶
func GenerateNode(cons Constructor, idx int, addr string) *Node
GenerateNode create the necessary key pair & identites out of the given addresses. for a singel node
func GenerateNodes ¶
func GenerateNodes(cons Constructor, addresses []string) []*Node
GenerateNodes create the necessary key pair & identites out of the given addresses. The IDs will be created sequentially from 0.
func GenerateNodesFromAllocation ¶
func GenerateNodesFromAllocation(cons Constructor, alloc map[string][]*NodeInfo) []*Node
GenerateNodesFromAllocation returns a list of Node from the allocation returned by Allocator + filled with the addresses
func (*Node) ToRecord ¶
func (n *Node) ToRecord() (*NodeRecord, error)
ToRecord maps a Node to a NodeRecord, its string-human-readable equivalent
type NodeInfo ¶
NodeInfo is the output of the allocator. The allocator only tries to assign the ID and the status, not the physical network address since that is dependent on the chosen platform.
type NodeList ¶
type NodeList []*Node
NodeList is a type that contains all informations on all nodes, and that implements the Registry interface. It is useful for binaries that retrieves multiple node information - not only the Identity.
func ReadAll ¶
func ReadAll(uri string, parser NodeParser, c Constructor) (NodeList, error)
ReadAll reads the whole set of nodes from the given parser to the given URI. It returns the node list which can be used as a Registry as well
func (*NodeList) Identities ¶
Identities implements the handel.Registry interface
type NodeParser ¶
type NodeParser interface { // Reads all NodeRecords from a given URI. It can be a CSV file // encoded for example. Read(uri string) ([]*NodeRecord, error) // Writes all node records to an URI. It can be a file. Write(uri string, records []*NodeRecord) error }
NodeParser is an interface that can read / write node records.
func NewCSVParser ¶
func NewCSVParser() NodeParser
NewCSVParser is a NodeParser that reads/writes to a CSV file
type NodeRecord ¶
type NodeRecord struct { ID int32 Addr string Private string // hex encoded Public string // hex encoded }
NodeRecord holds a node's information in a readable string format
func (*NodeRecord) ToNode ¶
func (n *NodeRecord) ToNode(c Constructor) (*Node, error)
ToNode the private and public key from the given constructor and returns the secret key and the corresponding identity
type Platform ¶
type Platform interface {
String() string
}
Platform represents the platform where multiple Handel nodes can run. It can be a process for localhost platform's or EC2 instance for aws.
type PublicKey ¶
type PublicKey interface { handel.PublicKey Marshallable }
PublicKey can also Marshal itself on top of the regular handel PublicKey
type RoundRandomOffline ¶
type RoundRandomOffline struct {
Allocator
}
RoundRandomOffline uses RoundRobin allocator to setups the alive nodes but chooses randomly offline nodes in a round robin way for each platforms
type RoundRobin ¶
type RoundRobin struct{}
RoundRobin allocates the nodes in a round robin fashion as to minimise the number of nodes on each platforms.
type RunConfig ¶
type RunConfig struct { // How many nodes should we spin for this run Nodes int // threshold of signatures to wait for Threshold int // Number of failing nodes Failing int // Number of processes for this run Processes int // Handel items configurable - will be merged with defaults Handel *HandelConfig // extra for particular information for specific platform for examples Extra map[string]string }
RunConfig is the config holding parameters for a specific run. A platform can start multiple runs sequentially with different parameters each.
func (*RunConfig) GetHandelConfig ¶
GetHandelConfig returns the config to pass down to handel instances Returns the default if not set
func (*RunConfig) GetThreshold ¶
GetThreshold returns the threshold to use for this run config - if 0 it returns the number of nodes
type SecretConstructor ¶
SecretConstructor is an interface that can issue a secret key. Useful since SecretKey() method is not mandatory in Handel.
type SecretKey ¶
type SecretKey interface { Marshallable handel.SecretKey }
SecretKey can also Marshal itself on top of the regular handel SecretKey
type SimulConstructor ¶
type SimulConstructor struct {
// contains filtered or unexported fields
}
SimulConstructor is a constructor that wraps around a handel.Constructor and add useful methods for the simulation (private key generation, etc)
func (*SimulConstructor) Handel ¶
func (h *SimulConstructor) Handel() handel.Constructor
Handel implements the Constructor interface
func (*SimulConstructor) KeyPair ¶
func (h *SimulConstructor) KeyPair(r io.Reader) (SecretKey, PublicKey)
KeyPair implements the Constructor interface
func (*SimulConstructor) PublicKey ¶
func (h *SimulConstructor) PublicKey() PublicKey
PublicKey implements the Constructor interface
func (*SimulConstructor) SecretKey ¶
func (h *SimulConstructor) SecretKey() SecretKey
SecretKey implements the Constructor interface
func (*SimulConstructor) Signature ¶
func (h *SimulConstructor) Signature() handel.Signature
Signature implements the Constructor interface
type SyncMaster ¶
SyncMaster is a struct that handles the synchronization of all launched binaries by first expecting a message from each one of them, then sending them back a "START" message when all are ready. It uses UDP. The "Protocol" looks like this: - the SyncMaster listens on a UDP socket - each node sends a "READY" message to the starter over that socket. - the SyncMaster waits for n different READY messages. - once that is done, the SyncMaster sends a START message to all nodes.
A READY message is a Packet which contains a structure inside the MultiSig field, as to re-use the UDP code already present.
func NewSyncMaster ¶
func NewSyncMaster(addr string, expected, total int) *SyncMaster
NewSyncMaster returns an SyncMaster that listens on the given address, for a expected number of READY messages.
func (*SyncMaster) NewPacket ¶
func (s *SyncMaster) NewPacket(p *handel.Packet)
NewPacket implements the Listener interface
func (*SyncMaster) Stop ¶
func (s *SyncMaster) Stop()
Stop stops the network layer of the syncmaster
type SyncSlave ¶
SyncSlave sends its state to the master and waits for a START message
func NewSyncSlave ¶
NewSyncSlave returns a Sync to use as a node in the system to synchronize with the master
func (*SyncSlave) Signal ¶
Signal sends an individual signal for the given state signalling only the given ID.
func (*SyncSlave) SignalAll ¶
SignalAll sends a signal for the given state by sending all ids given to the slave in one packet.
func (*SyncSlave) WaitMaster ¶
WaitMaster first signals the master node for this state and returns the channel that gets signaled when the master sends back a message with the same id. This signals all ids given in parameter at once in one packet.