key

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: May 16, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFolderFlag = "homedir"

ConfigFolderFlag holds the name of the flag to set using the CLI to change the default configuration folder of drand. It mimicks the gpg flag option.

View Source
const GroupFolderName = "groups"
View Source
const KeyFolderName = "key"

Variables

View Source
var ErrAbsent = errors.New("store can't find requested object")
View Source
var ErrStoreFile = errors.New("store file issues")
View Source
var G1 = Pairing.G1()
View Source
var G2 = Pairing.G2()
View Source
var Pairing = bn256.NewSuite()

Functions

func DefaultThreshold

func DefaultThreshold(n int) int

func Load

func Load(path string, t Tomler) error

func Save

func Save(path string, t Tomler, secure bool) error

Types

type BeaconSignature

type BeaconSignature struct {
	Timestamp   int64
	PreviousSig string
	Signature   string
}

BeaconSignature is the final reconstructed BLS signature that is saved in the filesystem.

func NewBeaconSignature

func NewBeaconSignature(timestamp int64, previousSig, signature []byte) *BeaconSignature

NewBeaconSignature initializes a beacon signature from - a timestamp - a previous sig. Can be nil if there is no previous signature - a signature of the timestamp and the previous sig

func (*BeaconSignature) FromTOML

func (b *BeaconSignature) FromTOML(i interface{}) error

FromTOML initializes b from a TOML-compatible version of a beacon signature

func (*BeaconSignature) RawSig

func (b *BeaconSignature) RawSig() []byte

RawSig returns the signature

func (*BeaconSignature) TOML

func (b *BeaconSignature) TOML() interface{}

TOML returns a TOML-compatible version of this beacon signature

func (*BeaconSignature) TOMLValue

func (b *BeaconSignature) TOMLValue() interface{}

TOMLValue returns an empty TOML-compatible version of a beacon signature

type ByKey

type ByKey []*Identity

ByKey is simply an interface to sort lexig

func (ByKey) Len

func (b ByKey) Len() int

func (ByKey) Less

func (b ByKey) Less(i, j int) bool

func (ByKey) Swap

func (b ByKey) Swap(i, j int)

type DistPublic

type DistPublic struct {
	Key kyber.Point
}

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. The public key belongs in the same group as the individual public key,i.e. G2

func (*DistPublic) FromTOML

func (d *DistPublic) FromTOML(i interface{}) error

FromTOML initializes d from the TOML-compatible version of a DistPublic

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 {
	Key string
}

DistPublicTOML is a TOML compatible value of a DistPublic

type Group

type Group struct {
	Nodes     []*IndexedPublic
	Threshold int
}

Group is a list of IndexedPublic providing helper methods to search and get public keys from a list.

func NewGroup

func NewGroup(list []*Identity, threshold int) *Group

NewGroup returns a list of identities as a Group. The threshold is set to a the default returned by DefaultThreshod.

func (*Group) Contains

func (g *Group) Contains(pub *Identity) bool

Contains returns true if the public key is contained in the list or not.

func (*Group) Filter

func (g *Group) Filter(indexes []int) *Group

func (*Group) FromTOML

func (g *Group) FromTOML(i interface{}) error

FromTOML decodes the group from the toml struct

func (*Group) Identities

func (g *Group) Identities() []*Identity

func (*Group) Index

func (g *Group) Index(pub *Identity) (int, bool)

Index returns the index of the given public key with a boolean indicating whether the public has been found or not.

func (*Group) Len

func (g *Group) Len() int

Len returns the number of participants in the group

func (*Group) Points

func (g *Group) Points() []kyber.Point

Points returns itself under the form of a list of kyber.Point

func (*Group) Public

func (g *Group) Public(i int) *Identity

Public returns the public associated to that index or panic otherwise. XXX Change that to return error

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

type GroupTOML

type GroupTOML struct {
	Nodes     []*PublicTOML
	Threshold int
}

GroupTOML is the representation of a Group TOML compatible

type Identity

type Identity struct {
	Key  kyber.Point
	Addr string
}

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 (*Identity) Address

func (i *Identity) Address() string

Address implements the net.Peer interface

func (*Identity) Equal

func (p *Identity) Equal(p2 *Identity) bool

Equal returns true if the cryptographic public key of p equals p2's

func (*Identity) FromTOML

func (p *Identity) FromTOML(i interface{}) error

FromTOML loads reads the TOML description of the public key

func (*Identity) TOML

func (p *Identity) TOML() interface{}

TOML returns a empty TOML-compatible version of the public key

func (*Identity) TOMLValue

func (p *Identity) TOMLValue() interface{}

TOMLValue returns a TOML-compatible interface value

type IndexedPublic

type IndexedPublic struct {
	*Identity
	Index int
}

IndexedPublic wraps a Public with its index relative to the group

type Private

type Private struct {
	Key    kyber.Scalar
	Public *Identity
}

Private is a wrapper around a random scalar and the corresponding public key in G2

func NewKeyPair

func NewKeyPair(address string) *Private

NewKeyPair returns a freshly created private / public key pair. The group is decided by the group variable by default. Currently, drand only supports bn256.

func (*Private) FromTOML

func (p *Private) FromTOML(i interface{}) error

FromTOML constructs the private key from an unmarshalled structure from TOML

func (*Private) TOML

func (p *Private) TOML() interface{}

TOML returns a struct that can be marshalled using a TOML-encoding library

func (*Private) TOMLValue

func (p *Private) TOMLValue() interface{}

TOMLValue returns an empty TOML-compatible interface value

type PrivateTOML

type PrivateTOML struct {
	Key string
}

PrivateTOML is the TOML-able version of a private key

type PublicTOML

type PublicTOML struct {
	Address string
	Key     string
}

PublicTOML is the TOML-able version of a public key

type Share

type Share dkg.DistKeyShare

Share represents the private information that a node holds after a successful DKG. This information MUST stay private !

func (*Share) FromTOML

func (s *Share) FromTOML(i interface{}) error

FromTOML initializes the share from the given TOML-compatible share interface

func (*Share) Public

func (s *Share) Public() *DistPublic

Public returns the distributed public key associated with the distributed key share

func (*Share) TOML

func (s *Share) TOML() interface{}

TOML returns a TOML-compatible version of this share

func (*Share) TOMLValue

func (s *Share) TOMLValue() interface{}

TOMLValue returns an empty TOML compatible interface of that Share

type ShareTOML

type ShareTOML struct {
	Commits []string
	Share   string
	Index   int
}

ShareTOML is the TOML representation of a dkg.DistKeyShare

type Store

type Store interface {
	// SavePrivate saves the private key generated by drand as well as the
	// public identity key associated
	SavePrivate(p *Private) error
	// LoadPrivate loads the private/public key pair associated with the drand
	// operator
	LoadPrivate() (*Private, error)
	SaveShare(share *Share) error
	LoadShare() (*Share, error)
	SaveGroup(*Group) error
	LoadGroup() (*Group, error)
	SaveDistPublic(d *DistPublic) error
	LoadDistPublic() (*DistPublic, 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

func NewFileStore(baseFolder string) Store

NewDefaultFileStore

type Tomler

type Tomler interface {
	TOML() interface{}
	FromTOML(i interface{}) error
	TOMLValue() interface{}
}

Tomler represents any struct that can be (un)marshalled into/from toml format

Jump to

Keyboard shortcuts

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