tss

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const MaxUint32 = ^uint32(0)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(encryptedData, key string) (string, error)

func AesEncrypt

func AesEncrypt(data, key string) (string, error)

func ClearSessionLog

func ClearSessionLog(session string)

func Contains

func Contains(s []string, searchterm string) bool

Contains checks if a given string slice contains a specific search term. It iterates through the slice and returns true if the search term is found, false otherwise.

func ConvertPubKeyToBTCAddress

func ConvertPubKeyToBTCAddress(pubKeyCompressed, mainnetORtestnet3 string) (string, error)

func DecodeAddress

func DecodeAddress(address string) (string, error)

func DisableLogs

func DisableLogs()

func DiscoverPeer

func DiscoverPeer(id, pubkey, localIP, remoteIP, port, timeout string) (string, error)

func EciesDecrypt

func EciesDecrypt(encryptedData, privateKeyHex string) (string, error)

func EciesEncrypt

func EciesEncrypt(data, publicKeyHex string) (string, error)

func FetchData

func FetchData(url, decKey, data string) (string, error)

func FetchUTXODetails

func FetchUTXODetails(txID string, vout uint32) (*wire.TxOut, bool, error)

func GenerateKeyPair

func GenerateKeyPair() (string, error)

func GetDERSignature

func GetDERSignature(r, s *big.Int) ([]byte, error)

func GetDerivePathBytes

func GetDerivePathBytes(derivePath string) ([]uint32, error)

func GetDerivedPubKey

func GetDerivedPubKey(hexPubKey, hexChainCode, path string, isEdDSA bool) (string, error)

func GetHexEncodedPubKey

func GetHexEncodedPubKey(pubKey *tcrypto.ECPoint) (string, error)

GetHexEncodedPubKey returns the hexadecimal encoded string representation of an ECDSA/EDDSA public key. It takes a pointer to an ECPoint as input and returns the encoded string and an error. If the ECPoint is nil, it returns an empty string and an error indicating a nil ECPoint. If the ECPoint is not on the curve, it returns an empty string and an error indicating an invalid ECPoint.

func GetNetwork

func GetNetwork() (string, error)

func GetThreshold

func GetThreshold(value int) (int, error)

GetThreshold calculates the threshold value based on the input value. It takes an integer value as input and returns the threshold value and an error. If the input value is negative, it returns an error with the message "invalid input".

func HashToInt

func HashToInt(hash []byte, c elliptic.Curve) *big.Int

HashToInt converts a byte slice hash to a big.Int value using the provided elliptic curve. If the length of the hash is greater than the orderBytes of the curve, it truncates the hash. It then performs a right shift on the resulting big.Int value to ensure it fits within the orderBits of the curve. The converted big.Int value is returned.

func Hook

func Hook(message string)

func InitLog

func InitLog()

func JoinKeygen

func JoinKeygen(ppmPath, key, partiesCSV, encKey, decKey, session, server, chaincode, sessionKey string) (string, error)

func JoinKeysign

func JoinKeysign(server, key, partiesCSV, session, sessionKey, encKey, decKey, keyshare, derivePath, message string) (string, error)

func ListenForPeer

func ListenForPeer(id, pubkey, port, timeout string) (string, error)

func LocalPreParams

func LocalPreParams(ppmFile string, timeoutMinutes int) (bool, error)

func Logf

func Logf(format string, v ...any)

Logf function: formats message and logs it

func Logln

func Logln(v ...any)

Logln: Logs a message like fmt.Println

func MpcSendBTC

func MpcSendBTC(

	server, key, partiesCSV, session, sessionKey, encKey, decKey, keyshare, derivePath,

	publicKey, senderAddress, receiverAddress string, amountSatoshi, estimatedFee int64) (string, error)

func PostTx

func PostTx(rawTxHex string) (string, error)

func PreParams

func PreParams(ppmFile string) (*ecdsaKeygen.LocalPreParams, error)

func PublishData

func PublishData(port, timeout, enckey, data string) (string, error)

func RecommendedFees

func RecommendedFees(feeType string) (int, error)

func RunRelay

func RunRelay(port string) (string, error)

func SecP256k1Recover

func SecP256k1Recover(r, s, v, h string) (string, error)

func SendBitcoin

func SendBitcoin(wifKey, publicKey, senderAddress, receiverAddress string, preview, amountSatoshi int64) (string, error)

func SessionLog

func SessionLog(session string) string

func SessionState

func SessionState(session string) string

func SetEventListener

func SetEventListener(l GoLogListener)

SetEventListener sets the listener for UTXO events

func SetHookListener

func SetHookListener(h HookListener)

func SetNetwork

func SetNetwork(network string) (string, error)

func Sha256

func Sha256(msg string) (string, error)

func StopRelay

func StopRelay() (string, error)

func TotalUTXO

func TotalUTXO(address string) (string, error)

func UseAPI

func UseAPI(network, base string) (string, error)

func UseFeePolicy

func UseFeePolicy(feeType string) (string, error)

Types

type FeeResponse

