derived

package
v4.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: GPL-3.0 Imports: 18 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// DerivationPathFormat describes the structure of how keys are derived from a master key.
	DerivationPathFormat = "m / purpose / coin_type / account_index / withdrawal_key / validating_key"
	// ValidatingKeyDerivationPathTemplate defining the hierarchical path for validating
	// keys for Prysm Ethereum validators. According to EIP-2334, the format is as follows:
	// m / purpose / coin_type / account_index / withdrawal_key / validating_key
	ValidatingKeyDerivationPathTemplate = "m/12381/3600/%d/0/0"
)

Variables

View Source
var (
	DefaultMnemonicLanguage        = "english"
	ErrUnsupportedMnemonicLanguage = errors.New("unsupported mnemonic language")
)

ErrUnsupportedMnemonicLanguage is returned when trying to use an unsupported mnemonic language.

Functions

func GenerateAndConfirmMnemonic

func GenerateAndConfirmMnemonic(mnemonicLanguage string, skipMnemonicConfirm bool) (string, error)

GenerateAndConfirmMnemonic requires confirming the generated mnemonics.

Types

type Keymanager

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

Keymanager implementation for derived, HD keymanager using EIP-2333 and EIP-2334.

func NewKeymanager

func NewKeymanager(
	ctx context.Context,
	cfg *SetupConfig,
) (*Keymanager, error)

NewKeymanager instantiates a new derived keymanager from configuration options.

func (*Keymanager) DeleteKeystores

func (km *Keymanager) DeleteKeystores(
	ctx context.Context, publicKeys [][]byte,
) ([]*keymanager.KeyStatus, error)

DeleteKeystores for a derived keymanager.

func (*Keymanager) ExtractKeystores

func (km *Keymanager) ExtractKeystores(
	ctx context.Context, publicKeys []bls.PublicKey, password string,
) ([]*keymanager.Keystore, error)

ExtractKeystores retrieves the secret keys for specified public keys in the function input, encrypts them using the specified password, and returns their respective EIP-2335 keystores.

func (*Keymanager) FetchValidatingPrivateKeys

func (km *Keymanager) FetchValidatingPrivateKeys(ctx context.Context) ([][32]byte, error)

FetchValidatingPrivateKeys fetches the list of validating private keys from the keymanager.

func (*Keymanager) FetchValidatingPublicKeys

func (km *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)

FetchValidatingPublicKeys fetches the list of validating public keys from the keymanager.

func (*Keymanager) ImportKeystores

func (km *Keymanager) ImportKeystores(
	ctx context.Context, keystores []*keymanager.Keystore, passwords []string,
) ([]*keymanager.KeyStatus, error)

ImportKeystores for a derived keymanager.

func (*Keymanager) ListKeymanagerAccounts

func (km *Keymanager) ListKeymanagerAccounts(ctx context.Context, cfg keymanager.ListKeymanagerAccountConfig) error

func (*Keymanager) RecoverAccountsFromMnemonic

func (km *Keymanager) RecoverAccountsFromMnemonic(
	ctx context.Context, mnemonic, mnemonicLanguage, mnemonicPassphrase string, numAccounts int,
) error

RecoverAccountsFromMnemonic given a mnemonic phrase, is able to regenerate N accounts from a derived seed, encrypt them according to the EIP-2334 JSON standard, and write them to disk. Then, the mnemonic is never stored nor used by the validator.

func (*Keymanager) Sign

Sign signs a message using a validator key.

func (*Keymanager) SubscribeAccountChanges

func (km *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][fieldparams.BLSPubkeyLength]byte) event.Subscription

SubscribeAccountChanges creates an event subscription for a channel to listen for public key changes at runtime, such as when new validator accounts are imported into the keymanager while the validator process is running.

func (*Keymanager) ValidatingAccountNames

func (km *Keymanager) ValidatingAccountNames(_ context.Context) ([]string, error)

ValidatingAccountNames for the derived keymanager.

type MnemonicGenerator

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

MnemonicGenerator implements methods for creating mnemonic seed phrases in english using a given source of entropy such as a private key.

func (*MnemonicGenerator) ConfirmAcknowledgement

func (m *MnemonicGenerator) ConfirmAcknowledgement(phrase string) error

ConfirmAcknowledgement displays the mnemonic phrase to the user and confirms the user has written down the phrase securely offline.

func (*MnemonicGenerator) Generate

func (_ *MnemonicGenerator) Generate(data []byte) (string, error)

Generate a mnemonic seed phrase in english using a source of entropy given as raw bytes.

type SetupConfig

type SetupConfig struct {
	Wallet           iface.Wallet
	ListenForChanges bool
}

SetupConfig includes configuration values for initializing a keymanager, such as passwords, the wallet, and more.

Jump to

Keyboard shortcuts

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