Releases: paulmillr/noble-curves
2.0.0
High-level
v2 massively simplifies internals, improves security, reduces bundle size and lays path for the future. To simplify upgrading, upgrade first to curves 1.9.x. It would show deprecations in vscode-like text editor.
- The package is now ESM-only. ESM can finally be loaded from common.js on node v20.19+
- Node v20.19 is now the minimum required version
- Package imports now work correctly in bundler-less environments, such as browsers
- Reduces npm package size (traffic consumed): 354KB => 300KB
- Reduces unpacked npm size (on-disk space): 2.1MB => 1.2MB
- Make bundle sizes smaller, compared to v1.x: -4KB for schnorr, -5.3KB for ristretto255, -9.4KB for x448
.js
extension must be used for all modules- Old:
@noble/curves/ed25519
- New:
@noble/curves/ed25519.js
- This simplifies working in browsers natively without transpilers
- Old:
New features
- webcrypto: create friendly noble-like wrapper over built-in WebCrypto
- oprf: implement RFC 9497 OPRFs (oblivious pseudorandom functions)
- We support p256, p384, p521, ristretto255 and decaf448
- weierstrass, edwards: add
isValidSecretKey
,isValidPublicKey
- misc: add Brainpool curves: brainpoolP256r1, brainpoolP384r1, brainpoolP512r1
Changes
- Most methods now expect Uint8Array, string hex inputs are prohibited
- The change simplifies reasoning, improves security and reduces malleability
Point.fromHex
now expects string-only hex inputs, usePoint.fromBytes
for Uint8Array
- Breaking changes of ECDSA (secp256k1, p256, p384...):
- sign, verify: Switch to prehashed messages. Instead of
messageHash, the methods now expect unhashed message.
To bring back old behavior, use option{prehash: false}
- sign, verify: Switch to lowS signatures by default.
This change doesn't affect secp256k1, which has been using lowS since beginning.
To bring back old behavior, use option{lowS: true}
- sign, verify: Switch to Uint8Array signatures (format: 'compact') by default.
- verify: der format must be explicitly specified in
{format: 'der'}
.
This reduces malleability - verify: prohibit Signature-instance signature. User must now always do
signature.toBytes()
- sign, verify: Switch to prehashed messages. Instead of
- Breaking changes of BLS signatures (bls12-381, bn254):
- Move getPublicKey, sign, verify, signShortSignature etc into two new namespaces:
bls.longSignatures (G1 pubkeys, G2 sigs) and bls.shortSignatures (G1 sigs, G2 pubkeys). - verifyBatch now expects array of inputs
{message: ..., publicKey: ...}[]
- Move getPublicKey, sign, verify, signShortSignature etc into two new namespaces:
- Curve changes:
- Massively simplify curve creation, split it into point creation & sig generator creation
- New methods are
weierstrass() + ecdsa()
/edwards() + eddsa()
- weierstrass / edwards expect simplified curve params (Fp became p)
- ecdsa / eddsa expect Point class and hash
- Remove unnecessary Fn argument in
pippenger
- modular changes:
- Field#fromBytes() now validates elements to be in 0..order-1 range
- Upgrade typescript compilation env to ts5.9 and es2022
- Massively improve error messages, make them more descriptive
Renamings
- Module changes
p256
,p384
,p521
modules have been moved intonist
jubjub
module has been moved intomisc
- Point changes
- ExtendedPoint, ProjectivePoint => Point
- Point coordinates (projective / extended) from px/ex, py/ey, pz/ez, et => X, Y, Z, T
- Point.normalizeZ, Point.msm => separate methods in
abstract/curve.js
submodule - Point.fromPrivateKey() got removed, use
Point.BASE.multiply()
andPoint.Fn.fromBytes(secretKey)
- toRawBytes, fromRawBytes => toBytes, fromBytes
- RistrettoPoint => ristretto255.Point, DecafPoiont => decaf448.Point
- Signature (ECDSA) changes
- toCompactRawBytes, toDERRawBytes => toBytes('compact'), toBytes('der')
- toCompactHex, toDERHex => toHex('compact'), toHex('der')
- fromCompact, fromDER => fromBytes(format), fromHex(format)
- utils changes
- randomPrivateKey => randomSecretKey
- utils.precompute, Point#_setWindowSize => Point#precompute
- edwardsToMontgomery => utils.toMontgomery
- edwardsToMontgomeryPriv => utils.toMontgomerySecret
- Rename all curve-specific hash-to-curve methods to
*curve*_hasher
.
Example:secp256k1.hashToCurve
=>secp256k1_hasher.hashToCurve()
- Massive type renamings and improvements
Removed features
- Point#multiplyAndAddUnsafe, Point#hasEvenY
- CURVE property with all kinds of random stuff. Point.CURVE() now replaces it, but only provides
curve parameters - Remove
pasta
,bn254_weierstrass
(NOT pairing-based bn254) curves - Field.MASK
- utils.normPrivateKeyToScalar
Full Changelog: 1.9.6...2.0.0
1.9.7
- edwards: rename newly introduced / experimental
toMontgomeryPriv
=>toMontgomerySecret
- weierstrass: Add back SignatureConstructor
- More deprecations and preparations for v2
Full Changelog: 1.9.6...1.9.7
1.9.6
- edwards: expose nBitLength, nByteLength
- Experimental CurveLengths interface: rename secret, public to secretKey, publicKey
- Point precomputes: initialize calculation earlier, within
weierstrass()
method (still lazy, waits for first call) - bls: new internal
tower
from v2 - ed448: Ensure there are two different Fn fields with different BITS length for ed448 / decaf448
Full Changelog: 1.9.5...1.9.6
1.9.5
1.9.4
1.9.3
The release contains bugfixes and a few improvements which pave the way for upcoming v2.0.
There are lots of renamings and API adjustments; but all old code would work as-is. The code would visually flagged as "deprecated" (using jsdoc flag) in typescript-supported code environments, which makes it easy to upgrade to new versions.
- Rename
*privateKey
to*secretKey
everywhere for consistency with post-quantum and non-noble libraries - Add
keygen
method to curves which creates both secret and public keys - weierstrass: make endomorphism generic and work for all Koblitz curves
- weierstrass: add fromBytes and toBytes to Signature, deprecate fromDER, fromCompact, toDERRawBytes, toCompactRawBytes
- edwards: move edwardsToMontgomery into utils.toMontgomery
- decaf, ristretto: new interface which makes it more similar to other Points
- ed448: add ED448_TORSION_GROUP
- curve: add curve.info interface to all curves for better interop.
- curve: change public wNAF API
- modular: add sqrt9mod16
- hash-to-curve: move all hashers into _hasher props. E.g.
secp256k1_hasher
- test: Add ACVP test vectors
Sensitive code changes
- wNAF: mostly renamings
- Field bound validation: for scalars (Fn) and curve fields (Fp)
Full Changelog: 1.9.2...1.9.3
1.9.2
The release contains bugfixes and a few improvements which pave the way for upcoming v2.0.
- edwards, weierstrass: big refactor, implement much simpler ECDSA / EdDSA API. #192
- Old code is still working until v2
- New API is experimental until next patch release
- toRawBytes => toBytes
- ExtendedPoint, ProjectivePoint => Point
- Point now has
Fp
andFn
static properties which are its fields
- weierstrass: add support for ECDSA with cofactor>1 curves
- weierstrass: add support for points having x:0
- bls: big refactor, improve types, add new
bls.longSignatures
andbls.shortSignatures
APIs- Old code is still working until v2
- New API is experimental until next patch release
- utils: reuse noble-hashes utils
- Use randomBytes and hmac from noble-hashes by default
Sensitive code changes
- edwards, weierstrass: refactor logic for range checks
- weierstrass: improve
sign()
logic for k generation - weierstrass: harden multiplyUnsafe, stop using multiplyAndAddUnsafe
New contributors
- Add a test that BLS12-381 augmented signatures can be verified by @randombit in #191
Full Changelog: 1.9.1...1.9.2
1.9.1
- abstract/fft - new experimental implementation of FFT (Fast Fourier Transform) / NTT
- abstract/edwards: verify curve parameters (equation) on initialization
- abstract/weierstrass: verify curve parameters (discriminant) on initialization
- abstract/weierstrass: improve getSharedSecret arg validation for rare curves
- abstract/weierstrass: fix invalid sig recovery decoding length for rare curves
- abstract/modular: improve sqrt calculation
- x25519, x448: accept more valid inputs for priv / pub keys
- secp256k1: improve tree-shaking
Full Changelog: 1.9.0...1.9.1
1.9.0
The release contains bugfixes and a few improvements which pave the way for upcoming v2.0.
- Modules are now available with
.js
extension- Old:
@noble/curves/ed25519
- New:
@noble/curves/ed25519.js
- Old path is still available
- This simplifies working in browsers natively without transpilers
- Old:
- poseidon: add support for sponge, grain LFSR
- p256, p384, p521: merge into new "nist" module
- weierstrass: prohibit y=0 when initializing
- hash-to-curve: use inv0 everywhere to ensure ZERO elements are returned in exceptional cases
- modular: improve sqrt logic (tonelliShanks, legendre)
- modular: fix FpInvertBatch creating arrays with holes instead of arrays with undefined
- pasta: deprecate curves
- update noble-hashes to 1.8.0
Full Changelog: 1.8.2...1.9.0
1.8.2
- Important: this release adjusts wNAF scalar multiplication logic
- The adjustment is small (deduplication), but wNAF is sensitive code handling private keys
- Verify the change yourself #184
- edwards: (ed25519, ed448) always use complete formula in add()
- edwards: (ed25519, ed448) ban points with z=0 (zero points have z=1)
- ed25519: use slower, but more precise CURVE.a definition
- weierstrass: freeze Signature on creation
- weierstrass: Fix curve in Palemoon browser #176
- hash-to-curve: throw better error for 0 in mapToCurve
- tower: fix wrong
Fp12
fields type - misc: new module. Contains jubjub and babyjubjub.
- utils: use built-in Uint8Array toHex / fromHex when available. Gives 13x speed-up on 256b arrays, 20x speed-up on 32kb arrays
Other changes
- Update noble-hashes to 1.7.2
- Reduce standalone file build size by 0.5kb
- Standalone build files are now attested in CI. Check out README for verification guide
- Typescript source can now be used without compilation in node.js v24, due to erasableSyntaxOnly
New Contributors
- @tuantran-genetica made their first contribution in #181
- @kigawas made their first contribution in #183
Acknowledgments
Thanks to @ChALkeR for spotting edwards bug.
Full Changelog: 1.8.1...1.8.2