mnemonic

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BitsPerWord = wordlist4096.BitsPerWord

BitsPerWord is the number of bits of information represented by each word in the wordlist.

Variables

View Source
var ErrInvalidIndex = errors.New("word index value is too large")

ErrInvalidIndex is returned when given a word index which cannot be represented in at most BitsPerWord bits.

View Source
var ErrInvalidWord = errors.New("word is not a member of the wordlist")

ErrInvalidWord is returned when a word is passed to DecodeWords which is not a member of the wordlist.

Functions

func DecodeIndices

func DecodeIndices(indices []uint16) (*big.Int, error)

DecodeIndices decodes the given wordlist indices into an integer representation.

Returns ErrInvalidIndex if any of the given indices are outside the domain of the word list size.

func DecodeWords

func DecodeWords(words []string) ([]uint16, error)

DecodeWords decodes the given set of words into their indices in the wordlist. The words can be in either upper or lower case.

Returns ErrInvalidWord if any of the words are not members of the wordlist.

func EncodeToIndices

func EncodeToIndices(payloadInt *big.Int, bitSize uint) ([]uint16, error)

EncodeToIndices encodes the given payload as a slice of word indices.

The bitSize parameter determines how many words will be used to encode the payload, which is calculated as:

nWords = ceil(bitSize / BitsPerWord)

bitSize does not necessarily have to be evenly divisible by BitsPerWord. If there is any unused space, it will be encoded at the leading edge of the resulting slice of indices.

func EncodeToWords

func EncodeToWords(indices []uint16) ([]string, error)

EncodeToWords encodes the given word indices as a series of words from the wordlist. The returned phrase is encoded with lower-case characters.

Returns ErrInvalidIndex if any of the given indices are outside the domain of the word list.

Types

This section is empty.

Jump to

Keyboard shortcuts

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