or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdkey-management.mdpoint-operations.mdsignatures.mdutilities.md
tile.json

tessl/npm-noble--ed25519

Fastest 5KB JS implementation of ed25519 EDDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@noble/ed25519@3.0.x

To install, run

npx @tessl/cli install tessl/npm-noble--ed25519@3.0.0

index.mddocs/

Noble Ed25519

Fastest 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.

Package Information

  • Package Name: @noble/ed25519
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @noble/ed25519

Core Imports

import * 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');

Basic Usage

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);

Architecture

Noble Ed25519 is built around several key components:

  • Core Cryptographic Functions: RFC8032-compliant ed25519 operations for signing and verification
  • Dual API: Both synchronous and asynchronous versions of all operations
  • Point Operations: Complete edwards curve point arithmetic with the Point class
  • Security Features: Constant-time algorithms, SUF-CMA security, consensus-friendly verification
  • Utility Functions: Hash functions, byte manipulation, key generation utilities
  • Multi-Runtime Support: Works in Node.js, Deno, Bun, and browsers

Capabilities

Key Management

Core 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;

Key Management

Digital Signatures

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 };

Digital Signatures

Point Operations

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;
}>;

Point Operations

Utility Functions

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>;

Utility Functions

Types

type Bytes = Uint8Array;

type ExtK = {
  head: Bytes;
  prefix: Bytes;
  scalar: bigint;
  point: Point;
  pointBytes: Bytes;
};