crypto: reduce EC key processing overhead - #65908
Conversation
Avoid creating temporary EVP objects and repeating key validation while retaining the private scalar range and public/private consistency checks. Assisted-by: GitHub Copilot Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Avoid reconstructing EC keys for key details and TLS ephemeral-key curve reporting. Assisted-by: GitHub Copilot Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Query provider coordinates together instead of serializing and decoding the public point. Assisted-by: GitHub Copilot Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Read private scalars and matching uncompressed provider encodings directly. Assisted-by: GitHub Copilot Signed-off-by: Filip Skokan <panva.ip@gmail.com>
|
Review requested:
|
Use EVP_PKEY_bits() to determine the width of ECDSA signature components on OpenSSL 3. This avoids reconstructing the EC group and public point just to read the group order size. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: GitHub Copilot
b534fc9 to
b406b68
Compare
|
Benchmark GHA (crypto / create-keyobject): https://github.com/nodejs/node/actions/runs/34219400423 Results
Benchmark results:
|
|
Benchmark GHA (crypto / ec-): https://github.com/nodejs/node/actions/runs/34219408729 Results
Benchmark results:
|
|
Benchmark GHA (crypto / webcrypto-sign): https://github.com/nodejs/node/actions/runs/34219404291 Results
Benchmark results:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65908 +/- ##
==========================================
+ Coverage 90.18% 90.19% +0.01%
==========================================
Files 771 771
Lines 265103 265039 -64
Branches 50353 50333 -20
==========================================
- Hits 239082 239061 -21
+ Misses 16968 16943 -25
+ Partials 9053 9035 -18
🚀 New features to boost your workflow:
|
Reduces unnecessary work when importing and using EC keys.
Streamlines private JWK import while preserving validation, and reads curve metadata, JWK coordinates, raw key material, and signature component sizes directly instead of reconstructing EC keys. Includes focused tests and benchmarks.
Raw private-key imports defer public-point derivation until needed, allowing signing and ECDH to avoid that cost. Operations needing the public point derive it once and cache the completed key.Dropped because this optimization does not work on OpenSSL >= 4 openssl/openssl#29054 makes provider imports derive the missing public point eagerly. rip 0ddf3c9