function publicBytesFromPrivateBytes
publicBytesFromPrivateBytes(
privateKey: Uint8Array,
): Promise<Uint8Array>

Derives public key from private key using x25519 curve.

Useful for getting public key from private key.

Examples

Derive public key from private key

import { assertEquals } from "@std/assert";
import { randomPrivateKeyBytes, publicBytesFromPrivateBytes } from "@hertzg/wg-keys";

const privateKeyBytes = randomPrivateKeyBytes();
const publicKeyBytes = await publicBytesFromPrivateBytes(privateKeyBytes);

assertEquals(publicKeyBytes.length, 32);

Parameters

privateKey: Uint8Array

Private key bytes

optional
options: ImportPrivateKeyOptions

Configuration options for key import

Return Type

Promise<Uint8Array>

Public key bytes

Usage

import { publicBytesFromPrivateBytes } from ".";