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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ndwallet-core

v0.9.6

Published

Core cryptographic library for NDWallet browser environments

Readme

NDWallet Core

A WebAssembly-based core library for cryptographic operations in browser environments. This library provides high-performance cryptographic primitives for key derivation, encryption/decryption, secret sharing, and seed phrase management.

Features

  • WebAuthn Integration: Seamless integration with the WebAuthn API for passkey-based authentication
  • PRF Extension Support: Use the WebAuthn PRF extension for more secure key derivation
  • Key Derivation: Derive cryptographic keys from WebAuthn responses
  • Encryption/Decryption: AES-GCM encryption for secure data storage
  • Secret Sharing: Shamir's Secret Sharing for distributing secrets across multiple locations
  • Seed Phrase Management: BIP39 seed phrase generation, validation, and conversion
  • Wallet Module: High-level wallet creation and management functions
  • WASM Performance: Near-native performance for cryptographic operations

Installation

npm install ndwallet-core

Prerequisites

To build this library, you'll need:

  1. Rust and Cargo (https://rustup.rs/)
  2. wasm-pack (https://rustwasm.github.io/wasm-pack/installer/)
  3. Node.js and npm

Building

# Build the WASM module and TypeScript wrapper
npm run build

Usage

Core Cryptographic Functions

import { ndWalletCore, LOCAL_SHARE_ENCRYPTION_CONTEXT } from 'ndwallet-core';

// Start WebAuthn registration with PRF extension
async function register() {
  // Get registration options from your server
  let options = await fetchRegistrationOptionsFromServer();
  
  // Add PRF extension to options
  options = ndWalletCore.addPrfExtensionToRegistrationOptions(options);
  
  // Start WebAuthn registration
  const response = await ndWalletCore.startRegistration(options);
  
  // Derive a master key from the PRF output
  const masterKey = ndWalletCore.deriveMasterKeyFromPrf(response);
  
  // Derive an encryption key for a specific context
  const encryptionKey = ndWalletCore.deriveEncryptionKey(masterKey, LOCAL_SHARE_ENCRYPTION_CONTEXT);
  
  // Generate a seed phrase
  const seedPhrase = ndWalletCore.generateSeedPhrase();
  
  // Split the seed phrase into shares (2 of 3 threshold)
  const shares = ndWalletCore.splitSecret(seedPhrase, 2, 3);
  
  // Encrypt a share
  const encryptedShare = ndWalletCore.encryptData(shares[0], encryptionKey);
  
  // Send the registration response and other data to your server
  await sendToServer(response, encryptedShare);
}

// Start WebAuthn authentication with PRF extension
async function authenticate() {
  // Get authentication options from your server
  let options = await fetchAuthenticationOptionsFromServer();
  
  // Get the PRF salt from your server
  const prfSalt = await getPrfSaltFromServer();
  
  // Add PRF extension to options
  options = ndWalletCore.addPrfExtensionToAuthenticationOptions(options, prfSalt);
  
  // Start WebAuthn authentication
  const response = await ndWalletCore.startAuthentication(options);
  
  // Derive a master key from the PRF output
  const masterKey = ndWalletCore.deriveMasterKeyFromPrf(response);
  
  // Derive an encryption key for a specific context
  const encryptionKey = ndWalletCore.deriveEncryptionKey(masterKey, LOCAL_SHARE_ENCRYPTION_CONTEXT);
  
  // Get encrypted share from localStorage or server
  const encryptedShare = getEncryptedShare();
  
  // Decrypt the share
  const share = ndWalletCore.decryptData(encryptedShare, encryptionKey);
  
  // Send the authentication response to your server
  await sendToServer(response);
}

### Wallet Module

```javascript
import {
  generateSeedPhrase,
  createWallet,
  restoreFromBackup,
  getAddress,
  recoverSeedPhrase
} from 'ndwallet-core';

// Generate a new seed phrase
const seedPhrase = generateSeedPhrase();

// Create a wallet
const wallet = await createWallet({
  seedPhrase,
  network: 'ethereum',
  accountIndex: 0,
  storage: {
    storeLocally: true,
    storeOnServer: true,
    createBackup: true
  }
});

console.log('Wallet address:', wallet.address);

// Get address for different network/account
const btcAddress = getAddress(wallet, 'bitcoin', 0);

See the Wallet Module README for more details.

API Reference

Constants

  • LOCAL_SHARE_ENCRYPTION_CONTEXT: Context for local share encryption
  • SERVER_SHARE_ENCRYPTION_CONTEXT: Context for server share encryption
  • BACKUP_SHARE_ENCRYPTION_CONTEXT: Context for backup share encryption

WebAuthn API

  • startRegistration(options): Start WebAuthn registration with PRF extension
  • startAuthentication(options): Start WebAuthn authentication with PRF extension
  • addPrfExtensionToRegistrationOptions(options, prfSalt): Add PRF extension to registration options
  • addPrfExtensionToAuthenticationOptions(options, prfSalt): Add PRF extension to authentication options
  • generate_prf_salt(): Generate a random PRF salt
  • create_prf_extension(salt): Create a PRF extension input for WebAuthn
  • extract_prf_from_response(response): Extract PRF output from WebAuthn response

Key Derivation

  • deriveMasterKeyFromPrf(response): Derive a master key from a WebAuthn response using PRF extension
  • derive_encryption_key(masterKey, context): Derive an encryption key from a master key and context
  • deriveEncryptionKey(masterKey, context): High-level wrapper for derive_encryption_key

Encryption/Decryption

  • encrypt_data(data, key): Encrypt data using AES-GCM
  • encryptData(data, key): High-level wrapper for encrypt_data
  • decrypt_data(encryptedData, key): Decrypt data using AES-GCM
  • decryptData(encryptedData, key): High-level wrapper for decrypt_data

Seed Phrase Management

  • generate_seed_phrase(): Generate a random BIP39 seed phrase
  • generateSeedPhrase(): High-level wrapper for generate_seed_phrase
  • seed_phrase_to_seed(seedPhrase): Convert a BIP39 seed phrase to a seed
  • seedPhraseToSeed(seedPhrase): High-level wrapper for seed_phrase_to_seed

Secret Sharing

  • split_secret(secret, threshold, shares): Split a secret into shares using Shamir's Secret Sharing
  • splitSecret(secret, threshold, shares): High-level wrapper for split_secret
  • combine_shares(shares): Combine shares to reconstruct a secret
  • combineShares(shares): High-level wrapper for combine_shares

License

MIT