dkg

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicatedShare is reported when adding an private key share of same id.
	ErrDuplicatedShare = fmt.Errorf("invalid share")
	// ErrNoIDToRecover is reported when no id is provided for recovering private
	// key.
	ErrNoIDToRecover = fmt.Errorf("no id to recover private key")
	// ErrShareNotFound is reported when the private key share of id is not found
	// when recovering private key.
	ErrShareNotFound = fmt.Errorf("share not found")
)
View Source
var (
	// ErrEmptySignature is reported if the signature is empty.
	ErrEmptySignature = fmt.Errorf("invalid empty signature")
)

Functions

func NewPrivateKeyShares

func NewPrivateKeyShares(t int) (*PrivateKeyShares, *PublicKeyShares)

NewPrivateKeyShares creates a DKG private key shares of threshold t.

func RecoverSignature

func RecoverSignature(sigs []PartialSignature, signerIDs IDs) (
	crypto.Signature, error)

RecoverSignature recovers TSIG signature.

Types

type ID

type ID = bls.ID

ID is the id for DKG protocol.

func BytesID

func BytesID(id []byte) (ID, error)

BytesID creates a new ID structure, It returns err if the byte slice is not valid.

func NewID

func NewID(id []byte) ID

NewID creates a ew ID structure.

type IDs

type IDs []ID

IDs is an array of ID.

type PartialSignature

type PartialSignature crypto.Signature

PartialSignature is a partial signature in DKG+TSIG protocol.

type PrivateKey

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

PrivateKey represents a private key structure implments Crypto.PrivateKey interface.

func NewPrivateKey

func NewPrivateKey() *PrivateKey

NewPrivateKey creates a new PrivateKey structure.

func (*PrivateKey) Bytes

func (prv *PrivateKey) Bytes() []byte

Bytes returns []byte representation of private key.

func (*PrivateKey) DecodeRLP

func (prv *PrivateKey) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*PrivateKey) EncodeRLP

func (prv *PrivateKey) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*PrivateKey) MarshalJSON

func (prv *PrivateKey) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller.

func (*PrivateKey) PublicKey

func (prv *PrivateKey) PublicKey() crypto.PublicKey

PublicKey returns the public key associate this private key.

func (*PrivateKey) SetBytes

func (prv *PrivateKey) SetBytes(bytes []byte) error

SetBytes sets the private key data to []byte.

func (*PrivateKey) Sign

func (prv *PrivateKey) Sign(hash common.Hash) (crypto.Signature, error)

Sign calculates a signature.

func (*PrivateKey) String

func (prv *PrivateKey) String() string

String returns string representation of privat key.

func (*PrivateKey) UnmarshalJSON

func (prv *PrivateKey) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaller.

type PrivateKeyShares

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

PrivateKeyShares represents a private key shares for DKG protocol.

func NewEmptyPrivateKeyShares

func NewEmptyPrivateKeyShares() *PrivateKeyShares

NewEmptyPrivateKeyShares creates an empty private key shares.

func NewRandomPrivateKeyShares

func NewRandomPrivateKeyShares() *PrivateKeyShares

NewRandomPrivateKeyShares constructs a private key shares randomly.

func (*PrivateKeyShares) AddShare

func (prvs *PrivateKeyShares) AddShare(ID ID, share *PrivateKey) error

AddShare adds a share.

func (*PrivateKeyShares) DecodeRLP

func (prvs *PrivateKeyShares) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*PrivateKeyShares) EncodeRLP

func (prvs *PrivateKeyShares) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*PrivateKeyShares) Equal

func (prvs *PrivateKeyShares) Equal(other *PrivateKeyShares) bool

Equal check equality between two PrivateKeyShares instances.

func (*PrivateKeyShares) RecoverPrivateKey

func (prvs *PrivateKeyShares) RecoverPrivateKey(qualifyIDs IDs) (
	*PrivateKey, error)

