code wiki / (root) / x25519_ephemeral.nx

x25519_ephemeral.nx

buildroot/runtime/x25519_ephemeral.nx

3169 B82 linesdepth 4pulls 5 transitivereach 0 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.

dependencies 3 imports · 0 importers

syscalls.nx rand.nx x25519.nx x25519_ephemeral.nx

imports: syscalls.nxrand.nxx25519.nx

imported by: nobody (leaf or entry point)

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

main x25519_gen_keypair x25519_keypair_private rand_bytes rand_open_urandom sys_read x25519_keypair_public x25519_base_point x25519 fe_alloc fe_from_bytes fe_one fe_zero fe_zero ↻ fe_copy x25519_ladder_step fe_cswap fe_alloc ↻ fe_add fe_sq fe_mul fe_sub fe_mul ↻ fe_mul_a24 fe_alloc ↻ fe_mul ↻ fe_cswap ↻ fe_invert fe_alloc ↻ fe_sq ↻ fe_mul ↻ fe_mul ↻ fe_to_bytes fe_alloc ↻ fe_copy ↻

structs

none

consts

none

functions

33func x25519_base_point(out: *u8) -> i64 {
43func x25519_keypair_private(priv_out: *u8) -> i64 {
called by 1: x25519_gen_keypair calls 1: rand_bytes
50func x25519_keypair_public(priv: *u8, pub_out: *u8) -> i64 {
58func x25519_gen_keypair(priv_out: *u8, pub_out: *u8) -> i64 {
68func x25519_shared_secret(my_priv: *u8, peer_pub: *u8,
calls 1: x25519
74func main() -> i64 {