initiator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxEffectiveBalanceInGwei is the max effective balance
	MaxEffectiveBalanceInGwei phase0.Gwei = 32000000000
)

Variables

View Source
var IsSupportedDepositNetwork = func(network eth2_key_manager_core.Network) bool {
	return network == eth2_key_manager_core.PyrmontNetwork || network == eth2_key_manager_core.PraterNetwork || network == eth2_key_manager_core.MainNetwork
}

IsSupportedDepositNetwork returns true if the given network is supported

Functions

This section is empty.

Types

type Data

type Data struct {
	PublicKey string         `json:"publicKey"`
	Operators []OperatorData `json:"operators"`
}

type DepositDataJson

type DepositDataJson struct {
	PubKey                string      `json:"pubkey"`
	WithdrawalCredentials string      `json:"withdrawal_credentials"`
	Amount                phase0.Gwei `json:"amount"`
	Signature             string      `json:"signature"`
	DepositMessageRoot    string      `json:"deposit_message_root"`
	DepositDataRoot       string      `json:"deposit_data_root"`
	ForkVersion           string      `json:"fork_version"`
	NetworkName           string      `json:"network_name"`
	DepositCliVersion     string      `json:"deposit_cli_version"`
}

type Initiator

type Initiator struct {
	Logger     *zap.Logger
	Client     *req.Client
	Operators  Operators
	VerifyFunc func(id uint64, msg, sig []byte) error
	PrivateKey *rsa.PrivateKey
}

func New

func New(privKey *rsa.PrivateKey, operatorMap Operators, logger *zap.Logger) *Initiator

func (*Initiator) CreateVerifyFunc

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

func (*Initiator) GetThreshold

func (c *Initiator) GetThreshold(ids []uint64) (int, error)

func (*Initiator) MakeMultiple

func (c *Initiator) MakeMultiple(id [24]byte, allmsgs [][]byte) (*wire.MultipleSignedTransports, error)

func (*Initiator) ProcessDKGResultResponse

func (c *Initiator) ProcessDKGResultResponse(responseResult [][]byte, id [24]byte) ([]dkg.Result, *bls.PublicKey, map[ssvspec_types.OperatorID]*bls.PublicKey, map[ssvspec_types.OperatorID]*bls.Sign, map[ssvspec_types.OperatorID]*bls.Sign, error)

func (*Initiator) SendAndCollect

func (c *Initiator) SendAndCollect(op Operator, method string, data []byte) ([]byte, error)

func (*Initiator) SendExchangeMsgs

func (c *Initiator) SendExchangeMsgs(exchangeMsgs [][]byte, id [24]byte, operators []*wire.Operator) ([][]byte, error)

func (*Initiator) SendInitMsg

func (c *Initiator) SendInitMsg(init *wire.Init, id [24]byte, operators []*wire.Operator) ([][]byte, error)

func (*Initiator) SendKyberMsgs

func (c *Initiator) SendKyberMsgs(kyberDeals [][]byte, id [24]byte, operators []*wire.Operator) ([][]byte, error)

func (*Initiator) SendToAll

func (c *Initiator) SendToAll(method string, msg []byte, operatorsIDs []*wire.Operator) ([][]byte, error)

func (*Initiator) StartDKG

func (c *Initiator) StartDKG(id [24]byte, withdraw []byte, ids []uint64, fork [4]byte, forkName string, owner common.Address, nonce uint64) (*DepositDataJson, *KeyShares, error)

func (*Initiator) VerifyAll

func (c *Initiator) VerifyAll(id [24]byte, allmsgs [][]byte) error

type KeyShares

type KeyShares struct {
	Version   string    `json:"version"`
	CreatedAt time.Time `json:"createdAt"`
	Data      Data      `json:"data"`
	Payload   Payload   `json:"payload"`
}

func GeneratePayload

func GeneratePayload(result []dkg.Result, sigOwnerNonce []byte) (*KeyShares, error)

type KeySharesKeys

type KeySharesKeys struct {
	PublicKeys    []string `json:"publicKeys"`
	EncryptedKeys []string `json:"encryptedKeys"`
}

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 MockInitiator

type MockInitiator interface {
	SendAndCollect(op Operator, method string, data []byte) ([]byte, error)
	SendToAll(method string, msg []byte) ([][]byte, error)
	PakeMultiple(id [24]byte, allmsgs [][]byte) (*wire.MultipleSignedTransports, error)
	StartDKG(withdraw []byte, ids []uint64, threshold uint64, fork [4]byte, forkName string, owner common.Address, nonce uint64) (*DepositDataJson, *KeyShares, error)
	CreateVerifyFunc(ops []*wire.Operator) (func(id uint64, msg []byte, sig []byte) error, error)
	ProcessDKGResultResponse(responseResult [][]byte, id [24]byte) ([]dkg.Result, *bls.PublicKey, map[ssvspec_types.OperatorID]*bls.PublicKey, map[ssvspec_types.OperatorID]*bls.Sign, map[ssvspec_types.OperatorID]*bls.Sign, error)
	SendKyberMsgs(kyberDeals [][]byte, id [24]byte) ([][]byte, error)
	SendExchangeMsgs(exchangeMsgs [][]byte, id [24]byte) ([][]byte, error)
	SendInitMsg(init *wire.Init, id [24]byte) ([][]byte, error)
}

type Operator

type Operator struct {
	Addr   string
	ID     uint64
	PubKey *rsa.PublicKey
}

type OperatorData

type OperatorData struct {
	ID          uint64 `json:"id"`
	OperatorKey string `json:"operatorKey"`
}

type OperatorDataJson

type OperatorDataJson struct {
	Addr   string `json:"ip"`
	ID     uint64 `json:"id"`
	PubKey string `json:"public_key"`
}

type Operators

type Operators map[uint64]Operator

func LoadOperatorsJson

func LoadOperatorsJson(operatorsMetaData []byte) (Operators, error)

type Payload

type Payload struct {
	PublicKey   string   `json:"publicKey"`
	OperatorIDs []uint64 `json:"operatorIds"`
	SharesData  string   `json:"sharesData"`
}

Jump to

Keyboard shortcuts

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