type FeeResponse struct {
	FastestFee  int `json:"fastestFee"`
	HalfHourFee int `json:"halfHourFee"`
	HourFee     int `json:"hourFee"`
	EconomyFee  int `json:"economyFee"`
	MinimumFee  int `json:"minimumFee"`
}

type GoLogListener

type GoLogListener interface {
	OnGoLog(message string)
}

type HookListener

type HookListener interface {
	OnMessage(message string)
}

type KeygenRequest

type KeygenRequest struct {
	LocalPartyID string
	AllParties   string
	ChainCodeHex string
}

func (KeygenRequest) GetAllParties

func (r KeygenRequest) GetAllParties() []string

type KeygenResponse

type KeygenResponse struct {
	PubKey string `json:"pub_key"`
}

type KeysignRequest

type KeysignRequest struct {
	PubKey               string `json:"pub_key"`
	MessageToSign        string `json:"message_to_sign"` // base64 encoded
	KeysignCommitteeKeys string `json:"keysign_committee_keys"`
	LocalPartyKey        string `json:"local_party_key"`
	DerivePath           string `json:"derive_path"`
}

func (KeysignRequest) GetKeysignCommitteeKeys

func (r KeysignRequest) GetKeysignCommitteeKeys() []string

type KeysignResponse

type KeysignResponse struct {
	Msg          string `json:"msg"`
	MsgHex       string `json:"msg_hex"`
	R            string `json:"r"`
	S            string `json:"s"`
	DerSignature string `json:"der_signature"`
	RecoveryID   string `json:"recovery_id"`
}

type LocalState

type LocalState struct {
	PubKey              string                         `json:"pub_key"`
	ECDSALocalData      ecdsaKeygen.LocalPartySaveData `json:"ecdsa_local_data"`
	KeygenCommitteeKeys []string                       `json:"keygen_committee_keys"`
	LocalPartyKey       string                         `json:"local_party_key"`
	ChainCodeHex        string                         `json:"chain_code_hex"`
	ResharePrefix       string                         `json:"reshare_prefix"`
}

type LocalStateAccessor

type LocalStateAccessor interface {
	GetLocalState(pubKey string) (string, error)
	SaveLocalState(pubkey, localState string) error
}

type LocalStateAccessorImp

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

func (*LocalStateAccessorImp) GetLocalState

func (l *LocalStateAccessorImp) GetLocalState(keyshare string) (string, error)

func (*LocalStateAccessorImp) SaveLocalState

func (l *LocalStateAccessorImp) SaveLocalState(pubKey, localState string) error

type Message

type Message struct {
	SessionID string   `json:"session_id,omitempty"`
	From      string   `json:"from,omitempty"`
	To        []string `json:"to,omitempty"`
	Body      string   `json:"body,omitempty"`
	SeqNo     string   `json:"sequence_no,omitempty"`
	Hash      string   `json:"hash,omitempty"`
}

Message structure

type MessageFromTss

type MessageFromTss struct {
	WireBytes   []byte `json:"wire_bytes"`
	From        string `json:"from"`
	To          string `json:"to"`
	IsBroadcast bool   `json:"is_broadcast"`
}

type Messenger

type Messenger interface {
	Send(from, to, body string) error
}

type MessengerImp

type MessengerImp struct {
	Server     string
	SessionID  string
	SessionKey string
	Mutex      sync.Mutex
}

func (*MessengerImp) Send

func (m *MessengerImp) Send(from, to, body string) error

type Service

type Service interface {
	KeygenECDSA(req *KeygenRequest) (*KeygenResponse, error)
	KeysignECDSA(req *KeysignRequest) (*KeysignResponse, error)
	ApplyData(string) error
}

type ServiceImpl

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

func NewService

func NewService(msg Messenger, stateAccessor LocalStateAccessor, createPreParam bool, ppmFile string) (*ServiceImpl, error)

func (*ServiceImpl) ApplyData

func (s *ServiceImpl) ApplyData(msg string) error

func (*ServiceImpl) KeygenECDSA

func (s *ServiceImpl) KeygenECDSA(req *KeygenRequest) (*KeygenResponse, error)

func (*ServiceImpl) KeysignECDSA

func (s *ServiceImpl) KeysignECDSA(req *KeysignRequest) (*KeysignResponse, error)

type Session

type Session struct {
	SessionID    string   `json:"sessionID"`
	Participants []string `json:"participants"`
}

Session structure

type Status

type Status struct {
	Step  int
	SeqNo int
	Index int
	Info  string
	Type  string
	Done  bool
	Time  int
}

type UTXO

type UTXO struct {
	TxID  string `json:"txid"`
	Vout  uint32 `json:"vout"`
	Value int64  `json:"value"` // Value in satoshis
}

UTXO represents an unspent transaction output

func FetchUTXOs

func FetchUTXOs(address string) ([]UTXO, error)

FetchUTXOs fetches UTXOs for a given address

func SelectUTXOs

func SelectUTXOs(utxos []UTXO, totalAmount int64, strategy string) ([]UTXO, int64, error)

SelectUTXOs selects the optimal set of UTXOs based on the strategy

Jump to

Keyboard shortcuts

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