From 9c8d1b3b6da5504b0945adbf7367a5eb79f97490 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sun, 2 Aug 2026 13:41:12 +0100 Subject: [PATCH] clean up --- src/Simplex/Chat/Library/Commands.hs | 6 ++---- src/Simplex/Chat/Library/Internal.hs | 3 +-- src/Simplex/Chat/Library/Subscriber.hs | 12 ++++-------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Simplex/Chat/Library/Commands.hs b/src/Simplex/Chat/Library/Commands.hs index 571bc6599d..a123ab7152 100644 --- a/src/Simplex/Chat/Library/Commands.hs +++ b/src/Simplex/Chat/Library/Commands.hs @@ -2288,8 +2288,7 @@ processChatCommand cxt nm = \case -- set group link info and incognito profile, generate and store membership keys incognitoProfile <- if incognito then Just <$> liftIO generateRandomProfile else pure Nothing let cReqHash = contactCReqHash $ CRContactUri crData {crScheme = SSSimplex} e2e - gVar <- asks random - (_, memberPrivKey) <- atomically $ C.generateKeyPair gVar + (_, memberPrivKey) <- atomically . C.generateKeyPair =<< asks random gInfo' <- withFastStore $ \db -> do gInfo' <- updatePreparedRelayedGroup db cxt user gInfo mainCReq cReqHash incognitoProfile rootKey memberPrivKey publicMemberCount_ -- Pre-emptively create owner members with trusted keys from link data @@ -2431,8 +2430,7 @@ processChatCommand cxt nm = \case Left e -> throwError $ ChatErrorStore e Right _ -> throwError $ ChatErrorStore SEDuplicateContactLink subMode <- chatReadVar subscriptionMode - gVar <- asks random - rootKey@(rootPubKey, rootPrivKey) <- atomically $ C.generateKeyPair gVar + rootKey@(rootPubKey, rootPrivKey) <- atomically . C.generateKeyPair =<< asks random let entityId = C.sha256Hash $ C.pubKeyBytes rootPubKey -- TODO [address DR] remove this option and switch to IKUsePQ True let (pqInitKeys, useDR) = case pqRatchet_ of diff --git a/src/Simplex/Chat/Library/Internal.hs b/src/Simplex/Chat/Library/Internal.hs index b49e251092..d85b06c2f1 100644 --- a/src/Simplex/Chat/Library/Internal.hs +++ b/src/Simplex/Chat/Library/Internal.hs @@ -2215,8 +2215,7 @@ createUserMemberKey :: GroupInfo -> CM GroupInfo createUserMemberKey gInfo@GroupInfo {groupId, membership, groupKeys} | useRelays' gInfo || isJust groupKeys = pure gInfo | otherwise = do - g <- asks random - (_, memberPrivKey) <- atomically $ C.generateKeyPair g + (_, memberPrivKey) <- atomically . C.generateKeyPair =<< asks random withStore' $ \db -> setUserMemberKey db groupId (groupMemberId' membership) memberPrivKey pure gInfo {groupKeys = Just GroupKeys {publicGroupKeys = Nothing, memberPrivKey}} diff --git a/src/Simplex/Chat/Library/Subscriber.hs b/src/Simplex/Chat/Library/Subscriber.hs index 3a05a461ee..69ffa3654b 100644 --- a/src/Simplex/Chat/Library/Subscriber.hs +++ b/src/Simplex/Chat/Library/Subscriber.hs @@ -600,8 +600,7 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage = void $ withStore' $ \db -> resetMemberContactFields db ct' XGrpLinkInv glInv -> do -- XGrpLinkInv here means we are connecting via business contact card, so we replace contact with group - g <- asks random - memberKeys <- atomically $ C.generateKeyPair g + memberKeys <- atomically . C.generateKeyPair =<< asks random (gInfo, host) <- withStore $ \db -> do liftIO $ deleteContactCardKeepConn db connId ct createGroupInvitedViaLink db cxt user conn'' memberKeys glInv @@ -2620,8 +2619,7 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage = when (fromRole < GRAdmin || fromRole < memRole) $ throwChatError (CEGroupContactRole c) when (fromMemId == memId) $ throwChatError CEGroupDuplicateMemberId -- [incognito] if direct connection with host is incognito, create membership using the same incognito profile - g <- asks random - memberKeys <- atomically $ C.generateKeyPair g + memberKeys <- atomically . C.generateKeyPair =<< asks random (gInfo@GroupInfo {groupId, localDisplayName, groupProfile, membership}, hostId) <- withStore $ \db -> createGroupInvitation db cxt user ct inv customUserProfileId memberKeys void $ createChatItem user (CDGroupSnd gInfo Nothing) False CIChatBanner Nothing Nothing (Just epochStart) let GroupMember {groupMemberId, memberId = membershipMemId} = membership @@ -3088,14 +3086,12 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage = toView $ CEvtContactConnecting user ct pure (conn', Nothing) XGrpLinkInv glInv -> do - g <- asks random - memberKeys <- atomically $ C.generateKeyPair g + memberKeys <- atomically . C.generateKeyPair =<< asks random (gInfo, host) <- withStore $ \db -> createGroupInvitedViaLink db cxt user conn' memberKeys glInv toView $ CEvtGroupLinkConnecting user gInfo host pure (conn', Just gInfo) XGrpLinkReject glRjct@GroupLinkRejection {rejectionReason} -> do - g <- asks random - memberKeys <- atomically $ C.generateKeyPair g + memberKeys <- atomically . C.generateKeyPair =<< asks random (gInfo, host) <- withStore $ \db -> createGroupRejectedViaLink db cxt user conn' memberKeys glRjct toView $ CEvtGroupLinkConnecting user gInfo host toViewTE $ TEGroupLinkRejected user gInfo rejectionReason