🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/KevinJoiner/mnemonic

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/KevinJoiner/mnemonic

v0.0.0-20240226173518-343f1791b339
Source
Go
Version published
Created
Source

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
}

FAQs

Package last updated on 26 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts