Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateRandomMnemonic(entropy int, wordlist []string) (mnemonic []string, err error)
- func MnemonicFromEntropy(entropy []byte, wordlist []string) (mnemonic []string, err error)
- func SeedFromMnemonic(mnemonic []string, passphrase string, wordlist []string) (seed []byte, err error)
Constants ¶
const IdeographicSpace = "\u3000"
IdeographicSpace is used to join Japanese mnemonic phrases.
Variables ¶
var ChineseSimplifiedWordList = []string{}/* 2048 elements not displayed */
var ChineseTraditionalWordList = []string{}/* 2048 elements not displayed */
var CzechWordList = []string{}/* 2048 elements not displayed */
var EnglishWordList = []string{}/* 2048 elements not displayed */
var ErrBadEntropy = errors.New("entropy must be 128-256 bits, divisible by 32")
var ErrOutOfEntropy, _ = wrapped.New("not enough entropy available in the OS entropy pool")
var ErrWrongChecksum = errors.New("wrong mnemonic phrase: checksum doesn't match")
var ErrWrongLength = errors.New("wrong mnemonic length: must be 12, 15, 18, 21 or 24 words")
var ErrWrongWord = errors.New("wrong word in mnemonic phrase: not on the wordlist")
var FrenchWordList = []string{}/* 2048 elements not displayed */
var ItalianWordList = []string{}/* 2048 elements not displayed */
var JapaneseWordList = []string{}/* 2048 elements not displayed */
var KoreanWordList = []string{}/* 2048 elements not displayed */
var LangSpace = map[string]string{ "english": " ", "chinese_simplified": " ", "chinese_traditional": " ", "czech": " ", "french": " ", "italian": " ", "japanese": IdeographicSpace, "korean": " ", "portuguese": " ", "spanish": " ", }
LangSpace is the joining whitespace for each language.
var PortugueseWordList = []string{}/* 2048 elements not displayed */
var SpanishWordList = []string{}/* 2048 elements not displayed */
var WordLists = map[string][]string{ "english": EnglishWordList, "chinese_simplified": ChineseSimplifiedWordList, "chinese_traditional": ChineseTraditionalWordList, "czech": CzechWordList, "french": FrenchWordList, "italian": ItalianWordList, "japanese": JapaneseWordList, "korean": KoreanWordList, "portuguese": PortugueseWordList, "spanish": SpanishWordList, }
Word Lists for each language. Language names are from BIP39 test vectors.
Functions ¶
func GenerateRandomMnemonic ¶ added in v0.0.3
GenerateRandomMnemonic generates a 12-24 word mnemonic phrase with 128-256 bits of entropy.
Implements BIP-39 as described in https://en.bitcoin.it/wiki/BIP_0039
The number of entropy bits must be between 128 and 256 inclusive, and divisible by 32 as per BIP-39.
Returns the generated mnemonic phrase.
Can return the following errors: ErrBadEntropy (entropy length is incorrect; expects 128,160,192,224,256) ErrOutOfEntropy (the OS entropy source is exhausted)
func MnemonicFromEntropy ¶
MnemonicFromEntropy converts 128-256 bits of entropy to a 12-24 word mnemonic phrase.
Implements BIP-39 as described in https://en.bitcoin.it/wiki/BIP_0039
The number of entropy bits must be between 128 and 256 inclusive, and divisible by 32 as per BIP-39.
Returns the encoded mnemonic phrase.
Can return the following errors: ErrBadEntropy (entropy length is incorrect; expects 16,20,24,28,32 bytes)
func SeedFromMnemonic ¶
func SeedFromMnemonic(mnemonic []string, passphrase string, wordlist []string) (seed []byte, err error)
SeedFromMnemonicPhrase derives a cryptographically random seed from a mnemonic phrase.
Implements BIP-39 as described in https://en.bitcoin.it/wiki/BIP_0039
This function verifies the 12-24 words are on the wordlist, and verifies the checksum bits included in the mnemonic phrase.
The passphrase is an optional string used to protect the seed derived from the mnemonic phrase (via PBKDF2)
Can return the following errors: ErrWrongLength (wrong number of words; expects 12,15,18,21,24) ErrWrongWord (one or more words are not on the word-list) ErrWrongChecksum (one or more of the words is incorrect, leading to a checksum mismatch)
Types ¶
This section is empty.