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 3f274359..1a546f32 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 @@ -36,6 +36,7 @@ type PendingSession struct { ThresholdN int ThresholdT int SelectedParties []string + Participants []use_cases.ParticipantInfo // CRITICAL: Correct PartyIndex from database (via JoinSession) CreatedAt time.Time } @@ -417,6 +418,7 @@ func createCoManagedSessionEventHandler( ThresholdN: int(event.ThresholdN), ThresholdT: int(event.ThresholdT), SelectedParties: event.SelectedParties, + Participants: sessionInfo.Participants, // CRITICAL: Save participants with correct PartyIndex from database CreatedAt: time.Now(), }) @@ -450,18 +452,10 @@ func createCoManagedSessionEventHandler( participateCtx, cancel := context.WithTimeout(ctx, 10*time.Minute) defer cancel() - // Build SessionInfo from session_started event (NOT from pendingSession cache) - // session_started event contains ALL participants who have joined, - // including external parties that joined dynamically after session_created - // Note: We already called JoinSession in session_created phase, - // so we use ExecuteWithSessionInfo to skip the duplicate JoinSession call - participants := make([]use_cases.ParticipantInfo, len(event.SelectedParties)) - for i, p := range event.SelectedParties { - participants[i] = use_cases.ParticipantInfo{ - PartyID: p, - PartyIndex: i, - } - } + // CRITICAL: Use participants from pendingSession (which came from JoinSession response) + // These contain the correct PartyIndex values from the database, NOT loop indices + // The JoinSession response already includes all participants with their assigned indices + participants := pendingSession.Participants if isSignSession { // Execute signing protocol