Hi, for some of our users the app crashes when we try to get the EdDSA signature using the private key.
We use the following method from CryptoKit in the Curve25519.Signing.PrivateKey
extension:
public func signature<D>(for data: D) throws -> Data where D : DataProtocol
The data that we want to sign is a string that is converted using the algorithm SHA256
Our implementation looks something like this:
func foo(text: String) throws -> String {
var algorithm = SHA256()
algorithm.update(data: text.data(using: .utf8)!)
guard self.hasPrivateKey else {
// Error handling
}
do {
let signature = try self.privateKey.signature(for: algorithm.finalize()) // App crashes here if not using do-catch statement
// signature will be used and transformed to return String...
} catch {
// Error handling
}
}
I would appreciate any hints on how to solve or inspect this.
Many thanks.