Documentation
¶
Index ¶
- Constants
- func EntropyToMnemonic(entropy []byte) (string, error)
- func GenerateNewEntropy() ([]byte, error)
- func InitBLS() error
- func SeedFromEntropy(entropy []byte, password string) ([]byte, error)
- func SeedFromMnemonic(mnemonic string, password string) ([]byte, error)
- type AccountStorage
- type AttestationSlashStatus
- type HDKey
- type MasterDerivableKey
- type Network
- func (n Network) DepositContractAddress() string
- func (n Network) EstimatedCurrentEpoch() phase0.Epoch
- func (n Network) EstimatedCurrentSlot() phase0.Slot
- func (n Network) EstimatedEpochAtSlot(slot phase0.Slot) phase0.Epoch
- func (n Network) EstimatedSlotAtTime(time int64) phase0.Slot
- func (n Network) FullPath(relativePath string) string
- func (n Network) GenesisForkVersion() phase0.Version
- func (n Network) GenesisValidatorsRoot() phase0.Root
- func (n Network) MinGenesisTime() uint64
- func (n Network) SlotDurationSec() time.Duration
- func (n Network) SlotsPerEpoch() uint64
- type ProposalDetectionType
- type ProposalSlashStatus
- type SlashingProtector
- type SlashingStore
- type Storage
- type ValidatorAccount
- type ValidatorInfo
- type VoteDetectionType
- type Wallet
- type WalletContext
- type WalletStorage
- type WalletType
Constants ¶
const (
// BaseEIP2334Path is the base EIP2334 path.
BaseEIP2334Path = "m/12381/3600"
)
EIP2334 paths.
Variables ¶
This section is empty.
Functions ¶
func EntropyToMnemonic ¶
EntropyToMnemonic creates the mnemonic passphrase.
func GenerateNewEntropy ¶
GenerateNewEntropy generates a new entropy
func SeedFromEntropy ¶
SeedFromEntropy creates seed from the given entropy the seed is the product of applying a key derivation algo (PBKDF2) on the mnemonic (as the entropy) and the password as salt. please see https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
func SeedFromMnemonic ¶
SeedFromMnemonic generates a new seed. The seed is the product of applying a key derivation algo (PBKDF2) on the mnemonic (as the entropy) and the password as salt. Please see https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
Types ¶
type AccountStorage ¶ added in v1.0.1
type AccountStorage interface {
// SaveAccount saves the given account
SaveAccount(account ValidatorAccount) error
// DeleteAccount deletes account by uuid
DeleteAccount(accountID uuid.UUID) error
// OpenAccount returns nil,nil if no account was found
OpenAccount(accountID uuid.UUID) (ValidatorAccount, error)
// SetEncryptor sets the given encryptor to the wallet.
SetEncryptor(encryptor encryptor.Encryptor, password []byte)
}
AccountStorage represents the behavior of the account storage
type AttestationSlashStatus ¶
type AttestationSlashStatus struct {
Attestation *phase0.AttestationData
Status VoteDetectionType
}
AttestationSlashStatus represents attestation slashing status
type HDKey ¶
type HDKey struct {
// contains filtered or unexported fields
}
HDKey is a derived key from MasterDerivableKey which is able to sign messages, return thee public key and more.
func NewHDKeyFromPrivateKey ¶
NewHDKeyFromPrivateKey is the constructor of HDKey
func (*HDKey) MarshalJSON ¶
MarshalJSON is the custom JSON marshaler
func (*HDKey) UnmarshalJSON ¶
UnmarshalJSON is the custom JSON unmarshaler
type MasterDerivableKey ¶
type MasterDerivableKey struct {
// contains filtered or unexported fields
}
MasterDerivableKey is responsible for managing privKey derivation, signing and encryption. follows EIP 2333,2334 MasterDerivableKey is not intended to be used a signing key, just as a medium for managing keys
func MasterKeyFromPrivateKey ¶ added in v1.0.8
func MasterKeyFromPrivateKey(privateKey []byte, network Network) (*MasterDerivableKey, error)
MasterKeyFromPrivateKey gets the private key from master key
func MasterKeyFromSeed ¶
func MasterKeyFromSeed(seed []byte, network Network) (*MasterDerivableKey, error)
MasterKeyFromSeed is the constructor of MasterDerivableKey. Base privKey is m / purpose / coin_type / as EIP 2334 defines
type Network ¶
type Network string
Network represents the network.
const ( // PyrmontNetwork represents the Pyrmont test network. PyrmontNetwork Network = "pyrmont" // PraterNetwork represents the Prater test network. PraterNetwork Network = "prater" // HoleskyNetwork represents the Holesky test network. HoleskyNetwork Network = "holesky" // MainNetwork represents the main network. MainNetwork Network = "mainnet" )
Available networks.
func NetworkFromString ¶
NetworkFromString returns network from the given string value
func (Network) DepositContractAddress ¶
DepositContractAddress returns the deposit contract address of the network.
func (Network) EstimatedCurrentEpoch ¶
EstimatedCurrentEpoch estimates the current epoch https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
func (Network) EstimatedCurrentSlot ¶
EstimatedCurrentSlot returns the estimation of the current slot
func (Network) EstimatedEpochAtSlot ¶
EstimatedEpochAtSlot estimates epoch at the given slot
func (Network) EstimatedSlotAtTime ¶
EstimatedSlotAtTime estimates slot at the given time
func (Network) GenesisForkVersion ¶ added in v1.3.0
GenesisForkVersion returns the genesis fork version of the network.
func (Network) GenesisValidatorsRoot ¶ added in v1.3.0
GenesisValidatorsRoot returns the genesis validators root of the network.
func (Network) MinGenesisTime ¶
MinGenesisTime returns min genesis time value
func (Network) SlotDurationSec ¶
SlotDurationSec returns slot duration
func (Network) SlotsPerEpoch ¶
SlotsPerEpoch returns number of slots per one epoch
type ProposalDetectionType ¶
type ProposalDetectionType string
ProposalDetectionType represents proposal slashing detection type
const ( DoubleProposal ProposalDetectionType = "DoubleProposal" HighestProposalVote ProposalDetectionType = "HighestProposalVote" ValidProposal ProposalDetectionType = "Valid" Error ProposalDetectionType = "Error" )
Proposal slashing detection types
type ProposalSlashStatus ¶
type ProposalSlashStatus struct {
Slot phase0.Slot
Status ProposalDetectionType
Error error
}
ProposalSlashStatus represents proposal slashing status
type SlashingProtector ¶
type SlashingProtector interface {
IsSlashableAttestation(pubKey []byte, attestation *phase0.AttestationData) (*AttestationSlashStatus, error)
IsSlashableProposal(pubKey []byte, slot phase0.Slot) (*ProposalSlashStatus, error)
UpdateHighestAttestation(pubKey []byte, attestation *phase0.AttestationData) error
UpdateHighestProposal(pubKey []byte, slot phase0.Slot) error
FetchHighestAttestation(pubKey []byte) (*phase0.AttestationData, bool, error)
FetchHighestProposal(pubKey []byte) (phase0.Slot, bool, error)
}
SlashingProtector represents the behavior of the slashing protector
type SlashingStore ¶
type SlashingStore interface {
SaveHighestAttestation(pubKey []byte, attestation *phase0.AttestationData) error
RetrieveHighestAttestation(pubKey []byte) (*phase0.AttestationData, bool, error)
SaveHighestProposal(pubKey []byte, slot phase0.Slot) error
RetrieveHighestProposal(pubKey []byte) (phase0.Slot, bool, error)
}
SlashingStore represents the behavior of the slashing store
type Storage ¶
type Storage interface {
WalletStorage
AccountStorage
// Name returns storage name.
Name() string
// Network returns the network storage is related to.
Network() Network
}
Storage represents storage behavior Any encryption is done on the implementation level but is not obligatory
type ValidatorAccount ¶
type ValidatorAccount interface {
// ID provides the ID for the account.
ID() uuid.UUID
// Name provides the name for the account.
Name() string
// BasePath provides the basePath of the account.
BasePath() string
// ValidatorPublicKey provides the public key for the validation key.
ValidatorPublicKey() []byte
// WithdrawalPublicKey provides the public key for the withdrawal key.
WithdrawalPublicKey() []byte
// ValidationKeySign signs data with the validation key.
ValidationKeySign(data []byte) ([]byte, error)
// GetDepositData returns deposit data
GetDepositData() (map[string]interface{}, error)
// SetContext sets the given context
SetContext(ctx *WalletContext)
}
ValidatorAccount holds the information and actions needed by validator account keys. It holds 2 keys, a validation and a withdrawal key. As a minimum, the ValidatorAccount should have at least the validation key. Withdrawal key is not mandatory to be present.
type ValidatorInfo ¶ added in v1.3.0
type ValidatorInfo struct {
Index phase0.ValidatorIndex
Pubkey phase0.BLSPubKey
WithdrawalCredentials []byte
ToExecutionAddress bellatrix.ExecutionAddress
}
ValidatorInfo represents the information of a validator
type VoteDetectionType ¶
type VoteDetectionType string
VoteDetectionType represents vote detection type
const ( DoubleVote VoteDetectionType = "DoubleVote" SurroundingVote VoteDetectionType = "SurroundingVote" SurroundedVote VoteDetectionType = "SurroundedVote" HighestAttestationVote VoteDetectionType = "HighestAttestationVote" )
Vote detection types
type Wallet ¶
type Wallet interface {
// ID provides the ID for the wallet.
ID() uuid.UUID
// Type provides the type of the wallet.
Type() WalletType
// CreateValidatorAccount creates a new validation (validator) key pair in the wallet.
// Keep in mind ND wallets will probably not allow this function, use AddValidatorAccount.
CreateValidatorAccount(seed []byte, indexPointer *int) (ValidatorAccount, error)
// CreateValidatorAccountFromPrivateKey creates validator account from Private Key
CreateValidatorAccountFromPrivateKey(privateKey []byte, indexPointer *int) (ValidatorAccount, error)
// AddValidatorAccount used to specifically add an account.
// Keep in mind HD wallets will probably not allow this function, use CreateValidatorAccount.
AddValidatorAccount(account ValidatorAccount) error
// Accounts provides all accounts in the wallet.
Accounts() []ValidatorAccount
// AccountByID provides a single account from the wallet given its ID.
// This will error if the account is not found.
// should return account = nil if not found (not an error!)
AccountByID(id uuid.UUID) (ValidatorAccount, error)
// AccountByPublicKey provides a single account from the wallet given its public key.
// This will error if the account is not found.
// should return account = nil if not found (not an error!)
AccountByPublicKey(pubKey string) (ValidatorAccount, error)
// DeleteAccountByPublicKey delete an account from the wallet given its public key.
// This will error if the account is not found.
// should return nil if not error otherwise the error
DeleteAccountByPublicKey(pubKey string) error
// SetContext sets the given context
SetContext(ctx *WalletContext)
}
Wallet is a container of accounts. Accounts = key pairs
type WalletContext ¶
WalletContext represents the wallet's context type
type WalletStorage ¶ added in v1.0.1
type WalletStorage interface {
// SaveWallet stores the given wallet.
SaveWallet(wallet Wallet) error
// OpenWallet returns nil,err if no wallet was found
OpenWallet() (Wallet, error)
// ListAccounts returns an empty array for no accounts
ListAccounts() ([]ValidatorAccount, error)
}
WalletStorage represents the behavior of the wallet storage
type WalletType ¶
type WalletType = string
WalletType represents wallet type
const ( HDWallet WalletType = "HD" // hierarchical deterministic wallet NDWallet WalletType = "ND" // non - deterministic )
Wallet types