Skip to content

feat: add ML-KEM/ML-DSA raw-public and raw-seed export/import#943

Merged
boorad merged 3 commits intomainfrom
feat/mlkem-raw-export-import
Feb 17, 2026
Merged

feat: add ML-KEM/ML-DSA raw-public and raw-seed export/import#943
boorad merged 3 commits intomainfrom
feat/mlkem-raw-export-import

Conversation

@boorad
Copy link
Collaborator

@boorad boorad commented Feb 17, 2026

Summary

Add raw key export/import support for ML-KEM and ML-DSA post-quantum algorithms, plus unwrapKey support for ML-KEM keys.

Changes

  • raw-public export/import for ML-KEM and ML-DSA public keys (raw encapsulation/verification key bytes)
  • raw-seed export/import for ML-KEM and ML-DSA private keys (seed-based serialization)
  • unwrapKey support for ML-KEM public keys (tested with AES-GCM wrap)
  • New initPqcRaw() Nitro bridge method — native C++ key import using EVP_PKEY_ML_KEM_*/EVP_PKEY_ML_DSA_* NIDs with OpenSSL 3.5+ gating
  • Extracted pqcImportKeyObject() helper — deduplicates key import logic shared by mldsaImportKey and mlkemImportKey
  • ML-DSA usage validation fix — now correctly restricts to ['verify'] for public and ['sign'] for private (was allowing both for any format)
  • Git safety rules — added .claude/rules/git-safety.xml and updated commit command

Testing

  • ML-KEM (512/768/1024): raw-public size check, raw-seed 64-byte check, roundtrip encapsulate/decapsulate, re-export idempotency
  • ML-DSA (44/65/87): raw-public size check, raw-seed 32-byte check, roundtrip sign/verify
  • ML-KEM-768 unwrapKey with AES-GCM (AES-KW incompatible — SPKI not 8-byte aligned per RFC 3394)
  • Error handling: invalid format rejection, bad usages rejection

… support

- Add initPqcRaw() to KeyObjectHandle Nitro spec and C++ implementation
  for importing ML-KEM/ML-DSA keys from raw bytes or seeds
- Extend C++ exportKey() to handle PQC raw public key and seed export
- Wire TypeScript subtle.exportKey() for raw-public and raw-seed formats
- Wire TypeScript mlkemImportKey()/mldsaImportKey() for raw and raw-seed
- Add comprehensive tests: size validation, roundtrip encapsulate/
  decapsulate, re-export consistency, unwrapKey with AES-KW
- Update implementation-coverage.md: ML-KEM-512/768/1024 raw-public,
  raw-seed, and unwrapKey all marked as implemented
Add .claude/rules/git-safety.xml with blocking rules:
- Never use --no-verify on commit or push
- Never commit to main
- Run clang-format and prettier before committing

Update .claude/commands/commit.md to include code quality
checks (clang-format, prettier, tsc) and 120s timeout.
Extract pqcImportKeyObject() to deduplicate key import logic shared by
mldsaImportKey and mlkemImportKey. Fix two test failures: ML-DSA-44
invalid format test now uses 'jwk' (truly unsupported) instead of 'raw'
(now valid), and ML-KEM unwrapKey test uses AES-GCM instead of AES-KW
(ML-KEM SPKI is not 8-byte aligned per RFC 3394). Add ML-DSA raw-public
and raw-seed export/import tests with sign/verify roundtrips. Add
protective comments at raw-seed normalization pass-through points.
@boorad boorad self-assigned this Feb 17, 2026
@github-actions
Copy link
Contributor

🤖 End-to-End Test Results - iOS

Status: ✅ Passed
Platform: iOS
Run: 22084737870

📸 Final Test Screenshot

Maestro Test Results - ios

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@github-actions
Copy link
Contributor

🤖 End-to-End Test Results - Android

Status: ✅ Passed
Platform: Android
Run: 22084737865

📸 Final Test Screenshot

Maestro Test Results - android

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@boorad boorad merged commit ad5a961 into main Feb 17, 2026
7 checks passed
@boorad boorad deleted the feat/mlkem-raw-export-import branch February 17, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments