session

package
v0.0.0-...-8cb8a38 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

States

Per Signing Session State

States per signing session. There may be multiple sessions running in parallel.

stateDiagram-v2
    state if_leader_state <<choice>>
    state "Is leader?" as IsLeader

    [*] --> IsLeader: Start signing session
    IsLeader --> if_leader_state: pick leader
    if_leader_state --> LeaderWaitingForCandidatesState: is leader
    if_leader_state --> CandidateWaitingForLeaderState: not leader
    LeaderWaitingForCandidatesState --> LeaderWaitingForCandidatesState: AddCandidateEvent

    state if_participant_state <<choice>>
    state "Is participant?" as IsParticipant

    LeaderWaitingForCandidatesState --> SigningState: t + 1 picked
    CandidateWaitingForLeaderState --> IsParticipant: StartSignerEvent
    IsParticipant --> if_participant_state
    if_participant_state --> SigningState: true
    if_participant_state --> DoneWithoutSignatureState: false

    SigningState --> SigningState: AddSigningPartEvent
    SigningState --> DoneWithSignatureState: Signing done
    SigningState --> ErrorState: Signing error
1. PickLeader
  1. All peers determine the leader
  2. Send JoinSessionMessage to leader
  3. Receive SigningPartyStartMessage
  4. If in session, go to Signing State
  5. If not in session, end state
2. Signing
  1. Send and receive SigningPartMessage until signature output
  2. Signature output go to Broadcast state
  3. Send SigningOutputMessage to check all peers have the same signature
  4. Go to Broadcast
3. Broadcast
  1. Broadcast message to destination chain Fury / Ethereum.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLeader

func GetLeader(txHash common.Hash, peerIDs peer.IDSlice, offset int64) (peer.ID, error)

GetLeader returns the leader of the given transaction hash and peer.IDSlice. The offset is only used when there is an inactive leader. The initial offset should be 0, and incremented only while the leader does not respond.

func NewSessionTransport

func NewSessionTransport(
	broadcaster broadcast.Broadcaster,
	sessionID mp_tss_types.AggregateSigningSessionID,
	partyIDStore *mp_tss.PartyIDStore,
	participants []peer.ID,
) mp_tss.Transporter

NewSessionTransport returns a new Transporter using reliable broadcast.

Types

type AddCandidateEvent

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

func NewAddCandidateEvent

func NewAddCandidateEvent(
	partyID *tss.PartyID,
	joinMsg types.JoinSessionMessage,
) *AddCandidateEvent

func (*AddCandidateEvent) SigningSessionEvent

func (e *AddCandidateEvent) SigningSessionEvent()

EventType

type AddSigningPartEvent

type AddSigningPartEvent struct {
	From        *tss.PartyID
	Data        []byte
	IsBroadcast bool
}

func NewAddSigningPartEvent

func NewAddSigningPartEvent(
	from *tss.PartyID,
	data []byte,
	isBroadcast bool,
) *AddSigningPartEvent

func (*AddSigningPartEvent) SigningSessionEvent

func (e *AddSigningPartEvent) SigningSessionEvent()

type CandidateWaitingForLeaderState

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

CandidateWaitingForLeaderState is the state of a signing session where the non-leaders wait for the leader to start the signing party.

func NewCandidateWaitingForLeaderState

func NewCandidateWaitingForLeaderState() (*CandidateWaitingForLeaderState, error)

NewCandidateWaitingForLeaderState returns a new CandidateWaitingForLeaderState.

func (*CandidateWaitingForLeaderState) SigningSessionState

func (s *CandidateWaitingForLeaderState) SigningSessionState()

type DoneNonParticipantState

type DoneNonParticipantState struct {
}

DoneNonParticipantState is the state when the peer is not a participant and thus has no signature.

func NewDoneNonParticipantState

func NewDoneNonParticipantState() *DoneNonParticipantState

NewDoneNonParticipantState returns a new DoneNonParticipantState.

func (*DoneNonParticipantState) SigningSessionState

func (s *DoneNonParticipantState) SigningSessionState()

type DoneState

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

DoneState is the state when the signing session is done and a signature is output.

func NewDoneState

func NewDoneState(signature tss_common.SignatureData) *DoneState

NewDoneState returns a new DoneState.

func (*DoneState) SigningSessionState

func (s *DoneState) SigningSessionState()

type ErrorState

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

ErrorState is the state when an error during signing occurs.

func NewErrorState

func NewErrorState(err *tss.Error) *ErrorState

NewErrorState returns a new ErrorState.

func (*ErrorState) SigningSessionState

func (s *ErrorState) SigningSessionState()

type LeaderWaitingForCandidatesState

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

LeaderWaitingForCandidatesState is the state of a signing session where the leader is waiting for candidates to join.

func NewLeaderWaitingForCandidatesState

func NewLeaderWaitingForCandidatesState() (*LeaderWaitingForCandidatesState, error)

NewLeaderWaitingForCandidatesState returns a new LeaderWaitingForCandidatesState.

func (*LeaderWaitingForCandidatesState) SigningSessionState

func (s *LeaderWaitingForCandidatesState) SigningSessionState()

type PickingLeaderState

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

PickingLeaderState is the state of a signing session where each peer is picking the leader.

func NewPickingLeaderState

func NewPickingLeaderState() *PickingLeaderState

NewPickingLeaderState returns a new PickingLeaderState.

func (*PickingLeaderState) SigningSessionState

