Minimal implementation of SLIP-0010 hierarchical deterministic (HD) wallets

Overview

micro-ed25519-hdkey

Secure, minimal implementation of SLIP-0010 hierarchical deterministic (HD) wallets.

Uses audited @noble/ed25519 under the hood. Based on audited code from scure-bip32.

Check out scure-bip39 if you also need mnemonic phrases.

Sponsored by the Kin Foundation for Kinetic.

Usage

npm install micro-ed25519-hdkey

Or

yarn add micro-ed25519-hdkey

The module exports a single class HDKey, which should be used like this:

import { HDKey } from 'micro-ed25519-hdkey';
const hdkey1 = HDKey.fromMasterSeed(seed);

// props
[hdkey1.depth, hdkey1.index, hdkey1.chainCode];
console.log(hdkey2.privateKey, hdkey2.publicKey);
console.log(hdkey3.derive("m/0/2147483647'/1'"));
const sig = hdkey3.sign(hash);
hdkey3.verify(hash, sig);

Note: chainCode property is essentially a private part of a secret "master" key, it should be guarded from unauthorized access.

The full API is:

class HDKey {
  public static HARDENED_OFFSET: number;
  public static fromMasterSeed(seed: Uint8Array | string): HDKey;

  readonly depth: number = 0;
  readonly index: number = 0;
  readonly chainCode: Uint8Array | null = null;
  readonly parentFingerprint: number = 0;
  public readonly privateKey: Uint8Array;

  get fingerprint(): number;
  get fingerprintHex(): string;
  get parentFingerprintHex(): string;
  get pubKeyHash(): Uint8Array;
  get publicKey(): Uint8Array;
  get publicKeyRaw(): Uint8Array;

  derive(path: string, forceHardened = false): HDKey;
  deriveChild(index: number): HDKey;
  sign(hash: Uint8Array): Uint8Array;
  verify(hash: Uint8Array, signature: Uint8Array): boolean;
}

Notes

  • SLIP-0010 publicKey is 33 bytes (see this issue), if you want 32-byte publicKey, use .publicKeyRaw getter
  • SLIP-0010 vectors fingerprint is actually parentFingerprint
  • SLIP-0010 doesn't allow deriving non-hardened keys for Ed25519, however some other libraries treat non-hardened keys (m/0/1) as hardened (m/0'/1'). If you want this behaviour, there is a flag forceHardened in derive method

License

MIT License

Copyright (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com)

You might also like...

Universal interface for web3 wallets

Universal interface for web3 wallets

Dec 31, 2022

enables communication between command-line or desktop applications and browser-based Ethereum wallets such as Metamask.

@securerpc/walletbus @securerpc/walletbus Abstract Quickstart Installation Usage Ethers.js Web3.js Configuration options Logging Development Automated

Dec 27, 2022

🌱 Ethereum provider solution for Dapp&Wallets, 🏷 If you have good suggestions, please submit issues

🌱 Ethereum provider solution for Dapp&Wallets,  🏷 If you have good suggestions, please submit issues

English | 简体中文 | 日本 ETH Wallet Modal An Ethereum Provider Solution for Integrated Wallets and Dapps ⚠️ Notice If you need to reduce unnecessary import

Dec 19, 2022

Universal interface for web3 wallets

web3-wallets Universal interface for web3 wallets dapp wallets blockchains ╭─

Dec 31, 2022

Fully undetected stealer (steals wallets, passwords, cookies, modifies discord client like piratestealer etc.)

Fully undetected stealer (steals wallets, passwords, cookies, modifies discord client like piratestealer etc.)

doenerium (CURRENTLY NOT WORKING BECAUSE OF OBFUSCATION; fixing later) Fully undetected stealer (0/67) I obfuscated this to prevent my stuff being ski

Nov 12, 2022

🚀 NFTank (NFT tank for dummies) will allow developers to quickly request NFTs to personal wallets or smart contracts in just a few clicks.

