bip39

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 10 Imported by: 0

README

BIP39-GO GoDoc Build Status

Package bip39 is the Golang implementation of the BIP39 spec.

Documentation

Overview

Package bip39 is the Golang implementation of the BIP39 spec.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrWordLen           = errors.New("Invalid word list length")
	ErrEntropyLen        = errors.New("Invalid entropy length")
	ErrChecksumIncorrect = errors.New("checksum incorrect")
)

Error list

Functions

func CheckMnemonic

func CheckMnemonic(mnemonic string, lg Language) error

CheckMnemonic creates entropy from mnemonic

func IsMnemonicValid

func IsMnemonicValid(m string, lg Language) bool

IsMnemonicValid validate menemonic

Example
var mnemonic = "check fiscal fit sword unlock rough lottery tool sting pluck bulb random"
res := IsMnemonicValid(mnemonic, English)
fmt.Println(res)
Output:

true

func MnemonicToSeed

func MnemonicToSeed(mnemonic string, passwd string) []byte

MnemonicToSeed creates seed by param passwd can be empty string

Example
mnemonic := "jungle devote wisdom slim census orbit merge order flip sketch add mass"
res := MnemonicToSeed(mnemonic, "")
fmt.Println(hex.EncodeToString(res))
Output:

f38fb5a8ca30abe8cd8a35428911d7277d9125ebc2f019a5d400cd765d1f6f56a552f0b92f8149b0d834f7e5b64a71548840ab7d4c826a58783429e366b21caf

func NewMnemonic

func NewMnemonic(length int, lang Language) (string, error)

NewMnemonic generates new mnemonic by words length

Example
// Words length can be 12 | 15 | 18 | 21 | 24
NewMnemonic(12, English)
NewMnemonic(24, ChineseTraditional)
NewMnemonic(12, English)
NewMnemonic(15, French)
NewMnemonic(18, Italian)
NewMnemonic(21, Japanese)
NewMnemonic(24, French)
Output:

func NewMnemonicByEntropy

func NewMnemonicByEntropy(entropy []byte, lang Language) (string, error)

NewMnemonicByEntropy generates new mnemonic by entropy provided

Example
entropy, _ := hex.DecodeString("79079bf165e25537e2dce15919440cc4")
mnemonic, _ := NewMnemonicByEntropy(entropy, English)
fmt.Println(mnemonic)
Output:

jungle devote wisdom slim census orbit merge order flip sketch add mass

Types

type Language

type Language uint8

Language is bip39 word lang type

const (
	ChineseSimplified Language = iota
	ChineseTraditional
	English
	French
	Italian
	Japanese
	Korean
	Spanish
	Czech
)

Language list

Directories

Path Synopsis
tools module

Jump to

Keyboard shortcuts

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