This repository was archived by the owner on Jan 22, 2025. It is now read-only.
[web3.js] Replace tweetnacl impl#27435
Merged
steveluscher merged 9 commits intosolana-labs:masterfrom Aug 28, 2022
steveluscher:ed25519-replacement
Merged
[web3.js] Replace tweetnacl impl#27435steveluscher merged 9 commits intosolana-labs:masterfrom steveluscher:ed25519-replacement
steveluscher merged 9 commits intosolana-labs:masterfrom
steveluscher:ed25519-replacement
Conversation
Codecov Report
@@ Coverage Diff @@
## master solana-labs/solana#27435 +/- ##
=========================================
- Coverage 76.9% 76.6% -0.3%
=========================================
Files 48 52 +4
Lines 2505 2648 +143
Branches 355 363 +8
=========================================
+ Hits 1927 2030 +103
- Misses 448 484 +36
- Partials 130 134 +4 |
|
@steveluscher it seems like the performance bottleneck is somewhere outside of ed25519, since tweetnacl should be 4x slower. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
This PR aims to replace the ed25519 keygen, signing, and verifying algorithms with smaller ones having fewer dependencies.
Summary of Changes
tweetnaclwith@noble/ed25519Bundle size
Used
package-build-statsto analyze the size change locally.tl;dr a ~4% reduction in bundle size after gzip.
Dependency tree
Replaced
tweetnaclfor@noble/ed25519, dropping about 4K gzipped.Produced using https://npmgraph.js.org/
Performance
Consider this keypair generation code:
Take 10 trials:
Results
No change.
Consider this transaction signing code:
Take 10 trials:
Results:
~6% slower.
Compatibility notes
Together, this, #27390, and #27127 make
@solana/web3.jsincompatible with React Native because of their use of:BigIntBigIntbigintliteralsBecause this team is small, we're likely to recommend that folks upgrade their React Native apps to 0.70 and convert them to run using the Hermes JavaScript engine, which in that version supports all of the above. Support for big integers is critical to most crypto apps, and React Native has now made Hermes the default engine. We would be best advised to skate where the puck is going.
Addresses solana-foundation/solana-web3.js#1103
Fixes #26933.