code wiki / (root) / x25519_ephemeral.nx

x25519_ephemeral.nx

buildroot/runtime/x25519_ephemeral.nx

3169 B82 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind orphan librarytopic 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)

structs

none

consts

none

functions

33func x25519_base_point(out: *u8) -> i64 {
43func x25519_keypair_private(priv_out: *u8) -> i64 {
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,
74func main() -> i64 {