mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 10:45:20 +00:00
Verification sheet: compute encryption status and fingerprint using short mesh ID mapping (fix 'not encrypted/handshake' for DMs with stable key)
This commit is contained in:
@@ -41,9 +41,27 @@ struct FingerprintView: View {
|
|||||||
.padding()
|
.padding()
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 16) {
|
VStack(alignment: .leading, spacing: 16) {
|
||||||
// Peer info
|
// Prefer short mesh ID for session/encryption status
|
||||||
let peerNickname = viewModel.meshService.peerNickname(peerID: peerID) ?? "Unknown"
|
let statusPeerID: String = {
|
||||||
let encryptionStatus = viewModel.getEncryptionStatus(for: peerID)
|
if peerID.count == 64, let short = viewModel.getShortIDForNoiseKey(peerID) { return short }
|
||||||
|
return peerID
|
||||||
|
}()
|
||||||
|
// Resolve a friendly name
|
||||||
|
let peerNickname: String = {
|
||||||
|
if let p = viewModel.getPeer(byID: statusPeerID) { return p.displayName }
|
||||||
|
if let name = viewModel.meshService.peerNickname(peerID: statusPeerID) { return name }
|
||||||
|
if peerID.count == 64, let data = Data(hexString: peerID) {
|
||||||
|
if let fav = FavoritesPersistenceService.shared.getFavoriteStatus(for: data), !fav.peerNickname.isEmpty { return fav.peerNickname }
|
||||||
|
let fp = data.sha256Fingerprint()
|
||||||
|
if let social = SecureIdentityStateManager.shared.getSocialIdentity(for: fp) {
|
||||||
|
if let pet = social.localPetname, !pet.isEmpty { return pet }
|
||||||
|
if !social.claimedNickname.isEmpty { return social.claimedNickname }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Unknown"
|
||||||
|
}()
|
||||||
|
// Accurate encryption state based on short ID session
|
||||||
|
let encryptionStatus = viewModel.getEncryptionStatus(for: statusPeerID)
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
if let icon = encryptionStatus.icon {
|
if let icon = encryptionStatus.icon {
|
||||||
@@ -74,7 +92,7 @@ struct FingerprintView: View {
|
|||||||
.font(.system(size: 12, weight: .bold, design: .monospaced))
|
.font(.system(size: 12, weight: .bold, design: .monospaced))
|
||||||
.foregroundColor(textColor.opacity(0.7))
|
.foregroundColor(textColor.opacity(0.7))
|
||||||
|
|
||||||
if let fingerprint = viewModel.getFingerprint(for: peerID) {
|
if let fingerprint = viewModel.getFingerprint(for: statusPeerID) {
|
||||||
Text(formatFingerprint(fingerprint))
|
Text(formatFingerprint(fingerprint))
|
||||||
.font(.system(size: 14, design: .monospaced))
|
.font(.system(size: 14, design: .monospaced))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
|
|||||||
Reference in New Issue
Block a user