feat(#627): add a contact from a key alone, with no advert
Adds MeshCoreConnector.addContactByKey, the device-side half of the identity exchange. It uses the stock CMD_ADD_UPDATE_CONTACT (command 9), whose handler creates the contact outright when the public key is unknown. Verified byte-identical to upstream meshcore-dev/MeshCore at 0679dbef, so this needs no capability gate and works on stock firmware, not only Offband builds. buildUpdateContactPathFrame gains an optional lastAdvert. It defaults to now, leaving all three existing path-update callers byte-identical, and addContactByKey passes the epoch. That epoch is the whole point. The firmware compares this field against every incoming advert with 'timestamp <= last_advert_timestamp' and silently discards the non-greater ones as replay attacks (BaseChatMesh.cpp:142-145). Advert timestamps come from the sender's clock, and two nodes on this mesh currently advertise with 2024 clocks, so stamping now would leave a key-added contact permanently deaf to its own adverts. A negative input clamps to zero rather than wrapping to a huge value, which would be the worst case for that guard. The frame is sent at full length with the 0xFF flood sentinel. The firmware length guard is only 'len >= 36' but updateContactFromFrame reads through offset 136 regardless (MyMesh.cpp:295-318), so the frame must never be trimmed. A test pins that too. Local state keeps lastSeen at the epoch so the contact reads as unverified until a real advert upgrades it (#630). Epic #619. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>pull/655/head
parent
bbea912cb0
commit
9b63983033
Loading…
Reference in new issue