Skip to content

crypto: add signDigest/verifyDigest and Ed25519ctx support#62345

Open
panva wants to merge 4 commits intonodejs:mainfrom
panva:sig-prehash
Open

crypto: add signDigest/verifyDigest and Ed25519ctx support#62345
panva wants to merge 4 commits intonodejs:mainfrom
panva:sig-prehash

Conversation

@panva
Copy link
Member

@panva panva commented Mar 19, 2026

notable-change PRs with changes that should be highlighted in changelogs. πŸ‘‡

Adds crypto.signDigest() and crypto.verifyDigest(), one-shot functions that sign/verify a pre-computed hash digest directly, without hashing internally.


const digest = crypto.createHash('sha256').update(data).digest();

const sig = crypto.signDigest('sha256', digest, privateKey);
const ok = crypto.verifyDigest('sha256', digest, publicKey, sig);

Supports RSA (PKCS#1 v1.5, PSS), ECDSA, DSA, Ed25519, and Ed448.

Also adds Ed25519 context string support to crypto.sign(), crypto.verify() as well as the new methods.

Resolves: #60263

Pre-hash variants of Ed25519 and Ed448 as well Ed25519 context is defined in RFC8032

@nodejs-github-bot
Copy link
Collaborator

Review requested:

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

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 19, 2026
@panva panva added crypto Issues and PRs related to the crypto subsystem. semver-minor PRs that contain new features and should be released in the next minor version. labels Mar 19, 2026
@panva panva marked this pull request as ready for review March 19, 2026 22:04
@panva panva added the notable-change PRs with changes that should be highlighted in changelogs. label Mar 19, 2026
@github-actions
Copy link
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @panva.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 81.66667% with 22 lines in your changes missing coverage. Please review.
βœ… Project coverage is 89.69%. Comparing base (b328bf7) to head (ce13128).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_sig.cc 76.13% 9 Missing and 12 partials ⚠️
lib/internal/crypto/sig.js 96.42% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #62345    +/-   ##
========================================
  Coverage   89.68%   89.69%            
========================================
  Files         676      676            
  Lines      206689   206798   +109     
  Branches    39579    39615    +36     
========================================
+ Hits       185370   185484   +114     
+ Misses      13450    13444     -6     
- Partials     7869     7870     +1     
Files with missing lines Coverage Ξ”
lib/crypto.js 93.04% <100.00%> (+0.07%) ⬆️
src/crypto/crypto_sig.h 63.63% <ΓΈ> (ΓΈ)
lib/internal/crypto/sig.js 95.98% <96.42%> (+0.25%) ⬆️
src/crypto/crypto_sig.cc 71.52% <76.13%> (+1.18%) ⬆️

... and 26 files with indirect coverage changes

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ChALkeR
Copy link
Member

ChALkeR commented Mar 20, 2026

Not entirely certain how this works, will test

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

Labels

crypto Issues and PRs related to the crypto subsystem. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crypto cant sign/verify prehashed inputs

3 participants