tss

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughPeers = errors.New("not enough input peers, need at least 2")
	ErrAbsentCurve    = errors.New("curve is nil")
	ErrPubKeyMismatch = errors.New("pubkey derived from recovered privkey is not equal to pubkey provided")
)
View Source
var (
	// ErrConversion for big int conversion error
	ErrConversion = errors.New("conversion error")
)

Functions

func AdderGenericHandle added in v1.2.0

func AdderGenericHandle(msg *Message, pm *PeerManager, peerID string) error

func ConvertDKGResult

func ConvertDKGResult(k *Pubkey, cfgShare string, cfgBKs map[string]BK) (*dkg.Result, error)

ConvertDKGResult converts DKG result from config.

func FromECDSAPub

func FromECDSAPub(pub *ecdsa.PublicKey) []byte

func GenerateSignature

func GenerateSignature(r, s *big.Int, pubkey *Pubkey, msg []byte) ([]byte, error)

func IsLowS

func IsLowS(k *ecdsa.PublicKey, s *big.Int) (bool, error)

IsLow checks that s is a low-S

func Keccak256

func Keccak256(data ...[]byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data.

func NewServiceAddExisting added in v1.2.0

func NewServiceAddExisting(pubkey *Pubkey, share string, threshold uint32, newClientID string, BKs map[string]BK) *serviceAddExisting

func NewServiceAddNew added in v1.2.0

func NewServiceAddNew(pubkey *Pubkey, threshold, rank uint32, BKs map[string]BK) *serviceAddNew

func NewServiceDkg

func NewServiceDkg(threshold, rank uint32, curve elliptic.Curve) *serviceDkg

func NewServiceSigner

func NewServiceSigner(pubkey *Pubkey, share string, BKs map[string]BK, message []byte) *serviceSigner

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) common.Address

func Receive

func Receive(tss GenericTSS, ctx context.Context, errs chan error, c *websocket.Conn)

func RecoverPrivateKey added in v0.2.0

func RecoverPrivateKey(curve elliptic.Curve, threshold uint32, pubKey *ecpointgrouplaw.ECPoint, peers []RecoveryPeer) (*ecdsa.PrivateKey, error)

func RecoverPrivateKeyWrapper added in v0.2.0

func RecoverPrivateKeyWrapper(clientPeerID string, pubkeyStr PubkeyStr, serverShareStr string, clientShareStr string, BKs map[string]BK) (*ecdsa.PrivateKey, error)

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

func Send

func Send(tss GenericTSS, ctx context.Context, errs chan error, c *websocket.Conn)

func ToLowS

func ToLowS(k *ecdsa.PublicKey, s *big.Int) (*big.Int, error)

Types

type BK

type BK struct {
	X    string
	Rank uint32
}

type ClientAdd added in v1.2.0

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

/////// New Client

func NewClientAdd added in v1.2.0

func NewClientAdd(peerID string, acceptingDevicePeerID string, pubkeyStr PubkeyStr, BKs map[string]BK) (*ClientAdd, error)

func (*ClientAdd) GetDoneChan added in v1.2.0

func (p *ClientAdd) GetDoneChan() chan struct{}

func (*ClientAdd) GetNextMessageToSend added in v1.2.0

func (p *ClientAdd) GetNextMessageToSend(peerID string) ([]byte, error)

func (*ClientAdd) GetNextMessageToSendAll added in v1.2.0

func (p *ClientAdd) GetNextMessageToSendAll() (Message, error)

func (*ClientAdd) HandleMessage added in v1.2.0

func (p *ClientAdd) HandleMessage(msg *Message) error

func (*ClientAdd) Process added in v1.2.0

func (p *ClientAdd) Process() (*DkgResult, error)

type ClientDkg

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

Client

func NewClientDkg

func NewClientDkg(clientPeerID string) (*ClientDkg, error)

func (*ClientDkg) DkgOrSign added in v1.1.0

func (p *ClientDkg) DkgOrSign() int

func (*ClientDkg) GetNextMessageToSend

