npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seeded-mnemonic

v0.1.0

Published

Seeding entropy in the creation of Mnemonic Phrases

Downloads

2

Readme

Seeded Mnemonic

Seeded Mnemonic is a simple library for seeding entropy in the creation of Mnemonic Phrases.

This library supports any non-empty string, or file, being passed as input, utilizing that input in place of entropy in the generation of mnemonic phrases for Ethereum, Bitcoin, and Solana, at lengths of 12, 18, and 24 words.

When the input is received, and prior to conversion to bits, a cryptographic hash of the input is generated. The hashing algorithm used is dependent on the blockchain selected when calling the seededMnemonic function. This hash will act as entropy in the creation of the mnemonic phrase.

  • For Ethereum, a Keccak-256 hash of the input is generated.
  • For Bitcoin, a SHA-256 hash of the input is generated.
  • For Solana, a SHA-512 hash of the input is generated.

After the entropy is generated, it is converted to binary and truncated to 128, 192, or 256 bits, depending on if a 12, 18, or 24-word mnemonic phrase is desired. The truncated entropy is then converted into a byte array, and hashed using SHA-256. A checksum is generated by extracting the first 4, 6, or 8 bits of the hash, which are appended to the end of the truncated entropy. Finally, the resulting string of bits is divided into segments of 11 bits each, with each segment corresponding to a word in the BIP39 wordlist, resulting in the mnemonic phrase.

Installation

npm install seeded-mnemonic

Usage

The following example demonstrates the use of the library to create a 12-word Ethereum mnemonic phrase using the string "Just be a rock." in place of entropy.

const { seededMnemonic } = require('seeded-mnemonic');

const input = "Just be a rock.";

const result = seededMnemonic.string(input, 12, 'ETH');
	console.log(`Mnemonic Phrase:`, result.seedPhrase);

This next example utilizes seededMnemonic.fs() to use a file as input in mnemonic phrase generation, in this case, a JSON file example.json, to create an 18-word Solana mnemonic phrase.

const { seededMnemonic } =  require('seeded-mnemonic');

const  input  =  './example.json';

const  result  =  seededMnemonic.fs(input, 18, 'SOL');
	console.log(`Mnemonic Phrase:`, result.seedPhrase);

Finally, this last example demonstrates the use of the seededMnemonic.string() to create a 24-word Bitcoin mnemonic phrase using text randomly generated by a simulated monkey using a typewriter, along with returning the bits obtained from the input/used for creating the mnemonic phrase.

const { seededMnemonic } = require('seeded-mnemonic');

const input = "IEINFULLXLLUKHHBFAGBLFLEHFWODUNGALDRQWHRAUL";

const result = seededMnemonic.string(input, 24, 'BTC', { returnBits: true });
	console.log(`Mnemonic Phrase:`, result.seedPhrase);
	console.log(`Bits:`, result.bits);