From 0ea64e02ae056f7b907bf4e2de0571e0a041d235 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 6 Dec 2025 07:35:03 -0800 Subject: [PATCH] fix(account): use only threshold_t parties for signing instead of all active parties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For 2-of-3 threshold signing, only 2 parties should participate in signing, not all 3. This fixes the 'failed to calculate Bob_mid' error that occurred when all parties tried to sign. Changes: - Modified CreateSigningSession to select exactly threshold_t parties when no signing config exists - For 2-of-3: now selects 2 parties instead of all 3 - Added logging to show party selection details 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../adapters/input/http/account_handler.go | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/backend/mpc-system/services/account/adapters/input/http/account_handler.go b/backend/mpc-system/services/account/adapters/input/http/account_handler.go index 3e577bd3..b8409344 100644 --- a/backend/mpc-system/services/account/adapters/input/http/account_handler.go +++ b/backend/mpc-system/services/account/adapters/input/http/account_handler.go @@ -732,12 +732,26 @@ func (h *AccountHTTPHandler) CreateSigningSession(c *gin.Context) { zap.String("username", req.Username), zap.Strings("configured_parties", partyIDs)) } else { - // Use all active parties (original behavior) - partyIDs = allActivePartyIDs + // For threshold signing, select minimum required parties (threshold_t) + // For 2-of-3, we need exactly 2 parties to sign (not all 3) + requiredParties := accountOutput.Account.ThresholdT + if len(allActivePartyIDs) < requiredParties { + c.JSON(http.StatusBadRequest, gin.H{ + "error": "insufficient active parties for signing", + "required": requiredParties, + "available": len(allActivePartyIDs), + }) + return + } - logger.Info("Using all active parties for signing", + // Select first 'threshold_t' parties + partyIDs = allActivePartyIDs[:requiredParties] + + logger.Info("Using minimum required parties for threshold signing", zap.String("username", req.Username), - zap.Strings("active_parties", partyIDs)) + zap.Int("threshold_t", requiredParties), + zap.Int("total_active", len(allActivePartyIDs)), + zap.Strings("selected_parties", partyIDs)) } // Check if any of the selected parties is a delegate