void inviteUsersToChat(string chatName, string username) { string chatId = myChats[chatName].chatId; string joinerId = otherUsers[username].user_id; string joinerPubKey = otherUsers[username].pubKey; string symKeyEncrypted = myChats[chatName].getSharableKey(); // User's pub key is used to encrypt symmetric key AsymmetricKeyHelper asymKeyHelper = new AsymmetricKeyHelper("otherUserKey"); symKeyEncrypted = asymKeyHelper.EncryptWithAnotherPublicKey(symKeyEncrypted, joinerPubKey); string message = "{\"access_id\": \"" + this.access_id + "\", \"chatId\": \"" + chatId + "\", \"symKey\": \"" + symKeyEncrypted + "\", \"joinerId\": \"" + joinerId + "\"}"; serverConnection.WriteMessage("allowUserToJoinChat", message); }