// Package bip39wordlist provides the BIP39 English wordlist and helpers for // validating, normalizing, and generating BIP39 mnemonic phrases. // // The wordlist is embedded in the binary from english.txt and parsed once // at package initialization. The mnemonic helpers accept phrases in any // letter case and with any whitespace between words; NormalizeWordlist // returns the canonical lowercase, single-space-separated form that BIP39 // seed derivation requires, and refuses anything that is not a valid // mnemonic. package bip39wordlist import ( _ "embed" "slices" "strings" ) // WordlistSize is the number of words in a BIP39 wordlist. const WordlistSize = 2048 //go:embed english.txt var englishWordlistData string // WordlistEnglish is the BIP39 English wordlist, one entry per word, in // the canonical (sorted) BIP39 order. Callers must not modify it. // //nolint:gochecknoglobals // static lookup table parsed once from embedded data var WordlistEnglish = strings.Fields(englishWordlistData) // Wordlist is the default wordlist, which is WordlistEnglish. Callers must // not modify it. // //nolint:gochecknoglobals // static lookup table, alias of WordlistEnglish var Wordlist = WordlistEnglish // Contains reports whether word is in the English wordlist. The comparison // is exact, so word must already be lowercase. func Contains(word string) bool { _, found := slices.BinarySearch(WordlistEnglish, word) return found }