Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chainsafe/bls-hd-key

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chainsafe/bls-hd-key

BLS KDF and HD wallet utilities

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
905
decreased by-45.48%
Maintainers
3
Weekly downloads
 
Created
Source

BLS HD Key Utilities

npm (tag) Discord GitHub ES Version Node Version

Utility functions for managing BLS heirarchical deterministic accounts.

  1. Create a master private key from entropy
  2. Create a child private key from a private key and index
  3. Convert a standard path into an array of indices
  4. Create a decendent private key from a private key and array of indices

Implementation is following EIPS: EIP-2334, EIP-2333

For a higher-level interface, see @chainsafe/bls-keygen.

Example


import {deriveMasterSK, deriveChildSK, deriveChildSKMultiple, pathToIndices} from "@chainsafe/bls-hd-key";

// Create master private key (according to EIP-2333)

const entropy: Buffer = Buffer.from(...);
const masterKey: Buffer = deriveMasterSK(entropy);

// Create child private key one level deep

const childIndex: number = ...;
const childKey: Buffer = deriveChildSK(masterKey, childIndex);

// Convert a "path" into an array of indices (using validation rules of EIP-2334)

cont path = "m/12381/3600/0/0";
const childIndices: number[] = pathToIndices(path);

// Convert a "path" into an array of indices (validating an alternate key type)

const eth1KeyType = 60;
cont path = "m/12381/60/0/0";
const childIndices: number[] = pathToIndices(path, eth1KeyType);

// Create a child private key `childIndices.length` levels deep

const childIndices: number[] = [...];
const childKey = deriveChildSKMultiple(masterKey, childIndices);

// Compose functions to derive a child key from entropy and a path

const entropy: Buffer = Buffer.from(...);
cont path = "m/12381/3600/0/0";
const childKey = deriveChildSKMultiple(deriveMasterSK(entropy), pathToIndices(path));

Contrubuting

Requirements:

  • nodejs
  • yarn
yarn install
yarn run test

Audit

This repo was audited by Least Authority as part of this security audit, released 2020-03-23. Commit 767c998 verified in the report.

License

Apache-2.0

FAQs

Package last updated on 30 Jul 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc