feat: implement ML-KEM encapsulate/decapsulate#941
Merged
Conversation
Add ML-KEM-512/768/1024 support with key generation, encapsulation, and decapsulation via both Node.js-style and WebCrypto APIs. New APIs: - crypto.encapsulate() / crypto.decapsulate() - subtle.encapsulateBits() / subtle.decapsulateBits() - subtle.encapsulateKey() / subtle.decapsulateKey() - subtle.generateKey() for ML-KEM variants - subtle.importKey() / subtle.exportKey() (spki, pkcs8) Implementation: - Nitro HybridMlKemKeyPair module with OpenSSL 3.5+ EVP KEM APIs - C++ encapsulate/decapsulate using EVP_PKEY_encapsulate/decapsulate - Packed ArrayBuffer format for bridge efficiency - String-based EVP_PKEY type detection fallback for provider-only keys Also adds 'Both' platform option to feature request issue template and documents metro log location in CLAUDE.md.
…issues - Replace raw EVP_PKEY* with unique_ptr<EVP_PKEY> RAII wrapper in both HybridMlKemKeyPair and HybridMlDsaKeyPair, matching existing pattern from HybridDsaKeyPair/HybridDhKeyPair - Remove redundant ML-DSA string checks in getAsymmetricKeyType() fallback (already handled by EVP_PKEY_ML_DSA_* switch cases) - Simplify double buffer conversion in mlkem.ts decapsulate() - Extract shared ML-KEM test constants into mlkem_constants.ts
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 full ML-KEM (Module-Lattice Key Encapsulation Mechanism) support — a post-quantum cryptographic primitive for key encapsulation. Supports all three FIPS 203 parameter sets: ML-KEM-512, ML-KEM-768, and ML-KEM-1024.
Changes
API Surface
subtle.encapsulateBits(),subtle.encapsulateKey(),subtle.decapsulateBits(),subtle.decapsulateKey()crypto.encapsulate(),crypto.decapsulate()subtle.generateKey(),subtle.importKey(),subtle.exportKey()for ML-KEM key pairs (spki/pkcs8)Implementation
HybridMlKemKeyPairusing OpenSSL 3.5+ EVP encapsulation/decapsulation APIsMlKemclass with Nitro Module bindingsgetAsymmetricKeyType()usingEVP_PKEY_get0_type_name()for provider-only key typesEVP_PKEY_ptr(unique_ptr with custom deleter) in both ML-KEM and ML-DSA classesTests
Code Quality
mlkem_constants.tsdecapsulate()Testing
Tests run in the React Native example app. Test suite:
subtle.encapsulate/decapsulate.Closes #934
Closes #937