tss

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package tss contains implementation of Threshold Multi-Party ECDSA Signature Scheme. This package uses [tss-lib] protocol implementation based on [GG19].

[tss-lib]: https://github.com/binance-chain/tss-lib. [GG19]: Fast Multiparty Threshold ECDSA with Fast Trustless Setup, Rosario Gennaro and Steven Goldfeder, 2019, https://eprint.iacr.org/2019/114.pdf.

Index

Constants

View Source
const (
	KeyGenerationProtocolTimeout = 8 * time.Minute
	SigningProtocolTimeout       = 10 * time.Minute
)

Variables

This section is empty.

Functions

func GenerateTSSPreParams

func GenerateTSSPreParams(
	preParamsGenerationTimeout time.Duration,
) (*keygen.LocalPreParams, error)

GenerateTSSPreParams calculates parameters required by TSS key generation. It times out after defined period if the required parameters could not be generated. It is possible to generate the parameters way ahead of the TSS protocol execution.

func RegisterUnmarshalers

func RegisterUnmarshalers(broadcastChannel net.BroadcastChannel)

Types

type AnnounceMessage

type AnnounceMessage struct {
	SenderID MemberID
}

AnnounceMessage is a network message used to announce peer's presence.

func (*AnnounceMessage) Marshal

func (m *AnnounceMessage) Marshal() ([]byte, error)

Marshal converts this message to a byte array suitable for network communication.

func (*AnnounceMessage) Type

func (m *AnnounceMessage) Type() string

Type returns a string type of the `AnnounceMessage`.

func (*AnnounceMessage) Unmarshal

func (m *AnnounceMessage) Unmarshal(bytes []byte) error

Unmarshal converts a byte array produced by Marshal to a message.

type Config

type Config struct {
	// Timeout for pre-parameters generation in tss-lib.
	PreParamsGenerationTimeout configtime.Duration

	// Target size of the TSS pre params pool.
	PreParamsTargetPoolSize int
}

Config contains configuration for tss protocol execution.

func (*Config) GetPreParamsGenerationTimeout added in v1.2.0

func (c *Config) GetPreParamsGenerationTimeout() time.Duration

GetPreParamsGenerationTimeout returns pre-parameters generation timeout. If a value is not set it returns a default value.

func (*Config) GetPreParamsTargetPoolSize added in v1.6.0

func (c *Config) GetPreParamsTargetPoolSize() int

GetPreParamsTargetPoolSize returns the pre-parameters target pool size. If a value is not set it returns a default value.

type MemberID

type MemberID []byte

MemberID is an unique identifier of a member across the network.

func AnnounceProtocol

func AnnounceProtocol(
	parentCtx context.Context,
	publicKey *operator.PublicKey,
	keepAddress string,
	keepMemberAddresses []string,
	broadcastChannel net.BroadcastChannel,
	publicKeyToAddressFn func(cecdsa.PublicKey) []byte,
) (
	[]MemberID,
	error,
)

func MemberIDFromPublicKey

func MemberIDFromPublicKey(publicKey *operator.PublicKey) MemberID

MemberIDFromPublicKey creates a MemberID from a public key.

func MemberIDFromString

func MemberIDFromString(string string) (MemberID, error)

MemberIDFromPublicKey creates a MemberID from a string.

func (MemberID) Equal

func (id MemberID) Equal(memberID MemberID) bool

Equal checks if member IDs are equal.

func (MemberID) PublicKey

func (id MemberID) PublicKey() (*operator.PublicKey, error)

PublicKey returns the MemberID as a public key.

func (MemberID) String

func (id MemberID) String() string

String converts MemberID to string.

type ReadyMessage

type ReadyMessage struct {
	SenderID MemberID
}

ReadyMessage is a network message used to notify peer members about readiness to start protocol execution.

func (*ReadyMessage) Marshal

func (m *ReadyMessage) Marshal() ([]byte, error)

Marshal converts this message to a byte array suitable for network communication.

func (*ReadyMessage) Type

