or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

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

index.mddocs/

0

# Noble Ed25519

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: @noble/ed25519

7

- **Package Type**: npm

8

- **Language**: TypeScript

9

- **Installation**: `npm install @noble/ed25519`

10

11

## Core Imports

12

13

```typescript

14

import * as ed from '@noble/ed25519';

15

```

16

17

Named imports:

18

19

```typescript

20

import {

21

sign, signAsync, verify, verifyAsync,

22

getPublicKey, getPublicKeyAsync,

23

keygen, keygenAsync,

24

Point, etc, utils, hashes, hash

25

} from '@noble/ed25519';

26

```

27

28

CommonJS:

29

30

```javascript

31

const ed = require('@noble/ed25519');

32

```

33

34

## Basic Usage

35

36

```typescript

37

import * as ed from '@noble/ed25519';

38

39

// Generate keypair

40

const { secretKey, publicKey } = await ed.keygenAsync();

41

42

// Sign a message

43

const message = new TextEncoder().encode('hello noble');

44

const signature = await ed.signAsync(message, secretKey);

45

46

// Verify signature

47

const isValid = await ed.verifyAsync(signature, message, publicKey);

48

console.log(isValid); // true

49

50

// For sync operations, set hash function first

51

import { sha512 } from '@noble/hashes/sha512';

52

ed.hashes.sha512 = sha512;

53

54

// Now sync methods work

55

const syncPublicKey = ed.getPublicKey(secretKey);

56

const syncSignature = ed.sign(message, secretKey);

57

```

58

59

## Architecture

60

61

Noble Ed25519 is built around several key components:

62

63

- **Core Cryptographic Functions**: RFC8032-compliant ed25519 operations for signing and verification

64

- **Dual API**: Both synchronous and asynchronous versions of all operations

65

- **Point Operations**: Complete edwards curve point arithmetic with the `Point` class

66

- **Security Features**: Constant-time algorithms, SUF-CMA security, consensus-friendly verification

67

- **Utility Functions**: Hash functions, byte manipulation, key generation utilities

68

- **Multi-Runtime Support**: Works in Node.js, Deno, Bun, and browsers

69

70

## Capabilities

71

72

### Key Management

73

74

Core functionality for generating and handling ed25519 keys, supporting both synchronous and asynchronous operations.

75

76

```typescript { .api }

77

function keygenAsync(seed?: Bytes): Promise<{ secretKey: Bytes; publicKey: Bytes }>;

78

function keygen(seed?: Bytes): { secretKey: Bytes; publicKey: Bytes };

79

function getPublicKeyAsync(secretKey: Bytes): Promise<Bytes>;

80

function getPublicKey(secretKey: Bytes): Bytes;

81

```

82

83

[Key Management](./key-management.md)

84

85

### Digital Signatures

86

87

RFC8032-compliant signing and verification operations with both async and sync variants.

88

89

```typescript { .api }

90

function signAsync(message: Bytes, secretKey: Bytes): Promise<Bytes>;

91

function sign(message: Bytes, secretKey: Bytes): Bytes;

92

function verifyAsync(signature: Bytes, message: Bytes, publicKey: Bytes, opts?: EdDSAVerifyOpts): Promise<boolean>;

93

function verify(signature: Bytes, message: Bytes, publicKey: Bytes, opts?: EdDSAVerifyOpts): boolean;

94

95

type EdDSAVerifyOpts = { zip215?: boolean };

96

```

97

98

[Digital Signatures](./signatures.md)

99

100

### Point Operations

101

102

Complete edwards curve point arithmetic for advanced cryptographic operations and custom implementations.

103

104

```typescript { .api }

105

class Point {

106

static readonly BASE: Point;

107

static readonly ZERO: Point;

108

static CURVE(): EdwardsOpts;

109

static fromAffine(p: AffinePoint): Point;

110

static fromBytes(hex: Bytes, zip215?: boolean): Point;

111

static fromHex(hex: string, zip215?: boolean): Point;

112

113

readonly X: bigint;

114

readonly Y: bigint;

115

readonly Z: bigint;

116

readonly T: bigint;

117

118

constructor(X: bigint, Y: bigint, Z: bigint, T: bigint);

119

get x(): bigint;

120

get y(): bigint;

121

assertValidity(): this;

122

multiply(n: bigint, safe?: boolean): Point;

123

add(other: Point): Point;

124

subtract(other: Point): Point;

125

equals(other: Point): boolean;

126

toBytes(): Bytes;

127

toHex(): string;

128

}

129

130

type AffinePoint = { x: bigint; y: bigint };

131

type EdwardsOpts = Readonly<{

132

p: bigint; n: bigint; h: bigint; a: bigint; d: bigint; Gx: bigint; Gy: bigint;

133

}>;

134

```

135

136

[Point Operations](./point-operations.md)

137

138

### Utility Functions

139

140

Essential utility functions for byte manipulation, hashing, and key derivation operations.

141

142

```typescript { .api }

143

const etc: {

144

bytesToHex(b: Bytes): string;

145

hexToBytes(hex: string): Bytes;

146

concatBytes(...arrs: Bytes[]): Bytes;

147

mod(a: bigint, b?: bigint): bigint;

148

invert(num: bigint, md: bigint): bigint;

149

randomBytes(len?: number): Bytes;

150

};

151

152

const hashes: {

153

sha512Async(message: Bytes): Promise<Bytes>;

154

sha512: undefined | ((message: Bytes) => Bytes);

155

};

156

157

const utils: {

158

getExtendedPublicKeyAsync(secretKey: Bytes): Promise<ExtK>;

159

getExtendedPublicKey(secretKey: Bytes): ExtK;

160

randomSecretKey(seed?: Bytes): Bytes;

161

};

162

163

function hash(msg: Bytes): Promise<Bytes>;

164

```

165

166

[Utility Functions](./utilities.md)

167

168

## Types

169

170

```typescript { .api }

171

type Bytes = Uint8Array;

172

173

type ExtK = {

174

head: Bytes;

175

prefix: Bytes;

176

scalar: bigint;

177

point: Point;

178

pointBytes: Bytes;

179

};

180

```