From a09e163704624fd53731d25045a58bde7d6ef488 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 31 Dec 2025 06:01:40 -0800 Subject: [PATCH] fix(co-sign): fix CanStart() to check T parties for sign sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - For keygen sessions: require all N parties to join before starting - For sign sessions: require only T parties to join before starting - This fixes session_started event not being triggered for signing sessions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../domain/entities/mpc_session.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/mpc-system/services/session-coordinator/domain/entities/mpc_session.go b/backend/mpc-system/services/session-coordinator/domain/entities/mpc_session.go index 53068314..9b0b06c7 100644 --- a/backend/mpc-system/services/session-coordinator/domain/entities/mpc_session.go +++ b/backend/mpc-system/services/session-coordinator/domain/entities/mpc_session.go @@ -140,7 +140,15 @@ func (s *MPCSession) UpdateParticipantStatus(partyID value_objects.PartyID, stat // CanStart checks if all participants have joined and the session can start func (s *MPCSession) CanStart() bool { - if len(s.Participants) != s.Threshold.N() { + // Determine required participant count based on session type + // For keygen: all N parties must participate + // For sign: only T parties participate + requiredCount := s.Threshold.N() + if s.SessionType == SessionTypeSign { + requiredCount = s.Threshold.T() + } + + if len(s.Participants) != requiredCount { return false } @@ -151,7 +159,7 @@ func (s *MPCSession) CanStart() bool { readyCount++ } } - return readyCount == s.Threshold.N() + return readyCount == requiredCount } // Start transitions the session to in_progress