From 8124d951924b3e590ddfab39381cdbf27f7f300d Mon Sep 17 00:00:00 2001 From: Sudo-Ivan Date: Tue, 30 Dec 2025 23:46:00 -0600 Subject: [PATCH] fix: update announce hash generation in Transport to exclude hop count and header for uniqueness --- pkg/transport/transport.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/transport/transport.go b/pkg/transport/transport.go index e80719b..5df1ead 100644 --- a/pkg/transport/transport.go +++ b/pkg/transport/transport.go @@ -652,7 +652,11 @@ func (t *Transport) HandleAnnounce(data []byte, sourceIface common.NetworkInterf appData := data[common.SIZE_16+common.SIZE_32+common.ONE:] // Generate announce hash to check for duplicates - announceHash := sha256.Sum256(data) + // We exclude the hop count (byte 1) from the hash since it changes during propagation + // We also exclude the header (byte 0) just in case propagation flags change + // The destination hash (bytes 2-18) + payload (including random hash) is unique enough + hashData := data[common.TWO:] + announceHash := sha256.Sum256(hashData) hashStr := string(announceHash[:]) t.mutex.Lock() @@ -1081,7 +1085,11 @@ func (t *Transport) handleAnnouncePacket(data []byte, iface common.NetworkInterf identity.Remember(data, destinationHash, pubKey, appData) // Generate announce hash to check for duplicates - announceHash := sha256.Sum256(data) + // We exclude the hop count (byte 1) from the hash since it changes during propagation + // We also exclude the header (byte 0) just in case propagation flags change + // The destination hash (bytes 2-18) + payload (including random hash) is unique enough + hashData := data[common.TWO:] + announceHash := sha256.Sum256(hashData) hashStr := string(announceHash[:]) debug.Log(debug.DEBUG_INFO, "Announce hash", "hash", fmt.Sprintf("%x", announceHash[:8]))