Fastest 5KB JS implementation of ed25519 EDDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215
npx @tessl/cli install tessl/npm-noble--ed25519@3.0.0Fastest 5KB JavaScript/TypeScript implementation of ed25519 EdDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215. This high-performance cryptographic library provides both synchronous and asynchronous APIs for key generation, signing, and signature verification with maximum security and auditability.
npm install @noble/ed25519import * as ed from '@noble/ed25519';Named imports:
import {
sign, signAsync, verify, verifyAsync,
getPublicKey, getPublicKeyAsync,
keygen, keygenAsync,
Point, etc, utils, hashes, hash
} from '@noble/ed25519';CommonJS:
const ed = require('@noble/ed25519');import * as ed from '@noble/ed25519';
// Generate keypair
const { secretKey, publicKey } = await ed.keygenAsync();
// Sign a message
const message = new TextEncoder().encode('hello noble');
const signature = await ed.signAsync(message, secretKey);
// Verify signature
const isValid = await ed.verifyAsync(signature, message, publicKey);
console.log(isValid); // true
// For sync operations, set hash function first
import { sha512 } from '@noble/hashes/sha512';
ed.hashes.sha512 = sha512;
// Now sync methods work
const syncPublicKey = ed.getPublicKey(secretKey);
const syncSignature = ed.sign(message, secretKey);Noble Ed25519 is built around several key components:
Point classCore functionality for generating and handling ed25519 keys, supporting both synchronous and asynchronous operations.
function keygenAsync(seed?: Bytes): Promise<{ secretKey: Bytes; publicKey: Bytes }>;
function keygen(seed?: Bytes): { secretKey: Bytes; publicKey: Bytes };
function getPublicKeyAsync(secretKey: Bytes): Promise<Bytes>;
function getPublicKey(secretKey: Bytes): Bytes;RFC8032-compliant signing and verification operations with both async and sync variants.
function signAsync(message: Bytes, secretKey: Bytes): Promise<Bytes>;
function sign(message: Bytes, secretKey: Bytes): Bytes;
function verifyAsync(signature: Bytes, message: Bytes, publicKey: Bytes, opts?: EdDSAVerifyOpts): Promise<boolean>;
function verify(signature: Bytes, message: Bytes, publicKey: Bytes, opts?: EdDSAVerifyOpts): boolean;
type EdDSAVerifyOpts = { zip215?: boolean };Complete edwards curve point arithmetic for advanced cryptographic operations and custom implementations.
class Point {
static readonly BASE: Point;
static readonly ZERO: Point;
static CURVE(): EdwardsOpts;
static fromAffine(p: AffinePoint): Point;
static fromBytes(hex: Bytes, zip215?: boolean): Point;
static fromHex(hex: string, zip215?: boolean): Point;
readonly X: bigint;
readonly Y: bigint;
readonly Z: bigint;
readonly T: bigint;
constructor(X: bigint, Y: bigint, Z: bigint, T: bigint);
get x(): bigint;
get y(): bigint;
assertValidity(): this;
multiply(n: bigint, safe?: boolean): Point;
add(other: Point): Point;
subtract(other: Point): Point;
equals(other: Point): boolean;
toBytes(): Bytes;
toHex(): string;
}
type AffinePoint = { x: bigint; y: bigint };
type EdwardsOpts = Readonly<{
p: bigint; n: bigint; h: bigint; a: bigint; d: bigint; Gx: bigint; Gy: bigint;
}>;Essential utility functions for byte manipulation, hashing, and key derivation operations.
const etc: {
bytesToHex(b: Bytes): string;
hexToBytes(hex: string): Bytes;
concatBytes(...arrs: Bytes[]): Bytes;
mod(a: bigint, b?: bigint): bigint;
invert(num: bigint, md: bigint): bigint;
randomBytes(len?: number): Bytes;
};
const hashes: {
sha512Async(message: Bytes): Promise<Bytes>;
sha512: undefined | ((message: Bytes) => Bytes);
};
const utils: {
getExtendedPublicKeyAsync(secretKey: Bytes): Promise<ExtK>;
getExtendedPublicKey(secretKey: Bytes): ExtK;
randomSecretKey(seed?: Bytes): Bytes;
};
function hash(msg: Bytes): Promise<Bytes>;type Bytes = Uint8Array;
type ExtK = {
head: Bytes;
prefix: Bytes;
scalar: bigint;
point: Point;
pointBytes: Bytes;
};