tss

package
v0.0.0-...-2da98db Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package tss provides the TSS signer functionalities for the zetaclient to sign transactions on external chains

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTssAddrBTC

func GetTssAddrBTC(tssPubkey string, bitcoinChainID int64) (string, error)

GetTssAddrBTC generates a bech32 p2wpkh address from pubkey

func GetTssAddrEVM

func GetTssAddrEVM(tssPubkey string) (ethcommon.Address, error)

GetTssAddrEVM generates an EVM address from pubkey

func IsEnvFlagEnabled

func IsEnvFlagEnabled(flag string) bool

IsEnvFlagEnabled checks if the environment flag is enabled

func SetupTSSServer

func SetupTSSServer(
	peer p2p.AddrList,
	privkey tmcrypto.PrivKey,
	preParams *keygen.LocalPreParams,
	cfg config.Config,
	tssPassword string,
	enableMonitor bool,
) (*tss.TssServer, error)

SetupTSSServer creates a new TSS server TODO(revamp): move to TSS server file

func TestKeysign

func TestKeysign(tssPubkey string, tssServer tss.TssServer) error

Types

type ConcurrentKeysignsTracker

type ConcurrentKeysignsTracker struct {
	Logger zerolog.Logger
	// contains filtered or unexported fields
}

ConcurrentKeysignsTracker keeps track of concurrent keysigns performed by go-tss

func NewKeysignsTracker

func NewKeysignsTracker(logger zerolog.Logger) *ConcurrentKeysignsTracker

NewKeysignsTracker - constructor

func (*ConcurrentKeysignsTracker) EndMsgSign

func (k *ConcurrentKeysignsTracker) EndMsgSign()

EndMsgSign is decrementing the number of active signing ceremonies as well as updating the prometheus metric

func (*ConcurrentKeysignsTracker) GetNumActiveMessageSigns

func (k *ConcurrentKeysignsTracker) GetNumActiveMessageSigns() int64

GetNumActiveMessageSigns gets the current number of active signing ceremonies

func (*ConcurrentKeysignsTracker) StartMsgSign

func (k *ConcurrentKeysignsTracker) StartMsgSign()

StartMsgSign is incrementing the number of active signing ceremonies as well as updating the prometheus metric

type Key

type Key struct {
	PubkeyInBytes  []byte
	PubkeyInBech32 string
	AddressInHex   string
}

Key is a struct that holds the public key, bech32 pubkey, and address for the TSS

func NewTSSKey

func NewTSSKey(pk string) (*Key, error)

NewTSSKey creates a new TSS key

type TSS

type TSS struct {
	Server        *tss.TssServer
	Keys          map[string]*Key // PubkeyInBech32 => TSSKey
	CurrentPubkey string

	Signers         []string
	ZetacoreClient  interfaces.ZetacoreClient
	KeysignsTracker *ConcurrentKeysignsTracker

	// TODO: support multiple Bitcoin network, not just one network
	// https://github.com/zeta-chain/node/issues/1397
	BitcoinChainID int64
	// contains filtered or unexported fields
}

TSS is a struct that holds the server and the keys for TSS

func NewTSS

func NewTSS(
	ctx context.Context,
	client interfaces.ZetacoreClient,
	tssHistoricalList []observertypes.TSS,
	bitcoinChainID int64,
	hotkeyPassword string,
	tssServer *tss.TssServer,
) (*TSS, error)

NewTSS creates a new TSS instance which can be used to sign transactions

func (*TSS) BTCAddress

func (tss *TSS) BTCAddress() string

BTCAddress generates a bech32 p2wpkh address from pubkey

func (*TSS) BTCAddressWitnessPubkeyHash

func (tss *TSS) BTCAddressWitnessPubkeyHash() *btcutil.AddressWitnessPubKeyHash

BTCAddressWitnessPubkeyHash generates a bech32 p2wpkh address from pubkey

func (*TSS) EVMAddress

func (tss *TSS) EVMAddress() ethcommon.Address

EVMAddress generates an EVM address from pubkey

func (*TSS) EVMAddressList

func (tss *TSS) EVMAddressList() []ethcommon.Address

func (*TSS) InsertPubKey

func (tss *TSS) InsertPubKey(pk string) error

InsertPubKey adds a new key to the TSS keys map

func (*TSS) LoadTssFilesFromDirectory

func (tss *TSS) LoadTssFilesFromDirectory(tssPath string) error

LoadTssFilesFromDirectory loads the TSS files at the directory specified by the `tssPath`

func (*TSS) PubKeyCompressedBytes

func (tss *TSS) PubKeyCompressedBytes() []byte

PubKeyCompressedBytes returns the compressed bytes of the current pubkey

func (*TSS) Pubkey

func (tss *TSS) Pubkey() []byte

Pubkey returns the current pubkey

func (*TSS) Sign

func (tss *TSS) Sign(
	ctx context.Context,
	digest []byte,
	height uint64,
	nonce uint64,
	chainID int64,
	optionalPubKey string,
) ([65]byte, error)

Sign signs a digest digest should be Hashes of some data NOTE: Specify optionalPubkey to use a different pubkey than the current pubkey set during keygen

func (*TSS) SignBatch

func (tss *TSS) SignBatch(
	ctx context.Context,
	digests [][]byte,
	height uint64,
	nonce uint64,
	chainID int64,
) ([][65]byte, error)

SignBatch is hash of some data digest should be batch of hashes of some data

func (*TSS) Validate

func (tss *TSS) Validate() error

Validate validates the TSS

func (*TSS) VerifyKeysharesForPubkeys

func (tss *TSS) VerifyKeysharesForPubkeys(tssList []observertypes.TSS, granteePubKey32 string) error

VerifyKeysharesForPubkeys verifies the keyshares present on the node. It checks whether the node has TSS key shares for the TSS ceremonies it was part of.

Jump to

Keyboard shortcuts

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