Skip to content

Commit 02df75b

Browse files
authored
Merge pull request #9 from torusresearch/fix_denormalize_share
fix: conversion for denormalizeShare
2 parents a5f5488 + 5afe76b commit 02df75b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Sources/tss-client-swift/Helpers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ public class TSSHelpers {
219219
/// - userTssIndex: The current tss index for the user
220220
/// - userTssShare: The current tss share for the user
221221
///
222-
/// - Returns: `BigInt`
222+
/// - Returns: `String`
223223
///
224224
/// - Throws: `TSSClientError`
225-
public static func denormalizeShare(participatingServerDKGIndexes: [BigInt], userTssIndex: BigInt, userTssShare: BigInt) throws -> BigInt {
225+
public static func denormalizeShare(participatingServerDKGIndexes: [BigInt], userTssIndex: BigInt, userTssShare: BigInt) throws -> String {
226226
let coeff = try getDKLSCoefficient(isUser: true, participatingServerIndexes: participatingServerDKGIndexes, userTssIndex: userTssIndex, serverIndex: nil)
227227
let denormalizeShare = (coeff * userTssShare ).modulus(TSSClient.modulusValueSigned)
228-
return denormalizeShare
228+
return denormalizeShare.magnitude.serialize().toHexString()
229229
}
230230

231231
/// Calculates the public key that will be used for TSS signing.

Tests/tss-client-swiftTests/helperTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ final class helpersTests: XCTestCase {
6464
let denormalize2 = try TSSHelpers.denormalizeShare(participatingServerDKGIndexes: [BigInt(1), BigInt(2), BigInt(3) ], userTssIndex: BigInt(2), userTssShare: BigInt(sign: .plus, magnitude: share))
6565
let denormalize3 = try TSSHelpers.denormalizeShare(participatingServerDKGIndexes: [BigInt(1), BigInt(2), BigInt(3) ], userTssIndex: BigInt(3), userTssShare: BigInt(sign: .plus, magnitude: share))
6666

67-
XCTAssert(denormalize2 == BigInt("18db3574e4217154769ad9cd88900e7f1c198aa60a1379f3869ba8a7699e6b53", radix: 16))
68-
XCTAssert(denormalize3 == BigInt("008c6d9aba7210b8aa3b4d6ce6c448073eeb6433c65cae0d17a337039a1cea564a", radix: 16))
67+
XCTAssert(denormalize2 == "18db3574e4217154769ad9cd88900e7f1c198aa60a1379f3869ba8a7699e6b53")
68+
XCTAssert(denormalize3 == "8c6d9aba7210b8aa3b4d6ce6c448073eeb6433c65cae0d17a337039a1cea564a")
6969
}
7070

7171
func testFinalGetTSSPubkey() throws{

0 commit comments

Comments
 (0)