Documentation
¶
Index ¶
- Constants
- Variables
- func EC() elliptic.Curve
- func Edwards() elliptic.Curve
- func GetCurveByName(name CurveName) (elliptic.Curve, bool)
- func RegisterCurve(name CurveName, curve elliptic.Curve)
- func S256() elliptic.Curve
- func SameCurve(lhs, rhs elliptic.Curve) bool
- func SetCurve(curve elliptic.Curve)
- type BaseParty
- type CurveName
- type Error
- type Message
- type MessageContent
- type MessageImpl
- func (mm *MessageImpl) Content() MessageContent
- func (mm *MessageImpl) GetFrom() *PartyID
- func (mm *MessageImpl) GetTo() []*PartyID
- func (mm *MessageImpl) IsBroadcast() bool
- func (mm *MessageImpl) IsToOldAndNewCommittees() bool
- func (mm *MessageImpl) IsToOldCommittee() bool
- func (mm *MessageImpl) String() string
- func (mm *MessageImpl) Type() string
- func (mm *MessageImpl) ValidateBasic() bool
- func (mm *MessageImpl) WireBytes() ([]byte, *MessageRouting, error)
- func (mm *MessageImpl) WireMsg() *MessageWrapper
- type MessageRouting
- type MessageWrapper
- func (*MessageWrapper) Descriptor() ([]byte, []int)deprecated
- func (x *MessageWrapper) GetFrom() *MessageWrapper_PartyID
- func (x *MessageWrapper) GetIsBroadcast() bool
- func (x *MessageWrapper) GetIsToOldAndNewCommittees() bool
- func (x *MessageWrapper) GetIsToOldCommittee() bool
- func (x *MessageWrapper) GetMessage() *anypb.Any
- func (x *MessageWrapper) GetTo() []*MessageWrapper_PartyID
- func (*MessageWrapper) ProtoMessage()
- func (x *MessageWrapper) ProtoReflect() protoreflect.Message
- func (x *MessageWrapper) Reset()
- func (x *MessageWrapper) String() string
- type MessageWrapper_PartyID
- func (*MessageWrapper_PartyID) Descriptor() ([]byte, []int)deprecated
- func (x *MessageWrapper_PartyID) GetId() string
- func (x *MessageWrapper_PartyID) GetKey() []byte
- func (x *MessageWrapper_PartyID) GetMoniker() string
- func (mpid *MessageWrapper_PartyID) KeyInt() *big.Int
- func (*MessageWrapper_PartyID) ProtoMessage()
- func (x *MessageWrapper_PartyID) ProtoReflect() protoreflect.Message
- func (x *MessageWrapper_PartyID) Reset()
- func (x *MessageWrapper_PartyID) String() string
- type Parameters
- func (params *Parameters) Concurrency() int
- func (params *Parameters) EC() elliptic.Curve
- func (params *Parameters) NoProofFac() bool
- func (params *Parameters) NoProofMod() bool
- func (params *Parameters) PartialKeyRand() io.Reader
- func (params *Parameters) Parties() *PeerContext
- func (params *Parameters) PartyCount() int
- func (params *Parameters) PartyID() *PartyID
- func (params *Parameters) Rand() io.Reader
- func (params *Parameters) SafePrimeGenTimeout() time.Duration
- func (params *Parameters) SessionNonce() *big.Int
- func (params *Parameters) SetConcurrency(concurrency int)
- func (params *Parameters) SetNoProofFac()
- func (params *Parameters) SetNoProofMod()
- func (params *Parameters) SetPartialKeyRand(rand io.Reader)
- func (params *Parameters) SetRand(rand io.Reader)
- func (params *Parameters) SetSafePrimeGenTimeout(timeout time.Duration)
- func (params *Parameters) SetSessionNonce(nonce *big.Int)
- func (params *Parameters) Threshold() int
- func (params *Parameters) ValidateSessionNonce() error
- type ParsedMessage
- type Party
- type PartyID
- type PeerContext
- type ReSharingParameters
- func (rgParams *ReSharingParameters) IsNewCommittee() bool
- func (rgParams *ReSharingParameters) IsOldCommittee() bool
- func (rgParams *ReSharingParameters) NewParties() *PeerContext
- func (rgParams *ReSharingParameters) NewPartyCount() int
- func (rgParams *ReSharingParameters) NewPartyIndex() (int, bool)
- func (rgParams *ReSharingParameters) NewThreshold() int
- func (rgParams *ReSharingParameters) OldAndNewParties() []*PartyID
- func (rgParams *ReSharingParameters) OldAndNewPartyCount() int
- func (rgParams *ReSharingParameters) OldParties() *PeerContext
- func (rgParams *ReSharingParameters) OldPartyCount() int
- func (rgParams *ReSharingParameters) OldPartyIndex() (int, bool)
- type Round
- type SortedPartyIDs
- func (spids SortedPartyIDs) Exclude(exclude *PartyID) SortedPartyIDs
- func (spids SortedPartyIDs) FindByKey(key *big.Int) *PartyID
- func (spids SortedPartyIDs) IndexOf(party *PartyID) (int, bool)
- func (spids SortedPartyIDs) Keys() []*big.Int
- func (spids SortedPartyIDs) Len() int
- func (spids SortedPartyIDs) Less(a, b int) bool
- func (spids SortedPartyIDs) Swap(a, b int)
- func (spids SortedPartyIDs) ToUnSorted() UnSortedPartyIDs
- type UnSortedPartyIDs
Constants ¶
const MaxWireMessageSize = 4 << 20 // 4 MiB
MaxWireMessageSize limits allocations and decoding work on untrusted input.
Variables ¶
var File_protob_message_proto protoreflect.FileDescriptor
Functions ¶
func GetCurveByName ¶
return curve, exist(bool)
func RegisterCurve ¶
Types ¶
type BaseParty ¶
type BaseParty struct {
FirstRound Round
// contains filtered or unexported fields
}
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 ¶
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 BaseUpdate ¶
func BaseUpdate(p protocolParty, 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)
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 ¶
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, error)
Exported, used in `tss` client
func (*Parameters) Concurrency ¶
func (params *Parameters) Concurrency() int
func (*Parameters) EC ¶
func (params *Parameters) EC() elliptic.Curve
func (*Parameters) NoProofFac ¶
func (params *Parameters) NoProofFac() bool
func (*Parameters) NoProofMod ¶
func (params *Parameters) NoProofMod() bool
func (*Parameters) PartialKeyRand ¶
func (params *Parameters) PartialKeyRand() io.Reader
func (*Parameters) Parties ¶
func (params *Parameters) Parties() *PeerContext
func (*Parameters) PartyCount ¶
func (params *Parameters) PartyCount() int
func (*Parameters) PartyID ¶
func (params *Parameters) PartyID() *PartyID
PartyID returns a deep copy of the local identity.
func (*Parameters) Rand ¶
func (params *Parameters) Rand() io.Reader
func (*Parameters) SafePrimeGenTimeout ¶
func (params *Parameters) SafePrimeGenTimeout() time.Duration
func (*Parameters) SessionNonce ¶
func (params *Parameters) SessionNonce() *big.Int
SessionNonce returns a copy of the required per-session nonce used for SSID uniqueness. Party.Start rejects nil, zero, and negative nonces.
func (*Parameters) SetConcurrency ¶
func (params *Parameters) SetConcurrency(concurrency int)
The concurrency level must be >= 1.
func (*Parameters) SetNoProofFac ¶
func (params *Parameters) SetNoProofFac()
SetNoProofFac is blocked in secure builds.
func (*Parameters) SetNoProofMod ¶
func (params *Parameters) SetNoProofMod()
SetNoProofMod is blocked in secure builds.
func (*Parameters) SetPartialKeyRand ¶
func (params *Parameters) SetPartialKeyRand(rand io.Reader)
func (*Parameters) SetRand ¶
func (params *Parameters) SetRand(rand io.Reader)
func (*Parameters) SetSafePrimeGenTimeout ¶
func (params *Parameters) SetSafePrimeGenTimeout(timeout time.Duration)
func (*Parameters) SetSessionNonce ¶
func (params *Parameters) SetSessionNonce(nonce *big.Int)
SetSessionNonce sets a required per-session nonce that all parties must agree on. This value is mixed into the SSID to provide GG20 session binding, preventing cross-session proof replay attacks. All parties in the same session MUST use the same fresh positive nonce value. The caller is responsible for coordinating it and MUST NOT reuse it across protocol runs.
func (*Parameters) Threshold ¶
func (params *Parameters) Threshold() int
func (*Parameters) ValidateSessionNonce ¶
func (params *Parameters) ValidateSessionNonce() error
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 starts this party exactly once. Transport delivery may race Start;
// valid early messages are queued for the first round.
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 is safe to call concurrently for a party.
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 is safe to call concurrently for a party.
Update(msg ParsedMessage) (ok bool, err *Error)
// Running, WaitingFor, WrapError, and String are safe to call concurrently
// with Start and Update.
Running() bool
WaitingFor() []*PartyID
WrapError(err error, culprits ...*PartyID) *Error
// PartyID returns a defensive copy in v4.
PartyID() *PartyID
String() string
}
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 ¶
NewPartyID constructs a new PartyID Exported, used in `tss` client. `key` should remain consistent between runs for each party.
func (*PartyID) ValidateBasic ¶
type PeerContext ¶
type PeerContext struct {
// contains filtered or unexported fields
}
func NewPeerContext ¶
func NewPeerContext(parties SortedPartyIDs) *PeerContext
NewPeerContext takes a deep snapshot of the committee identities.
func (*PeerContext) IDs ¶
func (p2pCtx *PeerContext) IDs() SortedPartyIDs
IDs returns a deep copy. Mutating the result cannot alter this context.
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, error)
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) NewPartyIndex ¶
func (rgParams *ReSharingParameters) NewPartyIndex() (int, bool)
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
func (*ReSharingParameters) OldPartyIndex ¶
func (rgParams *ReSharingParameters) OldPartyIndex() (int, bool)
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) IndexOf ¶
func (spids SortedPartyIDs) IndexOf(party *PartyID) (int, bool)
IndexOf returns the committee-local position for a party key. Protocol code must use this value instead of trusting PartyID.Index received from a peer.
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