@@ -401,10 +401,11 @@ createConnection c nm userId enableNtfs checkNotices = withAgentEnv c .::. newCo
401401{-# INLINE createConnection #-}
402402
403403-- | Prepare connection link for contact mode (no network call).
404- -- Returns root key pair (for signing OwnerAuth), the created link, and internal params.
404+ -- Caller provides root signing key pair and link entity ID.
405+ -- Returns the created link and internal params.
405406-- The link address is fully determined at this point.
406- prepareConnectionLink :: AgentClient -> UserId -> Maybe ByteString -> Bool -> Maybe CRClientData -> AE (C. KeyPairEd25519 , CreatedConnLink 'CMContact, PreparedLinkParams )
407- prepareConnectionLink c userId linkEntityId checkNotices = withAgentEnv c . prepareConnectionLink' c userId linkEntityId checkNotices
407+ prepareConnectionLink :: AgentClient -> UserId -> C. KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> AE (CreatedConnLink 'CMContact, PreparedLinkParams )
408+ prepareConnectionLink c userId rootKey linkEntityId checkNotices = withAgentEnv c . prepareConnectionLink' c userId rootKey linkEntityId checkNotices
408409{-# INLINE prepareConnectionLink #-}
409410
410411-- | Create connection for prepared link (single network call).
@@ -918,23 +919,22 @@ newConn c nm userId enableNtfs checkNotices cMode linkData_ clientData pqInitKey
918919 `catchE` \ e -> withStore' c (`deleteConnRecord` connId) >> throwE e
919920
920921-- | Prepare connection link for contact mode (no network, no database).
921- -- Generates all cryptographic material and returns the link that will be created .
922- prepareConnectionLink' :: AgentClient -> UserId -> Maybe ByteString -> Bool -> Maybe CRClientData -> AM (C. KeyPairEd25519 , CreatedConnLink 'CMContact, PreparedLinkParams )
923- prepareConnectionLink' c userId linkEntityId checkNotices clientData = do
922+ -- Caller provides root signing key pair and link entity ID .
923+ prepareConnectionLink' :: AgentClient -> UserId -> C. KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> AM (CreatedConnLink 'CMContact, PreparedLinkParams )
924+ prepareConnectionLink' c userId rootKey @ (_, plpRootPrivKey) linkEntityId checkNotices clientData = do
924925 g <- asks random
925926 plpSrvWithAuth@ (ProtoServerWithAuth srv _) <- getSMPServer c userId
926927 when checkNotices $ checkClientNotices c plpSrvWithAuth
927928 AgentConfig {smpClientVRange, smpAgentVRange} <- asks config
928929 plpNonce@ (C. CbNonce corrId) <- atomically $ C. randomCbNonce g
929- sigKeys@ (_, plpRootPrivKey) <- atomically $ C. generateKeyPair g
930930 plpQueueE2EKeys@ (e2ePubKey, _) <- atomically $ C. generateKeyPair g
931931 let sndId = SMP. EntityId $ B. take 24 $ C. sha3_384 corrId
932932 qUri = SMPQueueUri smpClientVRange $ SMPQueueAddress srv sndId e2ePubKey (Just QMContact )
933933 connReq = CRContactUri $ ConnReqUriData SSSimplex smpAgentVRange [qUri] clientData
934- (plpLinkKey, plpSignedFixedData) = SL. encodeSignFixedData sigKeys smpAgentVRange connReq linkEntityId
934+ (plpLinkKey, plpSignedFixedData) = SL. encodeSignFixedData rootKey smpAgentVRange connReq ( Just linkEntityId)
935935 ccLink = CCLink connReq $ Just $ CSLContact SLSServer CCTContact srv plpLinkKey
936936 params = PreparedLinkParams {plpNonce, plpQueueE2EKeys, plpLinkKey, plpRootPrivKey, plpSignedFixedData, plpSrvWithAuth}
937- pure (sigKeys, ccLink, params)
937+ pure (ccLink, params)
938938
939939-- | Create connection for prepared link (single network call).
940940createConnectionForLink' :: AgentClient -> NetworkRequestMode -> UserId -> Bool -> CreatedConnLink 'CMContact -> PreparedLinkParams -> UserConnLinkData 'CMContact -> CR. InitialKeys -> SubscriptionMode -> AM ConnId
0 commit comments