bip39

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 13 Imported by: 0

README

BIP39-GO GoDoc ci codecov

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 mnemonic 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
const mnemonic = "check fiscal fit sword unlock rough lottery tool sting pluck bulb random"
fmt.Println(IsMnemonicValid(mnemonic, English))
Output:

true

func MnemonicToSeed

func MnemonicToSeed(mnemonic, passphrase string) []byte

MnemonicToSeed creates 64 bytes seed by pbkdf passphrace is optional,it can be empty string

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

84+1qMowq+jNijVCiRHXJ32RJevC8Bml1ADNdl0fb1alUvC5L4FJsNg09+W2SnFUiECrfUyCalh4NCnjZrIcrw==

func NewMnemonic

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

NewMnemonic creates new mnemonic by words length for language provided

func NewMnemonicByEntropy

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

NewMnemonicByEntropy create 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 int

Language is bip39 word lang type

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

Language list

func (Language) String added in v1.0.3

func (i Language) String() string

Directories

Path Synopsis
internal
tools module

Jump to

Keyboard shortcuts

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