         self.virgilClient = VSSClient(serviceConfig: self.preferences.virgilServiceConfig)
     }
 
-    public func initTalk(withCardId cardId: String, completion: @escaping (SecureTalk?, Error?)->()) {
+    public func initTalk(withRecipientWithIdentity identity: String, completion: @escaping (SecureTalk?, Error?)->()) {
         guard let identityCard = self.identityCard else {
             completion(nil, NSError(domain: SecureChat.ErrorDomain, code: -1, userInfo: [NSLocalizedDescriptionKey: "Identity card missing. Probably, SecureChat was not initialized."]))
             return
         }
-        
 
         guard let publicKey = self.preferences.crypto.importPublicKey(from: identityCard.publicKeyData) else {
             completion(nil, NSError(domain: SecureChat.ErrorDomain, code: -1, userInfo: [NSLocalizedDescriptionKey: "Error importing public key from identity card."]))
             return
         }
-
-        // FIXME
-        let secureTalk = SecureTalk(crypto: self.preferences.crypto, myPrivateKey: self.preferences.myPrivateKey, ephPrivateKey: self.preferences.crypto.generateKeyPair().privateKey, recipientPublicKey: publicKey, recipientLongTermKey: self.preferences.crypto.generateKeyPair().publicKey, recipientOneTimeKey: self.preferences.crypto.generateKeyPair().publicKey)
-        
-        completion(secureTalk, nil)
+        
+        self.client.getRecipientCardsSet(forIdentities: [identity]) { cardsSets, error in
+            guard error == nil else {
+                completion(nil, NSError(domain: SecureChat.ErrorDomain, code: -1, userInfo: [NSLocalizedDescriptionKey: "Error obtaining recipient cards set."]))
+                return
+            }
+            
+            guard let cardsSets = cardsSets, cardsSets.count > 0 else {
+                completion(nil, NSError(domain: SecureChat.ErrorDomain, code: -1, userInfo: [NSLocalizedDescriptionKey: "Error obtaining recipient cards set. Empty set."]))
+                return
+            }
+            
+            // FIXME: Multiple sessions?
+            let cardsSet = cardsSets[0]
+        
+            
+            let longTermPublicKeyData = cardsSet.longTermCard.publicKeyData
+            let oneTimePublicKeyData = cardsSet.oneTimeCard.publicKeyData
+            guard let oneTimePublicKey = self.preferences.crypto.importPublicKey(from: oneTimePublicKeyData),
+                let longTermPublicKey = self.preferences.crypto.importPublicKey(from: longTermPublicKeyData) else {
+                    completion(nil, NSError(domain: SecureChat.ErrorDomain, code: -1, userInfo: [NSLocalizedDescriptionKey: "Error importing eph public keys from cards."]))
+                    return
+            }
+
+            let secureTalk = SecureTalk(crypto: self.preferences.crypto, myPrivateKey: self.preferences.myPrivateKey, ephPrivateKey: self.preferences.crypto.generateKeyPair().privateKey, recipientPublicKey: publicKey, recipientLongTermKey: longTermPublicKey, recipientOneTimeKey: oneTimePublicKey)
+            
+            completion(secureTalk, nil)
+        }
     }
 }
 

        
        let requestSigner = VSSRequestSigner(crypto: self.preferences.crypto)
        try requestSigner.selfSign(request, with: keyPair.privateKey)
        try requestSigner.authoritySign(request, forAppId: identityCard.identifier, with: self.preferences.myPrivateKey)
        
        return request
    }
    
    fileprivate func addCards(forIdentityCard identityCard: VSSCard, includeLtcCard: Bool, numberOfOtcCards: Int, completion: @escaping (Error?)->()) throws {
        let keys = try self.generateAndSaveKeys(numberOfOtcKeys: numberOfOtcCards, generateLtcKey: includeLtcCard)
        
        var otcCardsRequests: [CreateEphemeralCardRequest] = []
        otcCardsRequests.reserveCapacity(numberOfOtcCards)
        for i in 0..<numberOfOtcCards {
            let request = try self.generateRequest(forIdentityCard: identityCard, keyPair: keys[i], isLtc: false)
            otcCardsRequests.append(request)
        }
        
        var ltcCardRequest: CreateEphemeralCardRequest?
        if includeLtcCard {
            let request = try self.generateRequest(forIdentityCard: identityCard, keyPair: keys.last!, isLtc: false)
            ltcCardRequest = request
        }
        
        let callback = { (error: Error?) in
            completion(error)

// MARK: Keys
extension SecureChat {
    static fileprivate let ServiceKeyName = "VIRGIL.SERVICE.INFO"
    static private let KeyNameFormat = "%@.%@"
    
    fileprivate func getEphKey(keyName: String) throws -> VSSPrivateKey {
        let keyEntryName = String(format: SecureChat.KeyNameFormat, "VIRGIL_EPHC_KEY", keyName)
        
        let keyEntry = try self.preferences.keyStorage.loadKeyEntry(withName: keyEntryName)
        
        guard let privateKey = self.preferences.crypto.importPrivateKey(from: keyEntry.value) else {
            throw NSError(domain: SecureChat.ErrorDomain, code: -1, userInfo: [NSLocalizedDescriptionKey: "Error loading eph private key."])
        }
        
        return privateKey
    }
    
    fileprivate func saveKeys(keys: [VSSPrivateKey], keyNames: [String], ltcKey: VSSPrivateKey?, ltcKeyName: String?) throws {
        let serviceInfo = try self.getServiceInfoEntry()
        
        var keyEntryNames: [String] = []
        keyEntryNames.reserveCapacity(keys.count)
        
        for i in 0..<keys.count {
            keyEntryNames.append(try self.savePrivateKey(keys[i], keyName: keyNames[i]))
        }
        
        let ltcKeyEntryName: String?
        if let ltcKey = ltcKey,
            let ltcKeyName = ltcKeyName {
            ltcKeyEntryName = try self.savePrivateKey(ltcKey, keyName: ltcKeyName)
        }
        else {
            ltcKeyEntryName = nil
        }
        
        let newServiceInfo = ServiceInfoEntry(ltcKeyName: ltcKeyEntryName ?? serviceInfo.ltcKeyName, otcKeysNames: serviceInfo.otcKeysNames + keyEntryNames)
        
        try self.updateServiceInfoEntry(newEntry: newServiceInfo)
    }
    
    private func savePrivateKey(_ key: VSSPrivateKey, keyName: String) throws -> String {
        let privateKeyData = self.preferences.crypto.export(key, withPassword: nil)
        
        let keyEntryName = String(format: SecureChat.KeyNameFormat, "VIRGIL_EPHC_KEY", keyName)
        let keyEntry = VSSKeyEntry(name: keyEntryName, value: privateKeyData)
        
        try self.preferences.keyStorage.store(keyEntry)
        
        return keyEntryName
    }
    
    private func updateServiceInfoEntry(newEntry: ServiceInfoEntry) throws {
