controllers

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPoolSize = 32

Variables

View Source
var (
	ErrSenderIsNotProposer = goerr.New("party is not proposer")
	ErrUnsupportedContent  = goerr.New("unsupported content")
	ErrInvalidRequestType  = goerr.New("invalid request type")
	ErrSenderIsNotSigner   = goerr.New("sender is no a current signer or has not accepted the proposal")
)

Functions

func Equal

func Equal(p1 *rarimo.Party, p2 *rarimo.Party) bool

func GetOperations

func GetOperations(client *grpc.ClientConn, ids ...string) ([]*rarimo.Operation, error)

func GetProposer

func GetProposer(parties []*rarimo.Party, sig string, sessionId uint64) rarimo.Party

GetProposer generates deterministic proposer based on linear congruential generator with seed from getHash(signature, sessionId)

func GetSignersSet

func GetSignersSet(acceptances map[string]struct{}, t int, sig string, sessionId uint64) map[string]struct{}

GetSignersSet generates deterministic signers set based on received acceptances and linear congruential generator with seed from getHash(signature, sessionId)

Types

type AcceptanceController

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

AcceptanceController is responsible for sharing and collecting acceptances for different types of session.

func (*AcceptanceController) Receive

Receive accepts acceptances from other parties and executes `iAcceptanceController.validate` function. If function returns positive result sender address will be added to the accepted list. Self acceptance will be added to the list after controller base logic execution. After context finishing it calls the `iAcceptanceController.finish` method to calculate the acceptance results.

func (*AcceptanceController) Run

Run initiates sharing of the acceptances with other parties. Should be launched only in case of valid proposal (session processing should be `true`)

func (*AcceptanceController) Type

func (*AcceptanceController) WaitFor

func (a *AcceptanceController) WaitFor()

WaitFor waits until controller finishes its logic. Context cancel should be called before. WaitFor should be called before.

type FinishController

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

FinishController is responsible for finishing sessions. For example: submit transactions, update session entry, etc.

func (*FinishController) Next

func (f *FinishController) Next() IController

func (*FinishController) Receive

func (*FinishController) Run

func (f *FinishController) Run(c context.Context)

Run initiates the report submitting for all parties that was included into Offenders set. After it executes the `iFinishController.finish` logic.

func (*FinishController) Type

func (*FinishController) WaitFor

func (f *FinishController) WaitFor()

WaitFor waits until controller finishes its logic. Context cancel should be called before.

type IController

type IController interface {
	// Receive accepts all incoming requests
	Receive(ctx context.Context, request *types.MsgSubmitRequest) error
	// Run will execute controller logic in separate goroutine
	Run(ctx context.Context)
	// WaitFor should be used to wait while controller finishes after canceling context.
	WaitFor()
	// Next returns next controller depending on current state or nil if session ended.
	Next() IController
	Type() types.ControllerType
}

IController interface represents the smallest independent part of flow.

type KeygenController

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

KeygenController is responsible for initial key generation. It can only be launched with empty secret storage and after finishing will update storage with generated secret.

func (*KeygenController) Receive

func (k *KeygenController) Receive(c context.Context, request *types.MsgSubmitRequest) error

Receive accepts the keygen requests from other parties and delivers them to the `tss.KeygenParty`

func (*KeygenController) Run

func (k *KeygenController) Run(c context.Context)

Run launches the `tss.KeygenParty` logic. After context canceling it will check the tss party result and execute `iKeygenController.finish` logic.

func (*KeygenController) Type

func (*KeygenController) WaitFor

func (k *KeygenController) WaitFor()

WaitFor waits until controller finishes its logic. Context cancel should be called before.

type LocalSessionData

type LocalSessionData struct {
	SessionId          uint64
	Processing         bool
	SessionType        types.SessionType
	Proposer           rarimo.Party
	Set                *core.InputSet
	NewSecret          *secret.TssSecret
	Indexes            []string
	Root               string
	Acceptances        map[string]struct{}
	OperationSignature string
	KeySignature       string
	NewParties         []*rarimo.Party
	Offenders          map[string]struct{}
	Signers            map[string]struct{}
	IsSigner           bool
}

LocalSessionData represents all necessary data from current session to be shared between controllers.

func NewSessionData

func NewSessionData(ctx core.Context, id uint64, sessionType types.SessionType) *LocalSessionData

func (*LocalSessionData) GetAcceptanceController

func (data *LocalSessionData) GetAcceptanceController() IController

GetAcceptanceController returns the acceptance controller for the provided session data For types.SessionType_DefaultSession the acceptance controller will be based on current parties set (all active and inactive parties). For types.SessionType_ReshareSession the acceptance controller will be based on current parties set (all active and inactive parties).

func (*LocalSessionData) GetFinishController

func (data *LocalSessionData) GetFinishController() IController

GetFinishController returns the finish controller for the provided session data

func (*LocalSessionData) GetKeySignController

func (data *LocalSessionData) GetKeySignController() IController

GetKeySignController returns the key signature controller based on the selected signers set.

func (*LocalSessionData) GetKeygenController

func (data *LocalSessionData) GetKeygenController() IController

GetKeygenController returns the keygen controller for the provided session data For types.SessionType_KeygenSession the keygen controller will be based on current parties set (all parties should be inactive). For types.SessionType_ReshareSession the keygen controller will be based on current parties set (all active and inactive parties).

func (*LocalSessionData) GetProposalController

func (data *LocalSessionData) GetProposalController() IController

GetProposalController returns the proposal controller for the provided session data For types.SessionType_DefaultSession the proposal controller will be based on current parties set (all active and inactive parties). For types.SessionType_ReshareSession the proposal controller will be based on current parties set (all active and inactive parties).

func (*LocalSessionData) GetRootSignController

func (data *LocalSessionData) GetRootSignController() IController

GetRootSignController returns the root signature controller based on the selected signers set.

func (*LocalSessionData) Next

func (data *LocalSessionData) Next() *LocalSessionData

type ProposalController

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

ProposalController is responsible for proposing and collecting proposals from proposer. Proposer will execute logic of defining the next session type and suggest data to suggest in session.

func (*ProposalController) Next

func (p *ProposalController) Next() IController

Next will return acceptance controller if proposal sharing or receiving was successful, otherwise, it will return finish controller. WaitFor should be called before.

func (*ProposalController) Receive

Receive accepts proposal from other parties. It will check that proposal was submitted from the selected session proposer. After it will execute the `iProposalController.accept` logic.

func (*ProposalController) Run

Run launches the sharing proposal logic in corresponding session in case of self party is a session proposer.

func (*ProposalController) Type

func (*ProposalController) WaitFor

func (p *ProposalController) WaitFor()

WaitFor waits until controller finishes its logic. Context cancel should be called before.

type SignatureController

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

SignatureController is responsible for signing data by signature producers.

func (*SignatureController) Receive

Receive accepts the signature requests from other parties and delivers it to the `tss.SignParty. If sender is not present in current signers set request will not be accepted.

func (*SignatureController) Run

Run launches the `tss.SignParty` logic. After context canceling it will check the tss party result and execute `iSignatureController.finish` logic.

func (*SignatureController) Type

func (*SignatureController) WaitFor

func (s *SignatureController) WaitFor()

WaitFor waits until controller finishes its logic. Context cancel should be called before.

Jump to

Keyboard shortcuts

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