diff --git a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt index 46fe98a0..8115b911 100644 --- a/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt +++ b/backend/mpc-system/services/service-party-android/app/src/main/java/com/durian/tssparty/data/repository/TssRepository.kt @@ -1216,6 +1216,13 @@ class TssRepository @Inject constructor( android.util.Log.d("TssRepository", "Starting TSS sign with ${allParticipants.size} participants, thresholdT=$thresholdT") // Start TSS sign + // Remove 0x prefix from messageHash - TSS library expects pure hex + val cleanMessageHash = if (messageHash.startsWith("0x") || messageHash.startsWith("0X")) { + messageHash.substring(2) + } else { + messageHash + } + android.util.Log.d("TssRepository", "Starting TSS sign with cleanMessageHash=${cleanMessageHash.take(20)}...") val startResult = tssNativeBridge.startSign( sessionId = sessionId, partyId = partyId, @@ -1223,7 +1230,7 @@ class TssRepository @Inject constructor( thresholdT = thresholdT, thresholdN = shareEntity.thresholdN, // Use original N from keygen participants = allParticipants, - messageHash = messageHash, + messageHash = cleanMessageHash, shareData = shareEntity.encryptedShare, password = password ) @@ -2158,7 +2165,14 @@ class TssRepository @Inject constructor( } // Start TSS sign - android.util.Log.d("TssRepository", "[CO-SIGN] Calling tssNativeBridge.startSign...") + // Remove 0x prefix from messageHash - TSS library expects pure hex + val rawMessageHash = session.messageHash ?: "" + val cleanMessageHash = if (rawMessageHash.startsWith("0x") || rawMessageHash.startsWith("0X")) { + rawMessageHash.substring(2) + } else { + rawMessageHash + } + android.util.Log.d("TssRepository", "[CO-SIGN] Calling tssNativeBridge.startSign with cleanMessageHash=${cleanMessageHash.take(20)}...") val startResult = tssNativeBridge.startSign( sessionId = sessionId, partyId = partyId, @@ -2166,7 +2180,7 @@ class TssRepository @Inject constructor( thresholdT = session.thresholdT, thresholdN = shareEntity.thresholdN, participants = session.participants, - messageHash = session.messageHash ?: "", + messageHash = cleanMessageHash, shareData = shareEntity.encryptedShare, password = password )