feat: PQC JWK import/export for ML-DSA and ML-KEM#1016
Merged
Conversation
Adds WebCrypto JWK support for ML-DSA-44/65/87 and ML-KEM-512/768/1024 using Node's `kty: 'AKP'` encoding (RFC 9269 / W3C WebCrypto draft): public keys carry the raw public bytes in `pub`, private keys add the seed in `priv`. On private-key import the public key is re-derived from the seed and constant-time compared against the supplied `pub`. Closes part of the #995 Node.js parity audit.
The example app exists to exercise the local workspace copy of the library — it should always pull from `workspace:*`, not the most recent npm version. Drop `dependencies.react-native-quick-crypto` from the @release-it/bumper output so releases no longer rewrite it, and restore `workspace:*` in example/package.json. The example version field is still kept in sync.
…ters Address review feedback on PQC JWK import/export PR (#996): - Centralize JWK structural validation in `validateJwkStructure`: - `ext`: existing - `use`: new — must match algorithm's expected use ('sig' or 'enc') when usages are non-empty (mirrors Node's `validateJwk`) - `key_ops`: new duplicate detection per Node's `validateKeyOps` - Reorder validation in all 8 importers (kmac, rsa, hmac, aes, ec, ed, mldsa, mlkem) so JWK structure (kty/use/key_ops/ext/alg) is checked before key-usage validation — matches Node and the WebCrypto spec. - Wrap every `handle.initJwk()` call site in try/catch so C++ errors surface as `DataError` DOMExceptions, not generic `Error`s. - Add type guard in `pqcIsPublicImport` so a non-object passed at `format === 'jwk'` is not silently treated as a public key. - Fix `lazyDOMException` to format the object-form domName correctly (was producing `[object Object]` in the message).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
🤖 End-to-End Test Results - AndroidStatus: ✅ Passed 📸 Final Test ScreenshotScreenshot automatically captured from End-to-End tests and will expire in 30 days This comment is automatically updated on each test run. |
Contributor
🤖 End-to-End Test Results - iOSStatus: ✅ Passed 📸 Final Test ScreenshotScreenshot automatically captured from End-to-End tests and will expire in 30 days This comment is automatically updated on each test run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Adds WebCrypto JWK support for ML-DSA-44/65/87 and ML-KEM-512/768/1024 using Node's
kty: 'AKP'encoding. Public keys carry the raw public bytes inpub; private keys add the seed inpriv. On private-key import the public key is re-derived from the seed and constant-time compared (CRYPTO_memcmp) against the suppliedpub.While here, hardened JWK import validation across all importers (kmac, rsa, hmac, aes, ec, ed, mldsa, mlkem) so the codebase aligns with Node's
validateJwk/validateKeyOpsand the WebCrypto spec.Changes
kty: 'AKP'withpub/priv(seed). Guarded byOPENSSL_VERSION_NUMBER >= 0x30500000L. Constant-time pub/derived-pub comparison on private import.validateJwkStructure(utils/validation.ts): one place forext,use,key_opsarray shape,key_opsduplicate detection, andkey_ops-covers-usages. Mirrors Node'svalidateJwk+validateKeyOps.SyntaxErrorfor cases where Node throwsDataError.DataErrorpropagation: everyhandle.initJwk()call site is wrapped in try/catch so C++ runtime errors surface asDataErrorDOMExceptions instead of genericErrors.pqcIsPublicImport: a non-object passed atformat === 'jwk'is no longer silently treated as a public key.lazyDOMExceptionfix: object-formdomNamewas producing[object Object]in error messages — now correctly usesdomName.nameand appends the cause.workspace:*for the example app dep and stopped the release bumper from rewriting it.—to ✅.Testing
bun tscclean across both packagesCloses #996.