From 001f0ac4805092a76cef38b30b617969c2701fb2 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 1 Jan 2026 22:04:18 -0800 Subject: [PATCH] fix(android): remove 0x prefix from messageHash before TSS sign MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TSS native library expects pure hex string without 0x prefix. Fix both startSigning (initiator) and executeSignAsJoiner (joiner) functions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../tssparty/data/repository/TssRepository.kt | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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 )