code wiki / (root) / nx_x25519mlkem768.nx

nx_x25519mlkem768.nx

buildroot/runtime/nx_x25519mlkem768.nx

7180 B140 linesdepth 4pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itoa_lib.nx nx_x25519.nx nx_ml_kem_768_wasm.nx nx_x25519mlkem768.nx

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

main sys_mmap x25519mlkem768_client_keyg sys_mmap ↻ xm_basepoint x25519 nx_scratch_save nx_scratch_init sys_mmap ↻ nx_scratch nx_scratch_init ↻ nx_scratch_oom sys_write sys_exit sys_mmap ↻ fe_alloc nx_scratch ↻ fe_from_bytes fe_one fe_zero fe_zero ↻ fe_copy x25519_ladder_step fe_cswap nx_scratch_save ↻ fe_alloc ↻ fe_add fe_sq fe_mul fe_sub fe_mul ↻ fe_mul_a24 nx_scratch_save ↻ fe_alloc ↻ fe_mul ↻ nx_scratch_restore nx_scratch_restore ↻ fe_cswap ↻ fe_invert nx_scratch_save ↻

structs

none

consts

25const XM_MAGIC_65536: i64 = 65536
27const XM_X_PUB: i64 = 32
28const XM_X_PRIV: i64 = 32
29const XM_X_SS: i64 = 32
30const XM_EK: i64 = 1184
31const XM_CT: i64 = 1088
32const XM_SS_K: i64 = 32
33const XM_DK: i64 = 2400
34const XM_CLIENT_SHARE: i64 = 1216 // ek(1184) || x_pub(32)
35const XM_SERVER_SHARE: i64 = 1120 // ct(1088) || x_pub(32)
36const XM_CLIENT_SECRET: i64 = 2432 // x_priv(32) || dk(2400)
37const XM_SHARED: i64 = 64 // mlkem_ss(32) || x_ss(32)

functions

39func 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 }
40func xm_off(p: *u8, k: i64) -> *u8 { return (p as i64 + k) as *u8 }
42func 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 }
44func 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 }
called by 1: main calls 1: sys_write
49func xm_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
52func x25519mlkem768_client_keygen(rand96: *u8, client_share: *u8, client_secret: *u8) -> i64
70func x25519mlkem768_server(client_share: *u8, rand64: *u8, server_share: *u8, shared: *u8) -> i64
92func x25519mlkem768_client_finish(server_share: *u8, client_secret: *u8, shared: *u8) -> i64
108func main() -> i64