Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultThreshold(n int) int
- func Delete(filePath string) error
- func Load(filePath string, t Tomler) error
- func MinimumT(n int) int
- func NewFileStores(baseFolder string) (map[string]Store, error)
- func PointToString(p kyber.Point) string
- func Save(filePath string, t Tomler, secure bool) error
- func ScalarToString(s kyber.Scalar) string
- func SelfSignAll(l log.Logger, multibeaconFolder string) error
- func StringToPoint(g kyber.Group, s string) (kyber.Point, error)
- func StringToScalar(g kyber.Group, s string) (kyber.Scalar, error)
- type ByKey
- type DistPublic
- func (d *DistPublic) Equal(d2 *DistPublic) bool
- func (d *DistPublic) FromTOML(sch *crypto.Scheme, i interface{}) error
- func (d *DistPublic) Hash() []byte
- func (d *DistPublic) Key() kyber.Point
- func (d *DistPublic) PubPoly(sch *crypto.Scheme) *share.PubPoly
- func (d *DistPublic) TOML() interface{}
- func (d *DistPublic) TOMLValue() interface{}
- type DistPublicTOML
- type Group
- func (g *Group) DKGNodes() []dkg.Node
- func (g *Group) Equal(g2 *Group) bool
- func (g *Group) Find(pub *Identity) *Node
- func (g *Group) FromTOML(i interface{}) error
- func (g *Group) GetGenesisSeed() []byte
- func (g *Group) Hash() []byte
- func (g *Group) Len() int
- func (g *Group) Node(i Index) *Node
- func (g *Group) Points() []kyber.Point
- func (g *Group) String() string
- func (g *Group) TOML() interface{}
- func (g *Group) TOMLValue() interface{}
- func (g *Group) ToProto(version common2.Version) *proto.GroupPacket
- func (g *Group) UnsignedIdentities() []*Node
- type GroupTOML
- type Identity
- func (i *Identity) Address() string
- func (i *Identity) Equal(i2 *Identity) bool
- func (i *Identity) FromTOML(t interface{}) error
- func (i *Identity) Hash() []byte
- func (i *Identity) String() string
- func (i *Identity) TOML() interface{}
- func (i *Identity) TOMLValue() interface{}
- func (i *Identity) ToProto() *proto.Identity
- func (i *Identity) ValidSignature() error
- type Index
- type Node
- type NodeTOML
- type Pair
- type PairTOML
- type PublicTOML
- type Share
- type ShareTOML
- type Store
- type Tomler
Constants ¶
const FolderName = "key"
FolderName is the name of the folder where drand keeps its keys
const GroupFolderName = "groups"
GroupFolderName is the name of the folder where drand keeps its group files
Variables ¶
var ErrInvalidKeyScheme = errors.New("the key's scheme may not match the beacon's scheme")
Functions ¶
func Delete ¶
Delete the resource denoted by the given path. If it is a file, it deletes the file; if it is a folder it delete the folder and all its content.
func MinimumT ¶
MinimumT calculates the threshold needed for the group to produce sufficient shares to decode
func NewFileStores ¶
NewFileStores will list all folder on base path and load every file store it can find. It will return a map with a beacon id as key and a file store as value.
func PointToString ¶
PointToString returns a hex-encoded string representation of the given point.
func Save ¶
Save the given Tomler interface to the given path. If secure is true, the file will have a 0700 security. TODO: move that to fs/
func ScalarToString ¶
ScalarToString returns a hex-encoded string representation of the given scalar.
func SelfSignAll ¶
SelfSignAll will go through all the stores in the multibeaconFolder and self-sign the keys unless they are already correctly self-signed.
func StringToPoint ¶
StringToPoint unmarshals a point in the given group from the given string.
Types ¶
type DistPublic ¶
DistPublic represents the distributed public key generated during a DKG. This is the information that can be safely exported to end users verifying a drand signature. It is the list of all commitments of the coefficients of the private distributed polynomial.
func (*DistPublic) Equal ¶
func (d *DistPublic) Equal(d2 *DistPublic) bool
Equal returns if all coefficients of the public key d are equal to those of d2
func (*DistPublic) FromTOML ¶
func (d *DistPublic) FromTOML(sch *crypto.Scheme, i interface{}) error
FromTOML initializes d from the TOML-compatible version of a DistPublic
func (*DistPublic) Hash ¶
func (d *DistPublic) Hash() []byte
Hash computes the hash of this distributed key.
func (*DistPublic) Key ¶
func (d *DistPublic) Key() kyber.Point
Key returns the first coefficient as representing the public key to be used to verify signatures issued by the distributed key.
func (*DistPublic) PubPoly ¶
func (d *DistPublic) PubPoly(sch *crypto.Scheme) *share.PubPoly
PubPoly provides the public polynomial commitment
func (*DistPublic) TOML ¶
func (d *DistPublic) TOML() interface{}
TOML returns a TOML-compatible version of d
func (*DistPublic) TOMLValue ¶
func (d *DistPublic) TOMLValue() interface{}
TOMLValue returns an empty TOML-compatible dist public interface
type DistPublicTOML ¶
type DistPublicTOML struct {
Coefficients []string
}
DistPublicTOML is a TOML compatible value of a DistPublic
type Group ¶
type Group struct { // Threshold to setup during the DKG or resharing protocol. Threshold int // Period to use for the beacon randomness generation Period time.Duration // Scheme indicates a set of values the process will use to act in specific ways Scheme *crypto.Scheme // ID is the unique identifier for this group ID string // CatchupPeriod is a delay to insert while in a catchup mode // also can be thought of as the minimum period allowed between // beacon and subsequent partial generation CatchupPeriod time.Duration // List of nodes forming this group Nodes []*Node // Time at which the first round of the chain is mined GenesisTime int64 // Seed of the genesis block. When doing a DKG from scratch, it will be // populated directly from the list of nodes and other parameters. WHen // doing a resharing, this seed is taken from the first group of the // network. GenesisSeed []byte // In case of a resharing, this is the time at which the network will // transition from the old network to the new network. TransitionTime int64 // The distributed public key of this group. It is nil if the group has not // ran a DKG protocol yet. PublicKey *DistPublic }
Group holds all information about a group of drand nodes.
func GroupFromProto ¶
GroupFromProto converts a protobuf group into a local Group object
func LoadGroup ¶
func LoadGroup(list []*Node, genesis int64, public *DistPublic, period time.Duration, transition int64, sch *crypto.Scheme, beaconID string) *Group
LoadGroup returns a group that contains all information with respect to a QUALified set of nodes that ran successfully a setup or reshare phase. The threshold is automatically guessed from the length of the distributed key. Note: only used in tests
func (*Group) DKGNodes ¶
DKGNodes return the slice of nodes of this group that is consumable by the dkg library: only the public key and index are used.
func (*Group) Find ¶
Find returns the Node that is equal to the given identity (without the index). If the node is not found, Find returns nil.
func (*Group) GetGenesisSeed ¶
GetGenesisSeed exposes the hash of the genesis seed for the group
func (*Group) Node ¶
Node returns the node at the given index if it exists in the group. If it does not, Node() returns nil.
func (*Group) TOML ¶
func (g *Group) TOML() interface{}
TOML returns a TOML-encodable version of the Group
func (*Group) TOMLValue ¶
func (g *Group) TOMLValue() interface{}
TOMLValue returns an empty TOML-compatible value of the group
func (*Group) ToProto ¶
func (g *Group) ToProto(version common2.Version) *proto.GroupPacket
ToProto encodes a local group object into its wire format
func (*Group) UnsignedIdentities ¶
UnsignedIdentities return true if all identities in the group are signed correctly or not. This method is here because of backward compatibility where identities were not self-signed before.
type GroupTOML ¶
type GroupTOML struct { Threshold int Period string CatchupPeriod string Nodes []*NodeTOML GenesisTime int64 TransitionTime int64 `toml:",omitempty"` GenesisSeed string `toml:",omitempty"` PublicKey *DistPublicTOML `toml:",omitempty"` SchemeID string ID string }
GroupTOML is the representation of a Group TOML compatible
type Identity ¶
Identity holds the corresponding public key of a Private. It also includes a valid internet facing ipv4 address where to this reach the node holding the public / private key pair.
func IdentityFromProto ¶
IdentityFromProto creates an identity from its wire representation and verifies it validity.
func (*Identity) Hash ¶
Hash returns the hash of the public key without signing the signature. The hash is the input to the signature Scheme. It does _not_ hash the address field as this may need to change while the node keeps the same key.
func (*Identity) TOML ¶
func (i *Identity) TOML() interface{}
TOML returns an empty TOML-compatible version of the public key
func (*Identity) TOMLValue ¶
func (i *Identity) TOMLValue() interface{}
TOMLValue returns a TOML-compatible interface value
func (*Identity) ValidSignature ¶
ValidSignature returns true if the signature included in this identity is correct or not
type Node ¶
Node is a wrapper around identity that additionally includes the index that the node has within this group. The index is computed initially when the group is first created. The index is useful only for drand nodes, and shouldn't be taken into account from an external point of view. The index is useful to be able to reshare correctly, and gives the ability to have a better logging: packets sent during DKG only contain an index, from which we can derive the actual address from the index.
func NodeFromProto ¶
NodeFromProto creates a node from its wire representation
type NodeTOML ¶
type NodeTOML struct { *PublicTOML Index Index }
NodeTOML is the node's toml representation
type Pair ¶
Pair is a wrapper around a random scalar and the corresponding public key
func NewKeyPair ¶
NewKeyPair returns a freshly created private / public key pair.
func (*Pair) FromTOML ¶
FromTOML constructs the private key from an unmarshalled structure from TOML
type PublicTOML ¶
PublicTOML is the TOML-able version of a public key
type Share ¶
type Share struct {}
Share represents the private information that a node holds after a successful DKG. This information MUST stay private !
func (*Share) FromTOML ¶
FromTOML initializes the share from the given TOML-compatible share interface
func (*Share) PrivateShare ¶
PrivateShare returns the private share used to produce a partial signature
func (*Share) PubPoly ¶
PubPoly returns the public polynomial that can be used to verify any individual partial signature
func (*Share) Public ¶
func (s *Share) Public() *DistPublic
Public returns the distributed public key associated with the distributed key share
type ShareTOML ¶
type ShareTOML struct { int Share string Commits []string // coefficients of the individual private polynomial generated by the node // at the given index. }Index
ShareTOML is the TOML representation of a dkg.DistKeyShare
type Store ¶
type Store interface { // SaveKeyPair saves the private key generated by drand as well as the // public identity key associated SaveKeyPair(p *Pair) error // LoadKeyPair loads the private/public key pair associated with the drand // operator LoadKeyPair() (*Pair, error) SaveGroup(*Group) error LoadGroup() (*Group, error) Reset() error }
Store abstracts the loading and saving of any private/public cryptographic material to be used by drand. For the moment, only a file based store is implemented.
func NewFileStore ¶
NewFileStore is used to create the config folder and all the subfolders. If a folder already exists, we simply check the rights