From 42ef635fb590e554e2c11565ce3255ed7ce3e2a6 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 31 Aug 2023 07:22:16 -0400 Subject: [PATCH] fix: add createKeyPair factory that defaults to a random key --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 429822e..fc6038b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,8 @@ import { S5Node } from "#node.js"; import type { S5NodeConfig } from "#node.js"; import type { SignedRegistryEntry } from "#service/registry.js"; +import { ed25519 } from "@noble/curves/ed25519"; +import KeyPairEd25519 from "#ed25519.js"; export * from "./types.js"; export { @@ -13,3 +15,7 @@ export type { S5NodeConfig, SignedRegistryEntry }; export function createNode(config: S5NodeConfig) { return new S5Node(config); } + +export function createKeyPair(privateKey?: Uint8Array) { + return new KeyPairEd25519(privateKey ?? ed25519.utils.randomPrivateKey()); +}