Skip to content

Add X-Wing (post-quantum) to the 3rd-party derive API#40

Open
0c-coder wants to merge 4 commits into
onlykey:heroku-deployfrom
0c-coder:pqc-xwing-derive
Open

Add X-Wing (post-quantum) to the 3rd-party derive API#40
0c-coder wants to merge 4 commits into
onlykey:heroku-deployfrom
0c-coder:pqc-xwing-derive

Conversation

@0c-coder

@0c-coder 0c-coder commented Jul 4, 2026

Copy link
Copy Markdown

Adds post-quantum X-Wing (ML-KEM-768 + X25519) to the existing 3rd-party derive API (onlykey-3rd-party.js + index.js) as keytype 6 -- same DERIVE_PUBLIC_KEY / DERIVE_SHARED_SECRET flow as the ECC keytypes. Not age, not PGP; identity is additional_d (SHA-256'd, like the ECC paths), no slots.

Split custody: the MCU can't run ML-KEM, so the device does the X25519 half (sk_X never leaves) and returns a 64-byte reply; the browser does the ML-KEM half from a 32-byte seed. Every device round-trip is <= 64 bytes; the 1088-byte ML-KEM ciphertext never reaches the device. Decryption still requires the physical OnlyKey.

New API on onlykey(6, enc_resp): derive_xwing_public_key -> [pk_X|mlkem_seed], browser builds the 1216-byte recipient; xwing_decapsulate -> only ct_X to the device ([ss_X|mlkem_seed]), browser does ML-KEM decaps + combine (button press); xwing_encapsulate -> host-side.

Files: onlykey-3rd-party.js (X-Wing branch), index.js (keytype enum + deriveXWingExample reference, not auto-run), xwing.js (KEM core), test/xwing-split.test.mjs (npm run test:pqc, 5/5), package.json (@noble deps).

Verified: KEM path round-trips; both edited files pass node --check.

NOTE(firmware): the 64-byte reply layout ([pk_X|seed] / [ss_X|seed] after the 53-byte response header) is the one device-side seam -- confirm against libraries#30. KEM math is unit-tested; only the transport framing needs a hardware check.

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