Examples

Random Key-pairs

Generate and print a random keyPair

import { generateKeyPair } from 'multicurve-keygen'

const keyPair = generateKeyPair('ed25519')

console.log(keyPair.publicKey.toString('hex'))

Reusable Root Node

Create an HD root node context bound to a root seed and curve type:

import { deriveNode } from 'multicurve-keygen'

const seed = '4ed9c4bceb0dd53cd55a4f8a442def799d01444c99d045193...'
const rootNode = deriveNode(seed, 'm', 'ed25519')

const childNode = rootNode.deriveNode("m/1234'")
// Or, const childNode = deriveNode(rootNode, "m/1234'")

console.log(childNode.keyPair.publicKey.toString('hex'))

Mnemonic Phrases

Derive a key pair from a mnemonic root seed

import * as Keygen from 'multicurve-keygen'

const seedPhrase = Keygen.generateMnemonic()
const seed = Keygen.mnemonicToSeed(seedPhrase)
const childKeyPair = Keygen.deriveKeyPair(seed, "m/1234'", 'ed25519')

console.log(childKeyPair.publicKey.toString('hex'))