Fastest 5KB JS implementation of ed25519 EDDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core functionality for generating and handling ed25519 keys, supporting both synchronous and asynchronous operations with optional seed input for deterministic key generation.
Generates a new ed25519 key pair with optional seed for deterministic generation.
/**
* Generate ed25519 key pair asynchronously
* @param seed - Optional 32-byte seed for deterministic generation
* @returns Promise resolving to key pair object
*/
function keygenAsync(seed?: Bytes): Promise<{ secretKey: Bytes; publicKey: Bytes }>;
/**
* Generate ed25519 key pair synchronously (requires hashes.sha512 to be set)
* @param seed - Optional 32-byte seed for deterministic generation
* @returns Key pair object
*/
function keygen(seed?: Bytes): { secretKey: Bytes; publicKey: Bytes };Usage Examples:
import * as ed from '@noble/ed25519';
// Generate random key pair (async)
const keyPair = await ed.keygenAsync();
console.log(keyPair.secretKey.length); // 32
console.log(keyPair.publicKey.length); // 32
// Generate deterministic key pair from seed
const seed = new Uint8Array(32).fill(1); // Example seed
const deterministicKeys = await ed.keygenAsync(seed);
// Sync version (requires setting hash function first)
import { sha512 } from '@noble/hashes/sha512';
ed.hashes.sha512 = sha512;
const syncKeys = ed.keygen();Derives the public key from a given secret key.
/**
* Derive public key from secret key asynchronously
* @param secretKey - 32-byte secret key
* @returns Promise resolving to 32-byte public key
*/
function getPublicKeyAsync(secretKey: Bytes): Promise<Bytes>;
/**
* Derive public key from secret key synchronously (requires hashes.sha512 to be set)
* @param secretKey - 32-byte secret key
* @returns 32-byte public key
*/
function getPublicKey(secretKey: Bytes): Bytes;Usage Examples:
import * as ed from '@noble/ed25519';
// Generate or obtain a secret key
const secretKey = ed.utils.randomSecretKey();
// Derive public key (async)
const publicKey = await ed.getPublicKeyAsync(secretKey);
// Derive public key (sync, requires hash function)
import { sha512 } from '@noble/hashes/sha512';
ed.hashes.sha512 = sha512;
const syncPublicKey = ed.getPublicKey(secretKey);
// Verify they're the same
console.log(Buffer.from(publicKey).equals(Buffer.from(syncPublicKey))); // trueUtility function for generating cryptographically secure random secret keys.
/**
* Generate a cryptographically secure random secret key
* @param seed - Optional seed for deterministic generation
* @returns 32-byte secret key
*/
utils.randomSecretKey(seed?: Bytes): Bytes;Usage Example:
import { utils } from '@noble/ed25519';
// Generate random secret key
const secretKey = utils.randomSecretKey();
console.log(secretKey.length); // 32
// Generate deterministic secret key from seed
const seed = new Uint8Array(32).fill(42);
const deterministicKey = utils.randomSecretKey(seed);type Bytes = Uint8Array;