tss

package
v0.0.0-...-e2a27c9 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_protob_message_proto protoreflect.FileDescriptor

Functions

func EC

func EC() elliptic.Curve

EC returns the current elliptic curve in use. The default is secp256k1

func Edwards

func Edwards() elliptic.Curve

func GetCurveByName

func GetCurveByName(name CurveName) (elliptic.Curve, bool)

return curve, exist(bool)

func RegisterCurve

func RegisterCurve(name CurveName, curve elliptic.Curve)

func S256

func S256() elliptic.Curve

secp256k1

func SetCurve

func SetCurve(curve elliptic.Curve)

SetCurve sets the curve used by TSS. Must be called before Start. The default is secp256k1 Deprecated

Types

type BaseParty

type BaseParty struct {
	FirstRound Round
	// contains filtered or unexported fields
}

func (*BaseParty) Running

func (p *BaseParty) Running() bool

func (*BaseParty) String

func (p *BaseParty) String() string

func (*BaseParty) ValidateMessage

func (p *BaseParty) ValidateMessage(msg ParsedMessage) (bool, *Error)

an implementation of ValidateMessage that is shared across the different types of parties (keygen, signing, dynamic groups)

func (*BaseParty) WaitingFor

func (p *BaseParty) WaitingFor() []*PartyID

func (*BaseParty) WrapError

func (p *BaseParty) WrapError(err error, culprits ...*PartyID) *Error

type CurveName

type CurveName string
const (
	Secp256k1 CurveName = "secp256k1"
	Ed25519   CurveName = "ed25519"
)

func GetCurveName

func GetCurveName(curve elliptic.Curve) (CurveName, bool)

return name, exist(bool)

type Error

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

fundamental is an error that has a message and a stack, but no caller.

func BaseStart

func BaseStart(p Party, task string, prepare ...func(Round) *Error) *Error

func BaseUpdate

func BaseUpdate(p Party, msg ParsedMessage, task string) (ok bool, err *Error)

an implementation of Update that is shared across the different types of parties (keygen, signing, dynamic groups)

func NewError

func NewError(err error, task string, round int, victim *PartyID, culprits ...*PartyID) *Error

func (*Error) Cause

func (err *Error) Cause() error

func (*Error) Culprits

func (err *Error) Culprits() []*PartyID

func (*Error) Error

func (err *Error) Error() string

func (*Error) Round

func (err *Error) Round() int

func (*Error) Task

func (err *Error) Task() string

func (*Error) Unwrap

func (err *Error) Unwrap() error

func (*Error) Victim

func (err *Error) Victim() *PartyID

type Message

type Message interface {
	// Type is encoded in the protobuf Any structure
	Type() string
	// The set of parties that this message should be sent to
	GetTo() []*PartyID
	// The party that this message is from
	GetFrom() *PartyID
	// Indicates whether the message should be broadcast to other participants
	IsBroadcast() bool
	// Indicates whether the message is to the old committee during re-sharing; used mainly in tests
	IsToOldCommittee() bool
	// Indicates whether the message is to both committees during re-sharing; used mainly in tests
	IsToOldAndNewCommittees() bool
	// Returns the encoded inner message bytes to send over the wire along with metadata about how the message should be delivered
	WireBytes() ([]byte, *MessageRouting, error)
	// Returns the protobuf message wrapper struct
	// Only its inner content should be sent over the wire, not this struct itself
	WireMsg() *MessageWrapper
	String() string
}

Message describes the interface of the TSS Message for all protocols

type MessageContent

type MessageContent interface {
	proto.Message
	ValidateBasic() bool
}

MessageContent represents a ProtoBuf message with validation logic

type MessageImpl

type MessageImpl struct {
	MessageRouting
	// contains filtered or unexported fields
}

Implements ParsedMessage; this is a concrete implementation of what messages produced by a LocalParty look like

func (*MessageImpl) Content

func (mm *MessageImpl) Content() MessageContent

func (*MessageImpl) GetFrom

func (mm *MessageImpl) GetFrom() *PartyID

func (*MessageImpl) GetTo

func (mm *MessageImpl) GetTo() []*PartyID

func (*MessageImpl) IsBroadcast

