Documentation ¶
Index ¶
- Constants
- Variables
- func Decrypt(g kyber.Group, fn func() hash.Hash, priv kyber.Scalar, o *drand.ECIESObject) ([]byte, error)
- func Encrypt(g kyber.Group, fn func() hash.Hash, public kyber.Point, msg []byte) (*drand.ECIESObject, error)
- type Client
- type Config
- type ConfigOption
- func WithBeaconCallback(fn func(*beacon.Beacon)) ConfigOption
- func WithBeaconPeriod(period time.Duration) ConfigOption
- func WithBoltOptions(opts *bolt.Options) ConfigOption
- func WithConfigFolder(folder string) ConfigOption
- func WithDbFolder(folder string) ConfigOption
- func WithDkgTimeout(t time.Duration) ConfigOption
- func WithGrpcOptions(opts ...grpc.DialOption) ConfigOption
- func WithListenAddress(addr string) ConfigOption
- type Drand
- func (d *Drand) BeaconLoop()
- func (d *Drand) NewBeacon(c context.Context, in *drand.BeaconRequest) (*drand.BeaconResponse, error)
- func (d *Drand) Private(c context.Context, priv *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error)
- func (d *Drand) Public(context.Context, *drand.PublicRandRequest) (*drand.PublicRandResponse, error)
- func (d *Drand) Setup(c context.Context, in *dkg_proto.DKGPacket) (*dkg_proto.DKGResponse, error)
- func (d *Drand) StartDKG() error
- func (d *Drand) Stop()
- func (d *Drand) WaitDKG() error
Constants ¶
const DefaultBeaconPeriod time.Duration = 1 * time.Minute
DefaultBeaconPeriod is the period in which the beacon logic creates new random beacon.
const DefaultConfigFolder = ".drand"
DefaultConfigFolder 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 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.
Variables ¶
var DefaultHash = sha256.New
var DefaultSeed = []byte("Truth is like the sun. You can shut it out for a time, but it ain't goin' away.")
Functions ¶
func Decrypt ¶
func Decrypt(g kyber.Group, fn func() hash.Hash, priv kyber.Scalar, o *drand.ECIESObject) ([]byte, error)
Decrypts does almost the same as Encrypt: the ephemereal static DH exchange, and the derivation of the symmetric key. It finally tries to decrypt the ciphertext and returns the plaintext if successful, an error otherwise.
func Encrypt ¶
func Encrypt(g kyber.Group, fn func() hash.Hash, public kyber.Point, msg []byte) (*drand.ECIESObject, error)
Encrypts performs a ephemereal-static DH exchange, creates the shared key from it using a KDF scheme (hkdf from Go at the time of writing) and then computes the ciphertext using a AEAD scheme (AES-GCM from Go at the time of writing). This methods returns the ephemeral point of the DH exchange, the ciphertext and the associated nonce. It returns an error if something went wrong during the encryption.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the endpoint logic, communicating with drand servers
func NewClient ¶
func NewClient(opts ...grpc.DialOption) *Client
NewClient returns a Client able to talk to drand instances
func (*Client) LastPublic ¶
func (c *Client) LastPublic(addr string, pub *key.DistPublic) (*drand.PublicRandResponse, error)
LastPublic returns the last randomness beacon from the server associated. It returns it if the randomness is valid.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
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) ConfigFolder ¶
func (*Config) ListenAddress ¶
ListenAddress returns the given default address or the listen address stored in the config thanks to WithListenAddress
type ConfigOption ¶
type ConfigOption func(*Config)
func WithBeaconCallback ¶
func WithBeaconCallback(fn func(*beacon.Beacon)) ConfigOption
func WithBeaconPeriod ¶
func WithBeaconPeriod(period time.Duration) ConfigOption
func WithBoltOptions ¶
func WithBoltOptions(opts *bolt.Options) ConfigOption
func WithConfigFolder ¶
func WithConfigFolder(folder string) ConfigOption
func WithDbFolder ¶
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 WithDkgTimeout ¶
func WithDkgTimeout(t time.Duration) ConfigOption
func WithGrpcOptions ¶
func WithGrpcOptions(opts ...grpc.DialOption) ConfigOption
func WithListenAddress ¶
func WithListenAddress(addr string) ConfigOption
WithListenAddress 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.
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 NewDrand ¶
NewDrand returns an drand struct that is ready to start the DKG protocol with the given group and then to serve randomness. It assumes the private key pair has been generated already.
func (*Drand) BeaconLoop ¶
func (d *Drand) BeaconLoop()
BeaconLoop starts periodically the TBLS protocol. The seed is the first message signed alongside with the current timestamp. All subsequent signatures are chained: s_i+1 = SIG(s_i || timestamp) For the moment, each resulting signature is stored in a file named beacons/<timestamp>.sig.
func (*Drand) NewBeacon ¶
func (d *Drand) NewBeacon(c context.Context, in *drand.BeaconRequest) (*drand.BeaconResponse, error)
func (*Drand) Private ¶
func (d *Drand) Private(c context.Context, priv *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error)
func (*Drand) Public ¶
func (d *Drand) Public(context.Context, *drand.PublicRandRequest) (*drand.PublicRandResponse, error)