tss

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 26 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 represents the amount of time before we give up trying to communicate key generation
	KeyGenerationProtocolTimeout = 8 * time.Minute
	// SigningProtocolTimeout represents the amount of time before we give up trying to communicate signing
	SigningProtocolTimeout = 10 * time.Minute
)

Variables

This section is empty.

Functions

func BroadcastRecoveryAddress added in v1.8.0

func BroadcastRecoveryAddress(
	parentCtx context.Context,
	btcRecoveryAddress string,
	maxFeePerVByte int32,
	groupID string,
	memberID MemberID,
	groupMemberIDs []MemberID,
	dishonestThreshold uint,
	networkProvider net.Provider,
	pubKeyToAddressFn func(cecdsa.PublicKey) []byte,
	chainParams *chaincfg.Params,
) ([]string, int32, error)

BroadcastRecoveryAddress broadcasts and receives the BTC recovery addresses of each client so that each client can retrieve the underlying bitcoin in the case that a keep is terminated.

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)

RegisterUnmarshalers is a boilerplate method to register unmarshaling on a broadcast channel

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 LiquidationRecoveryAnnounceMessage added in v1.8.0

type LiquidationRecoveryAnnounceMessage struct {
	SenderID           MemberID
	BtcRecoveryAddress string
	MaxFeePerVByte     int32
}

LiquidationRecoveryAnnounceMessage is a network message used announce a BTC recovery address to other signers on a group

func (*LiquidationRecoveryAnnounceMessage) Marshal added in v1.8.0

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

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

func (*LiquidationRecoveryAnnounceMessage) Type added in v1.8.0

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

func (*LiquidationRecoveryAnnounceMessage) Unmarshal added in v1.8.0

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

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

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,
	keepID chain.ID,
	keepMemberIDs []chain.ID,
	broadcastChannel net.BroadcastChannel,
	publicKeyToOperatorIDFunc func(*cecdsa.PublicKey) chain.ID,
) (
	[]MemberID,
	error,
)

AnnounceProtocol announces a client to the other clients in the keep network

func MemberIDFromPublicKey

func MemberIDFromPublicKey(publicKey *operator.PublicKey) MemberID

MemberIDFromPublicKey creates a MemberID from a public key.

func MemberIDFromString

func MemberIDFromString(string string) (MemberID, error)

MemberIDFromString 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 ProtocolMessage added in v1.8.0

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

ProtocolMessage 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 (*ProtocolMessage) Marshal added in v1.8.0

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

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

func (*ProtocolMessage) Type added in v1.8.0

func (m *ProtocolMessage) Type() string

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

func (*ProtocolMessage) Unmarshal added in v1.8.0

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

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

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 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() *cecdsa.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