func (mm *MessageImpl) IsBroadcast() bool

func (*MessageImpl) IsToOldAndNewCommittees

func (mm *MessageImpl) IsToOldAndNewCommittees() bool

only `true` in DGRound4Message (resharing)

func (*MessageImpl) IsToOldCommittee

func (mm *MessageImpl) IsToOldCommittee() bool

only `true` in DGRound2Message (resharing)

func (*MessageImpl) String

func (mm *MessageImpl) String() string

func (*MessageImpl) Type

func (mm *MessageImpl) Type() string

func (*MessageImpl) ValidateBasic

func (mm *MessageImpl) ValidateBasic() bool

func (*MessageImpl) WireBytes

func (mm *MessageImpl) WireBytes() ([]byte, *MessageRouting, error)

func (*MessageImpl) WireMsg

func (mm *MessageImpl) WireMsg() *MessageWrapper

type MessageRouting

type MessageRouting struct {
	// which participant this message came from
	From *PartyID
	// when `nil` the message should be broadcast to all parties
	To []*PartyID
	// whether the message should be broadcast to other participants
	IsBroadcast bool
	// whether the message should be sent to old committee participants rather than the new committee
	IsToOldCommittee bool
	// whether the message should be sent to both old and new committee participants
	IsToOldAndNewCommittees bool
}

MessageRouting holds the full routing information for the message, consumed by the transport

type MessageWrapper

type MessageWrapper struct {

	// Metadata optionally un-marshalled and used by the transport to route this message.
	IsBroadcast bool `protobuf:"varint,1,opt,name=is_broadcast,json=isBroadcast,proto3" json:"is_broadcast,omitempty"`
	// Metadata optionally un-marshalled and used by the transport to route this message.
	IsToOldCommittee bool `protobuf:"varint,2,opt,name=is_to_old_committee,json=isToOldCommittee,proto3" json:"is_to_old_committee,omitempty"` // used only in certain resharing messages
	// Metadata optionally un-marshalled and used by the transport to route this message.
	IsToOldAndNewCommittees bool `` // used only in certain resharing messages
	/* 139-byte string literal not displayed */
	// Metadata optionally un-marshalled and used by the transport to route this message.
	From *MessageWrapper_PartyID `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"`
	// Metadata optionally un-marshalled and used by the transport to route this message.
	To []*MessageWrapper_PartyID `protobuf:"bytes,4,rep,name=to,proto3" json:"to,omitempty"`
	// This field is actually what is sent through the wire and consumed on the other end by UpdateFromBytes.
	// An Any contains an arbitrary serialized message as bytes, along with a URL that
	// acts as a globally unique identifier for and resolves to that message's type.
	Message *anypb.Any `protobuf:"bytes,10,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

Wrapper for TSS messages, often read by the transport layer and not itself sent over the wire

func NewMessageWrapper

func NewMessageWrapper(routing MessageRouting, content MessageContent) *MessageWrapper

NewMessageWrapper constructs a MessageWrapper from routing metadata and content

func (*MessageWrapper) Descriptor deprecated

func (*MessageWrapper) Descriptor() ([]byte, []int)

Deprecated: Use MessageWrapper.ProtoReflect.Descriptor instead.

func (*MessageWrapper) GetFrom

func (x *MessageWrapper) GetFrom() *MessageWrapper_PartyID

func (*MessageWrapper) GetIsBroadcast

func (x *MessageWrapper) GetIsBroadcast() bool

func (*MessageWrapper) GetIsToOldAndNewCommittees

func (x *MessageWrapper) GetIsToOldAndNewCommittees() bool

func (*MessageWrapper) GetIsToOldCommittee

func (x *MessageWrapper) GetIsToOldCommittee() bool

func (*MessageWrapper) GetMessage

func (x *MessageWrapper) GetMessage() *anypb.Any

func (*MessageWrapper) GetTo

func (x *MessageWrapper) GetTo() []*MessageWrapper_PartyID

func (*MessageWrapper) ProtoMessage

func (*MessageWrapper) ProtoMessage()

func (*MessageWrapper) ProtoReflect

func (x *MessageWrapper) ProtoReflect() protoreflect.Message

func (*MessageWrapper) Reset

func (x *MessageWrapper) Reset()

func (*MessageWrapper) String

func (x *MessageWrapper) String() string

type MessageWrapper_PartyID

type MessageWrapper_PartyID struct {
	Id      string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"`
	Key     []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
	// contains filtered or unexported fields
}