RecoverPrivateKey recovers private key from the shares.

func (*PrivateKeyShares) RecoverPublicKey

func (prvs *PrivateKeyShares) RecoverPublicKey(qualifyIDs IDs) (
	*PublicKey, error)

RecoverPublicKey recovers public key from the shares.

func (*PrivateKeyShares) SetParticipants

func (prvs *PrivateKeyShares) SetParticipants(IDs IDs)

SetParticipants sets the DKG participants.

func (*PrivateKeyShares) Share

func (prvs *PrivateKeyShares) Share(ID ID) (*PrivateKey, bool)

Share returns the share for the ID.

type PublicKey

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

PublicKey represents a public key structure implements Crypto.PublicKey interface.

func RecoverGroupPublicKey

func RecoverGroupPublicKey(pubShares []*PublicKeyShares) *PublicKey

RecoverGroupPublicKey recovers group public key.

func (PublicKey) Bytes

func (pub PublicKey) Bytes() []byte

Bytes returns []byte representation of public key.

func (*PublicKey) Deserialize

func (pub *PublicKey) Deserialize(b []byte) error

Deserialize parses bytes representation of public key.

func (*PublicKey) Serialize

func (pub *PublicKey) Serialize() []byte

Serialize return bytes representation of public key.

func (PublicKey) VerifySignature

func (pub PublicKey) VerifySignature(
	hash common.Hash, signature crypto.Signature) bool

VerifySignature checks that the given public key created signature over hash.

type PublicKeyShares

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

PublicKeyShares represents a public key shares for DKG protocol.

func NewEmptyPublicKeyShares

func NewEmptyPublicKeyShares() *PublicKeyShares

NewEmptyPublicKeyShares creates an empty public key shares.

func (*PublicKeyShares) AddShare

func (pubs *PublicKeyShares) AddShare(shareID ID, share *PublicKey) error

AddShare adds a share.

func (*PublicKeyShares) Clone

func (pubs *PublicKeyShares) Clone() *PublicKeyShares

Clone clones every fields of PublicKeyShares. This method is mainly for testing purpose thus would panic when error.

func (*PublicKeyShares) DecodeRLP

func (pubs *PublicKeyShares) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*PublicKeyShares) EncodeRLP

func (pubs *PublicKeyShares) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*PublicKeyShares) Equal

func (pubs *PublicKeyShares) Equal(other *PublicKeyShares) bool

Equal checks equality of two PublicKeyShares instance.

func (*PublicKeyShares) MarshalJSON

func (pubs *PublicKeyShares) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller.

func (*PublicKeyShares) MasterKeyBytes

func (pubs *PublicKeyShares) MasterKeyBytes() []byte

MasterKeyBytes returns []byte representation of master public key.

func (*PublicKeyShares) Move

func (pubs *PublicKeyShares) Move() *PublicKeyShares

Move will invalidate itself. Do not access to original reference.

func (*PublicKeyShares) RecoverPublicKey

func (pubs *PublicKeyShares) RecoverPublicKey(qualifyIDs IDs) (
	*PublicKey, error)

RecoverPublicKey recovers private key from the shares.

func (*PublicKeyShares) Share

func (pubs *PublicKeyShares) Share(ID ID) (*PublicKey, error)

Share returns the share for the ID.

func (*PublicKeyShares) UnmarshalJSON

func (pubs *PublicKeyShares) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaller.

func (*PublicKeyShares) VerifyPrvShare

func (pubs *PublicKeyShares) VerifyPrvShare(ID ID, share *PrivateKey) (
	bool, error)

VerifyPrvShare verifies if the private key shares is valid.

func (*PublicKeyShares) VerifyPubShare

func (pubs *PublicKeyShares) VerifyPubShare(ID ID, share *PublicKey) (
	bool, error)

VerifyPubShare verifies if the public key shares is valid.

Jump to

Keyboard shortcuts

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