From 745efcd4f19b59bcfb131df2d127a3387a544e84 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 28 Sep 2026 17:37:41 +0100 Subject: Link two nodes without a connection over UDP (093, design 011's first stage) pure-serve --send OUTPUT=pure://host:port/INPUT sends an output's saved sends to another node's --link-port with no handshake: the first packet carries records. Keys come from the two nodes' keys (X25519, HKDF-SHA256, AES-128-GCM), with a random run in each packet's header so no nonce repeats across restarts; nothing is stored for them. What lasts is the apps' own: the sender's outbox and the receiver's heard numbers (pure_app_heard, new). The sender detects losses as RFC 9002 says, with NewReno, and trims a send once the receiver says it stored it; the receiver hands the owner whole records in order, which it applies from the one after the source's last heard number, stopping at a gap, and answers how far it stored with every acknowledgment. Stored bytes are the bytes on the wire: an output and an input of one shape need no JSON. server_links_udp kills the receiver, the sender, then both (-9) while four clients buy: every saved order is applied once, with no handshake (five runs, 10k-11k orders each). server_links_udp_lossy does it again in a namespace of its own with the link's packets delayed, lost (3 %) and reordered (10 %) by netem (three runs, 11k-12k orders). --- serve/seal.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'serve/seal.h') diff --git a/serve/seal.h b/serve/seal.h index a020e0d..e802b46 100644 --- a/serve/seal.h +++ b/serve/seal.h @@ -53,4 +53,23 @@ PureOpener *pure_opener(const PureSealKey *key, const char *suite, const unsigne bool pure_unseal(PureOpener *, uint64_t n, const char *aad, const unsigned char *sealed, size_t size, unsigned char *plain); void pure_opener_free(PureOpener *); + +/* Links (serve/link.h): the secret two nodes share (X25519 of this node's + * private key and the other's public key: the same on both sides, and + * never all zeros), keys from it (HKDF-SHA256 with the info given), and + * AES-128-GCM under such a key with the nonce the caller gives (sealing may + * be in place: out may be plain). A context is used by one thread at a time. */ +typedef struct PureAead PureAead; +enum { PURE_AEAD_KEY = 16, PURE_AEAD_NONCE = 12, PURE_AEAD_TAG = 16 }; +bool pure_link_secret(const PureSealKey *own, const unsigned char peer[PURE_SEAL_KEY], unsigned char out[32]); +bool pure_link_derive(const unsigned char secret[32], const unsigned char *info, size_t info_size, unsigned char *out, + size_t out_size); +PureAead *pure_aead(const unsigned char key[PURE_AEAD_KEY]); +/* size + PURE_AEAD_TAG bytes into out. */ +bool pure_aead_seal(PureAead *, const unsigned char nonce[PURE_AEAD_NONCE], const unsigned char *aad, size_t aad_size, + const unsigned char *plain, size_t size, unsigned char *out); +/* size - PURE_AEAD_TAG bytes into plain; false when it does not open. */ +bool pure_aead_open(PureAead *, const unsigned char nonce[PURE_AEAD_NONCE], const unsigned char *aad, + size_t aad_size, const unsigned char *sealed, size_t size, unsigned char *plain); +void pure_aead_free(PureAead *); #endif -- cgit v1.2.3