code wiki / (root) / nx_x25519_ephemeral.nx

nx_x25519_ephemeral.nx

buildroot/runtime/nx_x25519_ephemeral.nx

3453 B92 linesdepth 4pulls 5 transitivereach 620 importersview sourcekind tooltopic x25519
docsdependenciesstructsconstsfunctions

about

x25519_ephemeral.nx -- ephemeral keypair helper for X25519 ECDH. Higher-level wrapper around x25519.nx for the common TLS 1.3 handshake pattern: 1. Client: generate ephemeral private key from /dev/urandom 2. Client: derive public key = X25519(private_key, base_point) 3. Client: send public key in ClientHello key_share extension 4. Server: receive public key, generate its own keypair 5. Both: shared_secret = X25519(my_private, peer_public) Curve25519 base point (RFC 7748 ยง4.1): u = 9, encoded as 0x09 followed by 31 zero bytes. Documented here as a constant table to avoid re-construction per call. Invariants: XE1 Private key comes exclusively from rand_bytes (/dev/urandom); never derived, never stored across process lifetime. XE2 Public key derivation uses the same X25519 function as shared-secret computation, keeping one implementation path (no specialised base-point scalar mul that could diverge). XE3 Caller owns all buffers; no persistent state across calls. XE4 Base point represented as a read-only 32-byte constant; derivation is deterministic given the private key. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_7748

dependencies 3 imports · 31 importers

nx_syscalls.nx nx_rand.nx nx_x25519.nx nx_x25519_ephemeral.nx _h2_multistream_curl_daemon.nx _h2_multistream_interop_gate.nx _h2_serve_curl_daemon.nx _h2_serve_loopback_gate.nx nx_bench_x25519.nx nx_crypto_bench.nx nx_crypto_bench_full.nx nx_edge_daemon.nx nx_edge_serve_static_test.nx nx_pages_https_daemon.nx

diagram shows first 10 each side; +0 more imports, +21 more importers in the complete lists below.

imports: nx_syscalls.nxnx_rand.nxnx_x25519.nx

imported by: _h2_multistream_curl_daemon.nx_h2_multistream_interop_gate.nx_h2_serve_curl_daemon.nx_h2_serve_loopback_gate.nxnx_bench_x25519.nxnx_crypto_bench.nxnx_crypto_bench_full.nxnx_edge_daemon.nxnx_edge_serve_static_test.nxnx_pages_https_daemon.nxnx_ssh_kex.nxnx_ssh_lib.nxnx_tls13_client_session.nxnx_tls13_server_full_handshake_test.nxnx_tls13_server_session.nxnx_tls13_server_session_app_data_test.nxnx_tls13_server_session_derive_hs.nxnx_tls13_server_session_derive_hs_test.nxnx_tls13_server_session_derive_traffic_test.nxnx_tls13_server_session_emit_certificate_test.nxnx_tls13_server_session_emit_cv_test.nxnx_tls13_server_session_emit_ee_test.nxnx_tls13_server_session_emit_sf_test.nxnx_tls13_server_session_emit_sh_test.nxnx_tls13_server_session_recv_cf_test.nxnx_tls13_server_session_recv_ch_test.nxnx_tor_ntor.nxnx_tor_ntor_cli.nxnx_tor_ntor_gate.nxnx_tor_relay_gate.nxnx_x25519_kat_gate.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap x25519_gen_keypair x25519_keypair_private rand_bytes rand_open_urandom sys_openat_rd sys_read sys_close x25519_keypair_public sys_mmap ↻ x25519_base_point 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 ↻

structs

none

consts

none

functions

43func x25519_base_point(out: *u8) -> i64
53func x25519_keypair_private(priv_out: *u8) -> i64
60func x25519_keypair_public(priv: *u8, pub_out: *u8) -> i64
68func x25519_gen_keypair(priv_out: *u8, pub_out: *u8) -> i64
78func x25519_shared_secret(my_priv: *u8, peer_pub: *u8,
84func main() -> i64