peerid computed from noise fingerprint (#413)

This commit is contained in:
callebtc
2025-09-13 16:43:06 +02:00
committed by GitHub
parent ad77fd38c5
commit 3967ef8922
2 changed files with 6 additions and 93 deletions
@@ -37,11 +37,11 @@ class BluetoothMeshService(private val context: Context) {
private const val MAX_TTL: UByte = 7u
}
// My peer identification - same format as iOS
val myPeerID: String = generateCompatiblePeerID()
// Core components - each handling specific responsibilities
private val encryptionService = EncryptionService(context)
// My peer identification - derived from persisted Noise identity fingerprint (first 16 hex chars)
val myPeerID: String = encryptionService.getIdentityFingerprint().take(16)
private val peerManager = PeerManager()
private val fragmentManager = FragmentManager()
private val securityManager = SecurityManager(encryptionService, myPeerID)
@@ -904,15 +904,6 @@ class BluetoothMeshService(private val context: Context) {
}
}
/**
* Generate peer ID compatible with iOS - exactly 8 bytes (16 hex characters)
*/
private fun generateCompatiblePeerID(): String {
val randomBytes = ByteArray(8) // 8 bytes = 16 hex characters (like iOS)
Random.nextBytes(randomBytes)
return randomBytes.joinToString("") { "%02x".format(it) }
}
/**
* Convert hex string peer ID to binary data (8 bytes) - exactly same as iOS
*/