func (m *ReadyMessage) Type() string

Type returns a string type of the `ReadyMessage`.

func (*ReadyMessage) Unmarshal

func (m *ReadyMessage) Unmarshal(bytes []byte) error

Unmarshal converts a byte array produced by Marshal to a message.

type TSSProtocolMessage

type TSSProtocolMessage struct {
	SenderID    MemberID
	Payload     []byte
	IsBroadcast bool
	SessionID   string
}

TSSProtocolMessage is a network message used to transport messages generated in TSS protocol execution. It is a wrapper over a message generated by underlying implementation of the protocol.

func (*TSSProtocolMessage) Marshal

func (m *TSSProtocolMessage) Marshal() ([]byte, error)

Marshal converts this message to a byte array suitable for network communication.

func (*TSSProtocolMessage) Type

func (m *TSSProtocolMessage) Type() string

Type returns a string type of the `TSSMessage` so that it conforms to `net.Message` interface.

func (*TSSProtocolMessage) Unmarshal

func (m *TSSProtocolMessage) Unmarshal(bytes []byte) error

Unmarshal converts a byte array produced by Marshal to a message.

type ThresholdKey

type ThresholdKey keygen.LocalPartySaveData

ThresholdKey contains data of signer's threshold key.

func (*ThresholdKey) Marshal

func (tk *ThresholdKey) Marshal() ([]byte, error)

Marshal converts thresholdKey to byte array.

func (*ThresholdKey) Unmarshal

func (tk *ThresholdKey) Unmarshal(bytes []byte) error

Unmarshal converts a byte array back to thresholdKey.

type ThresholdSigner

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

ThresholdSigner is a threshold signer who completed key generation stage.

func GenerateThresholdSigner

func GenerateThresholdSigner(
	parentCtx context.Context,
	groupID string,
	memberID MemberID,
	groupMemberIDs []MemberID,
	dishonestThreshold uint,
	networkProvider net.Provider,
	pubKeyToAddressFn func(cecdsa.PublicKey) []byte,
	paramsBox *params.Box,
) (*ThresholdSigner, error)

GenerateThresholdSigner executes a threshold multi-party key generation protocol.

It expects unique identifiers of the current member as well as identifiers of all members of the signing group. Group ID should be unique for each concurrent execution.

Dishonest threshold `t` defines a maximum number of signers controlled by the adversary such that the adversary still cannot produce a signature. Any subset of `t + 1` players can jointly sign, but any smaller subset cannot.

TSS protocol requires pre-parameters such as safe primes to be generated for execution. The parameters should be generated prior to running this function. If not provided they will be generated.

As a result a signer will be returned or an error, if key generation failed.

func (*ThresholdSigner) CalculateSignature

func (s *ThresholdSigner) CalculateSignature(
	parentCtx context.Context,
	digest []byte,
	networkProvider net.Provider,
	pubKeyToAddressFn func(cecdsa.PublicKey) []byte,
) (*ecdsa.Signature, error)

CalculateSignature executes a threshold multi-party signature calculation protocol for the given digest. As a result the calculated ECDSA signature will be returned or an error, if the signature generation failed.

func (*ThresholdSigner) GroupID

func (s *ThresholdSigner) GroupID() string

GroupID return signing group unique identifer.

func (*ThresholdSigner) Marshal

func (s *ThresholdSigner) Marshal() ([]byte, error)

Marshal converts ThresholdSigner to byte array.

func (*ThresholdSigner) MemberID

func (s *ThresholdSigner) MemberID() MemberID

MemberID returns member's unique identifer.

func (*ThresholdSigner) PublicKey

func (s *ThresholdSigner) PublicKey() *ecdsa.PublicKey

PublicKey returns signer's ECDSA public key which is also the signing group's public key.

func (*ThresholdSigner) Unmarshal

func (s *ThresholdSigner) Unmarshal(bytes []byte) error

Unmarshal converts a byte array back to ThresholdSigner.

Directories

Path Synopsis
gen
pb

Jump to

Keyboard shortcuts

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