Skip to content

src: improve EC JWK import performance#62396

Open
panva wants to merge 1 commit intonodejs:mainfrom
panva:improve-ec-jwk-import
Open

src: improve EC JWK import performance#62396
panva wants to merge 1 commit intonodejs:mainfrom
panva:improve-ec-jwk-import

Conversation

@panva
Copy link
Member

@panva panva commented Mar 22, 2026

./node benchmark/crypto/create-keyobject.js keyFormat=jwk-public n=1000000 keyType=ec
Branch ops/sec
main 76,259
improve-ec-jwk-import 168,920

All EC JWK import supported curves go through the optimized branch but I left the old one in just in case.

@panva panva requested a review from jasnell March 22, 2026 19:05
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. labels Mar 22, 2026
auto point = ECPointPointer::New(group);
if (!point) return false;
if (!point.setFromBuffer({ptr, uncompressed_len}, group)) return false;
return EC_KEY_set_public_key(key_.get(), point.get()) == 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks fine but is the ncrypto repo PR opened for it? We really need to get the proper dependency update flow working there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not share the sense of urgency but yes i've opened an ncrypto PR with the changes from this and the other PR.

Copy link

@themavik themavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping EC_KEY_check_key when cofactor is 1 via EC_POINT_oct2point is a smart fast path in ECKeyPointer::setPublicKeyRaw. nit: confirm x.encodePaddedInto/y.encodePaddedInto always fill field_len bytes for curves you care about; weird encodings short of field_len would be a footgun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants