Adjust key generation, clean up userid's

This commit is contained in:
Garth Vander Houwen 2025-06-18 16:44:21 -07:00
parent a14ec9fc2d
commit e0678258be
7 changed files with 20 additions and 15 deletions

View file

@ -1808,7 +1808,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.6.7;
MARKETING_VERSION = 2.6.8;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -1841,7 +1841,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.6.7;
MARKETING_VERSION = 2.6.8;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -1872,7 +1872,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.7;
MARKETING_VERSION = 2.6.8;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -1904,7 +1904,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.7;
MARKETING_VERSION = 2.6.8;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View file

@ -118,10 +118,8 @@ public func createUser(num: Int64, context: NSManagedObjectContext) throws -> Us
context.performAndWait {
newUser = UserEntity(context: context)
newUser.num = num
let userId = String(format: "%016llX", num)
newUser.userId = "!\(userId)"
let userId = num.toHex()
newUser.userId = userId
let last4 = String(userId.suffix(4))
newUser.longName = "Meshtastic \(last4)"
newUser.shortName = last4

View file

@ -296,7 +296,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
if nodeInfo.hasUser {
let newUser = UserEntity(context: context)
newUser.userId = nodeInfo.user.id
newUser.userId = nodeInfo.num.toHex()
newUser.num = Int64(nodeInfo.num)
newUser.longName = nodeInfo.user.longName
newUser.shortName = nodeInfo.user.shortName
@ -394,7 +394,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
fetchedNode[0].user?.pkiEncrypted = true
fetchedNode[0].user?.publicKey = nodeInfo.user.publicKey
}
fetchedNode[0].user?.userId = nodeInfo.user.id
fetchedNode[0].user?.userId = nodeInfo.num.toHex()
fetchedNode[0].user?.num = Int64(nodeInfo.num)
fetchedNode[0].user?.numString = String(nodeInfo.num)
fetchedNode[0].user?.longName = nodeInfo.user.longName

View file

@ -182,7 +182,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
} else {
let newUser = UserEntity(context: context)
newUser.userId = newUserMessage.id
newUser.userId = newNode.num.toHex()
newUser.num = Int64(packet.from)
newUser.longName = newUserMessage.longName
newUser.shortName = newUserMessage.shortName
@ -306,7 +306,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
fetchedNode[0].telemetries? = NSOrderedSet(array: newTelemetries)
}
if nodeInfoMessage.hasUser {
fetchedNode[0].user?.userId = nodeInfoMessage.user.id
fetchedNode[0].user?.userId = nodeInfoMessage.num.toHex()
fetchedNode[0].user?.num = Int64(nodeInfoMessage.num)
fetchedNode[0].user?.longName = nodeInfoMessage.user.longName
fetchedNode[0].user?.shortName = nodeInfoMessage.user.shortName

View file

@ -122,7 +122,7 @@ struct NodeDetail: View {
.textSelection(.enabled)
}
.accessibilityElement(children: .combine)
if node.user?.keyMatch ?? false {
if let publicKey = node.user?.publicKey {
HStack {

View file

@ -305,7 +305,14 @@ struct SecurityConfig: View {
}
if status == errSecSuccess {
return randomBytes
// Generate a random "f" value and then adjust the value to make
// it valid as an "s" value for eval(). According to the specification
// we need to mask off the 3 right-most bits of f[0], mask off the
// left-most bit of f[31], and set the second to left-most bit of f[31].
var f = randomBytes
f[0] &= 0xF8
f[31] = (f[31] & 0x7F) | 0x40
return f
} else {
// Handle error, perhaps by logging or throwing an exception
Logger.mesh.debug("Error generating random bytes: \(status)")

View file

@ -313,7 +313,7 @@ struct ShareChannels: View {
guard let settingsString = try? channelSet.serializedData().base64EncodedString() else {
return
}
channelsUrl = ("https://meshtastic.org/e/\(replaceChannels ? "" : "?add=true")#" + settingsString.base64ToBase64url())
channelsUrl = ("https://meshtastic.org/e/#\(settingsString.base64ToBase64url())\(replaceChannels ? "" : "?add=true")")
}
}
}