PartyID represents a participant in the TSS protocol rounds. Note: The `id` and `moniker` are provided for convenience to allow you to track participants easier. The `id` is intended to be a unique string representation of `key` and `moniker` can be anything (even left blank).

func (*MessageWrapper_PartyID) Descriptor deprecated

func (*MessageWrapper_PartyID) Descriptor() ([]byte, []int)

Deprecated: Use MessageWrapper_PartyID.ProtoReflect.Descriptor instead.

func (*MessageWrapper_PartyID) GetId

func (x *MessageWrapper_PartyID) GetId() string

func (*MessageWrapper_PartyID) GetKey

func (x *MessageWrapper_PartyID) GetKey() []byte

func (*MessageWrapper_PartyID) GetMoniker

func (x *MessageWrapper_PartyID) GetMoniker() string

func (*MessageWrapper_PartyID) KeyInt

func (mpid *MessageWrapper_PartyID) KeyInt() *big.Int

func (*MessageWrapper_PartyID) ProtoMessage

func (*MessageWrapper_PartyID) ProtoMessage()

func (*MessageWrapper_PartyID) ProtoReflect

func (x *MessageWrapper_PartyID) ProtoReflect() protoreflect.Message

func (*MessageWrapper_PartyID) Reset

func (x *MessageWrapper_PartyID) Reset()

func (*MessageWrapper_PartyID) String

func (x *MessageWrapper_PartyID) String() string

type Parameters

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

func NewParameters

func NewParameters(ec elliptic.Curve, ctx *PeerContext, partyID *PartyID, partyCount, threshold int) *Parameters

Exported, used in `tss` client

func (*Parameters) Concurrency

func (params *Parameters) Concurrency() int

func (*Parameters) EC

func (params *Parameters) EC() elliptic.Curve

func (*Parameters) Parties

func (params *Parameters) Parties() *PeerContext

func (*Parameters) PartyCount

func (params *Parameters) PartyCount() int

func (*Parameters) PartyID

func (params *Parameters) PartyID() *PartyID

func (*Parameters) SafePrimeGenTimeout

func (params *Parameters) SafePrimeGenTimeout() time.Duration

func (*Parameters) SetConcurrency

func (params *Parameters) SetConcurrency(concurrency int)

The concurrency level must be >= 1.

func (*Parameters) SetSafePrimeGenTimeout

func (params *Parameters) SetSafePrimeGenTimeout(timeout time.Duration)

func (*Parameters) Threshold

func (params *Parameters) Threshold() int

type ParsedMessage

type ParsedMessage interface {
	Message
	Content() MessageContent
	ValidateBasic() bool
}

ParsedMessage represents a message with inner ProtoBuf message content

func NewMessage

func NewMessage(meta MessageRouting, content MessageContent, wire *MessageWrapper) ParsedMessage

func ParseWireMessage

func ParseWireMessage(wireBytes []byte, from *PartyID, isBroadcast bool) (ParsedMessage, error)

Used externally to update a LocalParty with a valid ParsedMessage

type Party

type Party interface {
	Start() *Error
	// The main entry point when updating a party's state from the wire.
	// isBroadcast should represent whether the message was received via a reliable broadcast
	UpdateFromBytes(wireBytes []byte, from *PartyID, isBroadcast bool) (ok bool, err *Error)
	// You may use this entry point to update a party's state when running locally or in tests
	Update(msg ParsedMessage) (ok bool, err *Error)
	Running() bool
	WaitingFor() []*PartyID
	ValidateMessage(msg ParsedMessage) (bool, *Error)
	StoreMessage(msg ParsedMessage) (bool, *Error)
	FirstRound() Round
	WrapError(err error, culprits ...*PartyID) *Error
	PartyID() *PartyID
	String() string
	// contains filtered or unexported methods
}

type PartyID

type PartyID struct {
	*MessageWrapper_PartyID
	Index int `json:"index"`
}

