Skip to content

Conversation

larabr
Copy link
Collaborator

@larabr larabr commented Jul 28, 2025

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.

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.
@larabr larabr force-pushed the tweetnacl-lazy-load branch 4 times, most recently from 9e33ad4 to 6a1f057 Compare July 31, 2025 13:43
…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.)
@larabr larabr force-pushed the tweetnacl-lazy-load branch from 6a1f057 to ed5554e Compare July 31, 2025 15:42
@larabr larabr merged commit 659e3db into openpgpjs:main Jul 31, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants