core

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0, MIT Imports: 38 Imported by: 3

Documentation

Index

Constants

View Source
const DefaultBeaconPeriod time.Duration = 1 * time.Minute

DefaultBeaconPeriod is the period in which the beacon logic creates new random beacon.

View Source
const DefaultConfigFolderName = ".drand"

DefaultConfigFolderName is the name of the folder containing all key materials (and the beacons db file by default). It is relative to the user's home directory.

View Source
const DefaultControlPort = "8888"

DefaultControlPort is the default port the functionnality control port communicate on.

View Source
const DefaultDBFolder = "db"

DefaultDBFolder is the name of the folder in which the db file is saved. By default it is relative to the DefaultConfigFolder path.

View Source
const DefaultDKGTimeout = 10 * time.Second

DefaultDKGTimeout is the default time of each DKG period by default. Note that by default, DKG uses the "fast sync" mode that shorten the first phase and the second phase, "as fast as possible" when the protocol runs smoothly (there is no malicious party).

View Source
const DefaultGenesisOffset = 1 * time.Second

DefaultGenesisOffset is the time the leader adds after the maximum DKG time (the full three phases) to compute the genesis time of the randomness chain.

View Source
const PrivateRandLength = 32

PrivateRandLength is the length of expected private randomness buffers

Variables

View Source
var DefaultResharingOffset = 30 * time.Second

DefaultResharingOffset is the time the leader adds to the current time to set the TransitionTime field in the group file when setting up a resharing. This time will be rounded up to the next round time of the beacon, since a beacon has to keep the same period.

View Source
var EciesHash = sha256.New

EciesHash is the hash function used for the ECIES encryption used in the private randomness feature.

View Source
var MaxWaitPrepareDKG = 24 * 7 * 2 * time.Hour

MaxWaitPrepareDKG is the maximum time the "automatic" setting up of the group can take. If the setup is still not finished after this time, it is canceled.

Functions

func DefaultConfigFolder

func DefaultConfigFolder() string

DefaultConfigFolder returns the default path of the configuration folder.

func Proxy added in v1.0.0

Proxy wraps a server interface into a client interface so it can be queried

Types

type Broadcast added in v1.2.6

type Broadcast interface {
	dkg.Board
	BroadcastDKG(c context.Context, p *drand.DKGPacket) (*drand.Empty, error)
	Stop()
}

Broadcast is an interface that represents the minimum functionality required by drand to both (1) be the interface between drand and the dkg logic and (2) implement the broadcasting mechanisn.

type Client

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

Client is the endpoint logic, communicating with drand servers XXX: This API should go away. Do not extend any further.

func NewGrpcClient added in v0.3.7

func NewGrpcClient(opts ...grpc.DialOption) *Client

NewGrpcClient returns a Client able to talk to drand instances using gRPC communication method

func NewGrpcClientFromCert added in v0.3.7

func NewGrpcClientFromCert(c *net.CertManager, opts ...grpc.DialOption) *Client

NewGrpcClientFromCert returns a client that contact its peer over TLS

func (*Client) ChainInfo added in v1.0.0

func (c *Client) ChainInfo(p net.Peer) (*chain.Info, error)

ChainInfo returns the chain info as reported by the given peer.

func (*Client) Private

func (c *Client) Private(id *key.Identity) ([]byte, error)

Private retrieves a private random value from the server. It does that by generating an ephemeral key pair, sends it encrypted to the remote server, and decrypts the response, the randomness. Client will attempt a TLS connection to the address in the identity if id.IsTLS() returns true

type Config

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

Config holds all relevant information for a drand node to run.

func NewConfig

func NewConfig(opts ...ConfigOption) *Config

NewConfig returns the config to pass to drand with the default options set and the updated values given by the options.

func (*Config) BoltOptions added in v0.9.0

func (d *Config) BoltOptions() *bolt.Options

BoltOptions returns the options given to the bolt db

func (*Config) Certs added in v0.3.7

func (d *Config) Certs() *net.CertManager

Certs returns all custom certs currently being trusted by drand.

func (*Config) ConfigFolder

func (d *Config) ConfigFolder() string

ConfigFolder returns the folder under which drand stores all its configuration.

func (*Config) ControlPort added in v0.4.0

func (d *Config) ControlPort() string

ControlPort returns the port used for control port communications which can be the default one or the port setup thanks to WithControlPort

func (*Config) DBFolder

func (d *Config) DBFolder() string

DBFolder returns the folder under which drand stores all generated beacons.

func (*Config) Logger added in v0.5.2

func (d *Config) Logger() log.Logger

Logger returns the logger associated with this config.

func (*Config) PrivateListenAddress added in v0.9.0

func (d *Config) PrivateListenAddress(defaultAddr string) string

