gomnemonic

package module
v0.0.0-...-9872875 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 10 Imported by: 0

README

gomnemonic

Introduction

This package is an implementation of the BIP39 specifications in the Go programming language. You can read the documentation here.

Example

package main

import (
    "fmt"

    "github.com/augcos/gomnemonic"
)

func main() {
    // we generate the random entropy
    entropy, _ := gomnemonic.GenEntropy(256)
    // we generate the mnemonic corresponding to that entropy
    mnemonic, _ := gomnemonic.GetMnemonicFromEntropy(entropy)
    // finally, we generate the 512-bit seed from the mnemonic, plus a passphrase
    seed, _ := gomnemonic.GetSeedFromMnemonic(mnemonic, "passphrase")
    
    fmt.Printf("Entropy: %x\n", entropy)
    fmt.Println("Mnemonic:", mnemonic)
    fmt.Printf("Seed: %x\n", seed)
}

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddChecksum

func AddChecksum(entropy []byte) ([]byte, error)

AddChecksum takes an entropy byte slice and adds the first bit of its SHA-256 hash. This is meant to be called by the user only when manual addition of the checksum is needed (e.g. custom entropy generator).

func GenEntropy

func GenEntropy(bitSize int) ([]byte, error)

GenEntropy returns a new randomly generated byte slice with bitSize bits (must be between 128-256 and be a multiple of 32) plus the checksum bits

func GetEntropyFromMnemonic

func GetEntropyFromMnemonic(mnemonic []string) ([]byte, error)

GetEntropyFromMnemonic takes a mnemonic string slice and returns the corresponding entropy byte slice

func GetMnemonicFromEntropy

func GetMnemonicFromEntropy(entropy []byte) ([]string, error)

GetMnemonicFromEntropy takes the entropy byte slice and returns the corresponding mnemonic as a string slice

func GetSeedFromMnemonic

func GetSeedFromMnemonic(mnemonic []string, passphrase string) ([]byte, error)

GetSeedFromMnemonic takes a mnemonic string slice and a passphrase string and returns the 521-bit seed byte slice

func SetWordList

func SetWordList(newList []string)

SetWordList sets any given string slice as the word list for the mnemonic

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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