PartyID represents a participant in the TSS protocol rounds. Note: The `id` and `moniker` are provided for convenience to allow you to track participants easier. The `id` is intended to be a unique string representation of `key` and `moniker` can be anything (even left blank).

func NewPartyID

func NewPartyID(id, moniker string, key *big.Int) *PartyID

NewPartyID constructs a new PartyID Exported, used in `tss` client. `key` should remain consistent between runs for each party.

func (PartyID) String

func (pid PartyID) String() string

func (*PartyID) ValidateBasic

func (pid *PartyID) ValidateBasic() bool

type PeerContext

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

func NewPeerContext

func NewPeerContext(parties SortedPartyIDs) *PeerContext

func (*PeerContext) IDs

func (p2pCtx *PeerContext) IDs() SortedPartyIDs

func (*PeerContext) SetIDs

func (p2pCtx *PeerContext) SetIDs(ids SortedPartyIDs)

type ReSharingParameters

type ReSharingParameters struct {
	*Parameters
	// contains filtered or unexported fields
}

func NewReSharingParameters

func NewReSharingParameters(ec elliptic.Curve, ctx, newCtx *PeerContext, partyID *PartyID, partyCount, threshold, newPartyCount, newThreshold int) *ReSharingParameters

Exported, used in `tss` client

func (*ReSharingParameters) IsNewCommittee

func (rgParams *ReSharingParameters) IsNewCommittee() bool

func (*ReSharingParameters) IsOldCommittee

func (rgParams *ReSharingParameters) IsOldCommittee() bool

func (*ReSharingParameters) NewParties

func (rgParams *ReSharingParameters) NewParties() *PeerContext

func (*ReSharingParameters) NewPartyCount

func (rgParams *ReSharingParameters) NewPartyCount() int

func (*ReSharingParameters) NewThreshold

func (rgParams *ReSharingParameters) NewThreshold() int

func (*ReSharingParameters) OldAndNewParties

func (rgParams *ReSharingParameters) OldAndNewParties() []*PartyID

func (*ReSharingParameters) OldAndNewPartyCount

func (rgParams *ReSharingParameters) OldAndNewPartyCount() int

func (*ReSharingParameters) OldParties

func (rgParams *ReSharingParameters) OldParties() *PeerContext

func (*ReSharingParameters) OldPartyCount

func (rgParams *ReSharingParameters) OldPartyCount() int

type Round

type Round interface {
	Params() *Parameters
	Start() *Error
	Update() (bool, *Error)
	RoundNumber() int
	CanAccept(msg ParsedMessage) bool
	CanProceed() bool
	NextRound() Round
	WaitingFor() []*PartyID
	WrapError(err error, culprits ...*PartyID) *Error
}

type SortedPartyIDs

type SortedPartyIDs []*PartyID

func GenerateTestPartyIDs

func GenerateTestPartyIDs(count int, startAt ...int) SortedPartyIDs

GenerateTestPartyIDs generates a list of mock PartyIDs for tests

func SortPartyIDs

func SortPartyIDs(ids UnSortedPartyIDs, startAt ...int) SortedPartyIDs

SortPartyIDs sorts a list of []*PartyID by their keys in ascending order Exported, used in `tss` client

func (SortedPartyIDs) Exclude

func (spids SortedPartyIDs) Exclude(exclude *PartyID) SortedPartyIDs

func (SortedPartyIDs) FindByKey

func (spids SortedPartyIDs) FindByKey(key *big.Int) *PartyID

func (SortedPartyIDs) Keys

func (spids SortedPartyIDs) Keys() []*big.Int

func (SortedPartyIDs) Len

func (spids SortedPartyIDs) Len() int

func (SortedPartyIDs) Less

func (spids SortedPartyIDs) Less(a, b int) bool

func (SortedPartyIDs) Swap

func (spids SortedPartyIDs) Swap(a, b int)

func (SortedPartyIDs) ToUnSorted

func (spids SortedPartyIDs) ToUnSorted() UnSortedPartyIDs

type UnSortedPartyIDs

type UnSortedPartyIDs []*PartyID

Jump to

Keyboard shortcuts

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