wallet

package
v0.0.0-...-e56efb7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

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"
)
View Source
const (
	// KeymanagerConfigFileName for the keymanager used by the wallet: imported, derived, or remote.
	KeymanagerConfigFileName = "keymanageropts.json"
	// NewWalletPasswordPromptText for wallet creation.
	NewWalletPasswordPromptText = "New wallet password"
	// WalletPasswordPromptText for wallet unlocking.
	PasswordPromptText = "Wallet password"
	// ConfirmPasswordPromptText for confirming a wallet password.
	ConfirmPasswordPromptText = "Confirm password"
	// DefaultWalletPasswordFile used to store a wallet password with appropriate permissions
	// if a user signs up via the Prysm web UI via RPC.
	DefaultWalletPasswordFile = "walletpassword.txt"
	// CheckExistsErrMsg for when there is an error while checking for a wallet
	CheckExistsErrMsg = "could not check if wallet exists"
	// CheckValidityErrMsg for when there is an error while checking wallet validity
	CheckValidityErrMsg = "could not check if wallet is valid"
	// InvalidWalletErrMsg for when a directory does not contain a valid wallet
	InvalidWalletErrMsg = "directory does not contain valid wallet"
)

Variables

View Source
var ErrInfinitePubKey = errors.New("received an infinite public key")

ErrInfinitePubKey describes an error due to an infinite public key.

View Source
var ErrNoWalletFound = errors.New(
	"no wallet found. You can create a new wallet with `validator wallet create`. " +
		"If you already did, perhaps you created a wallet in a custom directory, which you can specify using " +
		"`--wallet-dir=/path/to/my/wallet`",
)
View Source
var ErrSecretUnmarshal = errors.New("could not unmarshal bytes into secret key")

ErrSecretUnmarshal describes an error which happens during unmarshalling a secret key.

View Source
var ErrSigFailedToVerify = errors.New("signature did not verify")

ErrSigFailedToVerify returns when a signature of a block object(ie attestation, slashing, exit... etc) failed to verify.

View Source
var ErrZeroKey = errors.New("received secret key is zero")

ErrZeroKey describes an error due to a zero secret key.

Functions

func Exists

func Exists(walletDir string) (bool, error)

Exists checks if directory at walletDir exists

func IsValid

func IsValid(walletDir string) (bool, error)

IsValid checks if a folder contains a single key directory such as `derived`, `remote` or `imported`. Returns true if one of those subdirectories exist, false otherwise.

Types

type AccountsKeystoreRepresentation

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

AccountsKeystoreRepresentation defines an internal Prysm representation of validator accounts, encrypted according to the EIP-2334 standard but containing extra fields such as markers for disabled public keys.

type Config

type Config struct {
	WalletDir      string
	KeymanagerKind Kind
	WalletPassword string
}

Config to open a wallet programmatically.

type Keymanager

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

Keymanager implementation for imported keystores utilizing EIP-2335.

func NewKeymanager

func NewKeymanager(wallet *Wallet) (*Keymanager, error)

NewKeymanager instantiates a new imported keymanager from configuration options.

func (*Keymanager) Sign

func (km *Keymanager) Sign(slotInfo *SlotInfo, pubKeyIndex uint64) (bls.Signature, error)

Sign signs a message using a validator key.

func (*Keymanager) VerifySignature

func (km *Keymanager) VerifySignature(slotInfo *SlotInfo, pubKeyIndex uint64, signature bls.Signature) error

VerifyBlockSigningRoot verifies the signing root of a block given it's public key, signature and domain.

type Kind

type Kind int

Kind defines an enum for either imported, derived, or remote-signing keystores for Prysm wallets.

const (
	// Imported keymanager defines an on-disk, encrypted keystore-capable store.
	Imported Kind = iota
	// Derived keymanager using a hierarchical-deterministic algorithm.
	Derived
	// Remote keymanager capable of remote-signing data.
	Remote
)

func ParseKind

func ParseKind(k string) (Kind, error)

ParseKind from a raw string, returning a keymanager kind.

func (Kind) String

func (k Kind) String() string

String marshals a keymanager kind to a string value.

type SlotInfo

type SlotInfo struct {
	Epoch         uint64
	Slot          uint64
	ProposerIndex uint64
}

func NewSlotInfo

func NewSlotInfo(epoch, slot, proposerIndex uint64) *SlotInfo

func (*SlotInfo) DecodeRLP

func (s *SlotInfo) DecodeRLP(rlpData *rlp.Stream) error

DecodeRLP decodes the Ethereum

func (*SlotInfo) EncodeRLP

func (s *SlotInfo) EncodeRLP(w io.Writer) error

EncodeRLP serializes b into the Ethereum RLP block format.

func (*SlotInfo) Hash

func (s *SlotInfo) Hash() common.Hash

Hash returns the block hash of the header, which is simply the keccak256 hash of its RLP encoding.

type Wallet

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

Wallet is a primitive in Prysm's account management which has the capability of creating new accounts, reading existing accounts, and providing secure access to eth2 secrets depending on an associated keymanager (either imported, derived, or remote signing enabled).

func NewWallet

func NewWallet(cfg *Config) *Wallet

New creates a struct from config values.

func OpenWallet

func OpenWallet(_ context.Context, cfg *Config) (*Wallet, error)

OpenWallet instantiates a wallet from a specified path. It checks the type of keymanager associated with the wallet by reading files in the wallet path, if applicable. If a wallet does not exist, returns an appropriate error.

func (*Wallet) ReadFileAtPath

func (w *Wallet) ReadFileAtPath(filePath, fileName string) ([]byte, error)

ReadFileAtPath within the wallet directory given the desired path and filename.

Jump to

Keyboard shortcuts

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