nx_x25519mlkem768.nx
buildroot/runtime/nx_x25519mlkem768.nx
about
nx_x25519mlkem768.nx -- the MODERN post-quantum hybrid KEM X25519MLKEM768 (TLS 1.3 named group
0x11EC) per draft-ietf-tls-ecdhe-mlkem-05 (banked knowledge/fetched/pq_hybrid_ietf_draft.raw).
COMPLETES the post-quantum story: retires the UNWIRED constant-only NG_X25519_KYBER768_DRAFT00
(0x6399) "draft" by composing two COMPLETE primitives into the FINAL standardized hybrid --
* FIPS-203 ML-KEM-768 (nx_ml_kem_768_wasm: nx_mlkem_keygen/encaps/decaps)
* X25519 ECDH (nx_x25519: x25519 Montgomery ladder)
by CONCATENATION with the ML-KEM part FIRST (the spec's deliberately-reversed order, sec 3+4.3):
client key_exchange = ML-KEM-768 ek (1184) || X25519 pubkey (32) = 1216 bytes
server key_exchange = ML-KEM ciphertext (1088) || X25519 pubkey (32) = 1120 bytes
shared secret = ML-KEM shared secret (32) || X25519 shared secret (32) = 64 bytes
The 64-byte hybrid secret is quantum-safe iff EITHER component is (harvest-now-decrypt-later proof).
This is the KEM engine; the TLS wiring (offer 0x11EC in supported_groups + carry the shares in
key_share + feed the 64B secret to the key schedule) composes these three functions. Proven END-TO-
END by the round-trip KAT in main (client_keygen -> server -> client_finish => identical 64B secret).
license_tier: INDEPENDENT_REDERIVE
genealogy_id: international-research-sources/ietf/draft-ietf-tls-ecdhe-mlkem + nist/fips_203 + rfc_7748
lineage_id: nishi_x25519mlkem768_q10
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_x25519.nxnx_ml_kem_768_wasm.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 25 | const XM_MAGIC_65536: i64 = 65536 |
| 27 | const XM_X_PUB: i64 = 32 |
| 28 | const XM_X_PRIV: i64 = 32 |
| 29 | const XM_X_SS: i64 = 32 |
| 30 | const XM_EK: i64 = 1184 |
| 31 | const XM_CT: i64 = 1088 |
| 32 | const XM_SS_K: i64 = 32 |
| 33 | const XM_DK: i64 = 2400 |
| 34 | const XM_CLIENT_SHARE: i64 = 1216 // ek(1184) || x_pub(32) |
| 35 | const XM_SERVER_SHARE: i64 = 1120 // ct(1088) || x_pub(32) |
| 36 | const XM_CLIENT_SECRET: i64 = 2432 // x_priv(32) || dk(2400) |
| 37 | const XM_SHARED: i64 = 64 // mlkem_ss(32) || x_ss(32) |
functions
| 39 | func xm_cpy(dst: *u8, src: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { dst[i] = src[i]; i = i + 1 } return 0 } |
| 40 | func xm_off(p: *u8, k: i64) -> *u8 { return (p as i64 + k) as *u8 } |
| 42 | func xm_basepoint(bp: *u8) -> i64 { bp[0] = 9 as u8; var i: i64 = 1; while i < 32 { bp[i] = 0 as u8; i = i + 1 } return 0 } |
| 44 | func xm_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 49 | func xm_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 52 | func x25519mlkem768_client_keygen(rand96: *u8, client_share: *u8, client_secret: *u8) -> i64 |
| 70 | func x25519mlkem768_server(client_share: *u8, rand64: *u8, server_share: *u8, shared: *u8) -> i64 |
| 92 | func x25519mlkem768_client_finish(server_share: *u8, client_secret: *u8, shared: *u8) -> i64 |
| 108 | func main() -> i64 |