bip39

package
v0.0.0-...-38f4ca3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSlice

type BitSlice []string

BitSlice will hold the individual bits for a slice

type Checksum

type Checksum [sha256.Size]byte

Checksum holds SHA256 hash of the entropy

func (Checksum) ToBitSlice

func (c Checksum) ToBitSlice() BitSlice

ToBitSlice will convert the byte slice into an individual bit slice with each element holding one bit

type Language

type Language string

Language type

const (
	// English words
	English Language = "English"

	// Spanish words
	Spanish Language = "Spanish"

	// French words
	French Language = "French"

	// Italian words
	Italian Language = "Italian"

	// Japanese words
	Japanese Language = "Japanese"

	// Korean words
	Korean Language = "Korean"

	// ChineseSimple words
	ChineseSimple Language = "ChineseSimple"

	// ChineseTraditional words
	ChineseTraditional Language = "ChineseTraditional"
)

type Mnemonic

type Mnemonic string

Mnemonic holds a word string

func GetWord

func GetWord(lang Language, index int) (Mnemonic, error)

GetWord will return the word for the specified language at the index position

type Mnemonics

type Mnemonics []Mnemonic

Mnemonics is a simple wrapper for a string slice

func GenerateMnemonics

func GenerateMnemonics(r RandomEntropy, lang Language) (Mnemonics, error)

GenerateMnemonics will generate the set of mnemonic words (length dependent upon bitsize). An error will be returned if the RandomEntropy or Language are invalid Word Count: 128 = 12 words 160 = 15 words 192 = 18 words 224 = 21 words 256 = 24 words

func (Mnemonics) GenerateSeed

func (m Mnemonics) GenerateSeed(passphrase string) Seed

GenerateSeed will create a new Seed to use within a HD wallet

func (Mnemonics) JoinWords

func (m Mnemonics) JoinWords() string

JoinWords output the Mnemonics as a HEX string

func (Mnemonics) String

func (m Mnemonics) String() string

String will default to the HEX value (see #ToHex)

type RandomEntropy

type RandomEntropy []byte

RandomEntropy wraps a random series of bytes

func GenerateRandomEntropy

func GenerateRandomEntropy(bits int) (RandomEntropy, error)

GenerateRandomEntropy will generate a random number of bytes matching the length of bits required. The length of bits must be divisible by 32 or else a corresponding error will be returned.

func (RandomEntropy) GenerateMnemonics

func (r RandomEntropy) GenerateMnemonics(lang Language) (Mnemonics, error)

GenerateMnemonics will return the matching words for the provided entropy The number of words depends on the entropy bit size

func (RandomEntropy) String

func (r RandomEntropy) String() string

String will print the Entropy as a string

func (RandomEntropy) ToHex

func (r RandomEntropy) ToHex() RandomEntropyHex

ToHex will create a HEX string representation

type RandomEntropyHex

type RandomEntropyHex string

RandomEntropyHex will hold a Random hex value

func (RandomEntropyHex) ToRandomEntropy

func (h RandomEntropyHex) ToRandomEntropy() (RandomEntropy, error)

ToRandomEntropy will create the Random entropy from the Hex value

type Seed

type Seed []byte

Seed generated from the mnemonics

func GenerateSeed

func GenerateSeed(mnemonics, passphrase string) Seed

GenerateSeed will use the PBKDF2 to generate a hash (using the SHA512 hash) and performing 2048 iterations.

func (Seed) String

func (seed Seed) String() string

String will print the Entropy as a string

func (Seed) ToHex

func (seed Seed) ToHex() SeedHex

ToHex will create a Hex string representation

type SeedHex

type SeedHex string

SeedHex will hold a Seed hex value

func (SeedHex) ToSeed

func (h SeedHex) ToSeed() (Seed, error)

ToSeed will recreate the Seed from the HEX value

Jump to

Keyboard shortcuts

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