Skip to content

Performance regression on crypto createPublicKey and createPrivateKey APIs after node v17 #944

Open
@canova

Description

@canova

Hi, we use this package for our profiler-server repository. After upgrading the node version from v16 to v18, we observed ~30% performance regression. And after some investigation we realized that it's because of the createPublicKey and createPrivateKey calls that happen here:

node-jsonwebtoken/verify.js

Lines 122 to 125 in bc28861

secretOrPublicKey = createPublicKey(secretOrPublicKey);
} catch (_) {
try {
secretOrPublicKey = createSecretKey(typeof secretOrPublicKey === 'string' ? Buffer.from(secretOrPublicKey) : secretOrPublicKey);

I also filed an issue on nodejs for the regression on those APIs. For more context, please see it here: nodejs/node#50386

I was wondering if we can reduce the calls to these APIs in this repository with some caching mechanism maybe? I'm not sure as I'm not familiar with the code here. Wanted to ask to see if you have any ideas, thanks!

Version of this library used: 9.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions