imported

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package imported defines an implementation of an on-disk, EIP-2335 keystore.json approach towards defining validator accounts in Prysm. A validating private key is encrypted using a passphrase and its resulting encrypted file is stored as a keystore.json file under a unique, human-readable, account namespace. This imported keymanager approach relies on storing account information on-disk, making it trivial to import, backup and list all associated accounts for a user.

EIP-2335 is a keystore format defined by https://eips.ethereum.org/EIPS/eip-2335 for storing and defining encryption for BLS12-381 private keys, utilized by Ethereum. This keystore.json format is not compatible with the current keystore standard used in eth1 due to a lack of support for KECCAK-256. Passwords utilized for key encryptions are strings of arbitrary unicode characters. The password is first converted to its NFKD representation, stripped of control codes specified in the EIP link above, and finally the password is UTF-8 encoded.

Index

Constants

View Source
const (
	// KeystoreFileNameFormat exposes the filename the keystore should be formatted in.
	KeystoreFileNameFormat = "keystore-%d.json"
	// AccountsPath where all imported keymanager keystores are kept.
	AccountsPath = "accounts"
	// AccountsKeystoreFileName exposes the name of the keystore file.
	AccountsKeystoreFileName = "all-accounts.keystore.json"
)

Variables

This section is empty.

Functions

func ResetCaches

func ResetCaches()

ResetCaches for the keymanager.

Types

type AccountsKeystoreRepresentation added in v1.1.0

type AccountsKeystoreRepresentation struct {
	Crypto  map[string]interface{} `json:"crypto"`
	ID      string                 `json:"uuid"`
	Version uint                   `json:"version"`
	Name    string                 `json:"name"`
}

AccountsKeystoreRepresentation defines an internal Prysm representation of validator accounts, encrypted according to the EIP-2334 standard.

type Keymanager

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

Keymanager implementation for imported keystores utilizing EIP-2335.

func NewInteropKeymanager

func NewInteropKeymanager(_ context.Context, offset, numValidatorKeys uint64) (*Keymanager, error)

NewInteropKeymanager instantiates a new imported keymanager with the deterministically generated interop keys.

func NewKeymanager

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

NewKeymanager instantiates a new imported keymanager from configuration options.

func (*Keymanager) CreateAccountsKeystore added in v1.1.0

func (km *Keymanager) CreateAccountsKeystore(
	_ context.Context,
	privateKeys, publicKeys [][]byte,
) (*AccountsKeystoreRepresentation, error)

CreateAccountsKeystore creates a new keystore holding the provided keys.

func (*Keymanager) DeleteAccounts

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

DeleteAccounts takes in public keys and removes the accounts entirely. This includes their disk keystore and cached keystore.

func (*Keymanager) ExtractKeystores

func (km *Keymanager) ExtractKeystores(
	_ 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 private keys from the secret keys cache

func (*Keymanager) FetchValidatingPublicKeys

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

FetchValidatingPublicKeys fetches the list of active public keys from the imported account keystores.

func (*Keymanager) ImportKeypairs

func (km *Keymanager) ImportKeypairs(ctx context.Context, privKeys, pubKeys [][]byte) error

ImportKeypairs directly into the keymanager.

func (*Keymanager) ImportKeystores

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

ImportKeystores into the imported keymanager from an external source.

func (*Keymanager) Sign

Sign signs a message using a validator key.

func (*Keymanager) SubscribeAccountChanges

func (km *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][48]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() ([]string, error)

ValidatingAccountNames for a imported keymanager.

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