fix: missing file broadcast and leave message signatures + allow local development (#1078)

* add signatures to file transfers and LEAVE messages

* chore: setup project for local development and signing

---------

Co-authored-by: jack <212554440+jackjackbits@users.noreply.github.com>
This commit is contained in:
callebtc
2026-03-31 14:12:09 -05:00
committed by GitHub
co-authored by jack
parent f9f6ac92b8
commit 0331871980
8 changed files with 26 additions and 10 deletions
+13 -2
View File
@@ -525,7 +525,7 @@ final class BLEService: NSObject {
func stopServices() {
// Send leave message synchronously to ensure delivery
let leavePacket = BitchatPacket(
var leavePacket = BitchatPacket(
type: MessageType.leave.rawValue,
senderID: myPeerIDData,
recipientID: nil,
@@ -535,6 +535,10 @@ final class BLEService: NSObject {
ttl: messageTTL
)
if let signed = noiseService.signPacket(leavePacket) {
leavePacket = signed
}
// Send immediately to all connected peers (synchronized access to BLE state)
if let data = leavePacket.toBinaryData(padding: false) {
let leavePriority = priority(for: leavePacket, data: data)
@@ -731,7 +735,7 @@ final class BLEService: NSObject {
return
}
let packet = BitchatPacket(
var packet = BitchatPacket(
type: MessageType.fileTransfer.rawValue,
senderID: self.myPeerIDData,
recipientID: nil,
@@ -742,6 +746,13 @@ final class BLEService: NSObject {
version: 2
)
if let signed = self.noiseService.signPacket(packet) {
packet = signed
} else {
SecureLogger.error("❌ Failed to sign file broadcast packet", category: .security)
return
}
let senderHex = packet.senderID.hexEncodedString()
let dedupID = "\(senderHex)-\(packet.timestamp)-\(packet.type)"
self.messageDeduplicator.markProcessed(dedupID)