Documentation
¶
Index ¶
- Constants
- func MarshalConfigFile(ctx context.Context, cfg *Config) ([]byte, error)
- func MarshalEncryptedSeedFile(ctx context.Context, seedCfg *SeedConfig) ([]byte, error)
- type Config
- type EnglishMnemonicGenerator
- type Keymanager
- func (dr *Keymanager) Config() *Config
- func (dr *Keymanager) CreateAccount(ctx context.Context, logAccountInfo bool) (string, error)
- func (dr *Keymanager) DepositDataForAccount(accountIndex uint64) ([]byte, error)
- func (dr *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error)
- func (dr *Keymanager) FetchWithdrawalPublicKeys(ctx context.Context) ([][48]byte, error)
- func (dr *Keymanager) NextAccountNumber(ctx context.Context) uint64
- func (dr *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (bls.Signature, error)
- func (dr *Keymanager) ValidatingAccountNames(ctx context.Context) ([]string, error)
- type SeedConfig
- type SeedPhraseFactory
Constants ¶
const ( // EIPVersion used by this derived keymanager implementation. EIPVersion = "EIP-2334" // WithdrawalKeyDerivationPathTemplate defining the hierarchical path for withdrawal // keys for Prysm eth2 validators. According to EIP-2334, the format is as follows: // m / purpose / coin_type / account_index / withdrawal_key WithdrawalKeyDerivationPathTemplate = "m/12381/3600/%d/0" // ValidatingKeyDerivationPathTemplate defining the hierarchical path for validating // keys for Prysm eth2 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" // EncryptedSeedFileName for persisting a wallet's seed when using a derived keymanager. EncryptedSeedFileName = "seed.encrypted.json" )
Variables ¶
This section is empty.
Functions ¶
func MarshalConfigFile ¶
MarshalConfigFile returns a marshaled configuration file for a keymanager.
func MarshalEncryptedSeedFile ¶
func MarshalEncryptedSeedFile(ctx context.Context, seedCfg *SeedConfig) ([]byte, error)
MarshalEncryptedSeedFile json encodes the seed configuration for a derived keymanager.
Types ¶
type Config ¶
Config for a derived keymanager.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig for a derived keymanager implementation.
func UnmarshalConfigFile ¶
func UnmarshalConfigFile(r io.ReadCloser) (*Config, error)
UnmarshalConfigFile attempts to JSON unmarshal a derived keymanager configuration file into the *Config{} struct.
type EnglishMnemonicGenerator ¶
type EnglishMnemonicGenerator struct {
// contains filtered or unexported fields
}
EnglishMnemonicGenerator implements methods for creating mnemonic seed phrases in english using a given source of entropy such as a private key.
func (*EnglishMnemonicGenerator) ConfirmAcknowledgement ¶
func (m *EnglishMnemonicGenerator) ConfirmAcknowledgement(phrase string) error
ConfirmAcknowledgement displays the mnemonic phrase to the user and confirms the user has written down the phrase securely offline.
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, wallet iface.Wallet, cfg *Config, skipMnemonicConfirm bool, password string, ) (*Keymanager, error)
NewKeymanager instantiates a new derived keymanager from configuration options.
func (*Keymanager) Config ¶
func (dr *Keymanager) Config() *Config
Config returns the derived keymanager configuration.
func (*Keymanager) CreateAccount ¶
CreateAccount for a derived keymanager implementation. This utilizes the EIP-2335 keystore standard for BLS12-381 keystores. It uses the EIP-2333 and EIP-2334 for hierarchical derivation of BLS secret keys and a common derivation path structure for persisting accounts to disk. Each account stores the generated keystore.json file. The entire derived wallet seed phrase can be recovered from a BIP-39 english mnemonic.
func (*Keymanager) DepositDataForAccount ¶
func (dr *Keymanager) DepositDataForAccount(accountIndex uint64) ([]byte, error)
DepositDataForAccount with a given index returns the RLP encoded eth1 deposit transaction data.
func (*Keymanager) FetchValidatingPublicKeys ¶
func (dr *Keymanager) FetchValidatingPublicKeys(ctx context.Context) ([][48]byte, error)
FetchValidatingPublicKeys fetches the list of validating public keys from the keymanager.
func (*Keymanager) FetchWithdrawalPublicKeys ¶
func (dr *Keymanager) FetchWithdrawalPublicKeys(ctx context.Context) ([][48]byte, error)
FetchWithdrawalPublicKeys fetches the list of withdrawal public keys from keymanager
func (*Keymanager) NextAccountNumber ¶
func (dr *Keymanager) NextAccountNumber(ctx context.Context) uint64
NextAccountNumber managed by the derived 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) ValidatingAccountNames ¶
func (dr *Keymanager) ValidatingAccountNames(ctx context.Context) ([]string, error)
ValidatingAccountNames for the derived keymanager.
type SeedConfig ¶
type SeedConfig struct { Crypto map[string]interface{} `json:"crypto"` ID string `json:"uuid"` NextAccount uint64 `json:"next_account"` Version uint `json:"version"` Name string `json:"name"` }
SeedConfig json file representation as a Go struct.
func InitializeWalletSeedFile ¶
func InitializeWalletSeedFile(ctx context.Context, password string, skipMnemonicConfirm bool) (*SeedConfig, error)
InitializeWalletSeedFile creates a new, encrypted seed using a password input and persists its encrypted file metadata to disk under the wallet path.
func SeedFileFromMnemonic ¶
func SeedFileFromMnemonic(ctx context.Context, mnemonic string, password string) (*SeedConfig, error)
SeedFileFromMnemonic uses the provided mnemonic seed phrase to generate the appropriate seed file for recovering a derived wallets.
type SeedPhraseFactory ¶
type SeedPhraseFactory interface { Generate(data []byte) (string, error) ConfirmAcknowledgement(phrase string) error }
SeedPhraseFactory defines a struct which can generate new seed phrases in human-readable format from a source of entropy in raw bytes. It also provides methods for verifying a user has successfully acknowledged the mnemonic phrase and written it down offline.