Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update with torusUtils 9.0.0 #32

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift" , from: "8.1.0"),
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift" , from: "9.0.0"),

// dev dependencies only
.package(name:"jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"),
],
Expand Down
4 changes: 2 additions & 2 deletions Sources/ThresholdKey/Modules/TssModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ public final class TssModule {
public static func get_dkg_pub_key(threshold_key: ThresholdKey, tssTag: String, nonce: String, nodeDetails: AllNodeDetailsModel, torusUtils: TorusUtils) async throws -> TSSPubKeyResult {
let extendedVerifierId = try threshold_key.get_extended_verifier_id()
let split = extendedVerifierId.components(separatedBy: "\u{001c}")

let result = try await torusUtils.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.torusNodePub, verifier: split[0], verifierId: split[1], extendedVerifierId: "\(split[1])\u{0015}\(tssTag)\u{0016}\(nonce)")
let result = try await torusUtils.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, verifier: split[0], verifierId: split[1], extendedVerifierId: "\(split[1])\u{0015}\(tssTag)\u{0016}\(nonce)")

guard let x = result.finalKeyData?.X, let y = result.finalKeyData?.Y, let nodeIndexes = result.nodesData?.nodeIndexes else {
throw RuntimeError("conversion error")
Expand Down
18 changes: 9 additions & 9 deletions Tests/tkeypkgTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ final class integrationTests: XCTestCase {

let nodeManager = NodeDetailManager(network: .sapphire(.SAPPHIRE_DEVNET))
let nodeDetail = try await nodeManager.getNodeDetails(verifier: TORUS_TEST_VERIFIER, verifierID: TORUS_TEST_EMAIL)
let torusUtils = TorusUtils(serverTimeOffset: 1000, network: .sapphire(.SAPPHIRE_DEVNET), clientId: "CLIENT ID")
let torusUtils = try TorusUtils.init(params: .init(clientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET), serverTimeOffset: 1000 ))

let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let verifierParams = VerifierParams(verifier_id: TORUS_TEST_EMAIL)
let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.torusNodeEndpoints, torusNodePubs: nodeDetail.torusNodePub, indexes: nodeDetail.torusIndexes, verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken)
let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.torusNodeEndpoints, verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken)

let signature_collection = retrievedShare.sessionData!.sessionTokenData.map { token in
["data": Data(hex: token!.token).base64EncodedString(),
let signature_collection = retrievedShare.sessionData.sessionTokenData.map { token in
["data": Data.init(hexString: token!.token)?.base64EncodedString(),
"sig": token!.signature]
}

Expand Down Expand Up @@ -122,14 +122,14 @@ final class integrationTests: XCTestCase {

let nodeManager = NodeDetailManager(network: .sapphire(.SAPPHIRE_DEVNET))
let nodeDetail = try await nodeManager.getNodeDetails(verifier: TORUS_TEST_VERIFIER, verifierID: TORUS_TEST_EMAIL)
let torusUtils = TorusUtils(serverTimeOffset: 1000, network: .sapphire(.SAPPHIRE_DEVNET), clientId: "CLIENT ID")

let torusUtils = try TorusUtils.init(params: .init(clientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET), serverTimeOffset: 1000 ))
let idToken = try generateIdToken(email: TORUS_TEST_EMAIL)
let verifierParams = VerifierParams(verifier_id: TORUS_TEST_EMAIL)
let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.torusNodeSSSEndpoints, torusNodePubs: nodeDetail.torusNodePub, indexes: nodeDetail.torusIndexes, verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken)
let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.torusNodeSSSEndpoints, verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken)

let signature_collection = retrievedShare.sessionData!.sessionTokenData.map { token in
["data": Data(hex: token!.token).base64EncodedString(),
let signature_collection = retrievedShare.sessionData.sessionTokenData.map { token in
["data": Data.init(hexString: token!.token)?.base64EncodedString(),
"sig": token!.signature]
}

Expand Down
9 changes: 6 additions & 3 deletions Tests/tkeypkgTests/tkey_base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import Foundation
import TorusUtils

class tkey_baseTests: XCTestCase {

var torus = TorusUtils.init(network: .sapphire(.SAPPHIRE_DEVNET), clientId: "CLIENT ID")

var torus : TorusUtils
override init() {
self.torus = try! TorusUtils.init(params: .init(clientId: "CLIENT_ID", network: .sapphire(.SAPPHIRE_DEVNET)))
super.init()
}
override func setUp() async throws {

let postbox_key = try! PrivateKey.generate()
let storage_layer = try! StorageLayer(enable_logging: true, host_url: "https://metadata.tor.us", server_time_offset: 2)
let service_provider = try! ServiceProvider(enable_logging: true, postbox_key: postbox_key.hex)
Expand Down
Loading