librawallet

package
v0.0.0-...-194be82 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MNEMONIC_SALT_PREFIX string = "LIBRA WALLET: mnemonic salt prefix$"
	MASTER_KEY_SALT      string = "LIBRA WALLET: master key salt$"
	INFO_PREFIX          string = "LIBRA WALLET: derived key$"
)
View Source
const (
	PublicKeySize = 32
)

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair(mnemonic Mnemonic, childNum uint64) *crypto.KeyPair

Types

type Account

type Account struct {
	Address  types.AccountAddress
	KeyPair  *crypto.KeyPair
	Sequence uint64
}

func NewAccount

func NewAccount(mnemonic string, childNumber uint64) (*Account, error)

Create Account from Mnemonic and child number.

func NewAccountFromKeyPair

func NewAccountFromKeyPair(keyPair *crypto.KeyPair) *Account

Create account from key pair

func NewAccountFromSecret

func NewAccountFromSecret(secret string) (*Account, error)

Create Account from Secret Key.

type ExtendedPrivKey

type ExtendedPrivKey struct {
	ChildNumber uint64
	PrivateKey  ed25519.PrivateKey
}

func (*ExtendedPrivKey) GetAddress

func (e *ExtendedPrivKey) GetAddress() types.AccountAddress

func (*ExtendedPrivKey) GetPublic

func (e *ExtendedPrivKey) GetPublic() ed25519.PublicKey

func (*ExtendedPrivKey) ToString

func (e *ExtendedPrivKey) ToString() string

Returns Private Key hex string representation

type KeyFactory

type KeyFactory struct {
	Master []byte
	Seed   *Seed
}

func NewKeyFactory

func NewKeyFactory(seed *Seed) *KeyFactory

func (*KeyFactory) GenerateKey

func (k *KeyFactory) GenerateKey(childNumber uint64) *ExtendedPrivKey

type Mnemonic

type Mnemonic []string

func GenerateMnemonic

func GenerateMnemonic() Mnemonic

func (Mnemonic) ToBytes

func (m Mnemonic) ToBytes() []byte

func (Mnemonic) ToString

func (m Mnemonic) ToString() string

type Seed

type Seed struct {
	Data []byte
}

func NewSeed

func NewSeed(mnemonic Mnemonic, salt string) *Seed

/ This constructor implements the one-way function that allows to generate a Seed from a / particular Mnemonic and salt. WalletLibrary implements a fixed salt, but a user could / choose a user-defined salt instead of the hardcoded one.

type WalletLibrary

type WalletLibrary struct {
	Mnemonic   Mnemonic
	KeyFactory *KeyFactory
	KeyLeaf    uint64
	AddressMap map[string]uint64 //string is hex string of AccountAddress
}

func NewWalletLibrary

func NewWalletLibrary(mnemonicStr string) *WalletLibrary

func (*WalletLibrary) GenerateAddress

func (w *WalletLibrary) GenerateAddress(depth uint64) error

TODO: Complete immplementation for Generating Multiple address up to a depth

func (*WalletLibrary) GetAccount

func (w *WalletLibrary) GetAccount(childNumber uint64) (*Account, error)

Get Account in wallet library with child number.

func (*WalletLibrary) NewAddress

func (w *WalletLibrary) NewAddress() (types.AccountAddress, uint64, error)

Create new address in wallet library.

Jump to

Keyboard shortcuts

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