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() types.Epoch
- func (n Network) EstimatedCurrentSlot() types.Slot
- func (n Network) EstimatedEpochAtSlot(slot types.Slot) types.Epoch
- func (n Network) EstimatedSlotAtTime(time int64) types.Slot
- func (n Network) ForkVersion() []byte
- func (n Network) FullPath(relativePath string) string
- 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 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 *eth.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" // 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) ForkVersion ¶
ForkVersion returns the fork version 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 { Proposal *eth.BeaconBlock Status ProposalDetectionType Error error }
ProposalSlashStatus represents proposal slashing status
type SlashingProtector ¶
type SlashingProtector interface { IsSlashableAttestation(pubKey []byte, attestation *eth.AttestationData) (*AttestationSlashStatus, error) IsSlashableProposal(pubKey []byte, block *eth.BeaconBlock) (*ProposalSlashStatus, error) // Will potentially update the highest attestation given this latest attestation. UpdateHighestAttestation(pubKey []byte, attestation *eth.AttestationData) error UpdateHighestProposal(pubKey []byte, block *eth.BeaconBlock) error RetrieveHighestAttestation(pubKey []byte) (*eth.AttestationData, error) }
SlashingProtector represents the behavior of the slashing protector
type SlashingStore ¶
type SlashingStore interface { SaveHighestAttestation(pubKey []byte, attestation *eth.AttestationData) error RetrieveHighestAttestation(pubKey []byte) *eth.AttestationData SaveHighestProposal(pubKey []byte, block *eth.BeaconBlock) error RetrieveHighestProposal(pubKey []byte) *eth.BeaconBlock }
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 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 ¶
type WalletContext struct {
Storage Storage
}
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