upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/nostr.h
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-07-29 14:11:58 -0300
committerGitHub <noreply@github.com>2026-07-29 14:11:58 -0300
commit41b2ba748531605a1afd84fdb967330c0efc529f (patch)
tree4675efd69a09bee537bb7606bd895bd1a4995827 /src/nostr.h
parent997e511e120272e8f2ddd29716b486e597410f02 (diff)
net: exchange signed .btf descriptors between peers (#32)
Discovery has depended entirely on the Nostr relays. Two connected nodes never told each other who else existed, so a relay outage left a running network unable to grow, and a node that found one stale peer had no way to learn there was anything better. The old `addr` gossip went out with the IRC seed. Peers now trade signed descriptors over a new "btfpeers" message: our own first, then peers that actually answered us. The receiver checks each Schnorr signature against the key the `.btf` address decodes to, so the sender is trusted for nothing -- forging an entry needs somebody else's secret key. That leaves flooding with self-generated keys, which the per-message caps and the "peers that answered" ordering are there to blunt. Unknown commands are ignored (main.cpp), so nodes without this just drop the message; nothing here is a protocol break. The cache from the peer-cache change now keeps each peer's descriptor verbatim alongside the parsed fields, because that signature is what makes a peer relayable. Entries without one -- resolved through Nostr, or written before this -- stay dialable, just not passed on. A dial never clears a descriptor already on file.
Diffstat (limited to 'src/nostr.h')
-rw-r--r--src/nostr.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nostr.h b/src/nostr.h
index 04149e3..b5eb5e3 100644
--- a/src/nostr.h
+++ b/src/nostr.h
@@ -82,6 +82,14 @@ bool BtfGetIdentity(unsigned char pubkey[32], unsigned char enc_sk[32]);
82// This node's printable .btf address, or "" if the identity failed to load. 82// This node's printable .btf address, or "" if the identity failed to load.
83std::string BtfLocalAddress(); 83std::string BtfLocalAddress();
84 84
85// This node's own signed descriptor, ready to hand to a peer over the wire.
86// "" until ThreadBtfAccept has registered at a rendezvous.
87std::string BtfLocalDescriptor();
88
89// The shared secp256k1 context, for btf::VerifyDescriptor (which takes it as
90// void* to keep headers free of secp). NULL if the identity failed to load.
91void* BtfSecpContext();
92
85// Resolve a .btf address via the public discovery relays: fetch the owner's 93// Resolve a .btf address via the public discovery relays: fetch the owner's
86// self-certified descriptor and return its meeting node ("host:port") and 94// self-certified descriptor and return its meeting node ("host:port") and
87// x25519 public key for the end-to-end channel. 95// x25519 public key for the end-to-end channel.