Skip to content

DIMO-Network/mnemonic

Repository files navigation

Mnemonic

GitHub license GoDoc Go Report Card

Overview

The Mnemonic package provides a flexible and customizable way to encode data into a mnemonic word list. It implements the BIP-0039 specification using big.Int, allowing for the use of arbitrary entropy sizes.

Features

  • BIP-0039 Specification: The implementation adheres to the BIP-0039 specification, providing compatibility with various cryptographic systems.

  • Arbitrary Entropy Sizes: This package allows users to work with arbitrary entropy sizes, providing flexibility in encoding different types of data.

  • Number Obfuscation: For enhanced usability with IDs, the package offers optional number obfuscation. This feature uses Modular Multiplicative Inverse to convert the provided number into a seemingly random number before generating the mnemonic word list using https://github.com/c2h5oh/hide

Getting Started

Installation

To use this package in your Go project, run the following command:

go get github.com/DIMO-Network/mnemonic

Example Usage

All Examples can be found in the go docs or examples_test.go

package main

import (
	"fmt"
	"github.com/DIMO-Network/mnemonic"
)

func main() {
	// Example usage with a number
	id := int32(1)
	words := mnemonic.FromInt(id)
	obfuscatedWords := mnemonic.FromInt32WithObfuscation(id)
	fmt.Println(words)
	fmt.Println(obfuscatedWords)
	// Output: [abandon abandon about]
	// [learn island zoo]

	// Example usage with a word list
	obfuscatedWords := []string{"learn", "island", "zoo"}
	deobfuscatedUint, err := mnemonic.ToUint32WithDeobfuscation(obfuscatedWords)
	if err != nil {
		panic(err)
	}

	fmt.Println(deobfuscatedUint)
	// Output: 1
}

About

Creates mnemonic word list from arbitrary data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages