dkg

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const ResultSignatureHashByteSize = 32

Variables

This section is empty.

Functions

func Publish

func Publish(
	ctx context.Context,
	logger log.StandardLogger,
	sessionID string,
	memberIndex group.MemberIndex,
	channel net.BroadcastChannel,
	membershipValidator *group.MembershipValidator,
	resultSigner ResultSigner,
	resultSubmitter ResultSubmitter,
	result *Result,
) error

Publish signs the DKG result for the given group member, collects signatures from other members and verifies them, and submits the DKG result.

func RegisterUnmarshallers

func RegisterUnmarshallers(channel net.BroadcastChannel)

RegisterUnmarshallers initializes the given broadcast channel to be able to perform DKG protocol interactions by registering all the required protocol message unmarshallers.

Types

type Executor

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

Executor represents an ECDSA distributed key generation process executor.

func NewExecutor

func NewExecutor(
	logger log.StandardLogger,
	scheduler *generator.Scheduler,
	persistence persistence.BasicHandle,
	preParamsPoolSize int,
	preParamsGenerationTimeout time.Duration,
	preParamsGenerationDelay time.Duration,
	preParamsGenerationConcurrency int,
	keyGenerationConcurrency int,
) *Executor

NewExecutor creates a new Executor instance.

func (*Executor) Execute

func (e *Executor) Execute(
	ctx context.Context,
	logger log.StandardLogger,
	seed *big.Int,
	sessionID string,
	memberIndex group.MemberIndex,
	groupSize int,
	dishonestThreshold int,
	excludedMembersIndexes []group.MemberIndex,
	channel net.BroadcastChannel,
	membershipValidator *group.MembershipValidator,
) (*Result, error)

Execute runs the tECDSA distributed key generation protocol, given a broadcast channel to mediate with, a block counter used for time tracking, a member index to use in the group, dishonest threshold, and block height when DKG protocol should start.

This function also supports DKG execution with a subset of the selected group by passing a non-empty excludedMembers slice holding the members that should be excluded.

func (*Executor) PreParamsCount

func (e *Executor) PreParamsCount() int

PreParamsCount returns the current count of the DKG pre-parameters.

type PersistedPreParams

type PersistedPreParams = generator.Persisted[PreParams]

PersistedPreParams is an alias for Persisted PreParams used in generator.Persistence interface implementation.

type PreParams

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

PreParams represents tECDSA DKG pre-parameters that were not yet consumed by DKG protocol execution.

func (*PreParams) Marshal

func (pp *PreParams) Marshal() ([]byte, error)

Marshal converts the PreParams to a byte array.

func (*PreParams) Unmarshal

func (pp *PreParams) Unmarshal(bytes []byte) error

Unmarshal converts a byte array back to the PreParams.

type Result

type Result struct {
	// Group represents the group state, including members, disqualified,
	// and inactive members.
	Group *group.Group
	// PrivateKeyShare is the tECDSA private key share required to operate
	// in the signing group generated as result of the DKG protocol.
	PrivateKeyShare *tecdsa.PrivateKeyShare
}

Result of distributed key generation protocol.

func (*Result) GroupPublicKey

func (r *Result) GroupPublicKey() (*ecdsa.PublicKey, error)

GroupPublicKey returns the public key corresponding to the private key share generated during the DKG protocol execution.

func (*Result) GroupPublicKeyBytes

func (r *Result) GroupPublicKeyBytes() ([]byte, error)

GroupPublicKeyBytes returns the public key corresponding to the private key share generated during the DKG protocol execution. The resulting slice has 65 bytes and starts with the 04 prefix denoting an uncompressed key.

func (*Result) MisbehavedMembersIndexes

func (r *Result) MisbehavedMembersIndexes() []group.MemberIndex

MisbehavedMembersIndexes returns the indexes of group members that misbehaved during the DKG procedure. The indexes are sorted.

type ResultSignatureHash

type ResultSignatureHash [ResultSignatureHashByteSize]byte

ResultSignatureHash is a signature hash of the DKG Result. The hashing algorithm used depends on the client code.

func ResultSignatureHashFromBytes

func ResultSignatureHashFromBytes(bytes []byte) (ResultSignatureHash, error)

ResultSignatureHashFromBytes converts bytes slice to ResultSignatureHash. It requires provided bytes slice size to be exactly ResultSignatureHashByteSize.

type ResultSigner

type ResultSigner interface {
	// SignResult signs the provided DKG result. It returns the information
	// pertaining to the signing process: public key, signature, result hash.
	SignResult(result *Result) (*SignedResult, error)
	// VerifySignature verifies if the signature was generated from the provided
	// DKG result has using the provided public key.
	VerifySignature(signedResult *SignedResult) (bool, error)
}

ResultSigner is the interface that provides ability to sign the DKG result and verify the results received from other group members.

type ResultSubmitter

type ResultSubmitter interface {
	// SubmitResult submits the DKG result along with the supporting signatures.
	SubmitResult(
		ctx context.Context,
		memberIndex group.MemberIndex,
		result *Result,
		signatures map[group.MemberIndex][]byte,
	) error
}

ResultSubmitter is the interface that provides ability to submit the DKG result to the chain.

type SignedResult

type SignedResult struct {
	PublicKey  []byte
	Signature  []byte
	ResultHash ResultSignatureHash
}

SignedResult represents information pertaining to the process of signing a DKG result: the public key used during signing, the resulting signature and the hash of the DKG result that was used during signing.

Directories

Path Synopsis
gen
pb

Jump to

Keyboard shortcuts

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