bip39

package module
v0.0.0-...-3e0f42b Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMnemonic is returned when trying to use a malformed mnemonic.
	ErrInvalidMnemonic = errors.New("Invalid mnenomic")

	// ErrEntropyLengthInvalid is returned when trying to use an entropy set with
	// an invalid size.
	ErrEntropyLengthInvalid = errors.New("Entropy length must be [128, 256] and a multiple of 32")

	// ErrValidatedSeedLengthMismatch is returned when a validated seed is not the
	// same size as the given seed. This should never happen is present only as a
	// sanity assertion.
	ErrValidatedSeedLengthMismatch = errors.New("Seed length does not match validated seed length")

	// ErrChecksumIncorrect is returned when entropy has the incorrect checksum.
	ErrChecksumIncorrect = errors.New("Checksum incorrect")
)
View Source
var AllWordLists = map[string]WordList{
	"english":             English,
	"chinese_simplified":  ChineseSimplified,
	"chinese_traditional": ChineseTraditional,
	"czech":               Czech,
	"french":              French,
	"italian":             Italian,
	"japanese":            Japanese,
	"korean":              Korean,
	"portuguese":          Portuguese,
	"spanish":             Spanish,
}
View Source
var ChineseSimplified = newList("chinese_simplified", worddata.AllLanguages["chinese_simplified"], "e3721bbf")
View Source
var ChineseTraditional = newList("chinese_traditional", worddata.AllLanguages["chinese_traditional"], "3c20b443")
View Source
var Czech = newList("czech", worddata.AllLanguages["czech"], "d1b5fda0")
View Source
var English = newList("english", worddata.AllLanguages["english"], "c1dbd296")
View Source
var French = newList("french", worddata.AllLanguages["french"], "3e56b216")
View Source
var Italian = newList("italian", worddata.AllLanguages["italian"], "2fc7d07e")
View Source
var Japanese = newList("japanese", worddata.AllLanguages["japanese"], "acc1419")
View Source
var Korean = newList("korean", worddata.AllLanguages["korean"], "4ef461eb")
View Source
var PadByteSlice = padByteSlice
View Source
var Portuguese = newList("portuguese", worddata.AllLanguages["portuguese"], "e627a546")
View Source
var Spanish = newList("spanish", worddata.AllLanguages["spanish"], "266e4f3d")

Functions

func ErrUnknownWord

func ErrUnknownWord(reason string) error

func NewEntropy

func NewEntropy(bitSize int) ([]byte, error)

func NewSeed

func NewSeed(mnemonic string, password string) []byte

NewSeed creates a hashed seed output given a provided string and password. No checking is performed to validate that the string provided is a valid mnemonic.

func NewSeedWithErrorChecking

func NewSeedWithErrorChecking(mnemonic string, password string, wl WordList) ([]byte, error)

NewSeedWithErrorChecking creates a hashed seed output given the mnemonic string, password, and word list An error is returned if the mnemonic is not convertible to a byte array.

func SetDefaultLangugage

func SetDefaultLangugage(wordList WordList)

set default language

Types

type Mnemonic

type Mnemonic []string

func MnemonicFromString

func MnemonicFromString(mn string) Mnemonic

func NewMnemonic

func NewMnemonic(entropy []byte, wl WordList) (Mnemonic, error)

func (Mnemonic) IsValid

func (mn Mnemonic) IsValid(wl WordList) error

func (Mnemonic) String

func (mn Mnemonic) String() string

func (Mnemonic) ToByteArray

func (mn Mnemonic) ToByteArray(wl WordList) ([]byte, error)

func (Mnemonic) ToEntropy

func (mn Mnemonic) ToEntropy(wl WordList) ([]byte, error)

type WordList

type WordList interface {
	// IndexOf gets index of word in word list. return -1 if word is not found in list
	IndexOf(word string) int
	// WordOf returns word at index in word list. "" if index is out of bounds
	WordOf(index int) string
	// List returns the full word list
	List() []string
}

func DefaultLanguage

func DefaultLanguage() WordList

The default language is english

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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