🚀 NFTank (NFT tank for dummies) will allow developers to quickly request NFTs to personal wallets or smart contracts in just a few clicks.

👷‍♂️ NFTank 🚀 NFTank (NFT tank for dummies) will allow developers to quickly request NFTs to personal wallets or smart contracts in just a few click

Nov 8, 2022

Adapter application for consuming web3 messages from ie. wallets, and passing them on to starknet

🐍 StarknNet web3 account Development setup Clone deps with submodules git clone --recurse-submodules [email protected]:software-mansion-labs/starknet-we

Nov 21, 2022

💥 Snapy Recovery: Social recovery for MetaMask wallets

💥 Snapy Recovery: Social recovery for MetaMask wallets

💥 Snappy Recovery Social Recovery for MetaMask wallets using "Snaps", sandboxed JS plugins for MetaMask. Watch the demo on YouTube: How it works, vis

Nov 12, 2022

Fully undetected grabber (grabs wallets, passwords, cookies, modifies discord client etc.)

Fully undetected grabber (grabs wallets, passwords, cookies, modifies discord client etc.)

⚔️ TurkoRat 🛡️ Telegram server: https://t.me/turcoflex Discord server: https://discord.gg/v6xwtcgrQ5 🌐 〢 Content 📁 Setting up ⚔️ Features 📸 Screen

Dec 20, 2022
Releases(0.1.1)
Owner
Paul Miller
Paul Miller
A deterministic object hashing algorithm for Node.js

Deterministic-Object-Hash A deterministic object hashing algorithm for Node.js. The Problem Using JSON.stringify on two objects that are deeply equal

Zane Bauman 7 Nov 30, 2022
Generate deterministic fake values: The same input will always generate the same fake-output.

import { copycat } from '@snaplet/copycat' copycat.email('foo') // => '[email protected]' copycat.email('bar') // => 'Thurman.Schowalter668@

Snaplet 201 Dec 30, 2022
A lightweight Nano Node implementation made for wallets, exchanges and other services.

About This is a Light Nano Node implementation made for Wallets, Exchanges and other services. This Node has been built to be compatible with the offi

Nano - Light Net 7 Jun 25, 2022
Hierarchical Converter for Array of Objects

Conversor Hierárquico para Array de Objetos - Hierarchical Converter to Array of Objects Docker-compose Cria a interface network e containers indicado

Victor Vinícius Eustáquio de Almeida 2 Jan 27, 2022
Neo: Hierarchical Confusion Matrix Visualization

Neo: Hierarchical Confusion Matrix The confusion matrix, a ubiquitous visualization for helping people evaluate machine learning models, is a tabular

Apple 252 Dec 15, 2022
The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.

EaselJS EaselJS is a library for building high-performance interactive 2D content in HTML5. It provides a feature-rich display list to allow you to ma

CreateJS 8k Dec 29, 2022
A plugin for creating hierarchical navigation in Astro projects. Supports breadcrumbs too!

astro-navigation A plugin for creating hierarchical navigation in Astro projects. Supports breadcrumbs too! Full docs coming soon! Basic usage This pa

Tony Sullivan 7 Dec 19, 2022
Gatsby-starter-minimal-blog - Typography driven, feature-rich blogging theme with minimal aesthetics.

Gatsby-starter-minimal-blog - Typography driven, feature-rich blogging theme with minimal aesthetics. Includes tags/categories support and extensive features for code blocks such as live preview, line numbers, and line highlighting.

Priya Chakraborty 0 Jan 29, 2022
Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet

Overview Sheetzapper imports your account value accross Zapper.fi supported wallets and dapps into a Google Sheet. This allows you to chart your net w

null 4 Nov 27, 2022
Generate random ethereum wallets & private keys and then check if they match a wallet that contains some kind of balance, so that you can take it. In Node.js

Ethereum-Stealer Generate random ethereum wallets & private keys and then check if they match a wallet that contains some kind of balance, so that you

Michał 74 Dec 24, 2022