wallet

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2019 License: MIT Imports: 11 Imported by: 0

README

go-textile-wallet

Made by Textile Chat on Slack GitHub license Go Report Card CircleCI branch standard-readme compliant

Textile's wallet implementation in Go

Go to the docs for more about Textile.

Join us on our public Slack channel for news, discussions, and status updates. Check out our blog for the latest posts and announcements.

Table of Contents

Install

go get github.com/textileio/go-textile-wallet

Usage

Go to https://godoc.org/github.com/textileio/go-textile-wallet.

Contributing

This project is a work in progress. As such, there's a few things you can do right now to help out:

  • Ask questions! We'll try to help. Be sure to drop a note (on the above issue) if there is anything you'd like to work on and we'll update the issue to let others know. Also get in touch on Slack.
  • Open issues, file issues, submit pull requests!
  • Perform code reviews. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
  • Take a look at the code. Contributions here that would be most helpful are top-level comments about how it should look based on your understanding. Again, the more eyes the better.
  • Add tests. There can never be enough tests.

Before you get started, be sure to read our contributors guide and our contributor covenant code of conduct.

Changelog

Changelog is published to Releases.

License

MIT

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

func IsValidPath(path string) bool

IsValidPath check whether or not the path has valid segments.

Types

type Key

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

func DeriveForPath

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

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

NewMasterKey generates a new master key from seed.

func (*Key) Derive

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

func (*Key) PublicKey

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

PublicKey returns public key for a derived private key.

func (*Key) RawSeed

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

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

func WalletFromMnemonic

func WalletFromMnemonic(mnemonic string) *Wallet

func WalletFromWordCount

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

func (*Wallet) AccountAt

func (w *Wallet) AccountAt(index int, passphrase string) (*account.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

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

func NewWordCount

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

func (WordCount) EntropySize

func (w WordCount) EntropySize() int

Directories

Path Synopsis
Package crc16 is implementation according to CCITT standards.
Package crc16 is implementation according to CCITT standards.

Jump to

Keyboard shortcuts

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