mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
1345e89809
Removed the usage of the OWSAES256Key (using CryptoKit and raw data instead) Removed the pre-compiled headers to speed up builds with minor changes (explicit imports instead) # Conflicts: # Session.xcodeproj/project.pbxproj # SessionMessagingKit/Database/Models/ClosedGroup.swift # SessionMessagingKit/Protos/Generated/SNProto.swift # SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift # SessionMessagingKit/Protos/SessionProtos.proto # SessionMessagingKit/Sending & Receiving/MessageSender.swift # SessionMessagingKit/Sending & Receiving/Pollers/CurrentUserPoller.swift # SessionMessagingKit/Utilities/ProfileManager.swift # SessionSnodeKit/Models/DeleteAllMessagesRequest.swift # SessionSnodeKit/Models/GetMessagesRequest.swift # SessionSnodeKit/Models/SendMessageRequest.swift # SessionSnodeKit/Types/SnodeAPINamespace.swift
45 lines
1.4 KiB
Swift
45 lines
1.4 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import Clibsodium
|
|
import Sodium
|
|
|
|
extension Sign {
|
|
|
|
/**
|
|
Converts an Ed25519 public key to an X25519 public key.
|
|
- Parameter ed25519PublicKey: The Ed25519 public key to convert.
|
|
- Returns: The X25519 public key if conversion is successful.
|
|
*/
|
|
public func toX25519(ed25519PublicKey: PublicKey) -> PublicKey? {
|
|
var x25519PublicKey = PublicKey(repeating: 0, count: 32)
|
|
|
|
// FIXME: It'd be nice to check the exit code here, but all the properties of the object
|
|
// returned by the call below are internal.
|
|
let _ = crypto_sign_ed25519_pk_to_curve25519 (
|
|
&x25519PublicKey,
|
|
ed25519PublicKey
|
|
)
|
|
|
|
return x25519PublicKey
|
|
}
|
|
|
|
/**
|
|
Converts an Ed25519 secret key to an X25519 secret key.
|
|
- Parameter ed25519SecretKey: The Ed25519 secret key to convert.
|
|
- Returns: The X25519 secret key if conversion is successful.
|
|
*/
|
|
public func toX25519(ed25519SecretKey: SecretKey) -> SecretKey? {
|
|
var x25519SecretKey = SecretKey(repeating: 0, count: 32)
|
|
|
|
// FIXME: It'd be nice to check the exit code here, but all the properties of the object
|
|
// returned by the call below are internal.
|
|
let _ = crypto_sign_ed25519_sk_to_curve25519 (
|
|
&x25519SecretKey,
|
|
ed25519SecretKey
|
|
)
|
|
|
|
return x25519SecretKey
|
|
}
|
|
}
|