diff --git a/Sources/tss-client-swift/Helpers.swift b/Sources/tss-client-swift/Helpers.swift index 53057a2..85b07de 100644 --- a/Sources/tss-client-swift/Helpers.swift +++ b/Sources/tss-client-swift/Helpers.swift @@ -219,13 +219,13 @@ public class TSSHelpers { /// - userTssIndex: The current tss index for the user /// - userTssShare: The current tss share for the user /// - /// - Returns: `String` + /// - Returns: `BigInt` /// /// - Throws: `TSSClientError` - public static func denormalizeShare(participatingServerDKGIndexes: [BigInt], userTssIndex: BigInt, userTssShare: BigInt) throws -> String { + public static func denormalizeShare(participatingServerDKGIndexes: [BigInt], userTssIndex: BigInt, userTssShare: BigInt) throws -> BigInt { let coeff = try getDKLSCoefficient(isUser: true, participatingServerIndexes: participatingServerDKGIndexes, userTssIndex: userTssIndex, serverIndex: nil) let denormalizeShare = (coeff * userTssShare ).modulus(TSSClient.modulusValueSigned) - return denormalizeShare.magnitude.serialize().toHexString() + return denormalizeShare } /// Calculates the public key that will be used for TSS signing. diff --git a/Tests/tss-client-swiftTests/helperTests.swift b/Tests/tss-client-swiftTests/helperTests.swift index 4f4828f..00e95fb 100644 --- a/Tests/tss-client-swiftTests/helperTests.swift +++ b/Tests/tss-client-swiftTests/helperTests.swift @@ -64,8 +64,8 @@ final class helpersTests: XCTestCase { let denormalize2 = try TSSHelpers.denormalizeShare(participatingServerDKGIndexes: [BigInt(1), BigInt(2), BigInt(3) ], userTssIndex: BigInt(2), userTssShare: BigInt(sign: .plus, magnitude: share)) let denormalize3 = try TSSHelpers.denormalizeShare(participatingServerDKGIndexes: [BigInt(1), BigInt(2), BigInt(3) ], userTssIndex: BigInt(3), userTssShare: BigInt(sign: .plus, magnitude: share)) - XCTAssert(denormalize2 == "18db3574e4217154769ad9cd88900e7f1c198aa60a1379f3869ba8a7699e6b53") - XCTAssert(denormalize3 == "8c6d9aba7210b8aa3b4d6ce6c448073eeb6433c65cae0d17a337039a1cea564a") + XCTAssert(denormalize2 == BigInt("18db3574e4217154769ad9cd88900e7f1c198aa60a1379f3869ba8a7699e6b53", radix: 16)) + XCTAssert(denormalize3 == BigInt("008c6d9aba7210b8aa3b4d6ce6c448073eeb6433c65cae0d17a337039a1cea564a", radix: 16)) } func testFinalGetTSSPubkey() throws{