func (s *PickingLeaderState) SigningSessionState()

type SessionIDToTxHash

type SessionIDToTxHash map[string]eth_common.Hash

SessionIDToTxHash maps session ID -> tx_hash, to get a session from session ID instead of tx_hash

type SessionStore

type SessionStore struct {
	Signing *SigningSessionStore
}

func NewSessionStore

func NewSessionStore() *SessionStore

NewSessionStore returns a new SessionStore.

type SessionTransport

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

SessionTransport is a transport for a specific session.

func (*SessionTransport) Receive

func (mt *SessionTransport) Receive() chan mp_tss.ReceivedPartyState

Receive returns the channel for receiving messages from other parties. This can also be used to add messages to be handled from other parties.

func (*SessionTransport) Send

func (mt *SessionTransport) Send(
	ctx context.Context,
	data []byte,
	routing *tss.MessageRouting,
	isResharing bool,
) error

Send sends a tss message with the provided routing data.

type SigningSession

type SigningSession struct {
	TxHash    eth_common.Hash
	MsgToSign *big.Int
	// contains filtered or unexported fields
}

SigningSession is a session for signing a message, consisting of all of the states that are required to do so for 1 transaction.

func NewSigningSession

func NewSigningSession(
	ctx context.Context,
	sessionStore *SigningSessionStore,
	broadcaster broadcast.Broadcaster,
	txHash eth_common.Hash,
	msgToSign *big.Int,
	threshold int,
	currentPeerID peer.ID,
	peerIDs peer.IDSlice,
	currentPartyID *tss.PartyID,
	partyIDStore *mp_tss.PartyIDStore,
	key keygen.LocalPartySaveData,
) (*SigningSession, <-chan SigningSessionResult, error)

func (*SigningSession) Update

func (s *SigningSession) Update(event SigningSessionEvent) error

func (*SigningSession) UpdateAddCandidateEvent

func (s *SigningSession) UpdateAddCandidateEvent(
	ev *AddCandidateEvent,
) error

func (*SigningSession) UpdateAddSigningPartEvent

func (s *SigningSession) UpdateAddSigningPartEvent(
	ev *AddSigningPartEvent,
) error

func (*SigningSession) UpdateStartSignerEvent

func (s *SigningSession) UpdateStartSignerEvent(
	ev *StartSignerEvent,
) error

type SigningSessionEvent

type SigningSessionEvent interface {
	SigningSessionEvent()
}

SigningSessionEvent is implemented by all events that are part of a signing session.

type SigningSessionResult

type SigningSessionResult struct {
	Signature *tss_common.SignatureData
	Err       *tss.Error
}

SigningSessionResult is the result of a signing session.

func NewSigningSessionResult

func NewSigningSessionResult(
	signature *tss_common.SignatureData,
	err *tss.Error,
) SigningSessionResult

NewSigningSessionResult returns a new SigningSessionResult.

func (*SigningSessionResult) HasSignature

func (res *SigningSessionResult) HasSignature() bool

type SigningSessionState

type SigningSessionState interface {
	SigningSessionState()
}

SigningSessionState is the state of a signing session.

type SigningSessionStore

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

SigningSessionStore keeps track of signing sessions.

func NewSigningSessionStore

func NewSigningSessionStore() *SigningSessionStore

NewSigningSessionStore returns a new signing session store.

func (*SigningSessionStore) GetSessionFromID

func (s *SigningSessionStore) GetSessionFromID(
	sessID types.AggregateSigningSessionID,
) (*SigningSession, bool)

GetSessionFromID returns the signing session for the given session ID.

func (*SigningSessionStore) GetSessionFromTxHash

func (s *SigningSessionStore) GetSessionFromTxHash(txHash eth_common.Hash) (*SigningSession, bool)

GetSessionFromTxHash returns the signing session for the given transaction hash.

func (*SigningSessionStore) NewSession

func (s *SigningSessionStore) NewSession(
	ctx context.Context,
	broadcaster broadcast.Broadcaster,
	txHash eth_common.Hash,
	msgToSign *big.Int,
	threshold int,
	currentPeerID peer.ID,
	peerIDs peer.IDSlice,
	currentPartyID *tss.PartyID,
	partyIDStore *mp_tss.PartyIDStore,
	key keygen.LocalPartySaveData,
) (*SigningSession, <-chan SigningSessionResult, error)

NewSession adds and returns a new signing session. This session does not have a session ID and must be set later with SetSessionID.

func (*SigningSessionStore) SetSessionID

func (s *SigningSessionStore) SetSessionID(txHash eth_common.Hash, sessID types.AggregateSigningSessionID)

SetSessionID sets the session ID for the given signing session transaction hash.

type SigningState

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

SigningState is the state of a signing session where all participants are signing.

func NewSigningState

func NewSigningState(transport mp_tss.Transporter) *SigningState

NewSigningState returns a new SigningState.

func (*SigningState) SigningSessionState

func (s *SigningState) SigningSessionState()

type StartSignerEvent

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

func NewStartSignerEvent

func NewStartSignerEvent(
	tssParams *tss.Parameters,
	transport mp_tss.Transporter,
	participants []peer.ID,
) *StartSignerEvent

func (*StartSignerEvent) SigningSessionEvent

func (e *StartSignerEvent) SigningSessionEvent()

type TssSessions

type TssSessions map[eth_common.Hash]*SigningSession

TssSessions maps a transaction hash to signing session

Jump to

Keyboard shortcuts

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