dkg

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 16 Imported by: 3

Documentation

Overview

Package dkg implements the protocol described in "A threshold cryptosystem without a trusted party" by Torben Pryds Pedersen. https://dl.acm.org/citation.cfm?id=1754929.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDupPubKey          = errors.New("duplicated share public key")
	ErrDupPubKeyIndex     = errors.New("duplicated public key index")
	ErrCanNotFindID       = errors.New("can't find id in group IDs")
	ErrCasting            = errors.New("casting failed")
	ErrRespNotApproval    = errors.New("response not approval")
	ErrNotCertified       = errors.New("not certified")
	ErrCanNotLoadSec      = errors.New("can't load sec")
	ErrCanNotLoadGroup    = errors.New("can't load group")
	ErrResponseNoApproval = errors.New("response no approval")
	ErrDKGNotCertified    = errors.New("dkg is not certified")
)

Functions

This section is empty.

Types

type DKGError

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

func (*DKGError) Error

func (e *DKGError) Error() string

func (*DKGError) Format

func (e *DKGError) Format(f fmt.State, c rune)

func (*DKGError) FormatError

func (e *DKGError) FormatError(p errors.Printer) error

func (*DKGError) Unwrap

func (e *DKGError) Unwrap() error

type Deal

type Deal struct {
	SessionId            string                  `protobuf:"bytes,1,opt,name=sessionId,proto3" json:"sessionId,omitempty"`
	Index                uint32                  `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
	Deal                 *pedersen.EncryptedDeal `protobuf:"bytes,3,opt,name=deal,proto3" json:"deal,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
	XXX_unrecognized     []byte                  `json:"-"`
	XXX_sizecache        int32                   `json:"-"`
}

func (*Deal) Descriptor

func (*Deal) Descriptor() ([]byte, []int)

func (*Deal) GetDeal

func (m *Deal) GetDeal() *pedersen.EncryptedDeal

func (*Deal) GetIndex

func (m *Deal) GetIndex() uint32

func (*Deal) GetSessionId

func (m *Deal) GetSessionId() string

func (*Deal) ProtoMessage

func (*Deal) ProtoMessage()

func (*Deal) Reset

func (m *Deal) Reset()

func (*Deal) String

func (m *Deal) String() string

func (*Deal) XXX_DiscardUnknown

func (m *Deal) XXX_DiscardUnknown()

func (*Deal) XXX_Marshal

func (m *Deal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Deal) XXX_Merge

func (dst *Deal) XXX_Merge(src proto.Message)

func (*Deal) XXX_Size

func (m *Deal) XXX_Size() int

func (*Deal) XXX_Unmarshal

func (m *Deal) XXX_Unmarshal(b []byte) error

type DistKeyGenerator

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

DistKeyGenerator is the struct that runs the DKG protocol.

func NewDistKeyGenerator

func NewDistKeyGenerator(suite Suite, longterm kyber.Scalar, participants []kyber.Point, t int) (*DistKeyGenerator, error)

NewDistKeyGenerator returns a DistKeyGenerator out of the suite, the longterm secret key, the list of participants, the threshold t parameter and a given secret. It returns an error if the secret key's commitment can't be found in the list of participants.

func NewDistKeyGeneratorWithoutSecret

func NewDistKeyGeneratorWithoutSecret(suite Suite, longterm kyber.Scalar, participants []kyber.Point, t int) (*DistKeyGenerator, error)

NewDistKeyGeneratorWithoutSecret simply returns a DistKeyGenerator with an nil secret. It is used to renew the private shares without affecting the secret.

func (*DistKeyGenerator) Certified

func (d *DistKeyGenerator) Certified() bool

Certified returns true if at least t deals are certified (see vss.Verifier.DealCertified()). If the distribution is certified, the protocol can continue using d.SecretCommits().

func (*DistKeyGenerator) Deals

func (d *DistKeyGenerator) Deals() (map[int]*Deal, error)

Deals returns all the deals that must be broadcasted to all participants. The deal corresponding to this DKG is already added to this DKG and is omitted from the returned map. To know which participant a deal belongs to, loop over the keys as indices in the list of participants:

