Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeFullEntropy(data []byte) ([]byte, byte, error)
- func EntropyLenCompatible(n EntropyLen) bool
- func GenerateMnemonic(rand io.Reader, n EntropyLen, lang ...dict.Language) (string, error)
- func GenerateSeed(mnemonic string, passphrase ...string) ([]byte, error)
- func NewMnemonic(entropy []byte, lang ...dict.Language) (string, error)
- func RecoverFullEntropy(mnemonic string, lang ...dict.Language) ([]byte, error)
- func ValidateMnemonic(mnemonic string, lang ...dict.Language) bool
- type EntropyLen
Constants ¶
const ( Size128 = EntropyLen(16 + 4*iota) Size160 Size192 Size224 Size256 )
enumerations of supported entropy length in bytes
const WordIndexBitSize = 11
WordIndexBitSize specifies the bit width for splitting the full entropy (raw+checksum) into index groups
Variables ¶
var ( // ErrChecksum signals the invalid checksum of a full entropy ErrChecksum = errors.New("invalid checksum") // ErrEntropyLen denotes a unsupported entropy length ErrEntropyLen = errors.New("incompatible entropy length") // ErrInvalidWord signals the mnemonic contains non-official words ErrInvalidWord = errors.New("mnemonic contains out-of-dict words") // ErrMnemonicLen signals a invalid mnemonic length ErrMnemonicLen = errors.New("invalid mnemonic length") )
enumerations of possible errors
Functions ¶
func DecodeFullEntropy ¶
DecodeFullEntropy decodes the full entropy into the raw entropy and the corresponding checksum, where the n/4 least significant bits if the effective checksum.
func EntropyLenCompatible ¶
func EntropyLenCompatible(n EntropyLen) bool
EntropyLenCompatible checks if the provided entropy length is supported, which should be Size128, Size160, Size192, Size224 or Size256 currently
func GenerateMnemonic ¶
GenerateMnemonic constructs a mnemonic randomly based on the n bytes read out of the provided random sources for the provided language (as the global default if none)
func GenerateSeed ¶
GenerateSeed converts a mnemonic into a 512-bits seed based on a passphrase which is empty if not provided.
func NewMnemonic ¶
NewMnemonic constructs the mnemonic w.r.t a language (the global default configured by dict pkg if none provided) for the given entropy
func RecoverFullEntropy ¶
RecoverFullEntropy recovers the entropy plus the checksum from the given mnemonic