Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@noble/ed25519

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@noble/ed25519 - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

28

index.d.ts

@@ -1,2 +0,7 @@

type CURVET = {
/**
* ed25519 curve parameters. Equation is −x² + y² = -a + dx²y².
* Gx and Gy are generator coordinates. p is field order, n is group order.
* h is cofactor.
*/
declare const CURVE: {
a: bigint;

@@ -10,9 +15,12 @@ d: bigint;

};
declare const CURVE: CURVET;
type Bytes = Uint8Array;
type Hex = Bytes | string;
interface AffinePoint {
/** Alias to Uint8Array. */
export type Bytes = Uint8Array;
/** Hex-encoded string or Uint8Array. */
export type Hex = Bytes | string;
/** Point in 2d xy affine coordinates. */
export interface AffinePoint {
x: bigint;
y: bigint;
}
/** Point in xyzt extended coordinates. */
declare class Point {

@@ -52,11 +60,18 @@ readonly ex: bigint;

};
/** Creates 32-byte ed25519 public key from 32-byte private key. Async. */
declare const getPublicKeyAsync: (priv: Hex) => Promise<Bytes>;
/** Creates 32-byte ed25519 public key from 32-byte private key. To use, set `etc.sha512Sync` first. */
declare const getPublicKey: (priv: Hex) => Bytes;
/** Signs message (NOT message hash) using private key. Async. */
declare const signAsync: (msg: Hex, privKey: Hex) => Promise<Bytes>;
/** Signs message (NOT message hash) using private key. To use, set `etc.sha512Sync` first. */
declare const sign: (msg: Hex, privKey: Hex) => Bytes;
type DVO = {
export type DVO = {
zip215?: boolean;
};
/** Verifies signature on message and public key. Async. */
declare const verifyAsync: (s: Hex, m: Hex, p: Hex, opts?: DVO) => Promise<boolean>;
/** Verifies signature on message and public key. To use, set `etc.sha512Sync` first. */
declare const verify: (s: Hex, m: Hex, p: Hex, opts?: DVO) => boolean;
/** Math, hex, byte helpers. Not in `utils` because utils share API with noble-curves. */
declare const etc: {

@@ -72,2 +87,3 @@ bytesToHex: (b: Bytes) => string;

};
/** ed25519-specific key utilities. */
declare const utils: {

@@ -74,0 +90,0 @@ getExtendedPublicKeyAsync: (priv: Hex) => Promise<ExtK>;

/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
/**
* 4KB JS implementation of ed25519 EDDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215.
* @module
*/
const P = 2n ** 255n - 19n; // ed25519 is twisted edwards curve

@@ -6,5 +10,11 @@ const N = 2n ** 252n + 27742317777372353535851937790883648493n; // curve's (group) order

const Gy = 0x6666666666666666666666666666666666666666666666666666666666666658n; // base point y
const _d = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
/**
* ed25519 curve parameters. Equation is −x² + y² = -a + dx²y².
* Gx and Gy are generator coordinates. p is field order, n is group order.
* h is cofactor.
*/
const CURVE = {
a: -1n, // where a=-1, d = -(121665/121666) == -(121665 * inv(121666)) mod P
d: 37095705934669439343138083508754565189542113879843219016388785533085940283555n,
a: -1n, // -1 mod p
d: _d, // -(121665/121666) mod p
p: P, n: N, h: 8, Gx: Gx, Gy: Gy // field prime, curve (group) order, cofactor

@@ -22,2 +32,3 @@ };

const isPoint = (p) => (p instanceof Point ? p : err('Point expected')); // is xyzt point
/** Point in xyzt extended coordinates. */
class Point {

@@ -262,3 +273,5 @@ constructor(ex, ey, ez, et) {

const getExtendedPublicKey = (priv) => hash2extK(sha512s(toU8(priv, 32)));
/** Creates 32-byte ed25519 public key from 32-byte private key. Async. */
const getPublicKeyAsync = (priv) => getExtendedPublicKeyAsync(priv).then(p => p.pointBytes);
/** Creates 32-byte ed25519 public key from 32-byte private key. To use, set `etc.sha512Sync` first. */
const getPublicKey = (priv) => getExtendedPublicKey(priv).pointBytes;

@@ -281,2 +294,3 @@ function hashFinish(asynchronous, res) {

};
/** Signs message (NOT message hash) using private key. Async. */
const signAsync = async (msg, privKey) => {

@@ -288,2 +302,3 @@ const m = toU8(msg); // RFC8032 5.1.6: sign msg with key async

};
/** Signs message (NOT message hash) using private key. To use, set `etc.sha512Sync` first. */
const sign = (msg, privKey) => {

@@ -322,6 +337,9 @@ const m = toU8(msg); // RFC8032 5.1.6: sign msg with key sync

// RFC8032 5.1.7: verification async, sync
/** Verifies signature on message and public key. Async. */
const verifyAsync = async (s, m, p, opts = dvo) => hashFinish(true, _verify(s, m, p, opts));
/** Verifies signature on message and public key. To use, set `etc.sha512Sync` first. */
const verify = (s, m, p, opts = dvo) => hashFinish(false, _verify(s, m, p, opts));
const cr = () => // We support: 1) browsers 2) node.js 19+
typeof globalThis === 'object' && 'crypto' in globalThis && 'subtle' in globalThis.crypto ? globalThis.crypto : undefined;
/** Math, hex, byte helpers. Not in `utils` because utils share API with noble-curves. */
const etc = {

@@ -354,2 +372,3 @@ bytesToHex: b2h,

} });
/** ed25519-specific key utilities. */
const utils = {

@@ -356,0 +375,0 @@ getExtendedPublicKeyAsync: getExtendedPublicKeyAsync,

/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
/**
* 4KB JS implementation of ed25519 EDDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215.
* @module
*/
const P = 2n ** 255n - 19n; // ed25519 is twisted edwards curve

@@ -6,11 +10,19 @@ const N = 2n ** 252n + 27742317777372353535851937790883648493n; // curve's (group) order

const Gy = 0x6666666666666666666666666666666666666666666666666666666666666658n; // base point y
type CURVET = {
const _d = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
/**
* ed25519 curve parameters. Equation is −x² + y² = -a + dx²y².
* Gx and Gy are generator coordinates. p is field order, n is group order.
* h is cofactor.
*/
const CURVE: {
a: bigint; d: bigint; p: bigint; n: bigint; h: number; Gx: bigint; Gy: bigint;
}
const CURVE: CURVET = { // Curve's formula is −x² + y² = -a + dx²y²
a: -1n, // where a=-1, d = -(121665/121666) == -(121665 * inv(121666)) mod P
d: 37095705934669439343138083508754565189542113879843219016388785533085940283555n,
} = {
a: -1n, // -1 mod p
d: _d, // -(121665/121666) mod p
p: P, n: N, h: 8, Gx: Gx, Gy: Gy // field prime, curve (group) order, cofactor
};
type Bytes = Uint8Array; type Hex = Bytes | string; // types
/** Alias to Uint8Array. */
export type Bytes = Uint8Array;
/** Hex-encoded string or Uint8Array. */
export type Hex = Bytes | string;
const err = (m = ''): never => { throw new Error(m); }; // error helper, messes-up stack trace

@@ -28,4 +40,6 @@ const isS = (s: unknown): s is string => typeof s === 'string'; // is string

const isPoint = (p: any) => (p instanceof Point ? p : err('Point expected')); // is xyzt point
interface AffinePoint { x: bigint, y: bigint } // Point in 2d xy affine coordinates
class Point { // Point in xyzt extended coordinates
/** Point in 2d xy affine coordinates. */
export interface AffinePoint { x: bigint, y: bigint }
/** Point in xyzt extended coordinates. */
class Point {
constructor(readonly ex: bigint, readonly ey: bigint, readonly ez: bigint, readonly et: bigint) {}

@@ -223,4 +237,6 @@ static readonly BASE: Point = new Point(Gx, Gy, 1n, M(Gx * Gy)); // Generator / Base point

const getExtendedPublicKey = (priv: Hex) => hash2extK(sha512s(toU8(priv, 32)))
/** Creates 32-byte ed25519 public key from 32-byte private key. Async. */
const getPublicKeyAsync = (priv: Hex): Promise<Bytes> =>
getExtendedPublicKeyAsync(priv).then(p => p.pointBytes)
/** Creates 32-byte ed25519 public key from 32-byte private key. To use, set `etc.sha512Sync` first. */
const getPublicKey = (priv: Hex): Bytes => getExtendedPublicKey(priv).pointBytes;

@@ -247,2 +263,3 @@ type Finishable<T> = { // Reduces logic duplication between

};
/** Signs message (NOT message hash) using private key. Async. */
const signAsync = async (msg: Hex, privKey: Hex): Promise<Bytes> => {

@@ -254,2 +271,3 @@ const m = toU8(msg); // RFC8032 5.1.6: sign msg with key async

};
/** Signs message (NOT message hash) using private key. To use, set `etc.sha512Sync` first. */
const sign = (msg: Hex, privKey: Hex): Bytes => {

@@ -261,3 +279,3 @@ const m = toU8(msg); // RFC8032 5.1.6: sign msg with key sync

};
type DVO = { zip215?: boolean };
export type DVO = { zip215?: boolean };
const dvo: DVO = { zip215: true };

@@ -287,4 +305,7 @@ const _verify = (sig: Hex, msg: Hex, pub: Hex, opts: DVO = dvo): Finishable<boolean> => {

// RFC8032 5.1.7: verification async, sync
/** Verifies signature on message and public key. Async. */
const verifyAsync = async (s: Hex, m: Hex, p: Hex, opts: DVO = dvo): Promise<boolean> =>
hashFinish(true, _verify(s, m, p, opts));
/** Verifies signature on message and public key. To use, set `etc.sha512Sync` first. */
const verify = (s: Hex, m: Hex, p: Hex, opts: DVO = dvo): boolean =>

@@ -295,2 +316,3 @@ hashFinish(false, _verify(s, m, p, opts));

typeof globalThis === 'object' && 'crypto' in globalThis && 'subtle' in globalThis.crypto ? globalThis.crypto : undefined;
/** Math, hex, byte helpers. Not in `utils` because utils share API with noble-curves. */
const etc = {

@@ -320,2 +342,3 @@ bytesToHex: b2h satisfies (b: Bytes) => string as (b: Bytes) => string,

} });
/** ed25519-specific key utilities. */
const utils = {

@@ -322,0 +345,0 @@ getExtendedPublicKeyAsync: getExtendedPublicKeyAsync as (priv: Hex) => Promise<ExtK>,

{
"name": "@noble/ed25519",
"version": "2.2.1",
"version": "2.2.2",
"description": "Fastest 4KB JS implementation of ed25519 EDDSA signatures compliant with RFC8032, FIPS 186-5 & ZIP215",

@@ -5,0 +5,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc