initiator

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: 28 Imported by: 0

Documentation

Index

Constants

View Source
const DepositCliVersion = "2.7.0"

DepositCliVersion is last version accepted by launchpad

Variables

This section is empty.

Functions

func CreateVerifyFunc added in v1.1.0

func CreateVerifyFunc(ops Operators) func(id uint64, msg []byte, sig []byte) error

CreateVerifyFunc creates function to verify each participating operator RSA signature for incoming to initiator messages

func ParseAsError added in v1.2.0

func ParseAsError(msg []byte) (parsedErr, err error)

parseAsError parses the error from an operator

func ValidatedOperatorData added in v1.0.0

func ValidatedOperatorData(ids []uint64, operators Operators) ([]*wire.Operator, error)

ValidatedOperatorData validates operators information data before starting a DKG ceremony

func VerifyDepositData added in v1.0.0

func VerifyDepositData(depsitDataJson *DepositDataJson, withdrawCred []byte, owner common.Address, nonce uint16) error

Types

type CeremonySigs added in v1.2.0

type CeremonySigs struct {
	ValidatorPubKey    string   `json:"validator"`
	OperatorIDs        []uint64 `json:"operatorIds"`
	Sigs               string   `json:"ceremonySigs"`
	InitiatorPublicKey string   `json:"initiatorPublicKey"`
}

type Data

type Data struct {
	ShareData `json:"data"`
	Payload   Payload `json:"payload"`
}

Data structure as a part of KeyShares representing BLS validator public key and information about validators

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"`
}

DepositDataJson structure to create a resulting deposit data JSON file according to ETH2 protocol

type Initiator

type Initiator struct {
	Logger     *zap.Logger                            // logger
	Client     *req.Client                            // http client
	Operators  Operators                              // operators info mapping
	VerifyFunc func(id uint64, msg, sig []byte) error // function to verify signatures of incoming messages
	PrivateKey *rsa.PrivateKey                        // a unique initiator's RSA private key used for signing messages and identity
	Version    []byte
}

Initiator main structure for initiator

func New

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

New creates a main initiator structure

func (*Initiator) GetAndCollect added in v1.1.0

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

GetAndCollect request Get at operator route

func (*Initiator) GetCeremonySigs added in v1.2.0

func (c *Initiator) GetCeremonySigs(dkgResults []dkg.Result) (*CeremonySigs, error)

func (*Initiator) MakeMultiple

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

MakeMultiple creates a one combined message from operators with initiator signature

func (*Initiator) Ping added in v1.1.0

func (c *Initiator) Ping(ips []string) error

func (*Initiator) ProcessDKGResultResponse

func (c *Initiator) ProcessDKGResultResponse(dkgResults []dkg.Result) (sharePks []*bls.PublicKey, sigDepositShares, ssvContractOwnerNonceSigShares []*bls.Sign, err error)

ProcessDKGResultResponse deserializes incoming DKG result messages from operators

func (*Initiator) SendAndCollect

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

SendAndCollect ssends http message to operator and read the response

func (*Initiator) SendExchangeMsgs

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

SendExchangeMsgs sends combined exchange messages to each operator participating in DKG ceremony

func (*Initiator) SendInitMsg

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

SendInitMsg sends initial DKG ceremony message to participating operators from initiator

func (*Initiator) SendKyberMsgs

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

SendKyberMsgs sends combined kyber messages to each operator participating in DKG ceremony

func (*Initiator) SendPingMsg added in v1.1.0

func (c *Initiator) SendPingMsg(ping *wire.Ping, operators []*wire.Operator) ([][]byte, error)

func (*Initiator) SendReshareMsg added in v1.0.0

func (c *Initiator) SendReshareMsg(reshare *wire.Reshare, id [24]byte, ops []*wire.Operator) ([][]byte, error)

func (*Initiator) SendToAll

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

SendToAll sends http messages to all operators. Makes sure that all responses are received

func (*Initiator) StartDKG

func (c *Initiator) StartDKG(id [24]byte, withdraw []byte, ids []uint64, network eth2_key_manager_core.Network, owner common.Address, nonce uint64) (*DepositDataJson, *KeyShares, *CeremonySigs, error)

StartDKG starts DKG ceremony at initiator with requested parameters

func (*Initiator) StartReshare added in v1.0.0

func (c *Initiator) StartReshare(id [24]byte, newOpIDs []uint64, keysharesFile, ceremonySigs []byte, nonce uint64) (*KeyShares, *CeremonySigs, error)

func (*Initiator) VerifyAll

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

VerifyAll verifies incoming to initiator messages from operators. Incoming message from operator should have same DKG ceremony ID and a valid signature

type KeyShares

type KeyShares struct {
	Version   string    `json:"version"`
	CreatedAt time.Time `json:"createdAt"`
	Shares    []Data    `json:"shares"`
}

KeyShares structure to create an json file for ssv smart contract

func GenerateAggregatesKeyshares added in v1.1.0

func GenerateAggregatesKeyshares(keySharesArr []*KeyShares) (*KeyShares, error)

func GeneratePayload

func GeneratePayload(result []dkg.Result, sigOwnerNonce []byte, owner common.Address, nonce uint64) (*KeyShares, error)

GeneratePayload generates at initiator ssv smart contract payload using DKG result received from operators participating in DKG ceremony

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 Operator

type Operator struct {
	Addr   string         // ip:port
	ID     uint64         // operators ID
	PubKey *rsa.PublicKey // operators RSA public key
}

Operator structure represents operators info which is public

type OperatorData

type OperatorData struct {
	ID          uint64 `json:"id"`
	OperatorKey string `json:"operatorKey"` // encoded RSA public key
}

OperatorData structure to represent information about operators participating in signing validator's duty

type OperatorDataJson

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

OperatorDataJson is used to store operators info ar JSON

type Operators

type Operators map[uint64]Operator

Operators mapping storage for operator structs [ID]operator

func LoadOperatorsJson

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

LoadOperatorsJson deserialize operators data from JSON

func (Operators) Clone added in v1.1.0

func (o Operators) Clone() Operators

type Payload

type Payload struct {
	PublicKey   string   `json:"publicKey"`   // validator's public key
	OperatorIDs []uint64 `json:"operatorIds"` // operators IDs
	SharesData  string   `json:"sharesData"`  // encrypted private BLS shares of each operator participating in DKG
}

type ShareData added in v1.1.0

type ShareData struct {
	OwnerNonce   uint64         `json:"ownerNonce"`
	OwnerAddress string         `json:"ownerAddress "`
	PublicKey    string         `json:"publicKey"`
	Operators    []OperatorData `json:"operators"`
}

Jump to

Keyboard shortcuts

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