mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
1.2 KiB
Swift
24 lines
1.2 KiB
Swift
5 years ago
|
|
||
|
@objc public extension SSKProtoPrekeyBundleMessage {
|
||
|
|
||
|
@objc(builderFromPreKeyBundle:)
|
||
|
public static func builder(from preKeyBundle: PreKeyBundle) -> SSKProtoPrekeyBundleMessageBuilder {
|
||
|
let builder = self.builder()
|
||
|
builder.setIdentityKey(preKeyBundle.identityKey)
|
||
|
builder.setDeviceID(UInt32(preKeyBundle.deviceId))
|
||
|
builder.setPrekeyID(UInt32(preKeyBundle.preKeyId))
|
||
|
builder.setPrekey(preKeyBundle.preKeyPublic)
|
||
|
builder.setSignedKeyID(UInt32(preKeyBundle.signedPreKeyId))
|
||
|
builder.setSignedKey(preKeyBundle.signedPreKeyPublic)
|
||
|
builder.setSignature(preKeyBundle.signedPreKeySignature)
|
||
|
return builder
|
||
|
}
|
||
|
|
||
|
@objc(getPreKeyBundleWithTransaction:)
|
||
|
public func getPreKeyBundle(with transaction: YapDatabaseReadWriteTransaction) -> PreKeyBundle? {
|
||
|
let registrationId = TSAccountManager.sharedInstance().getOrGenerateRegistrationId(transaction)
|
||
|
return PreKeyBundle(registrationId: Int32(registrationId), deviceId: Int32(deviceID), preKeyId: Int32(prekeyID), preKeyPublic: prekey,
|
||
|
signedPreKeyPublic: signedKey, signedPreKeyId: Int32(signedKeyID), signedPreKeySignature: signature, identityKey: identityKey)
|
||
|
}
|
||
|
}
|