func (p *ClientDkg) GetNextMessageToSend() (Message, error)

func (*ClientDkg) HandleMessage

func (p *ClientDkg) HandleMessage(msg *Message) error

func (*ClientDkg) Process

func (p *ClientDkg) Process() (*DkgResult, error)

type ClientSigner

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

Client

func NewClientSigner

func NewClientSigner(clientPeerID string, pubkeyStr PubkeyStr, share string, BKs map[string]BK, message []byte) (*ClientSigner, error)

func (*ClientSigner) DkgOrSign added in v1.1.0

func (p *ClientSigner) DkgOrSign() int

func (*ClientSigner) GetNextMessageToSend

func (p *ClientSigner) GetNextMessageToSend() ([]byte, error)

func (*ClientSigner) HandleMessage

func (p *ClientSigner) HandleMessage(msg types.Message) error

func (*ClientSigner) Process

func (p *ClientSigner) Process() (*Signature, error)

func (*ClientSigner) Test

func (p *ClientSigner) Test() []byte

type DKGResult

type DKGResult struct {
	Share  string
	Pubkey Pubkey
	BKs    map[string]BK
}

type DkgResult

type DkgResult struct {
	Pubkey  PubkeyStr
	BKs     map[string]BK
	Share   string
	Address string
	PeerID  string
}

func MergeDkgResults added in v1.2.0

func MergeDkgResults(first, second *DkgResult) (*DkgResult, bool)

func PostProcessResult added in v1.2.0

func PostProcessResult(result ProcessResult) (*DkgResult, error)

type ExistingClientAdd added in v1.2.0

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

/////// Existing client

func NewExistingClientAdd added in v1.2.0

func NewExistingClientAdd(newClientPeerID string, peerID string, pubkeyStr PubkeyStr, share string, BKs map[string]BK) (*ExistingClientAdd, error)

func (*ExistingClientAdd) GetDoneChan added in v1.2.0

func (p *ExistingClientAdd) GetDoneChan() chan struct{}

func (*ExistingClientAdd) GetNextMessageToSend added in v1.2.0

func (p *ExistingClientAdd) GetNextMessageToSend(peerID string) ([]byte, error)

func (*ExistingClientAdd) GetNextMessageToSendAll added in v1.2.0

func (p *ExistingClientAdd) GetNextMessageToSendAll() (Message, error)

func (*ExistingClientAdd) HandleMessage added in v1.2.0

func (p *ExistingClientAdd) HandleMessage(msg *Message) error

func (*ExistingClientAdd) Process added in v1.2.0

func (p *ExistingClientAdd) Process() (*DkgResult, error)

type GenericTSS

type GenericTSS interface {
	// Process() (*Signature, error)
	// ProcessStr() (string, error)
	GetNextMessageToSend() ([]byte, error)
	HandleMessage(types.Message) error
	DkgOrSign() int
}

type KeccakState

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

because it doesn't copy the internal state, but also modifies the internal state.

func NewKeccakState

func NewKeccakState() KeccakState

NewKeccakState creates a new KeccakState

type Message

type Message struct {
	PeerID  string
	Message interface{}
}

type PeerManager

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

func NewPeerManager

func NewPeerManager(id string) *PeerManager

func (*PeerManager) AddPeer

func (p *PeerManager) AddPeer(peerID string)

AddPeers adds peers to peer list.

func (*PeerManager) GetNextMessageToSend

func (p *PeerManager) GetNextMessageToSend(peerID string) ([]byte, error)

Not appropriate for Adder

func (*PeerManager) GetNextMessageToSendAll added in v1.2.0

func (p *PeerManager) GetNextMessageToSendAll() (Message, error)

func (*PeerManager) GetNextMessageToSendPeer added in v1.2.0

func (p *PeerManager) GetNextMessageToSendPeer(peerID string) (Message, error)

func (*PeerManager) HandleMessage

func (p *PeerManager) HandleMessage(msg types.Message) error

func (*PeerManager) MustSend

func (p *PeerManager) MustSend(peerID string, message interface{})

func (*PeerManager) NumPeers

