import { secp256k1, schnorr } from '@noble/curves/secp256k1.js';import { p256, p384, p521 } from '@noble/curves/nist.js';import { ed25519 } from '@noble/curves/ed25519.js';import { ed448 } from '@noble/curves/ed448.js';import { brainpoolP256r1, brainpoolP384r1, brainpoolP512r1 } from '@noble/curves/misc.js';for (const curve of [ secp256k1, schnorr, p256, p384, p521, ed25519, ed448, brainpoolP256r1, brainpoolP384r1, brainpoolP512r1]) { const { secretKey, publicKey } = curve.keygen(); const msg = new TextEncoder().encode('hello noble'); const sig = curve.sign(msg, secretKey); const isValid = curve.verify(sig, msg, publicKey); console.log(curve, secretKey, publicKey, sig, isValid);}// Specific private keyimport { hexToBytes } from '@noble/curves/utils.js';const secret2 = hexToBytes('46c930bc7bb4db7f55da20798697421b98c4175a52c630294d75a84b9c126236');const pub2 = secp256k1.getPublicKey(secret2);
Messages are always hashed first: see prehashed signing.
ECDSA uses deterministic k, EdDSA follows RFC 8032, Schnorr (secp256k1-only) follows BIP 340: see Specs.
MuSig2 signature scheme and BIP324 ElligatorSwift mapping for secp256k1
are available in a separate package.
ristretto255, decaf448
import { ristretto255, ristretto255_hasher, ristretto255_oprf } from '@noble/curves/ed25519.js';import { decaf448, decaf448_hasher, decaf448_oprf } from '@noble/curves/ed448.js';console.log(ristretto255.Point, decaf448.Point);
Check out RFC 9496 more info on ristretto255 & decaf448.
Check out separate documentation for Point, hasher and oprf.
Prehashed signing
import { secp256k1 } from '@noble/curves/secp256k1.js';import { keccak_256 } from '@noble/hashes/sha3.js';const { secretKey } = secp256k1.keygen();const msg = new TextEncoder().encode('hello noble');// prehash: true (default) - hash using secp256k1.hash (sha256)const sig = secp256k1.sign(msg, secretKey);// prehash: false - hash using custom hashconst sigKeccak = secp256k1.sign(keccak_256(msg), secretKey, { prehash: false });
By default (prehash: true), sign() and verify() apply the curve's built-in hash to the message first:
sha256 for secp256k1, sha512 for p521. prehash: false allows using a custom hash
(e.g. secp256k1 + keccak_256). In noble-curves v1, prehash: false was the default.
Recovering public keys from signatures
import { secp256k1 } from '@noble/curves/secp256k1.js';const { secretKey, publicKey } = secp256k1.keygen();const msg = new TextEncoder().encode('hello noble');const sigRec = secp256k1.sign(msg, secretKey, { format: 'recovered' });const publicKey_ = secp256k1.recoverPublicKey(sigRec, msg); // == publicKey// recovered sig is compact sig with an extra byteconst sigNoRec = secp256k1.sign(msg, secretKey, { format: 'compact' });// sigNoRec == sigRec.slice(1)// Signature instanceconst sigInstance = secp256k1.Signature.fromBytes(sigRec, 'recovered');
Public key recovery is only supported with ECDSA. It is a simple math operation:
there are no guarantees the signing was actually done. A forged (r, s, h) recovers into
a random public key, but it's not feasible to find m which would lead to this specific forged h.
Hedged ECDSA with noise
import { secp256k1 } from '@noble/curves/secp256k1.js';const { secretKey } = secp256k1.keygen();const msg = new TextEncoder().encode('hello noble');// extraEntropy: false - default, hedging disabledconst sigNoisy = secp256k1.sign(msg, secretKey);// extraEntropy: true - fetch 32 random bytes from CSPRNGconst sigNoisyA = secp256k1.sign(msg, secretKey, { extraEntropy: true });// extraEntropy: bytes - specific extra entropyconst ent = Uint8Array.from([0xca, 0xfe, 0x01, 0x23]);const sigNoisy2 = secp256k1.sign(msg, secretKey, { extraEntropy: ent });
By default, ECDSA signatures are deterministic (RFC 6979). Purely deterministic signatures are
vulnerable to fault attacks, so newer schemes, such as BIP340 schnorr, incorporate randomness
into sig generation - a.k.a. hedging. extraEntropy enables hedged mode. For more info, check out
Deterministic signatures are not your friends.
Consensus-friendliness vs e-voting
import { ed25519 } from '@noble/curves/ed25519.js';const { secretKey, publicKey } = ed25519.keygen();const msg = new TextEncoder().encode('hello noble');const sig = ed25519.sign(msg, secretKey);// zip215: trueconst isValid = ed25519.verify(sig, msg, publicKey);// SBS / e-voting / RFC8032 / FIPS 186-5const isValidRfc = ed25519.verify(sig, msg, publicKey, { zip215: false });
zip215: true (default) uses the more permissive, consensus-friendly verification rules defined in ZIP215.
zip215: false enforces strict RFC 8032 / FIPS 186-5 verification and adds SBS-based
non-repudiation, which is useful for contract signing, e-voting and blockchains.
Both modes have SUF-CMA (strong unforgeability under chosen message attacks);
most other libraries have neither SUF-CMA nor SBS.
See Taming the many EdDSAs for more info.
ECDH: Diffie-Hellman shared secrets
import { x25519 } from '@noble/curves/ed25519.js';const alice = x25519.keygen();const bob = x25519.keygen();const sharedKey = x25519.getSharedSecret(alice.secretKey, bob.publicKey);// Same API: secp256k1, p256, p384, p521, x448// converting ed25519 keys to x25519import { ed25519 } from '@noble/curves/ed25519.js';const alice2 = ed25519.keygen();const bob2 = ed25519.keygen();const aliceSecX = ed25519.utils.toMontgomerySecret(alice2.secretKey);const bobPubX = ed25519.utils.toMontgomery(bob2.publicKey);const sharedKey2 = x25519.getSharedSecret(aliceSecX, bobPubX);
We provide ECDH over all Weierstrass curves, and over 2 Montgomery curves
X25519 (Curve25519) & X448 (Curve448), conforming to RFC 7748.
In Weierstrass curves, shared secrets:
Include y-parity bytes: use key.slice(1) to strip it
Are not hashed: use hashing or KDF on top, like sha256(shared) or hkdf(shared)
webcrypto: friendly wrapper
import { ed25519, x25519 } from '@noble/curves/webcrypto.js';// signatures: p256, p384, p521, ed25519, ed448const keys = await ed25519.keygen();const msg = new TextEncoder().encode('hello noble');const sig = await ed25519.sign(msg, keys.secretKey);const isValid = await ed25519.verify(sig, msg, keys.publicKey);// ECDH: p256, p384, p521, x25519, x448const alice = await x25519.keygen();const bob = await x25519.keygen();const shared = await x25519.getSharedSecret(alice.secretKey, bob.publicKey);// key conversion between noble (raw) and webcrypto (pkcs8 / spki) formatsimport { p256 as p256n } from '@noble/curves/nist.js';import { p256 } from '@noble/curves/webcrypto.js';const nobleKeys = p256n.keygen();const secretKeyPkcs8 = await p256.utils.convertSecretKey(nobleKeys.secretKey, 'raw', 'pkcs8');const publicKeySpki = await p256.utils.convertPublicKey(nobleKeys.publicKey, 'raw', 'spki');
A thin wrapper over built-in WebCrypto, mirroring the noble API. Methods are always async;
runtime support varies - check with await curve.isSupported().
Check out micro-key-producer for
pure JS key conversion utils.
import { secp256k1_hasher } from '@noble/curves/secp256k1.js';const msg = Uint8Array.from([0xca, 0xfe, 0x01, 0x23]);const point = secp256k1_hasher.hashToCurve(msg);const pointDst = secp256k1_hasher.hashToCurve(msg, { DST: 'hello noble' });const pointNu = secp256k1_hasher.encodeToCurve(msg);const scalar = secp256k1_hasher.hashToScalar(msg);// Same API: p256_hasher, p384_hasher, p521_hasher (nist.js),// ed25519_hasher, ristretto255_hasher (ed25519.js), ed448_hasher, decaf448_hasher (ed448.js),// bls12_381.G1, bls12_381.G2.// ristretto255 & decaf448 also provide deriveToCurve.// abstract methodsimport { expand_message_xmd, expand_message_xof, hash_to_field } from '@noble/curves/abstract/hash-to-curve.js';
The module allows to hash arbitrary strings to elliptic curve points. Implements RFC 9380.
_hasher namespaces are separate from curves for tree-shaking:
users who don't need hash-to-curve won't have it in their builds.
OPRFs
import { p256_oprf, p384_oprf, p521_oprf } from '@noble/curves/nist.js';import { ristretto255_oprf } from '@noble/curves/ed25519.js';import { decaf448_oprf } from '@noble/curves/ed448.js';
We provide OPRFs (oblivious pseudorandom functions),
conforming to RFC 9497.
OPRF allows to interactively create an Output = PRF(Input, serverSecretKey):
Server cannot calculate Output by itself: it doesn't know Input
Client cannot calculate Output by itself: it doesn't know server secretKey
An attacker interception the communication can't restore Input/Output/serverSecretKey and can't
link Input to some value.
FROST threshold signatures
FROST implements RFC 9591 threshold Schnorr signing.
It is similar to multisig from the application point of view: any min of max participants
can jointly produce one Schnorr signature under a shared public key.
Supported ciphersuites are p256_FROST, ed25519_FROST, ed448_FROST, ristretto255_FROST,
secp256k1_FROST, and schnorr_FROST (Taproot-compatible secp256k1).
Signing has two rounds: selected signers commit first, then produce signature shares.
Key generation can be done with a trusted dealer (above) or with DKG (distributed key generation).
DKG has three rounds: participants commit to key generation, exchange private shares,
then derive final participant keys - see DKG.round1 / round2 / round3 usage in
the tests.
The library implements the cryptographic steps, not the surrounding application protocol:
callers still need authenticated communication, coordination, retries, session handling, and policy.
poseidon: Poseidon hash
Implements Poseidon ZK-friendly hash:
permutation and sponge.
There are many poseidon variants with different constants.
We don't provide them: you should construct them manually.
Check out scure-starknet package for a proper example.
Every curve exposes its Point class: secp256k1, schnorr, p256, p384, p521, ed25519, ed448,
ristretto255, decaf448, bls12_381.G1 / G2, bn254.G1, jubjub, babyjubjub.
Weierstrass points use projective (homogeneous) coordinates new Point(X, Y, Z),
edwards points use extended coordinates new Point(X, Y, Z, T); both with x=X/Z, y=Y/Z.
modular: Modular arithmetics & finite fields
import { mod, invert, Field } from '@noble/curves/abstract/modular.js';// Finite Field utilsconst fp = Field(2n ** 255n - 19n); // Finite field over 2^255-19fp.mul(591n, 932n); // multiplicationfp.pow(481n, 11024858120n); // exponentiationfp.div(5n, 17n); // division: 5/17 mod 2^255-19 == 5 * invert(17)fp.inv(5n); // modular inversefp.sqrt(4n); // square root// Non-Field generic utils are also availablemod(21n, 10n); // 21 mod 10 == 1n; fixed version of 21 % 10invert(17n, 10n); // invert(17) mod 10; modular multiplicative inverse
All arithmetics is done with JS bigints over finite fields,
which is defined from modular sub-module.
Field operations are not constant-time: see security.
The fact is mostly irrelevant, but the important method to keep in mind is pow,
which may leak exponent bits, when used naïvely.
Short Weierstrass curve's formula is y² = x³ + ax + b. weierstrass
expects arguments a, b, field characteristic p, curve order n,
cofactor h and coordinates Gx, Gy of generator point, and returns a Point class.
ecdsa combines a Point class with a hash function into a signature scheme.
Twisted Edwards curve's formula is ax² + y² = 1 + dx²y².
You must specify a, d, field characteristic p, curve order n (sometimes named as L),
cofactor h and coordinates Gx, Gy of generator point.
We've started regular AI-assisted self-audits in Apr 2026.
It is tested against property-based, cross-library and Wycheproof vectors,
and is being fuzzed in github ci.
If you see anything unusual: investigate and report.
Constant-timeness
We're targetting algorithmic constant time. JIT-compiler and Garbage Collector make "constant time"
extremely hard to achieve timing attack resistance
in a scripting language. Which means any other JS library can't have
constant-timeness. Even statically typed Rust, a language without GC,
makes it harder to achieve constant-time
for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones.
Use low-level libraries & languages.
Within those limits, secret-scalar multiplication provides specific, measurable properties:
Fixed operation sequence:multiply() uses signed fixed-window tables with
data-oblivious table scans — the number and order of point operations
is independent of the scalar value.
Scalar blinding: secret scalars are additionally masked as s + r·n with a random
128-bit r before multiplication. This applies to all multiplications on cofactor-1
curves (p256, p384, p521, secp256k1), and to base-point multiplications everywhere.
Statistical validation: a dudect-style Welch t-test harness (benchmark/ct.ts)
compares timing across adversarial scalar classes (sparse vs dense, low vs high bits,
near-order, bit patterns). Base-point multiplication shows no distinguishable timing on any
curve, and random-point multiplication shows none on the Weierstrass curves
(max |t| ≤ 2.8 at 1000 samples; threshold 4.5).
Known limitation: on cofactored Edwards curves (ed25519, ed448), multiplying a non-base
point by a secret scalar is not blinded. The same harness detects this reliably. EdDSA signing is
unaffected (it only multiplies the blinded base point), and X25519/X448 use a separate
Montgomery-ladder implementation (also unaffected). It matters for protocols that multiply arbitrary
Edwards/Ristretto points by long-lived secret scalars; prefer scalars that are
full-width by construction there. Note that detectability in an isolated harness does not
imply practical exploitability: we attempted scalar extraction in a realistic
cross-tenant / in-browser setting and were unable to recover Edwards scalars
even with 100,000 timing samples.
Memory dumping
Use low-level languages instead of JS / WASM if your goal is absolute security.
The library mostly uses Uint8Arrays and bigints.
Uint8Arrays have .fill(0) which instructs to fill content with zeroes
but there are no guarantees in JS
bigints are immutable and don't have a method to zeroize their content:
a user needs to wait until the next garbage collection cycle
hex strings are also immutable: there is no way to zeroize them
await fn() will write all internal variables to memory. With
async functions there are no guarantees when the code
chunk would be executed. Which means attacker can have
plenty of time to read data from memory.
This means some secrets could stay in memory longer than anticipated.
However, if an attacker can read application memory, it's doomed anyway:
there is no way to guarantee anything about zeroizing sensitive data without
complex tests-suite which will dump process memory and verify that there is
no sensitive data left. For JS it means testing all browsers (including mobile).
And, of course, it will be useless without using the same
test-suite in the actual application that consumes the library.
Supply chain security
Commits are signed with PGP keys to prevent forgery. Be sure to verify the commit signatures
Releases are made transparently through token-less GitHub CI and Trusted Publishing. Be sure to verify the provenance logs for authenticity.
Rare releasing is practiced to minimize the need for re-audits by end-users.
Dependencies are minimized and strictly pinned to reduce supply-chain risk.
We use as few dependencies as possible.
Version ranges are locked, and changes are checked with npm-diff.
Dev dependencies are excluded from end-user installs; they’re only used for development and build steps.
For this package, there is 1 dependency; and a few dev dependencies:
jsbt is used for benchmarking / testing / build tooling and developed by the same author
prettier, fast-check and typescript are used for code quality / test generation / ts compilation
Randomness
We rely on the built-in
crypto.getRandomValues,
which is considered a cryptographically secure PRNG.
Browsers have had weaknesses in the past - and could again - but implementing a userspace CSPRNG is even worse, as there’s no reliable userspace source of high-quality entropy.
Quantum computers
Cryptographically relevant quantum computer, if built, will allow to
break elliptic curve cryptography (both ECDSA / EdDSA & ECDH) using Shor's algorithm.
Consider switching to newer / hybrid algorithms, such as SPHINCS+. They are available in
noble-post-quantum.
NIST prohibits classical cryptography (RSA, DSA, ECDSA, ECDH) after 2035. Australian ASD prohibits it after 2030.
Speed
npm run benchmark
noble-curves spends 10+ ms to generate 20MB+ of base point precomputes.
This is done one-time per curve.
The generation is deferred until any method (pubkey, sign, verify) is called.
User can force precompute generation by manually calling Point.BASE.precompute(windowSize, false).
Check out the source code.
v2 massively simplifies internals, improves security, reduces bundle size and lays path for the future.
We tried to keep v2 as much backwards-compatible as possible.
Upgrade path: upgrade to curves v1.9.x first. Fix the deprecation warnings, then switch to v2.
Modules:
The package is now ESM-only. ESM can finally be loaded from common.js on node v20.19+
.js extension is now required: @noble/curves/ed25519 => @noble/curves/ed25519.js.
This enables native browser usage, without transpilers
p256, p384, p521 were moved into nist; jubjub was moved into misc
pasta and bn254_weierstrass (NOT pairing-based bn254) curves were removed
New features:
webcrypto: friendly noble-like wrapper over built-in WebCrypto
oprf: RFC 9497 OPRFs (oblivious pseudorandom functions)
for p256, p384, p521, ristretto255 and decaf448
weierstrass, edwards: new isValidSecretKey, isValidPublicKey methods
Massively improved, more descriptive error messages
Breaking changes:
Most methods now only accept Uint8Array; string hex inputs are prohibited.
This simplifies reasoning, improves security and reduces malleability.
Point.fromHex is now string-only: use Point.fromBytes for Uint8Array
ECDSA (secp256k1, p256, p384...) sign & verify:
Prehashed messages: methods now expect the unhashed message
instead of messageHash. Old behavior: {prehash: false}
lowS signatures by default. secp256k1 is unaffected: it has used
lowS since the beginning. Old behavior: {lowS: false}
Uint8Array signatures (format: 'compact') by default
verify: der format must be explicitly specified in {format: 'der'}.
This reduces malleability
verify: Signature instances are prohibited: call signature.toBytes() first
BLS signatures (bls12-381, bn254):
getPublicKey, sign, verify, signShortSignature etc were moved into two new namespaces:
longSignatures (G1 pubkeys, G2 sigs) and shortSignatures (G1 sigs, G2 pubkeys)
verifyBatch now expects array of inputs {message: ..., publicKey: ...}[]
Custom curves:
Curve creation was massively simplified and split into point creation &
sig generator creation: weierstrass() + ecdsa() / edwards() + eddsa().
weierstrass / edwards expect simplified curve params (Fp became p);
ecdsa / eddsa expect Point class and hash
pippenger: removed unnecessary Fn argument
Field#fromBytes() now validates elements to be in 0..order-1 range
Renamings (curves v1.9 highlights old names as deprecated):
Points
ExtendedPoint, ProjectivePoint => Point
Point coordinates px/ex, py/ey, pz/ez, et => X, Y, Z, T
toRawBytes, fromRawBytes => toBytes, fromBytes
Point.normalizeZ, Point.msm => separate methods in abstract/curve.js submodule