wallet

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// TextileAccountPrefix is a prefix for Textile key pairs derivation.
	TextileAccountPrefix = "m/44'/406'"
	// TextilePrimaryAccountPath is a derivation path of the primary account.
	TextilePrimaryAccountPath = "m/44'/406'/0'"
	// TextileAccountPathFormat is a path format used for Textile key pair
	// derivation as described in SEP-00XX. Use with `fmt.Sprintf` and `DeriveForPath`.
	TextileAccountPathFormat = "m/44'/406'/%d'"
	// FirstHardenedIndex is the index of the first hardened key (2^31).
	// https://youtu.be/2HrMlVr1QX8?t=390
	FirstHardenedIndex = uint32(0x80000000)
)

Variables

View Source
var (
	ErrInvalidPath        = fmt.Errorf("invalid derivation path")
	ErrNoPublicDerivation = fmt.Errorf("no public derivation for ed25519")
)
View Source
var ErrInvalidWordCount = fmt.Errorf("invalid word count (must be 12, 15, 18, 21, or 24)")

Functions

func IsValidPath added in v0.1.10

func IsValidPath(path string) bool

IsValidPath check whether or not the path has valid segments.

Types

type Key added in v0.1.10

type Key struct {
	Key       []byte
	ChainCode []byte
}

func DeriveForPath added in v0.1.10

func DeriveForPath(path string, seed []byte) (*Key, error)

DeriveForPath derives key for a path in BIP-44 format and a seed. Ed25119 derivation operated on hardened keys only.

func NewMasterKey added in v0.1.10

func NewMasterKey(seed []byte) (*Key, error)

NewMasterKey generates a new master key from seed.

func (*Key) Derive added in v0.1.10

func (k *Key) Derive(i uint32) (*Key, error)

func (*Key) PublicKey added in v0.1.10

func (k *Key) PublicKey() (ed25519.PublicKey, error)

PublicKey returns public key for a derived private key.

func (*Key) RawSeed added in v0.1.10

func (k *Key) RawSeed() [32]byte

RawSeed returns raw seed bytes

type Wallet

type Wallet struct {
	RecoveryPhrase string
}

Wallet is a BIP32 Hierarchical Deterministic Wallet based on stellar's implementation of https://github.com/satoshilabs/slips/blob/master/slip-0010.md, https://github.com/stellar/stellar-protocol/pull/63

func WalletFromEntropy added in v0.4.0

func WalletFromEntropy(entropySize int) (*Wallet, error)

func WalletFromMnemonic added in v0.4.0

func WalletFromMnemonic(mnemonic string) *Wallet

func WalletFromWordCount added in v0.4.0

func WalletFromWordCount(wordCount int) (*Wallet, error)

func (*Wallet) AccountAt added in v0.1.10

func (w *Wallet) AccountAt(index int, passphrase string) (*keypair.Full, error)

To understand how this works, refer to the living document: https://paper.dropbox.com/doc/Hierarchical-Deterministic-Wallets--Ae0TOjGObNq_zlyYFh7Ea0jNAQ-t7betWDTvXtK6qqD8HXKf

type WordCount added in v0.1.10

type WordCount int
const (
	TwelveWords     WordCount = 12
	FifteenWords    WordCount = 15
	EighteenWords   WordCount = 18
	TwentyOneWords  WordCount = 21
	TwentyFourWords WordCount = 24
)

func NewWordCount added in v0.1.10

func NewWordCount(cnt int) (*WordCount, error)

func (WordCount) EntropySize added in v0.1.10

func (w WordCount) EntropySize() int

Jump to

Keyboard shortcuts

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