for i,dd := range distDeals {
   sendTo(participants[i],dd)
}

If this method cannot process its own Deal, that indicates a sever problem with the configuration or implementation and results in a panic.

func (*DistKeyGenerator) DistKeyShare

func (d *DistKeyGenerator) DistKeyShare() (*DistKeyShare, error)

DistKeyShare generates the distributed key relative to this receiver. It throws an error if something is wrong such as not enough deals received. The shared secret can be computed when all deals have been sent and basically consists of a public point and a share. The public point is the sum of all aggregated individual public commits of each individual secrets. the share is evaluated from the global Private Polynomial, basically SUM of fj(i) for a receiver i.

func (*DistKeyGenerator) ProcessDeal

func (d *DistKeyGenerator) ProcessDeal(dd *Deal) (*Response, error)

ProcessDeal takes a Deal created by Deals() and stores and verifies it. It returns a Response to broadcast to every other participant. It returns an error in case the deal has already been stored, or if the deal is incorrect (see vss.Verifier.ProcessEncryptedDeal).

func (*DistKeyGenerator) ProcessJustification

func (d *DistKeyGenerator) ProcessJustification(j *Justification) error

ProcessJustification takes a justification and validates it. It returns an error in case the justification is wrong.

func (*DistKeyGenerator) ProcessResponse

func (d *DistKeyGenerator) ProcessResponse(resp *Response) (*Justification, error)

ProcessResponse takes a response from every other peer. If the response designates the deal of another participant than this dkg, this dkg stores it and returns nil with a possible error regarding the validity of the response. If the response designates a deal this dkg has issued, then the dkg will process the response, and returns a justification.

func (*DistKeyGenerator) QUAL

func (d *DistKeyGenerator) QUAL() []int

QUAL returns the index in the list of participants that forms the QUALIFIED set as described in the "New-DKG" protocol by Rabin. Basically, it consists of all participants that are not disqualified after having exchanged all deals, responses and justification. This is the set that is used to extract the distributed public key with SecretCommits() and ProcessSecretCommits().

func (*DistKeyGenerator) SetTimeout

func (d *DistKeyGenerator) SetTimeout()

SetTimeout triggers the timeout on all verifiers, and thus makes sure all verifiers have either responded, or have a StatusComplaint response.

type DistKeyShare

type DistKeyShare struct {
	// Coefficients of the public polynomial holding the public key.
	Commits []kyber.Point
	// Share of the distributed secret which is private information.
	Share *share.PriShare
	// Coefficients of the private polynomial generated by the node holding the
	// share. The final distributed polynomial is the sum of all these
	// individual polynomials, but it is never computed.
	PrivatePoly []kyber.Scalar
}

DistKeyShare holds the share of a distributed key for a participant.

func (*DistKeyShare) Commitments

func (d *DistKeyShare) Commitments() []kyber.Point

Commitments implements the dss.DistKeyShare interface so either pedersen or rabin dkg can be used with dss.

func (*DistKeyShare) PriShare

func (d *DistKeyShare) PriShare() *share.PriShare

PriShare implements the dss.DistKeyShare interface so either pedersen or rabin dkg can be used with dss.

func (*DistKeyShare) Public

func (d *DistKeyShare) Public() kyber.Point

Public returns the public key associated with the distributed private key.

func (*DistKeyShare) Renew

func (d *DistKeyShare) Renew(suite Suite, g *DistKeyShare) (*DistKeyShare, error)

Renew adds the new distributed key share g (with secret 0) to the distributed key share d.

type Justification

type Justification struct {
	// Index of the Dealer who answered with this Justification
	Index uint32
	// Justification issued from the Dealer
	Justification *vss.Justification
}

Justification holds the Justification from a Dealer as well as the index of the Dealer in question.

type PDKGInterface

type PDKGInterface interface {
	Loop()
	GetGroupPublicPoly(groupId string) *share.PubPoly
	GetShareSecurity(groupId string) *share.PriShare
	GetGroupIDs(groupId string) [][]byte
	GetGroupNumber() int
	Grouping(ctx context.Context, groupId string, Participants [][]byte) (chan [5]*big.Int, chan error, error)
	GroupDissolve(groupId string)
}

