x25519_ephemeral.nx
buildroot/runtime/x25519_ephemeral.nx
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
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
structs
| none |
consts
| none |
functions
| 33 | func x25519_base_point(out: *u8) -> i64 {
called by 1: x25519_keypair_public |
| 43 | func x25519_keypair_private(priv_out: *u8) -> i64 { |
| 50 | func x25519_keypair_public(priv: *u8, pub_out: *u8) -> i64 { |
| 58 | func x25519_gen_keypair(priv_out: *u8, pub_out: *u8) -> i64 { |
| 68 | func x25519_shared_secret(my_priv: *u8, peer_pub: *u8,
calls 1: x25519 |
| 74 | func main() -> i64 {
calls 1: x25519_gen_keypair |