mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
dbead5e3c8
Added a few types to make the code more readable Added the inbox request to the polling Added a couple of properties to the TSContactThread to indicate the originating open group to support SOGS DMs Added code to store the latest message id for an open group inbox Added a bunch of documentation from the API docs into the OpenGroupAPI (and associated models) Updated the OpenGroupAPI to match the latest docs Fixed the incorrect structure of the SendDirectMessageRequest Fixed an incorrect inbox endpoint path Tweaked the batch response handling so it wouldn't fail to parse all responses if a single one failed Renamed IdPrefix to SessionId.Prefix and cleaned up the type to be more readable & self-documenting
26 lines
1 KiB
Swift
26 lines
1 KiB
Swift
import Curve25519Kit
|
|
|
|
public extension ECKeyPair {
|
|
|
|
@objc var hexEncodedPrivateKey: String {
|
|
return privateKey.map { String(format: "%02hhx", $0) }.joined()
|
|
}
|
|
|
|
@objc var hexEncodedPublicKey: String {
|
|
// Prefixing with 'SessionId.Prefix.standard' is necessary for what seems to be a sort of Signal public key versioning system
|
|
return SessionId(.standard, publicKey: publicKey.bytes).hexString
|
|
}
|
|
|
|
@objc static func isValidHexEncodedPublicKey(candidate: String) -> Bool {
|
|
// Note: If the logic in here changes ensure it doesn't break `SessionId.Prefix(from:)`
|
|
// Check that it's a valid hexadecimal encoding
|
|
guard Hex.isValid(candidate) else { return false }
|
|
// Check that it has length 66 and a valid prefix
|
|
guard candidate.count == 66 && SessionId.Prefix.allCases.first(where: { candidate.hasPrefix($0.rawValue) }) != nil else {
|
|
return false
|
|
}
|
|
|
|
// It appears to be a valid public key
|
|
return true
|
|
}
|
|
}
|