feat: replace elliptic fallback with @noble/curves#214
Closed
fully-autonomous wants to merge 1 commit intocryptocoinjs:masterfrom
Closed
feat: replace elliptic fallback with @noble/curves#214fully-autonomous wants to merge 1 commit intocryptocoinjs:masterfrom
fully-autonomous wants to merge 1 commit intocryptocoinjs:masterfrom
Conversation
Replaces the JS fallback implementation (lib/elliptic.js) with a new implementation backed by @noble/curves/secp256k1 (lib/noble.js). The elliptic package has a known vulnerability (GHSA-848j-6marx-7j84) with no patched release published. @noble/curves uses constant-time implementations and is actively maintained. Since this package already requires Node >=18.0.0, BigInt is always available — the elliptic dependency can be removed entirely rather than kept as a secondary fallback. All 221 tests pass against the new implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the JS fallback implementation (
lib/elliptic.js) with a new implementation backed by@noble/curves/secp256k1(lib/noble.js).Motivation
The
ellipticpackage has an open vulnerability (GHSA-848j-6marx-7j84) with no patched release published. Every downstream user ofsecp256k1that falls back to the JS path (e.g. environments where native bindings fail to compile) inherits this vulnerability with no available fix.@noble/curvesuses audited, constant-time implementations and is actively maintained by Paul Miller. It is already a transitive dependency of many projects in this space (ethers v6, viem, etc.).What changes
lib/noble.jsimplements the same low-level interface aslib/elliptic.jsusing@noble/curves/secp256k1elliptic.jsentry point now loadslib/nobleinstead oflib/ellipticellipticdependency replaced with@noble/curvesinpackage.jsonlib/elliptic.jsis left in place (no breaking change to the file layout)Why drop elliptic entirely vs. keeping as secondary fallback
This package already requires
node >=18.0.0. BigInt has been available since Node 10.4 (2018), so there is no environment supported by this package that lacks BigInt. Keepingellipticas a secondary fallback would mean the vulnerability remains in the dependency tree for all users.Test results
All 221 tests pass against the new implementation.