mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-12-03 09:44:08 +00:00
An Advert's Ed25519 signature is the only cryptographic proof of identity MeshCore offers. Everything else is plaintext and attacker-chosen: pubkey, name and self-reported position are whatever the sender wrote, and hop counts, paths and prefixes carry no MAC. The capture rule in this repo covers provenance, not authenticity, so a 0-hop advert can be genuinely heard direct and still name a node that does not exist. Adverts captured here are published to CoreScope, the registry the name resolvers read from, so one forgery heard by one driver becomes a named node on someone else's screen. parsePacket now returns advertSig: the pubkey, the signature and the exact message the firmware signs, which is pubkey(32) || timestamp(4, LE) || app_data with app_data truncated to MAX_ADVERT_DATA_SIZE (meshcore-firmware src/Mesh.cpp:271-280 verifies what :404-437 signed, cap at src/MeshCore.h:12). The timestamp goes in as the raw wire bytes, not the parsed advertTs, so no re-encoding can disagree with what was received. Getting the 32-byte cap wrong would make every long advert look forged, so the fixture test covers it, and the real captured advert already in the fixtures verifies against its own signature, which is what proves the construction rather than asserting it. src/advertsig.js does the crypto and nothing else. Verification is async: @noble/ed25519 needs a hash and only the async path has one without extra wiring. The capture handler was already async. A forged advert can carry a pubkey or signature that is not a valid curve point, which noble rejects by throwing, so that is caught and read as a failed verification rather than taking the capture path down. A failed check drops the identity and keeps the reception. The SNR and RSSI measured at that position are real whoever wrote the advert; only the name attached to them is worthless, and discarding the row would lose genuine coverage. This is deliberately narrower than core-hunter, which refuses the whole reception (efiten/core-hunter#356), because that repo is about identity and this one is about coverage. As a side effect the node stops being a region-discovery candidate, so the app never sends an anonymous request to an address somebody invented. verifyAdverts is off unless config.json says otherwise, and is listed false in FEATURE_DEFAULTS as well as NO_CONFIG_DEFAULTS. It is the only flag that makes the app record less than it heard, and inheriting that silently would look like adverts going missing. The exported log header reports it next to the other three, because "no advert in the capture" and "advert rejected" are otherwise the same silence. Not done: no Settings UI for the flag, config.json only, matching the other three. The gate is not exercised against a forged advert on real hardware, only against fixtures and a signed synthetic advert. New dependency: @noble/ed25519 3.2.0. Bundle 435.17 kB -> 442.78 kB (gzip 136.22 -> 139.71). Tests: 255 pass (+16). SW cache v39 -> v40. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Manrn3qdrTJFz3C4o9PPFL