# micro-ed25519-hdkey

> Auditable minimal implementation of SLIP-0010 hierarchical deterministic (HD) wallets for ed25519

Latest version **0.1.2** (published 2022-10-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install micro-ed25519-hdkey
pnpm add micro-ed25519-hdkey
yarn add micro-ed25519-hdkey
bun add micro-ed25519-hdkey
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2022-10-04 |
| First published | 2022-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Paul Miller |
| Maintainers | paulmillr |
| Keywords | slip0010, SLIP 0010, ed25519, SLIP-0010, hierarchical, deterministic, hd key, bip0032, micro, code |

## Links

- npm: https://www.npmjs.com/package/micro-ed25519-hdkey
- Repository: https://github.com/paulmillr/micro-ed25519-hdkey
- Homepage: https://paulmillr.com/
- Issues: https://github.com/paulmillr/micro-ed25519-hdkey/issues
- Funding: https://paulmillr.com/funding/
- npm.io page: https://npm.io/package/micro-ed25519-hdkey

## Dependencies (2)

- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ~1.1.1
- [@noble/ed25519](https://npm.io/package/@noble/ed25519.md) ~1.7.1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2022-10-04
- 0.1.1 — 2022-10-03
- 0.0.1-security — 2022-10-03

## README

# micro-ed25519-hdkey

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

Uses audited [@noble/ed25519](https://github.com/paulmillr/noble-ed25519) under the hood. Based on audited code from [scure-bip32](https://github.com/paulmillr/scure-bip32).

Check out [scure-bip39](https://github.com/paulmillr/scure-bip39) if you also need mnemonic phrases.

## 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:

```ts
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:

```ts
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](https://github.com/satoshilabs/slips/issues/1251)), 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](./LICENSE)

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

---
_Source: https://npm.io/package/micro-ed25519-hdkey · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
