operator

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ErrTooManyRouteRequests = `{"error": "too many requests to /route"}`

TODO: either do all json or all SSZ

View Source
const MaxInstanceTime = 5 * time.Minute
View Source
const MaxInstances = 1024

Variables

This section is empty.

Functions

func GetOperatorID added in v1.1.0

func GetOperatorID(operators []*wire.Operator, pkBytes []byte) (uint64, error)

func RegisterRoutes

func RegisterRoutes(s *Server)

RegisterRoutes creates routes at operator to process messages incoming from initiator

Types

type Instance

type Instance interface {
	Process(uint64, *wire.SignedTransport) error
	ReadResponse() []byte
	ReadError() error
	VerifyInitiatorMessage(msg, sig []byte) error
	GetLocalOwner() *dkg.LocalOwner
}

Instance interface to process messages at DKG instances incoming from initiator

type InstanceID

type InstanceID [24]byte

InstanceID each new DKG ceremony has a unique random ID that we can identify messages and be able to process them in parallel

type KeySign

type KeySign struct {
	ValidatorPK ssvspec_types.ValidatorPK
	SigningRoot []byte
}

func (*KeySign) Decode

func (msg *KeySign) Decode(data []byte) error

Decode returns error if decoding failed

func (*KeySign) Encode

func (msg *KeySign) Encode() ([]byte, error)

Encode returns a msg encoded bytes or error

type Server

type Server struct {
	Logger     *zap.Logger  // logger
	HttpServer *http.Server // http server
	Router     chi.Router   // http router
	State      *Switch      // structure to store instances of DKG ceremonies
}

Server structure for operator to store http server and DKG ceremony instances

func New

func New(key *rsa.PrivateKey, logger *zap.Logger, ver []byte, id uint64) (*Server, error)

New creates Server structure using operator's RSA private key

func (*Server) Start

func (s *Server) Start(port uint16) error

Start runs a http server to listen for incoming messages at specified port

func (*Server) Stop

func (s *Server) Stop() error

Stop closes http server instance

type Switch

type Switch struct {
	Logger           *zap.Logger
	Mtx              sync.RWMutex
	InstanceInitTime map[InstanceID]time.Time // mapping to store DKG instance creation time
	Instances        map[InstanceID]Instance  // mapping to store DKG instances
	PrivateKey       *rsa.PrivateKey          // operator RSA private key
	Version          []byte
	PubKeyBytes      []byte
	OperatorID       uint64
}

Switch structure to hold many instances created for separate DKG ceremonies

func NewSwitch

func NewSwitch(pv *rsa.PrivateKey, logger *zap.Logger, ver, pkBytes []byte, id uint64) *Switch

NewSwitch creates a new Switch

func (*Switch) CleanInstances

func (s *Switch) CleanInstances() int

CleanInstances removes all instances at Switch

func (*Switch) CreateInstance

func (s *Switch) CreateInstance(reqID [24]byte, init *wire.Init, initiatorPublicKey *rsa.PublicKey) (Instance, []byte, error)

CreateInstance creates a LocalOwner instance with the DKG ceremony ID, that we can identify it later. Initiator public key identifies an initiator for new instance. There cant be two instances with the same ID, but one initiator can start several DKG ceremonies.

func (*Switch) CreateInstanceReshare added in v1.0.0

func (s *Switch) CreateInstanceReshare(reqID [24]byte, reshare *wire.Reshare, initiatorPublicKey *rsa.PublicKey) (Instance, []byte, error)

func (*Switch) CreateVerifyFunc

func (s *Switch) CreateVerifyFunc(ops []*wire.Operator) (func(id uint64, msg []byte, sig []byte) error, error)

CreateVerifyFunc verifies signatures for operators participating at DKG ceremony

func (*Switch) Decrypt

func (s *Switch) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt with RSA private key private DKG share key

func (*Switch) DecryptSecretDB added in v1.0.0

func (s *Switch) DecryptSecretDB(bin []byte) ([]byte, error)

DecryptSecretDB decrypts a secret share using operator's private key

func (*Switch) Encrypt

func (s *Switch) Encrypt(msg []byte) ([]byte, error)

Encrypt with RSA public key private DKG share key

func (*Switch) EncryptSecretDB added in v1.0.0

func (s *Switch) EncryptSecretDB(bin []byte) ([]byte, error)

EncryptSecretDB encrypts secret share object bytes using RSA key to store at DB

func (*Switch) InitInstance

func (s *Switch) InitInstance(reqID [24]byte, initMsg *wire.Transport, initiatorSignature []byte) ([]byte, error)

InitInstance creates a LocalOwner instance and DKG public key message (Exchange)

func (*Switch) InitInstanceReshare added in v1.0.0

func (s *Switch) InitInstanceReshare(reqID [24]byte, reshareMsg *wire.Transport, initiatorSignature []byte) ([]byte, error)

func (*Switch) MarshallAndSign added in v1.1.0

func (s *Switch) MarshallAndSign(msg wire.SSZMarshaller, msgType wire.TransportType, operatorID uint64, id [24]byte) ([]byte, error)

func (*Switch) Pong added in v1.1.0

func (s *Switch) Pong() ([]byte, error)

func (*Switch) ProcessMessage

func (s *Switch) ProcessMessage(dkgMsg []byte) ([]byte, error)

ProcessMessage processes incoming message to /dkg route

func (*Switch) SaveResultData added in v1.1.0

func (s *Switch) SaveResultData(incMsg *wire.SignedTransport) error

func (*Switch) Sign

func (s *Switch) Sign(msg []byte) ([]byte, error)

Sign creates a RSA signature for the message at operator before sending it to initiator

func (*Switch) VerifyIncomingMessage added in v1.1.0

func (s *Switch) VerifyIncomingMessage(incMsg *wire.SignedTransport) (uint64, error)

func (*Switch) VerifySig added in v1.1.0

func (s *Switch) VerifySig(incMsg *wire.SignedTransport, initiatorPubKey *rsa.PublicKey) error

Jump to

Keyboard shortcuts

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