func (p *PeerManager) NumPeers() uint32

func (*PeerManager) PeerIDs

func (p *PeerManager) PeerIDs() []string

func (*PeerManager) RegisterHandleMessage

func (p *PeerManager) RegisterHandleMessage(handleFunc func(types.Message) error)

func (*PeerManager) SelfID

func (p *PeerManager) SelfID() string

type ProcessResult added in v1.2.0

type ProcessResult struct {
	PublicKey *ecpointgrouplaw.ECPoint
	Share     *big.Int
	Bks       map[string]*birkhoffinterpolation.BkParameter
	PeerID    string
}

type Pubkey

type Pubkey struct {
	X *big.Int
	Y *big.Int
}

func NewPubkey

func NewPubkey(k PubkeyStr) (*Pubkey, error)

func (*Pubkey) GetAddress

func (k *Pubkey) GetAddress() common.Address

func (*Pubkey) GetBytes

func (k *Pubkey) GetBytes() []byte

func (*Pubkey) GetECDSA

func (k *Pubkey) GetECDSA() *ecdsa.PublicKey

func (*Pubkey) GetECPoint added in v0.2.0

func (k *Pubkey) GetECPoint() (*ecpointgrouplaw.ECPoint, error)

func (*Pubkey) GetStr

func (k *Pubkey) GetStr() PubkeyStr

type PubkeyStr

type PubkeyStr struct {
	X string
	Y string
}

type RecoveryPeer added in v0.2.0

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

type ServerAdd added in v1.2.0

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

/////// Server

func NewServerAdd added in v1.2.0

func NewServerAdd(newClientPeerID string, existingClientPeerID string, pubkeyStr PubkeyStr, share string, BKs map[string]BK) (*ServerAdd, error)

func (*ServerAdd) GetDoneChan added in v1.2.0

func (p *ServerAdd) GetDoneChan() chan struct{}

func (*ServerAdd) GetNextMessageToSend added in v1.2.0

func (p *ServerAdd) GetNextMessageToSend(peerID string) (Message, error)

func (*ServerAdd) GetOriginalWallet added in v1.2.0

func (p *ServerAdd) GetOriginalWallet() *DkgResult

func (*ServerAdd) HandleMessage added in v1.2.0

func (p *ServerAdd) HandleMessage(msg *Message) error

Handle messages coming from clients : if the target is the server, consume; else, add to list of messages to be sent through MustSend

func (*ServerAdd) Process added in v1.2.0

func (p *ServerAdd) Process() (*DkgResult, error)

type ServerDkg

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

func NewServerDkg

func NewServerDkg(clientPeerID string) (*ServerDkg, error)

func (*ServerDkg) DkgOrSign added in v1.1.0

func (p *ServerDkg) DkgOrSign() int

func (*ServerDkg) GetNextMessageToSend

func (p *ServerDkg) GetNextMessageToSend() (Message, error)

func (*ServerDkg) HandleMessage

func (p *ServerDkg) HandleMessage(msg *Message) error

func (*ServerDkg) Process

func (p *ServerDkg) Process() (*DkgResult, error)

type ServerSigner

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

Server

func NewServerSigner

func NewServerSigner(clientPeerID string, pubkeyStr PubkeyStr, share string, BKs map[string]BK, message []byte) (*ServerSigner, error)

func (*ServerSigner) DkgOrSign added in v1.1.0

func (p *ServerSigner) DkgOrSign() int

func (*ServerSigner) GetNextMessageToSend

func (p *ServerSigner) GetNextMessageToSend() ([]byte, error)

func (*ServerSigner) HandleMessage

func (p *ServerSigner) HandleMessage(msg types.Message) error

func (*ServerSigner) Process

func (p *ServerSigner) Process() (*Signature, error)

type Signature

type Signature struct {
	R         *big.Int
	S         *big.Int
	Signature []byte
}

type SigningParameters

type SigningParameters struct {
	Pubkey PubkeyStr
	BKs    map[string]BK
}

Jump to

Keyboard shortcuts

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