Documentation ¶
Overview ¶
Package direct 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 direct keymanager approach relies on storing account information on-disk, making it trivial to import, export 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.
Accounts are stored on disk according to the following structure using human-readable account namespaces as directories:
wallet-dir/ keymanageropts.json personally-conscious-echidna/ keystore.json deposit_data.ssz deposit_transaction.rlp shy-extroverted-robin/ keystore.json deposit_data.ssz deposit_transaction.rlp passwords/ personally-conscious-echidna.pass shy-extroverted-robin.pass
EIP-2335 keystores are stored alongside deposit data credentials for the created validator accounts. An additional deposit_transaction.rlp file is stored under the account, containing a raw bytes eth1 transaction data ready to be used to submit a 32ETH deposit to the eth2 deposit contract for a validator. Passwords are stored in a separate directory for easy unlocking of the associated keystores by an account namespace.
This direct keymanager can be customized via a keymanageropts.json file, which has the following JSON schema as its options:
{ "direct_eip_version": "EIP-2335" }
Currently, the only supported value for `direct_eip_version` is "EIP-2335".
Index ¶
- Constants
- func MarshalConfigFile(ctx context.Context, cfg *Config) ([]byte, error)
- type AccountStore
- type Config
- type Keymanager
- func (dr *Keymanager) Config() *Config
- func (dr *Keymanager) CreateAccount(ctx context.Context) (string, error)
- func (dr *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error)
- func (dr *Keymanager) ImportKeystores(cliCtx *cli.Context, keystores []*v2keymanager.Keystore) error
- func (dr *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error)
- func (dr *Keymanager) ValidatingAccountNames() ([]string, error)
Constants ¶
const ( // KeystoreFileName exposes the expected filename for the keystore file for an account. KeystoreFileName = "keystore-*.json" // KeystoreFileNameFormat exposes the filename the keystore should be formatted in. KeystoreFileNameFormat = "keystore-%d.json" // PasswordFileSuffix for passwords persisted as text to disk. PasswordFileSuffix = ".pass" // AccountsPath where all direct keymanager keystores are kept. AccountsPath = "accounts" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountStore ¶
type AccountStore struct { PrivateKeys [][]byte `json:"private_keys"` PublicKeys [][]byte `json:"public_keys"` }
AccountStore --
type Config ¶
type Config struct { EIPVersion string `json:"direct_eip_version"` AccountPasswordsDirectory string `json:"direct_accounts_passwords_directory"` }
Config for a direct keymanager.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig for a direct keymanager implementation.
func UnmarshalConfigFile ¶
func UnmarshalConfigFile(r io.ReadCloser) (*Config, error)
UnmarshalConfigFile attempts to JSON unmarshal a direct keymanager configuration file into the *Config{} struct.
type Keymanager ¶
type Keymanager struct {
// contains filtered or unexported fields
}
Keymanager implementation for direct keystores utilizing EIP-2335.
func NewKeymanager ¶
NewKeymanager instantiates a new direct keymanager from configuration options.
func (*Keymanager) Config ¶
func (dr *Keymanager) Config() *Config
Config for the direct keymanager.
func (*Keymanager) CreateAccount ¶
func (dr *Keymanager) CreateAccount(ctx context.Context) (string, error)
CreateAccount for a direct keymanager implementation. This utilizes the EIP-2335 keystore standard for BLS12-381 keystores. It stores the generated keystore.json file in the wallet and additionally generates withdrawal credentials. At the end, it logs the raw deposit data hex string for users to copy.
func (*Keymanager) FetchValidatingPublicKeys ¶
func (dr *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error)
FetchValidatingPublicKeys fetches the list of public keys from the direct account keystores.
func (*Keymanager) ImportKeystores ¶
func (dr *Keymanager) ImportKeystores(cliCtx *cli.Context, keystores []*v2keymanager.Keystore) error
ImportKeystores into the direct keymanager from an external source.
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) ValidatingAccountNames ¶
func (dr *Keymanager) ValidatingAccountNames() ([]string, error)
ValidatingAccountNames for a direct keymanager.