I'm trying to implement Yao's Millionaires' Problem algorithm in Swift and am hitting a snag.
To implement this algorithm, I need to generate an RSA private key and get n and d.
So far, I've created the key like this:
import Security
import Foundation
let tag = "com.example.keys.mykey".data(using: .utf8)!
let attributes: [String: Any] = [kSecAttrKeyType as String: kSecAttrKeyTypeRSA,
kSecAttrKeySizeInBits as String: 1024,
kSecPrivateKeyAttrs as String:
[kSecAttrIsPermanent as String: false,
kSecAttrApplicationTag as String: tag]
]
var error: Unmanaged<CFError>?
guard let privateKey = SecKeyCreateRandomKey(attributes as CFDictionary, &error) else {
throw error!.takeRetainedValue() as Error
}
privateKey seems to be of type SecKey but I can't figure out how to get n and d out of it.
How can I generate an RSA private key and get the n and d values?

