bip39

package module
v0.0.0-...-4750911 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: ISC Imports: 9 Imported by: 0

README

bip39

CircleCI codecov Go Report Card LICENSE

Implementation of BIP-0039

Requirement

  • go-1.11 with modules support

Installation

go get -u -v github.com/sammyne/bip39

References

Documentation

Index

Constants

View Source
const (
	Size128 = EntropyLen(16 + 4*iota)
	Size160
	Size192
	Size224
	Size256
)

enumerations of supported entropy length in bytes

View Source
const WordIndexBitSize = 11

WordIndexBitSize specifies the bit width for splitting the full entropy (raw+checksum) into index groups

Variables

View Source
var (
	// ErrChecksum signals the invalid checksum of a full entropy
	ErrChecksum = errors.New("invalid checksum")
	// ErrEntropyLen denotes a unsupported entropy length
	ErrEntropyLen = errors.New("incompatible entropy length")
	// ErrInvalidWord signals the mnemonic contains non-official words
	ErrInvalidWord = errors.New("mnemonic contains out-of-dict words")
	// ErrMnemonicLen signals a invalid mnemonic length
	ErrMnemonicLen = errors.New("invalid mnemonic length")
)

enumerations of possible errors

Functions

func DecodeFullEntropy

func DecodeFullEntropy(data []byte) ([]byte, byte, error)

DecodeFullEntropy decodes the full entropy into the raw entropy and the corresponding checksum, where the n/4 least significant bits if the effective checksum.

func EntropyLenCompatible

func EntropyLenCompatible(n EntropyLen) bool

EntropyLenCompatible checks if the provided entropy length is supported, which should be Size128, Size160, Size192, Size224 or Size256 currently

func GenerateMnemonic

func GenerateMnemonic(rand io.Reader, n EntropyLen,
	lang ...dict.Language) (string, error)

GenerateMnemonic constructs a mnemonic randomly based on the n bytes read out of the provided random sources for the provided language (as the global default if none)

func GenerateSeed

func GenerateSeed(mnemonic string, passphrase ...string) ([]byte, error)

GenerateSeed converts a mnemonic into a 512-bits seed based on a passphrase which is empty if not provided.

func NewMnemonic

func NewMnemonic(entropy []byte, lang ...dict.Language) (string, error)

NewMnemonic constructs the mnemonic w.r.t a language (the global default configured by dict pkg if none provided) for the given entropy

func RecoverFullEntropy

func RecoverFullEntropy(mnemonic string, lang ...dict.Language) (
	[]byte, error)

RecoverFullEntropy recovers the entropy plus the checksum from the given mnemonic

func ValidateMnemonic

func ValidateMnemonic(mnemonic string, lang ...dict.Language) bool

ValidateMnemonic checks if the mnemonic is valid against a language (default as the one set by dict pkg)

Types

type EntropyLen

type EntropyLen = int

EntropyLen alias int to ease semantic understanding

Directories

Path Synopsis
Package dict maintains stuff relevant to wordlists of different languages.
Package dict maintains stuff relevant to wordlists of different languages.

Jump to

Keyboard shortcuts

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