Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultConfigFolder() string
- func Proxy(s drand.PublicServer) client.Client
- type Client
- type Config
- func (d *Config) BoltOptions() *bolt.Options
- func (d *Config) Certs() *net.CertManager
- func (d *Config) ConfigFolder() string
- func (d *Config) ControlPort() string
- func (d *Config) DBFolder() string
- func (d *Config) Logger() log.Logger
- func (d *Config) PrivateListenAddress(defaultAddr string) string
- func (d *Config) PublicListenAddress(defaultAddr string) string
- func (d *Config) Version() string
- type ConfigOption
- func WithBeaconCallback(fn func(*chain.Beacon)) ConfigOption
- func WithBoltOptions(opts *bolt.Options) ConfigOption
- func WithCallOption(opts ...grpc.CallOption) ConfigOption
- func WithConfigFolder(folder string) ConfigOption
- func WithControlPort(port string) ConfigOption
- func WithDBFolder(folder string) ConfigOption
- func WithDKGCallback(fn func(*key.Share)) ConfigOption
- func WithDkgTimeout(t time.Duration) ConfigOption
- func WithGrpcOptions(opts ...grpc.DialOption) ConfigOption
- func WithInsecure() ConfigOption
- func WithLogLevel(level int) ConfigOption
- func WithPrivateListenAddress(addr string) ConfigOption
- func WithPrivateRandomness() ConfigOption
- func WithPublicListenAddress(addr string) ConfigOption
- func WithTLS(certPath, keyPath string) ConfigOption
- func WithTrustedCerts(certPaths ...string) ConfigOption
- func WithVersion(version string) ConfigOption
- type Drand
- func (d *Drand) BroadcastDKG(c context.Context, in *drand.DKGPacket) (*drand.Empty, error)
- func (d *Drand) ChainInfo(ctx context.Context, in *drand.ChainInfoRequest) (*drand.ChainInfoPacket, error)
- func (d *Drand) GetIdentity(ctx context.Context, req *drand.IdentityRequest) (*drand.Identity, error)
- func (d *Drand) GroupFile(ctx context.Context, in *drand.GroupRequest) (*drand.GroupPacket, error)
- func (d *Drand) Home(c context.Context, in *drand.HomeRequest) (*drand.HomeResponse, error)
- func (d *Drand) InitDKG(c context.Context, in *drand.InitDKGPacket) (*drand.GroupPacket, error)
- func (d *Drand) InitReshare(c context.Context, in *drand.InitResharePacket) (*drand.GroupPacket, error)
- func (d *Drand) PartialBeacon(c context.Context, in *drand.PartialBeaconPacket) (*drand.Empty, error)
- func (d *Drand) PeerMetrics(c context.Context) (map[string]http.Handler, error)
- func (d *Drand) PingPong(c context.Context, in *drand.Ping) (*drand.Pong, error)
- func (d *Drand) PrivateKey(ctx context.Context, in *drand.PrivateKeyRequest) (*drand.PrivateKeyResponse, error)
- func (d *Drand) PrivateRand(c context.Context, priv *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error)
- func (d *Drand) PublicKey(ctx context.Context, in *drand.PublicKeyRequest) (*drand.PublicKeyResponse, error)
- func (d *Drand) PublicRand(c context.Context, in *drand.PublicRandRequest) (*drand.PublicRandResponse, error)
- func (d *Drand) PublicRandStream(req *drand.PublicRandRequest, stream drand.Public_PublicRandStreamServer) error
- func (d *Drand) PushDKGInfo(ctx context.Context, in *drand.DKGInfoPacket) (*drand.Empty, error)
- func (d *Drand) Share(ctx context.Context, in *drand.ShareRequest) (*drand.ShareResponse, error)
- func (d *Drand) Shutdown(ctx context.Context, in *drand.ShutdownRequest) (*drand.ShutdownResponse, error)
- func (d *Drand) SignalDKGParticipant(ctx context.Context, p *drand.SignalDKGPacket) (*drand.Empty, error)
- func (d *Drand) StartBeacon(catchup bool)
- func (d *Drand) StartFollowChain(req *drand.StartFollowRequest, stream drand.Control_StartFollowChainServer) error
- func (d *Drand) Stop(ctx context.Context)
- func (d *Drand) StopBeacon()
- func (d *Drand) SyncChain(req *drand.SyncRequest, stream drand.Protocol_SyncChainServer) error
- func (d *Drand) WaitDKG() (*key.Group, error)
- func (d *Drand) WaitExit() chan bool
Constants ¶
const DefaultBeaconPeriod time.Duration = 1 * time.Minute
DefaultBeaconPeriod is the period in which the beacon logic creates new random beacon.
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.
const DefaultControlPort = "8888"
DefaultControlPort is the default port the functionnality control port communicate on.
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.
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).
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.
const PrivateRandLength = 32
PrivateRandLength is the length of expected private randomness buffers
Variables ¶
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.
var EciesHash = sha256.New
EciesHash is the hash function used for the ECIES encryption used in the private randomness feature.
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.
Types ¶
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.1.2
ChainInfo returns the chain info as reported by the given peer.
func (*Client) Private ¶
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 v1.1.2
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 ¶
ConfigFolder returns the folder under which drand stores all its configuration.
func (*Config) ControlPort ¶ added in v0.4.0
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 ¶
DBFolder returns the folder under which drand stores all generated beacons.
func (*Config) PrivateListenAddress ¶ added in v1.1.2
PrivateListenAddress returns the given default address or the listen address stored in the config thanks to WithPrivateListenAddress
func (*Config) PublicListenAddress ¶ added in v1.1.2
PublicListenAddress returns the given default address or the listen address stored in the config thanks to WithPublicListenAddress
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.1.2
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.5
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.5
func WithLogLevel(level int) ConfigOption
WithLogLevel sets the logging verbosity to the given level.
func WithPrivateListenAddress ¶ added in v1.1.2
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 v1.1.2
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 v1.1.2
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.1.2
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 ¶
LoadDrand restores a drand instance that is ready to serve randomness, with a pre-existing distributed share.
func NewDrand ¶
NewDrand returns an drand struct. It assumes the private key pair has been generated and saved already.
func (*Drand) BroadcastDKG ¶ added in v1.1.2
FreshDKG is the public method to call during a DKG protocol.
func (*Drand) ChainInfo ¶ added in v1.1.2
func (d *Drand) ChainInfo(ctx context.Context, in *drand.ChainInfoRequest) (*drand.ChainInfoPacket, error)
ChainInfo replies with the chain information this node participates to
func (*Drand) GetIdentity ¶ added in v1.1.2
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.5
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
func (d *Drand) Home(c context.Context, in *drand.HomeRequest) (*drand.HomeResponse, error)
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 v1.1.2
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.1.2
PeerMetrics exports a handler for retreiving metric information from group peers
func (*Drand) PingPong ¶ added in v0.4.0
PingPong simply responds with an empty packet, proving that this drand node is up and alive.
func (*Drand) PrivateKey ¶ added in v0.4.0
func (d *Drand) PrivateKey(ctx context.Context, in *drand.PrivateKeyRequest) (*drand.PrivateKeyResponse, error)
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.5
func (d *Drand) PrivateRand(c context.Context, priv *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error)
PrivateRand returns an ECIES encrypted random blob of 32 bytes from /dev/urandom
func (*Drand) PublicKey ¶ added in v0.4.0
func (d *Drand) PublicKey(ctx context.Context, in *drand.PublicKeyRequest) (*drand.PublicKeyResponse, error)
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.5
func (d *Drand) PublicRand(c context.Context, in *drand.PublicRandRequest) (*drand.PublicRandResponse, error)
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 v1.1.2
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 v1.1.2
PushDKGInfo triggers sending DKG info to other members
func (*Drand) Share ¶ added in v0.4.0
func (d *Drand) Share(ctx context.Context, in *drand.ShareRequest) (*drand.ShareResponse, error)
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.5
func (d *Drand) Shutdown(ctx context.Context, in *drand.ShutdownRequest) (*drand.ShutdownResponse, error)
Shutdown stops the node
func (*Drand) SignalDKGParticipant ¶ added in v1.1.2
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
StartBeacon initializes the beacon if needed and launch a go routine that runs the generation loop.
func (*Drand) StartFollowChain ¶ added in v1.1.2
func (d *Drand) StartFollowChain(req *drand.StartFollowRequest, stream drand.Control_StartFollowChainServer) error
StartFollowChain syncs up with a chain from other nodes
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 v1.1.2
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