npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@foxleys-rs/curve25519

v1.0.1

Published

Curve25519 for Javacript with rust binding

Readme


Table of Contents


Installation

npm install @foxleys-rs/curve25519

or with Yarn / pnpm / Bun:

yarn add @foxleys-rs/curve25519
pnpm add @foxleys-rs/curve25519
bun add @foxleys-rs/curve25519

This package ships prebuilt native binaries via napi-rs for all major platforms (no Rust toolchain required).


Supported Platforms

| Operating System | Architecture | libc | Prebuilt binaries | |------------------|--------------|---------------|-------------------| | Linux | x86_64 | glibc | Yes | | Linux | x86_64 | musl | Yes | | Linux | arm64 | glibc | Yes | | Linux | arm64 | musl | Yes | | macOS | x86_64 | — | Yes | | macOS | arm64 | — | Yes | | Windows | x86_64 | — | Yes | | Windows | arm64 | — | Yes |


Features

  • X25519 key pair generation and public key derivation
  • ECDH shared secret computation (X25519)
  • Ed25519 signing and signature verification
  • Extremely fast Rust core via napi-rs
  • Zero-dependency native binaries for Node.js ≥18
  • Automatic pure JavaScript fallback (curve25519-js) in environments without native support (e.g., some bundlers or testing)

Usage

/*
CJS
import curve from '@foxleys-rs/curve25519';
const {
  generateKeyPair,
  getPublicFromprivKey,
  calculateAgreement,
  calculateSignature,
  verifySignature,
} = curve;
*/
// ESM
import {
	generateKeyPair,
	getPublicFromPrivateKey,
	calculateAgreement,
	calculateSignature,
	verifySignature
} from "@foxleys-rs/curve25519";

// Generate a new key pair
const { pubKey, privKey } = generateKeyPair();

console.log("Public key :", pubKey);
console.log("Private key:", privKey);

// Derive public key from an existing private key (optional)
const pubKey2 = getPublicFromPrivateKey(privKey);

// Perform ECDH key exchange
const sharedSecret = calculateAgreement(pubKey, privKey);
console.log("Shared secret:", sharedSecret);

// Sign a message (Ed25519)
const message = Buffer.from("Hello, Curve25519!");
const signature = calculateSignature(privKey, message);

// Verify signature
const isValid = verifySignature(pubKey, message, signature);
console.log("Signature valid:", isValid);

All functions accept Buffer as input.


API

| Function | Description | Returns | |---------------------------------|--------------------------------------------------|---------------------------------| | generateKeyPair() | Generates a new X25519 key pair | { privKey: Buffer, pubKey: Buffer } | | getPublicFromPrivateKey(privKey) | Derives public key from private key | Buffer (33 bytes) | | calculateAgreement(pubKey, privKey) | Computes X25519 shared secret | Buffer (32 bytes) | | calculateSignature(privKey, msg) | Signs message with Ed25519 | Buffer (64 bytes) | | verifySignature(pubKey, msg, sig)| Verifies Ed25519 signature | boolean |


Performance

Benchmarks performed on Node.js 25. Results show average latency and throughput:

| Task | Latency (avg) | Throughput (avg ops/s) | |---------------------------------|--------------------|------------------------| | Rust generateKeyPair | 75.1 μs ± 0.80% | 13,610 | | Node generateKeyPair | 237.0 μs ± 3.90% | 5,225 | | Rust getPublicFromPrivateKey | 209.1 μs ± 0.78% | 4,876 | | Node getPublicFromPrivateKey | 1,735.8 μs ± 2.84% | 606 | | Rust calculateAgreement | 205.9 μs ± 0.43% | 4,892 | | Node calculateAgreement | 379.0 μs ± 2.44% | 2,835 | | Rust calculateSignature | 134.2 μs ± 0.27% | 7,492 | | Node calculateSignature | 37,241.7 μs ± 15.48% | 35 | | Rust verifySignature | 229.6 μs ± 0.37% | 4,389 | | Node verifySignature | 30,703.2 μs ± 17.43% | 45 |

The Rust implementation is 2–5× faster than equivalent pure JavaScript implementations, especially for signing and verification.


License

This project is licensed under the MIT License – see the LICENSE file for details.

Developed with ❤️ by Foxleys.