From a91c636dda6358586410f44aa3cf69b281fa8ebd Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 6 May 2019 11:17:52 +1000 Subject: [PATCH] Document things more --- .../Registration/OnboardingKeyPairViewController.swift | 2 ++ SignalServiceKit/src/Loki/ECKeyPair.m | 1 + 2 files changed, 3 insertions(+) diff --git a/Signal/src/ViewControllers/Registration/OnboardingKeyPairViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingKeyPairViewController.swift index f374dda7e..8a515ef74 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingKeyPairViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingKeyPairViewController.swift @@ -200,7 +200,9 @@ final class OnboardingKeyPairViewController : OnboardingBaseViewController { do { let hexEncodedPrivateKey = try Mnemonic.decode(mnemonic: mnemonic) let keyPair = ECKeyPair.generate(withHexEncodedPrivateKey: hexEncodedPrivateKey) + // Use KVC to access dbConnection even though it's private let databaseConnection = OWSIdentityManager.shared().value(forKey: "dbConnection") as! YapDatabaseConnection + // OWSPrimaryStorageIdentityKeyStoreIdentityKey is private so just use its value directly databaseConnection.setObject(keyPair, forKey: "TSStorageManagerIdentityKeyStoreIdentityKey", inCollection: OWSPrimaryStorageIdentityKeyStoreCollection) hexEncodedPublicKey = keyPair.hexEncodedPublicKey } catch let error { diff --git a/SignalServiceKit/src/Loki/ECKeyPair.m b/SignalServiceKit/src/Loki/ECKeyPair.m index ab88812cc..c58bccea2 100644 --- a/SignalServiceKit/src/Loki/ECKeyPair.m +++ b/SignalServiceKit/src/Loki/ECKeyPair.m @@ -19,6 +19,7 @@ extern void curve25519_donna(unsigned char *output, const unsigned char *a, cons NSMutableData *publicKey = [NSMutableData dataWithLength:ECCKeyLength]; if (!publicKey) { OWSFail(@"Could not allocate buffer"); } curve25519_donna(publicKey.mutableBytes, privateKey.mutableBytes, basepoint); + // Use KVC to access privateKey and publicKey even though they're private ECKeyPair *result = [ECKeyPair new]; [result setValue:[privateKey copy] forKey:@"privateKey"]; [result setValue:[publicKey copy] forKey:@"publicKey"];