open-index/open-npm huggingface dataset:
npm package: @olympus-protocol/bls-hd-key
Description: BLS KDF and HD wallet utilities
Author: ChainSafe Systems
Latest version: 0.2.1

# BLS HD Key Utilities

![npm (tag)](https://img.shields.io/npm/v/@chainsafe/bls-hd-key/latest)
[![Discord](https://img.shields.io/discord/593655374469660673.svg?label=Discord&logo=discord)](https://discord.gg/aMxzVcr)
![GitHub](https://img.shields.io/github/license/chainsafe/bls-hd-key)
![ES Version](https://img.shields.io/badge/ES-2015-yellow)
![Node Version](https://img.shields.io/badge/node-10.x-green)

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](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2334.md), [EIP-2333](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2333.md)

For a higher-level interface, see [@chainsafe/bls-keygen](https://github.com/chainsafe/bls-keygen).

### Example
```typescript

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

```bash
yarn install
yarn run test
```

### Audit

This repo was audited by Least Authority as part of [this security audit](https://github.com/ChainSafe/lodestar/blob/master/audits/2020-03-23_UTILITY_LIBRARIES.pdf), released 2020-03-23. Commit [`767c998`](https://github.com/ChainSafe/bls-hd-key/commit/767c998) verified in the report.

### License

Apache-2.0
npm package: @olympus-protocol/bls-keygen
Description: Typescript key management tool that works in the browser
Author: ChainSafe Systems
Latest version: 0.3.0

# BLS Keygen

Utility functions for generating BLS secret keys, built for NodeJs and Browser.

- Create a master key from BIP-39 mnemonic or entropy.
- Create a derived child key from BIP-39 mnemonic, entropy, or a master key.
- Create Eth2 validator keys from a master key.

Implementation follows EIPS: [EIP-2334](https://github.com/ethereum/EIPs/pull/2334), [EIP-2333](https://github.com/ethereum/EIPs/pull/2333)

For low-level [EIP-2333](https://github.com/ethereum/EIPs/pull/2333) and [EIP-2334](https://github.com/ethereum/EIPs/pull/2334) functionality, see [@chainsafe/bls-hd-key](https://github.com/chainsafe/bls-hd-key).

### Examples
```typescript


import {
    generateRandomSecretKey,
    deriveKeyFromMnemonic,
    deriveKeyFromEntropy,
    deriveKeyFromMaster,
    deriveEth2ValidatorKeys,
} from "@chainsafe/bls-keygen";

// random secret key
const secretKey = generateRandomSecretKey();

...

// secret key from mnemonic and optional EIP-2334 path
const masterSecretKey = deriveKeyFromMnemonic(
  "impact exit example acquire drastic cement usage float mesh source private bulb twenty guitar neglect",
);

const childSecretKey = deriveKeyFromMnemonic(
  "impact exit example acquire drastic cement usage float mesh source private bulb twenty guitar neglect",
  "m/12381/3600/0/0"
);

...

// secret key from entropy and optional EIP-2334 path
const masterSecretKey = deriveKeyFromEntropy(entropy);

const childSecretKey = deriveKeyFromEntropy(
  entropy,
  "m/12381/3600/0/0"
);


...

// child secret key from master secret key and EIP-2334 path
const childSecretKey = deriveKeyFromMaster(
  masterSecretKey,
  "m/12381/3600/0/0"
);

...

// create multiple eth2 validator keys from a master secret key
const keys0 = deriveEth2ValidatorKeys(masterSecretKey, 0);
const keys1 = deriveEth2ValidatorKeys(masterSecretKey, 1);

const { signing, withdrawal } = keys0;

```

### Contribution

Requirements:
- nodejs
- yarn

```bash
    yarn install
    yarn run test
```

### Audit

This repo was audited by Least Authority as part of [this security audit](https://github.com/ChainSafe/lodestar/blob/master/audits/2020-03-23_UTILITY_LIBRARIES.pdf), released 2020-03-23. Commit [`32b068`](https://github.com/ChainSafe/bls-hd-key/commit/32b068) verified in the report.

### License

Apache-2.0