Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/tss-client-swift/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ public class TSSHelpers {
/// - userTssIndex: The current tss index for the user
/// - userTssShare: The current tss share for the user
///
/// - Returns: `BigInt`
/// - Returns: `String`
///
/// - Throws: `TSSClientError`
public static func denormalizeShare(participatingServerDKGIndexes: [BigInt], userTssIndex: BigInt, userTssShare: BigInt) throws -> BigInt {
public static func denormalizeShare(participatingServerDKGIndexes: [BigInt], userTssIndex: BigInt, userTssShare: BigInt) throws -> String {
let coeff = try getDKLSCoefficient(isUser: true, participatingServerIndexes: participatingServerDKGIndexes, userTssIndex: userTssIndex, serverIndex: nil)
let denormalizeShare = (coeff * userTssShare ).modulus(TSSClient.modulusValueSigned)
return denormalizeShare
return denormalizeShare.magnitude.serialize().toHexString()
}

/// Calculates the public key that will be used for TSS signing.
Expand Down
4 changes: 2 additions & 2 deletions Tests/tss-client-swiftTests/helperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 == BigInt("18db3574e4217154769ad9cd88900e7f1c198aa60a1379f3869ba8a7699e6b53", radix: 16))
XCTAssert(denormalize3 == BigInt("008c6d9aba7210b8aa3b4d6ce6c448073eeb6433c65cae0d17a337039a1cea564a", radix: 16))
XCTAssert(denormalize2 == "18db3574e4217154769ad9cd88900e7f1c198aa60a1379f3869ba8a7699e6b53")
XCTAssert(denormalize3 == "8c6d9aba7210b8aa3b4d6ce6c448073eeb6433c65cae0d17a337039a1cea564a")
}

func testFinalGetTSSPubkey() throws{
Expand Down