@@ -815,13 +815,13 @@ DecodeState perhapsDecode(meshtastic_MeshPacket *p)
815815 (ourNode = nodeDB->getMeshNode (p->to )) != nullptr && ourNode->public_key .size > 0 ) {
816816 pkiAttempted = true ;
817817 LOG_DEBUG (" Attempt PKI decryption" );
818- // Resolve the sender's public key only for actual PKI-decrypt candidates: prefer NodeDB
819- // (hot store or warm tier), else a not-yet-committed key held during an in-progress
820- // key-verification handshake. On a full NodeDB miss, copyPublicKey() falls through to a
821- // linear scan of TrafficManagement's large NodeInfo cache, so it must not run for every
822- // encrypted channel packet from an unknown sender - only for packets we might decrypt .
818+ // Resolve the sender's key only for actual PKI-decrypt candidates, not every encrypted channel
819+ // packet: copyPublicKeyForDecrypt() can fall through to a linear scan of TrafficManagement's large
820+ // NodeInfo cache. It returns authoritative keys (hot/warm), or a cold-tier cache key only when it is
821+ // signer-proven - an unverified TOFU cache key must not back authenticated (pki_encrypted, p->from)
822+ // DM attribution .
823823 meshtastic_NodeInfoLite_public_key_t remotePublic = {0 , {0 }};
824- bool haveRemoteKey = nodeDB->copyPublicKey (p->from , remotePublic);
824+ bool haveRemoteKey = nodeDB->copyPublicKeyForDecrypt (p->from , remotePublic);
825825 // A pending key is an unverified identity claim supplied by whoever opened the handshake, so it is
826826 // accepted only for the exchange itself (checked after decode). perhapsEncode applies the same rule.
827827 bool havePendingKey = false ;
0 commit comments