diff --git a/backend/mpc-system/services/server-party-co-managed/cmd/server/main.go b/backend/mpc-system/services/server-party-co-managed/cmd/server/main.go index 44bef0bd..3f274359 100644 --- a/backend/mpc-system/services/server-party-co-managed/cmd/server/main.go +++ b/backend/mpc-system/services/server-party-co-managed/cmd/server/main.go @@ -32,6 +32,7 @@ type PendingSession struct { SessionID uuid.UUID JoinToken string MessageHash []byte + KeygenSessionID uuid.UUID // For sign sessions: the keygen session that created the keys ThresholdN int ThresholdT int SelectedParties []string @@ -392,7 +393,7 @@ func createCoManagedSessionEventHandler( // Immediately call JoinSession (this is required to trigger session_started) joinCtx, joinCancel := context.WithTimeout(ctx, 30*time.Second) - _, err := messageRouter.JoinSession(joinCtx, sessionID, partyID, joinToken) + sessionInfo, err := messageRouter.JoinSession(joinCtx, sessionID, partyID, joinToken) joinCancel() if err != nil { logger.Error("Failed to join session", @@ -404,13 +405,15 @@ func createCoManagedSessionEventHandler( logger.Info("Successfully joined session, waiting for session_started", zap.String("session_id", event.SessionId), - zap.String("party_id", partyID)) + zap.String("party_id", partyID), + zap.String("keygen_session_id", sessionInfo.KeygenSessionID.String())) // Store pending session for later use when session_started arrives pendingSessionCache.Store(event.SessionId, &PendingSession{ SessionID: sessionID, JoinToken: joinToken, MessageHash: event.MessageHash, + KeygenSessionID: sessionInfo.KeygenSessionID, // CRITICAL: Save the correct keygen session ID from JoinSession ThresholdN: int(event.ThresholdN), ThresholdT: int(event.ThresholdT), SelectedParties: event.SelectedParties, @@ -464,7 +467,8 @@ func createCoManagedSessionEventHandler( // Execute signing protocol logger.Info("Auto-participating in co_managed_sign session", zap.String("session_id", event.SessionId), - zap.String("party_id", partyID)) + zap.String("party_id", partyID), + zap.String("keygen_session_id", pendingSession.KeygenSessionID.String())) sessionInfo := &use_cases.SessionInfo{ SessionID: pendingSession.SessionID, @@ -472,7 +476,7 @@ func createCoManagedSessionEventHandler( ThresholdN: int(event.ThresholdN), ThresholdT: int(event.ThresholdT), MessageHash: pendingSession.MessageHash, - KeygenSessionID: uuid.Nil, // Use nil to trigger fallback logic (load most recent share) + KeygenSessionID: pendingSession.KeygenSessionID, // CRITICAL: Use the correct keygen session ID from JoinSession Participants: participants, }