PDKGInterface is a interface for DKG

func NewPDKG

func NewPDKG(p p2p.P2PInterface, suite suites.Suite) PDKGInterface

NewPDKG creates a pdkg struct

type PublicKey

type PublicKey struct {
	SessionId            string              `protobuf:"bytes,1,opt,name=sessionId,proto3" json:"sessionId,omitempty"`
	Index                uint32              `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
	Publickey            *pedersen.PublicKey `protobuf:"bytes,3,opt,name=publickey,proto3" json:"publickey,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

func (*PublicKey) Descriptor

func (*PublicKey) Descriptor() ([]byte, []int)

func (*PublicKey) GetIndex

func (m *PublicKey) GetIndex() uint32

func (*PublicKey) GetPublickey

func (m *PublicKey) GetPublickey() *pedersen.PublicKey

func (*PublicKey) GetSessionId

func (m *PublicKey) GetSessionId() string

func (*PublicKey) ProtoMessage

func (*PublicKey) ProtoMessage()

func (*PublicKey) Reset

func (m *PublicKey) Reset()

func (*PublicKey) String

func (m *PublicKey) String() string

func (*PublicKey) XXX_DiscardUnknown

func (m *PublicKey) XXX_DiscardUnknown()

func (*PublicKey) XXX_Marshal

func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PublicKey) XXX_Merge

func (dst *PublicKey) XXX_Merge(src proto.Message)

func (*PublicKey) XXX_Size

func (m *PublicKey) XXX_Size() int

func (*PublicKey) XXX_Unmarshal

func (m *PublicKey) XXX_Unmarshal(b []byte) error

type Response

type Response struct {
	SessionId            string             `protobuf:"bytes,1,opt,name=sessionId,proto3" json:"sessionId,omitempty"`
	Index                uint32             `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
	Response             *pedersen.Response `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"`
	XXX_NoUnkeyedLiteral struct{}           `json:"-"`
	XXX_unrecognized     []byte             `json:"-"`
	XXX_sizecache        int32              `json:"-"`
}

func (*Response) Descriptor

func (*Response) Descriptor() ([]byte, []int)

func (*Response) GetIndex

func (m *Response) GetIndex() uint32

func (*Response) GetResponse

func (m *Response) GetResponse() *pedersen.Response

func (*Response) GetSessionId

func (m *Response) GetSessionId() string

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) Reset

func (m *Response) Reset()

func (*Response) String

func (m *Response) String() string

func (*Response) XXX_DiscardUnknown

func (m *Response) XXX_DiscardUnknown()

func (*Response) XXX_Marshal

func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Response) XXX_Merge

func (dst *Response) XXX_Merge(src proto.Message)

func (*Response) XXX_Size

func (m *Response) XXX_Size() int

func (*Response) XXX_Unmarshal

func (m *Response) XXX_Unmarshal(b []byte) error

type Responses

type Responses struct {
	SessionId            string      `protobuf:"bytes,1,opt,name=sessionId,proto3" json:"sessionId,omitempty"`
	Response             []*Response `protobuf:"bytes,2,rep,name=response,proto3" json:"response,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

func (*Responses) Descriptor

func (*Responses) Descriptor() ([]byte, []int)

func (*Responses) GetResponse

func (m *Responses) GetResponse() []*Response

func (*Responses) GetSessionId

func (m *Responses) GetSessionId() string

func (*Responses) ProtoMessage

func (*Responses) ProtoMessage()

func (*Responses) Reset

func (m *Responses) Reset()

func (*Responses) String

func (m *Responses) String() string

func (*Responses) XXX_DiscardUnknown

func (m *Responses) XXX_DiscardUnknown()

func (*Responses) XXX_Marshal

func (m *Responses) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Responses) XXX_Merge

func (dst *Responses) XXX_Merge(src proto.Message)

func (*Responses) XXX_Size

func (m *Responses) XXX_Size() int

func (*Responses) XXX_Unmarshal

func (m *Responses) XXX_Unmarshal(b []byte) error

type Suite

type Suite suites.Suite

Suite wraps the functionalities needed by the dkg package

Jump to

Keyboard shortcuts

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