tss

package
v0.0.0-...-e3655fb Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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 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 "negative 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.

Types

type KeygenRequest

type KeygenRequest struct {
	LocalPartyID string
	AllParties   string
	ChainCodeHex string // hex encoded chain code
}

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 message that need to be signed
	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"`
	R            string `json:"r"`
	S            string `json:"s"`
	DerSignature string `json:"der_signature"`
	RecoveryID   string `json:"recovery_id"` // mostly used in ETH
}

type LocalState

type LocalState struct {
	PubKey              string                         `json:"pub_key"`
	ECDSALocalData      keygen.LocalPartySaveData      `json:"ecdsa_local_data"`
	EDDSALocalData      eddsaKeygen.LocalPartySaveData `json:"eddsa_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"`
}

LocalState represent the information that will be saved locally

type LocalStateAccessor

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

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 ReshareRequest

type ReshareRequest struct {
	PubKey           string `json:"pub_key"`
	LocalPartyID     string `json:"local_party_id"`
	NewParties       string `json:"all_parties"`
	ChainCodeHex     string `json:"chain_code_hex"`
	OldParties       string `json:"old_parties"`
	ResharePrefix    string `json:"reshare_prefix"`
	NewResharePrefix string `json:"new_reshare_prefix"`
}

ReshareRequest is used to request a reshare

func (ReshareRequest) GetNewParties

func (r ReshareRequest) GetNewParties() []string

func (ReshareRequest) GetOldParties

func (r ReshareRequest) GetOldParties() []string

type ReshareResponse

type ReshareResponse struct {
	PubKey        string `json:"pub_key"`
	ResharePrefix string `json:"reshare_prefix"`
}

type Service

type Service interface {
	// KeygenECDSA generates a new ECDSA keypair
	KeygenECDSA(req *KeygenRequest) (*KeygenResponse, error)
	// KeygenEDDSA generates a new EDDSA keypair
	KeygenEdDSA(req *KeygenRequest) (*KeygenResponse, error)
	// KeysignECDSA signs a message using ECDSA
	KeysignECDSA(req *KeysignRequest) (*KeysignResponse, error)
	// KeysignEDDSA signs a message using EDDSA
	KeysignEdDSA(req *KeysignRequest) (*KeysignResponse, error)
	// ApplyData applies the keygen data to the service
	ApplyData(string) error
}

type ServiceImpl

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

func NewService

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

NewService returns a new instance of the TSS service

func (*ServiceImpl) ApplyData

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

ApplyData accept the data from other peers , usually the communication is coordinate by the library user

func (*ServiceImpl) KeygenECDSA

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

func (*ServiceImpl) KeygenEdDSA

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

func (*ServiceImpl) KeysignECDSA

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

func (*ServiceImpl) KeysignEdDSA

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

func (*ServiceImpl) ReshareECDSA

func (s *ServiceImpl) ReshareECDSA(req *ReshareRequest) (*ReshareResponse, error)

func (*ServiceImpl) ResharingEdDSA

func (s *ServiceImpl) ResharingEdDSA(req *ReshareRequest) (*ReshareResponse, error)

Jump to

Keyboard shortcuts

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