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 eth2. 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
- func MarshalOptionsFile(_ context.Context, opts *KeymanagerOpts) ([]byte, error)
- func ResetCaches()
- type AccountStore
- type Keymanager
- func (dr *Keymanager) DeleteAccounts(ctx context.Context, publicKeys [][]byte) error
- func (dr *Keymanager) ExtractKeystores(_ context.Context, publicKeys []bls.PublicKey, password string) ([]*keymanager.Keystore, error)
- func (dr *Keymanager) FetchValidatingPrivateKeys(ctx context.Context) ([][32]byte, error)
- func (dr *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error)
- func (dr *Keymanager) ImportKeystores(ctx context.Context, keystores []*keymanager.Keystore, importsPassword string) error
- func (dr *Keymanager) KeymanagerOpts() *KeymanagerOpts
- func (dr *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error)
- func (dr *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][48]byte) event.Subscription
- func (dr *Keymanager) ValidatingAccountNames() ([]string, error)
- type KeymanagerOpts
- type SetupConfig
Constants ¶
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" )
Variables ¶
This section is empty.
Functions ¶
func MarshalOptionsFile ¶
func MarshalOptionsFile(_ context.Context, opts *KeymanagerOpts) ([]byte, error)
MarshalOptionsFile returns a marshaled options file for a keymanager.
Types ¶
type AccountStore ¶
type AccountStore struct { PrivateKeys [][]byte `json:"private_keys"` PublicKeys [][]byte `json:"public_keys"` }
AccountStore defines a struct containing 1-to-1 corresponding private keys and public keys for eth2 validators.
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) DeleteAccounts ¶
func (dr *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 (dr *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 (dr *Keymanager) FetchValidatingPrivateKeys(ctx context.Context) ([][32]byte, error)
FetchValidatingPrivateKeys fetches the list of private keys from the secret keys cache
func (*Keymanager) FetchValidatingPublicKeys ¶
func (dr *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error)
FetchValidatingPublicKeys fetches the list of public keys from the imported account keystores.
func (*Keymanager) ImportKeystores ¶
func (dr *Keymanager) ImportKeystores( ctx context.Context, keystores []*keymanager.Keystore, importsPassword string, ) error
ImportKeystores into the imported keymanager from an external source.
func (*Keymanager) KeymanagerOpts ¶
func (dr *Keymanager) KeymanagerOpts() *KeymanagerOpts
KeymanagerOpts for the imported keymanager.
func (*Keymanager) Sign ¶
func (dr *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error)
Sign signs a message using a validator key.
func (*Keymanager) SubscribeAccountChanges ¶
func (dr *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 (dr *Keymanager) ValidatingAccountNames() ([]string, error)
ValidatingAccountNames for a imported keymanager.
type KeymanagerOpts ¶
type KeymanagerOpts struct { EIPVersion string `json:"direct_eip_version"` Version string `json:"direct_version"` }
KeymanagerOpts for a imported keymanager.
func DefaultKeymanagerOpts ¶
func DefaultKeymanagerOpts() *KeymanagerOpts
DefaultKeymanagerOpts for a imported keymanager implementation.
func UnmarshalOptionsFile ¶
func UnmarshalOptionsFile(r io.ReadCloser) (*KeymanagerOpts, error)
UnmarshalOptionsFile attempts to JSON unmarshal a imported keymanager options file into a struct.
func (*KeymanagerOpts) String ¶
func (opts *KeymanagerOpts) String() string
String pretty-print of a imported keymanager options.
type SetupConfig ¶
type SetupConfig struct { Wallet iface.Wallet Opts *KeymanagerOpts SkipMnemonicConfirm bool Mnemonic string }
SetupConfig includes configuration values for initializing a keymanager, such as passwords, the wallet, and more.