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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mnemonicsafe

v1.0.2

Published

A secure backup solution for BIP-39 mnemonics inspired by SLIP-39 using Shamir's Secret Sharing and AES-256-GCM encryption.

Readme

MnemonicSafe

Node.js CI npm version npm downloads

MnemonicSafe is a secure backup solution for cryptocurrency mnemonics. Inspired by the ideas behind SLIP-39, MnemonicSafe splits a BIP-39 mnemonic into multiple shares using Shamir's Secret Sharing (SSS) and then encrypts each share using AES-256-GCM with unique passwords. This approach requires a threshold number of shares to reconstruct the original mnemonic, thereby enhancing security and resilience against loss or compromise.

Disclaimer:
MnemonicSafe is an educational and experimental project and is not an official implementation of SLIP-39 by SatoshiLabs. Use this code for testing and research purposes only, and never expose real mnemonics without a thorough security review.

Overview

MnemonicSafe works by:

  1. Converting the mnemonic into entropy:
    The provided BIP-39 mnemonic is validated and converted into its underlying binary entropy.

  2. Splitting the entropy using Shamir's Secret Sharing (SSS):
    The entropy is divided into multiple shares such that only a configurable threshold of shares is required to reconstruct the original secret.

  3. Encrypting each share:
    Each share is converted into a Base64 string and then encrypted using AES-256-GCM. A unique password is used for each share, and robust key derivation (using PBKDF2 with a random salt) ensures strong encryption.

  4. Reconstructing the mnemonic:
    By decrypting a threshold number of shares with their corresponding passwords and combining them via SSS, the original mnemonic is recovered.

While our code is sometimes called "SLIP-39" in this repository, note that SLIP-39 is a standard developed by SatoshiLabs. MnemonicSafe is inspired by these ideas but does not adhere to the official SLIP-39 specification.

Features

  • BIP-39 Mnemonic Conversion: Validates and converts mnemonics to entropy.
  • Secret Splitting with SSS: Splits the mnemonic's entropy into multiple shares.
  • AES-256-GCM Encryption: Encrypts each share with its own password using PBKDF2 key derivation, random salt, and IV.
  • Share Reconstruction: Combines a threshold number of decrypted shares to recover the original mnemonic.
  • Extensible Design: Ready for future enhancements like expiration metadata or threshold encryption.

Installation

Option 1: Install from npm (Recommended)

npm install mnemonicsafe

Option 2: Clone from Source

  1. Clone the Repository:

    git clone https://github.com/hackable/mnemonicsafe.git
    cd mnemonicsafe
  2. Install Dependencies:

    Make sure you have Node.js installed, then run:

    npm install

Usage

Basic Usage (npm package)

const MnemonicSafe = require('mnemonicsafe');

// Your BIP-39 mnemonic
const mnemonic = 'legal winner thank year wave sausage worth useful legal winner thank yellow';

// Configuration
const totalShares = 5;
const threshold = 3;
const passwords = ['password1!', 'password2@', 'password3#', 'password4$', 'password5%'];

// Split the mnemonic into encrypted shares
const encryptedShares = MnemonicSafe.splitMnemonic(mnemonic, totalShares, threshold, passwords);
console.log('Encrypted shares:', encryptedShares);

// Reconstruct the mnemonic using threshold number of shares
const selectedShares = encryptedShares.slice(0, threshold);
const selectedPasswords = passwords.slice(0, threshold);
const reconstructed = MnemonicSafe.reconstructMnemonic(selectedShares, selectedPasswords);
console.log('Reconstructed mnemonic:', reconstructed);

Browser Usage

The package is also available for browser environments. You can include it in your HTML:

<script src="node_modules/mnemonicsafe/dist/index.js"></script>
<script>
  // MnemonicSafe is now available as a global variable
  const mnemonic = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
  const encryptedShares = MnemonicSafe.splitMnemonic(mnemonic, 5, 3, ['pass1', 'pass2', 'pass3', 'pass4', 'pass5']);
  console.log('Encrypted shares:', encryptedShares);
</script>

Or using a module bundler like webpack or browserify:

import MnemonicSafe from 'mnemonicsafe';
// or
const MnemonicSafe = require('mnemonicsafe');

Development Usage (cloned repository)

Splitting a Mnemonic into Encrypted Shares

In the example.js file, a sample BIP-39 mnemonic is defined along with a configuration for splitting the mnemonic into shares:

  • Mnemonic:
    legal winner thank year wave sausage worth useful legal winner thank yellow

  • Configuration:

    • Total Shares: 5
    • Threshold: 3
    • Passwords: Unique password for each share (e.g., password1!, password2@, etc.)

The Process Involves:

  1. Converting the mnemonic into entropy.
  2. Splitting the entropy into 5 shares using Shamir's Secret Sharing (SSS).
  3. Encrypting each share with its corresponding password using AES-256-GCM.

Reconstructing the Mnemonic

The reconstruction process:

  1. Selects a threshold number of encrypted shares.
  2. Decrypts them using the corresponding passwords.
  3. Reassembles the original mnemonic using Shamir’s Secret Sharing.

Running the Example

To run the example and see the complete process:

node example.js