fix: add createKeyPair factory that defaults to a random key

This commit is contained in:
Derrick Hammer 2023-08-31 07:22:16 -04:00
parent 149c725624
commit 42ef635fb5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 0 deletions

View File

@ -1,6 +1,8 @@
import { S5Node } from "#node.js"; import { S5Node } from "#node.js";
import type { S5NodeConfig } from "#node.js"; import type { S5NodeConfig } from "#node.js";
import type { SignedRegistryEntry } from "#service/registry.js"; import type { SignedRegistryEntry } from "#service/registry.js";
import { ed25519 } from "@noble/curves/ed25519";
import KeyPairEd25519 from "#ed25519.js";
export * from "./types.js"; export * from "./types.js";
export { export {
@ -13,3 +15,7 @@ export type { S5NodeConfig, SignedRegistryEntry };
export function createNode(config: S5NodeConfig) { export function createNode(config: S5NodeConfig) {
return new S5Node(config); return new S5Node(config);
} }
export function createKeyPair(privateKey?: Uint8Array) {
return new KeyPairEd25519(privateKey ?? ed25519.utils.randomPrivateKey());
}