PrivateListenAddress returns the given default address or the listen address stored in the config thanks to WithPrivateListenAddress

func (*Config) PublicListenAddress added in v0.9.0

func (d *Config) PublicListenAddress(defaultAddr string) string

PublicListenAddress returns the given default address or the listen address stored in the config thanks to WithPublicListenAddress

func (*Config) Version added in v1.0.0

func (d *Config) Version() string

Version returns the configured version of the binary

type ConfigOption

type ConfigOption func(*Config)

ConfigOption is a function that applies a specific setting to a Config.

func WithBeaconCallback

func WithBeaconCallback(fn func(*chain.Beacon)) ConfigOption

WithBeaconCallback sets a function that is called each time a new random beacon is generated.

func WithBoltOptions

func WithBoltOptions(opts *bolt.Options) ConfigOption

WithBoltOptions applies boltdb specific options when storing random beacons.

func WithCallOption added in v0.3.7

func WithCallOption(opts ...grpc.CallOption) ConfigOption

WithCallOption applies grpc options when drand calls a gRPC method.

func WithConfigFolder

func WithConfigFolder(folder string) ConfigOption

WithConfigFolder sets the base configuration folder to the given string.

func WithControlPort added in v0.4.0

func WithControlPort(port string) ConfigOption

WithControlPort specifies which port on localhost the ListenerControl should bind to.

func WithDBFolder added in v1.0.0

func WithDBFolder(folder string) ConfigOption

WithDBFolder sets the path folder for the db file. This path is NOT relative to the DrandFolder path if set.

func WithDKGCallback added in v0.5.4

func WithDKGCallback(fn func(*key.Share)) ConfigOption

WithDKGCallback sets a function that is called when the DKG finishes. It passes in the share of this node and the distributed public key generated.

func WithDkgTimeout

func WithDkgTimeout(t time.Duration) ConfigOption

WithDkgTimeout sets the timeout under which the DKG must finish.

func WithGrpcOptions

func WithGrpcOptions(opts ...grpc.DialOption) ConfigOption

WithGrpcOptions applies grpc dialing option used when a drand node actively contacts another.

func WithInsecure added in v0.3.7

func WithInsecure() ConfigOption

WithInsecure allows drand to listen on standard non-encrypted port and to contact other nodes over non-encrypted TCP connections.

func WithLogLevel added in v0.5.2

func WithLogLevel(level int) ConfigOption

WithLogLevel sets the logging verbosity to the given level.

func WithPrivateListenAddress added in v0.9.0

func WithPrivateListenAddress(addr string) ConfigOption

WithPrivateListenAddress specifies the address the drand instance should bind to. It is useful if you want to advertise a public proxy address and the drand instance runs behind your network.

func WithPrivateRandomness added in v0.9.0

func WithPrivateRandomness() ConfigOption

WithPrivateRandomness enables the private randomness feature on the drand logic. When the feature is not enabled, the call returns an error.

func WithPublicListenAddress added in v0.9.0

func WithPublicListenAddress(addr string) ConfigOption

WithPublicListenAddress specifies the address the drand instance should bind to. It is useful if you want to advertise a public proxy address and the drand instance runs behind your network.

func WithTLS added in v0.3.7

func WithTLS(certPath, keyPath string) ConfigOption

WithTLS registers the certificates and private key path so drand can accept and issue connections using TLS.

func WithTrustedCerts added in v0.3.7

func WithTrustedCerts(certPaths ...string) ConfigOption

WithTrustedCerts saves the certificates at the given paths and forces drand to trust them. Mostly useful for testing.

func WithVersion added in v1.0.0

func WithVersion(version string) ConfigOption

WithVersion sets a version for drand, a visible string to other peers.

type Drand

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

Drand is the main logic of the program. It reads the keys / group file, it can start the DKG, read/write shars to files and can initiate/respond to TBlS signature requests.

func LoadDrand

func LoadDrand(s key.Store, c *Config) (*Drand, error)

LoadDrand restores a drand instance that is ready to serve randomness, with a pre-existing distributed share.

func NewDrand

func NewDrand(s key.Store, c *Config) (*Drand, error)

NewDrand returns an drand struct. It assumes the private key pair has been generated and saved already.

func (*Drand) BackupDatabase added in v1.2.6

func (d *Drand) BackupDatabase(ctx context.Context, req *drand.BackupDBRequest) (*drand.BackupDBResponse, error)

BackupDatabase triggers a backup of the primary database.

func (*Drand) BroadcastDKG added in v1.1.0

func (d *Drand) BroadcastDKG(c context.Context, in *drand.DKGPacket) (*drand.Empty, error)

BroadcastDKG is the public method to call during a DKG protocol.

func (*Drand) ChainInfo added in v1.0.0

ChainInfo replies with the chain information this node participates to

