hd

package
v0.10.2-patch Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hd provides basic functionality Hierarchical Deterministic Wallets.

The user must understand the overall concept of the BIP 32 and the BIP 44 specs:

https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki

In combination with the bip39 package in go-crypto this package provides the functionality for deriving keys using a BIP 44 HD path, or, more general, by passing a BIP 32 path.

In particular, this package (together with bip39) provides all necessary functionality to derive keys from mnemonics generated during the cosmos fundraiser.

Index

Constants

View Source
const (
	BIP44Prefix        = "44'/118'/"
	FullFundraiserPath = BIP44Prefix + "0'/0/0"
)

BIP44Prefix is the parts of the BIP32 HD path that are fixed by what we used during the fundraiser.

Variables

This section is empty.

Functions

func ComputeMastersFromSeed

func ComputeMastersFromSeed(seed []byte) (secret [32]byte, chainCode [32]byte)

ComputeMastersFromSeed returns the master public key, master secret, and chain code in hex.

func DerivePrivateKeyForPath

func DerivePrivateKeyForPath(privKeyBytes [32]byte, chainCode [32]byte, path string) ([32]byte, error)

DerivePrivateKeyForPath derives the private key by following the BIP 32/44 path from privKeyBytes, using the given chainCode.

Types

type BIP44Params

type BIP44Params struct {
	// contains filtered or unexported fields
}

BIP44Params wraps BIP 44 params (5 level BIP 32 path). To receive a canonical string representation ala m / purpose' / coin_type' / account' / change / address_index call String() on a BIP44Params instance.

func NewFundraiserParams

func NewFundraiserParams(account uint32, addressIdx uint32) *BIP44Params

NewFundraiserParams creates a BIP 44 parameter object from the params: m / 44' / 118' / account' / 0 / address_index The fixed parameters (purpose', coin_type', and change) are determined by what was used in the fundraiser.

func NewParams

func NewParams(purpose, coinType, account uint32, change bool, addressIdx uint32) *BIP44Params

NewParams creates a BIP 44 parameter object from the params: m / purpose' / coin_type' / account' / change / address_index

func NewParamsFromPath

func NewParamsFromPath(path string) (*BIP44Params, error)

Parse the BIP44 path and unmarshal into the struct. nolint: gocyclo

func (BIP44Params) DerivationPath

func (p BIP44Params) DerivationPath() []uint32

Return the BIP44 fields as an array.

func (BIP44Params) String

func (p BIP44Params) String() string

Jump to

Keyboard shortcuts

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