Lightweight build: lazy load tweetnacl dependency module#1877
Merged
larabr merged 2 commits intoopenpgpjs:mainfrom Jul 31, 2025
Merged
Lightweight build: lazy load tweetnacl dependency module#1877larabr merged 2 commits intoopenpgpjs:mainfrom
larabr merged 2 commits intoopenpgpjs:mainfrom
Conversation
For Ed25519/Ed25519Legacy native validation code does a sign-verify check over random data. This is faster than re-deriving the public point using tweetnacl. If the native implementation is not available, we fall back to re-deriving the public point only. For X25519/Curve25519Legacy, both the native and fallback flows do an ecdh exchange; in the fallback case, this results in slower performance compared to the existing check, but encryption subkeys are hardly ever validated directly (only in case of gnu-dummy keys), and this solution keeps the code simpler. Separately, all validation tests have been updated to use valid params from a different key, rather than corrupted parameters.
9e33ad4 to
6a1f057
Compare
twiss
approved these changes
Jul 31, 2025
…JS fallback) Since all major browsers have shipped support for the curve in WebCrypto, we only load the JS fallback if needed. Also, add native/non-native ECDH test for Curve25519Legacy. (The more modern X25519/X448 algo implementations cannot be tested that way since they include an HKDF step for which we assume native support and do not implement a fallback.)
6a1f057 to
ed5554e
Compare
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.
Since all major browsers have shipped support for the curve in WebCrypto, we only load the JS fallback if needed. This reduces the lightweight main bundle size by ~17KB.
The library was used for key validation, that had to be adapted as a result.
See commits for more details.