func (*Drand) GetIdentity added in v1.0.0

func (d *Drand) GetIdentity(ctx context.Context, req *drand.IdentityRequest) (*drand.Identity, error)

GetIdentity returns the identity of this drand node

func (*Drand) GroupFile added in v0.5.2

func (d *Drand) GroupFile(ctx context.Context, in *drand.GroupRequest) (*drand.GroupPacket, error)

GroupFile replies with the distributed key in the response

func (*Drand) Home added in v0.4.1

Home provides the address the local node is listening

func (*Drand) InitDKG added in v0.4.0

func (d *Drand) InitDKG(c context.Context, in *drand.InitDKGPacket) (*drand.GroupPacket, error)

InitDKG take a InitDKGPacket, extracts the informations needed and wait for the DKG protocol to finish. If the request specifies this node is a leader, it starts the DKG protocol.

func (*Drand) InitReshare added in v0.4.0

func (d *Drand) InitReshare(c context.Context, in *drand.InitResharePacket) (*drand.GroupPacket, error)

InitReshare receives information about the old and new group from which to operate the resharing protocol.

func (*Drand) PartialBeacon added in v0.7.5

func (d *Drand) PartialBeacon(c context.Context, in *drand.PartialBeaconPacket) (*drand.Empty, error)

PartialBeacon receives a beacon generation request and answers with the partial signature from this drand node.

func (*Drand) PeerMetrics added in v1.0.0

func (d *Drand) PeerMetrics(c context.Context) (map[string]http.Handler, error)

PeerMetrics exports a handler for retreiving metric information from group peers

func (*Drand) PingPong added in v0.4.0

func (d *Drand) PingPong(c context.Context, in *drand.Ping) (*drand.Pong, error)

PingPong simply responds with an empty packet, proving that this drand node is up and alive.

func (*Drand) PrivateKey added in v0.4.0

PrivateKey is a functionality of Control Service defined in protobuf/control that requests the long term private key of the drand node running locally

func (*Drand) PrivateRand added in v0.5.2

PrivateRand returns an ECIES encrypted random blob of 32 bytes from /dev/urandom

func (*Drand) PublicKey added in v0.4.0

PublicKey is a functionality of Control Service defined in protobuf/control that requests the long term public key of the drand node running locally

func (*Drand) PublicRand added in v0.5.2

PublicRand returns a public random beacon according to the request. If the Round field is 0, then it returns the last one generated.

func (*Drand) PublicRandStream added in v0.6.1

func (d *Drand) PublicRandStream(req *drand.PublicRandRequest, stream drand.Public_PublicRandStreamServer) error

PublicRandStream exports a stream of new beacons as they are generated over gRPC

func (*Drand) PushDKGInfo added in v0.9.0

func (d *Drand) PushDKGInfo(ctx context.Context, in *drand.DKGInfoPacket) (*drand.Empty, error)

PushDKGInfo triggers sending DKG info to other members

func (*Drand) Share added in v0.4.0

Share is a functionality of Control Service defined in protobuf/control that requests the private share of the drand node running locally

func (*Drand) Shutdown added in v0.5.4

Shutdown stops the node

func (*Drand) SignalDKGParticipant added in v0.9.0

func (d *Drand) SignalDKGParticipant(ctx context.Context, p *drand.SignalDKGPacket) (*drand.Empty, error)

SignalDKGParticipant receives a dkg signal packet from another member

func (*Drand) StartBeacon added in v0.4.0

func (d *Drand) StartBeacon(catchup bool)

StartBeacon initializes the beacon if needed and launch a go routine that runs the generation loop.

func (*Drand) StartFollowChain added in v1.0.2

func (d *Drand) StartFollowChain(req *drand.StartFollowRequest, stream drand.Control_StartFollowChainServer) error

StartFollowChain syncs up with a chain from other nodes

func (*Drand) Stop

func (d *Drand) Stop(ctx context.Context)

Stop simply stops all drand operations.

func (*Drand) StopBeacon added in v0.4.0

func (d *Drand) StopBeacon()

StopBeacon stops the beacon generation process and resets it.

func (*Drand) SyncChain added in v0.6.1

func (d *Drand) SyncChain(req *drand.SyncRequest, stream drand.Protocol_SyncChainServer) error

SyncChain is a inter-node protocol that replies to a syncing request from a given round

func (*Drand) WaitDKG

func (d *Drand) WaitDKG() (*key.Group, error)

WaitDKG waits on the running dkg protocol. In case of an error, it returns it. In case of a finished DKG protocol, it saves the dist. public key and private share. These should be loadable by the store.

func (*Drand) WaitExit added in v0.5.4

func (d *Drand) WaitExit() chan bool

WaitExit returns a channel that signals when drand stops its operations

Jump to

Keyboard shortcuts

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