From 6a4996c41f21831f5e9e90f5b4f6ede7c689b4eb Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:15:12 +0200 Subject: [PATCH 1/3] wip: update example --- Shared/ContentView.swift | 2 +- Shared/LoginModel.swift | 15 +-- Shared/ThresholdKeyView.swift | 66 ++-------- Shared/TssView.swift | 5 +- Shared/helper.swift | 2 +- tkey_ios.xcodeproj/project.pbxproj | 22 ++-- .../xcshareddata/swiftpm/Package.resolved | 122 ++++++++++-------- 7 files changed, 103 insertions(+), 131 deletions(-) diff --git a/Shared/ContentView.swift b/Shared/ContentView.swift index 3086e8f..0966b9f 100644 --- a/Shared/ContentView.swift +++ b/Shared/ContentView.swift @@ -15,7 +15,7 @@ struct ContentView: View { ProgressView() } else { if vm.loggedIn { - ThresholdKeyView(userData: vm.userData) + ThresholdKeyView(userData: vm.userData!) .tabItem { Image(systemName: "house.circle") Text("Home") diff --git a/Shared/LoginModel.swift b/Shared/LoginModel.swift index 36aee4d..7c49e31 100644 --- a/Shared/LoginModel.swift +++ b/Shared/LoginModel.swift @@ -6,7 +6,7 @@ class LoginModel: ObservableObject { @Published var loggedIn: Bool = false @Published var isLoading = false @Published var navigationTitle: String = "" - @Published var userData: TorusKeyData! + @Published var userData: TorusLoginResponse? func setup() async { await MainActor.run(body: { @@ -24,15 +24,10 @@ class LoginModel: ObservableObject { func loginWithCustomAuth() { Task { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .google, - clientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", - verifier: "google-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - browserRedirectURL: "https://scripts.toruswallet.io/redirect.html") - let tdsdk = CustomAuth( aggregateVerifierType: .singleLogin, aggregateVerifier: "google-lrc", subVerifierDetails: [sub], network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true) - let data = try await tdsdk.triggerLogin() - print(data) + + let tdsdk = try CustomAuth(config: CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "Client ID")) + + let data = try await tdsdk.triggerLogin(args: SubVerifierDetails(typeOfLogin: .google, verifier: "google-lrc", clientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", redirectURL: "https://scripts.toruswallet.io/redirect.html")) await MainActor.run(body: { self.userData = data diff --git a/Shared/ThresholdKeyView.swift b/Shared/ThresholdKeyView.swift index 5f824d3..0b7cdf8 100644 --- a/Shared/ThresholdKeyView.swift +++ b/Shared/ThresholdKeyView.swift @@ -1,9 +1,8 @@ import SwiftUI import TorusUtils import FetchNodeDetails -import CommonSources import CustomAuth -import tkey_mpc_swift +import tkey enum SpinnerLocation { case add_password_btn, change_password_btn, init_reconstruct_btn, nowhere @@ -15,7 +14,7 @@ enum SpinnerLocation { // } struct ThresholdKeyView: View { - @State var userData: TorusKeyData + @State var userData: TorusLoginResponse @State private var showAlert = false @State private var alertContent = "" @State private var totalShares = 0 @@ -53,18 +52,8 @@ struct ThresholdKeyView: View { showAlert = true alertContent = "Resetting your accuont.." do { - guard let finalKeyData = userData.torusKey.finalKeyData else { - alertContent = "Failed to get public address from userinfo" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } - guard let postboxkey = finalKeyData.privKey else { - alertContent = "Failed to get public address from userinfo" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } + let finalKeyData = userData.torusKey + let postboxkey = finalKeyData.finalKeyData.privKey let temp_storage_layer = try StorageLayer(enable_logging: true, host_url: "https://metadata.tor.us", server_time_offset: 2) let temp_service_provider = try ServiceProvider(enable_logging: true, postbox_key: postboxkey) let temp_threshold_key = try ThresholdKey( @@ -151,38 +140,12 @@ struct ThresholdKeyView: View { func initialize () { Task { showSpinner = SpinnerLocation.init_reconstruct_btn - guard let finalKeyData = userData.torusKey.finalKeyData else { - alertContent = "Failed to get public address from userinfo" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } + let finalKeyData = userData.torusKey.finalKeyData - guard let verifierLocal = userData.userInfo["verifier"] as? String, let verifierIdLocal = userData.userInfo["verifierId"] as? String else { - alertContent = "Failed to get verifier or verifierId from userinfo" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } - verifier = verifierLocal - verifierId = verifierIdLocal + let postboxkey = finalKeyData.privKey - guard let postboxkey = finalKeyData.privKey else { - alertContent = "Failed to get postboxkey" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } - - print(finalKeyData) - print(postboxkey) postboxkeyGlobal = postboxkey - guard let sessionData = userData.torusKey.sessionData else { - alertContent = "Failed to get sessionData" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } + let sessionData = userData.torusKey.sessionData let sessionTokenData = sessionData.sessionTokenData signatures = sessionTokenData.map { token in @@ -197,9 +160,9 @@ struct ThresholdKeyView: View { showSpinner = SpinnerLocation.nowhere return } - torusUtils = TorusUtils( enableOneKey: true, - network: .sapphire(.SAPPHIRE_MAINNET) - ) + + torusUtils = try TorusUtils(params: TorusOptions(clientId: "Client ID", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true)) + let fnd = NodeDetailManager(network: .sapphire(.SAPPHIRE_MAINNET)) nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierId) @@ -489,13 +452,8 @@ struct ThresholdKeyView: View { showAlert = true alertContent = "Resetting your accuont.." do { - guard let finalKeyData = userData.torusKey.finalKeyData else { - alertContent = "Failed to get public address from userinfo" - showAlert = true - showSpinner = SpinnerLocation.nowhere - return - } - let postboxkey = finalKeyData.privKey! + let finalKeyData = userData.torusKey.finalKeyData + let postboxkey = finalKeyData.privKey let temp_storage_layer = try StorageLayer(enable_logging: true, host_url: "https://metadata.tor.us", server_time_offset: 2) let temp_service_provider = try ServiceProvider(enable_logging: true, postbox_key: postboxkey) let temp_threshold_key = try ThresholdKey( diff --git a/Shared/TssView.swift b/Shared/TssView.swift index 95a7f5b..0cb04f1 100644 --- a/Shared/TssView.swift +++ b/Shared/TssView.swift @@ -1,5 +1,4 @@ import BigInt -import CommonSources import CryptoKit import FetchNodeDetails import Foundation @@ -8,7 +7,7 @@ import TorusUtils import tss_client_swift import Web3SwiftMpcProvider import web3 -import tkey_mpc_swift +import tkey struct TssView: View { @Binding var threshold_key: ThresholdKey! @@ -442,7 +441,7 @@ struct TssView: View { let chainID = 43113 // let RPC_URL = "https://rpc.ankr.com/eth_goerli" // let chainID = 5 - let web3Client = EthereumHttpClient(url: URL(string: RPC_URL)!) + let web3Client = EthereumHttpClient(url: URL(string: RPC_URL)!, network: .sepolia) let amount = 0.001 let toAddress = tssAccount.address diff --git a/Shared/helper.swift b/Shared/helper.swift index 886eda8..1760153 100644 --- a/Shared/helper.swift +++ b/Shared/helper.swift @@ -6,7 +6,7 @@ // import Foundation -import tkey_mpc_swift +import tkey func convertPublicKeyFormat ( publicKey: String, outFormat: PublicKeyEncoding ) throws -> String { let point = try KeyPoint(address: publicKey) diff --git a/tkey_ios.xcodeproj/project.pbxproj b/tkey_ios.xcodeproj/project.pbxproj index 92d758d..56451a4 100644 --- a/tkey_ios.xcodeproj/project.pbxproj +++ b/tkey_ios.xcodeproj/project.pbxproj @@ -22,13 +22,13 @@ B30B6B3B28BCC8AC00812C1E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B30B6B1128BCC8A900812C1E /* ContentView.swift */; }; B30B6B3C28BCC8AC00812C1E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B30B6B1228BCC8AC00812C1E /* Assets.xcassets */; }; B30B6B3D28BCC8AC00812C1E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B30B6B1228BCC8AC00812C1E /* Assets.xcassets */; }; - B33DD88A2B9AC576006EDB31 /* tkey-mpc-swift in Frameworks */ = {isa = PBXBuildFile; productRef = B33DD8892B9AC576006EDB31 /* tkey-mpc-swift */; }; B3E5316629EC4E7E00174AF1 /* ThresholdKeyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E5316529EC4E7E00174AF1 /* ThresholdKeyView.swift */; }; B3E5316729EC4E7E00174AF1 /* ThresholdKeyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E5316529EC4E7E00174AF1 /* ThresholdKeyView.swift */; }; B3E5316929EC4ED000174AF1 /* LoaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E5316829EC4ED000174AF1 /* LoaderView.swift */; }; B3E5316A29EC4ED000174AF1 /* LoaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E5316829EC4ED000174AF1 /* LoaderView.swift */; }; B3E5316F29EE75CA00174AF1 /* KeyChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E5316E29EE75CA00174AF1 /* KeyChain.swift */; }; B3E5317029EE75CA00174AF1 /* KeyChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3E5316E29EE75CA00174AF1 /* KeyChain.swift */; }; + B3E673252C5CB9EE0006A66B /* tkey in Frameworks */ = {isa = PBXBuildFile; productRef = B3E673242C5CB9EE0006A66B /* tkey */; }; DD694C2D29713D2B00B34585 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B30B6B1128BCC8A900812C1E /* ContentView.swift */; }; F00423A22A8B64D600F11B11 /* helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F00423A12A8B64D600F11B11 /* helper.swift */; }; F00423A32A8B64D600F11B11 /* helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F00423A12A8B64D600F11B11 /* helper.swift */; }; @@ -98,8 +98,8 @@ buildActionMask = 2147483647; files = ( 146B0D6929CC01F7000473A8 /* CustomAuth in Frameworks */, + B3E673252C5CB9EE0006A66B /* tkey in Frameworks */, F0B2A2282A9758C000DA2F79 /* Web3SwiftMpcProvider in Frameworks */, - B33DD88A2B9AC576006EDB31 /* tkey-mpc-swift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -221,7 +221,7 @@ packageProductDependencies = ( 146B0D6829CC01F7000473A8 /* CustomAuth */, F0B2A2272A9758C000DA2F79 /* Web3SwiftMpcProvider */, - B33DD8892B9AC576006EDB31 /* tkey-mpc-swift */, + B3E673242C5CB9EE0006A66B /* tkey */, ); productName = "tkey_ios (iOS)"; productReference = B30B6B1728BCC8AC00812C1E /* tkey_ios.app */; @@ -565,6 +565,7 @@ DEVELOPMENT_TEAM = 2Q63NCPY55; ENABLE_PREVIEWS = YES; EXCLUDED_ARCHS = ""; + GCC_NO_COMMON_BLOCKS = NO; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; @@ -603,6 +604,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 2Q63NCPY55; ENABLE_PREVIEWS = YES; + GCC_NO_COMMON_BLOCKS = NO; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; @@ -892,16 +894,16 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/torusresearch/customauth-swift-sdk"; requirement = { - kind = upToNextMajorVersion; - minimumVersion = 7.0.1; + branch = features_update; + kind = branch; }; }; B33DD8882B9AC576006EDB31 /* XCRemoteSwiftPackageReference "tkey-mpc-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/tkey/tkey-mpc-swift"; requirement = { - kind = upToNextMajorVersion; - minimumVersion = 2.0.1; + branch = update_features; + kind = branch; }; }; F0B2A2262A9758C000DA2F79 /* XCRemoteSwiftPackageReference "web3-swift-mpc-provider" */ = { @@ -909,7 +911,7 @@ repositoryURL = "https://github.com/tkey/web3-swift-mpc-provider/"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 2.0.1; + minimumVersion = 4.0.1; }; }; /* End XCRemoteSwiftPackageReference section */ @@ -920,10 +922,10 @@ package = 146B0D6729CC01F7000473A8 /* XCRemoteSwiftPackageReference "customauth-swift-sdk" */; productName = CustomAuth; }; - B33DD8892B9AC576006EDB31 /* tkey-mpc-swift */ = { + B3E673242C5CB9EE0006A66B /* tkey */ = { isa = XCSwiftPackageProductDependency; package = B33DD8882B9AC576006EDB31 /* XCRemoteSwiftPackageReference "tkey-mpc-swift" */; - productName = "tkey-mpc-swift"; + productName = tkey; }; F0B2A2272A9758C000DA2F79 /* Web3SwiftMpcProvider */ = { isa = XCSwiftPackageProductDependency; diff --git a/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index cb8c076..b972e52 100644 --- a/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,22 +1,13 @@ { - "originHash" : "e732749c7058f7671b4b14f915ff2b9bd4154d8fdb8270ce8592cdaa9a7c6216", + "originHash" : "d2f1a3776fdb81cd3fb63e88877768f05471648d110346bee3071dd6e037c127", "pins" : [ - { - "identity" : "anycodable", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Flight-School/AnyCodable", - "state" : { - "revision" : "862808b2070cd908cb04f9aafe7de83d35f81b05", - "version" : "0.6.7" - } - }, { "identity" : "bigint", "kind" : "remoteSourceControl", - "location" : "https://github.com/attaswift/BigInt", + "location" : "https://github.com/attaswift/BigInt.git", "state" : { - "revision" : "0ed110f7555c34ff468e72e1686e59721f2b0da6", - "version" : "5.3.0" + "revision" : "793a7fac0bfc318e85994bf6900652e827aef33e", + "version" : "5.4.1" } }, { @@ -24,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/krzyzanowskim/CryptoSwift.git", "state" : { - "revision" : "32f641cf24fc7abc1c591a2025e9f2f572648b0f", - "version" : "1.7.2" + "revision" : "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0", + "version" : "1.8.2" } }, { @@ -33,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tkey/curvelib.swift", "state" : { - "revision" : "7dad3bf1793de263f83406c08c18c9316abf082f", - "version" : "0.1.2" + "revision" : "9f88bd5e56d1df443a908f7a7e81ae4f4d9170ea", + "version" : "1.0.1" } }, { @@ -42,17 +33,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/torusresearch/customauth-swift-sdk", "state" : { - "revision" : "0f4b42136982e8cd21d57b2249505f30691f1ead", - "version" : "7.0.1" + "branch" : "features_update", + "revision" : "dfa6cb5e935524c0b32c430dcbbc32f02503e337" } }, { "identity" : "fetch-node-details-swift", "kind" : "remoteSourceControl", - "location" : "https://github.com/torusresearch/fetch-node-details-swift.git", + "location" : "https://github.com/torusresearch/fetch-node-details-swift", "state" : { - "revision" : "d591af500f32ce3c88d04af9bb74d746585acfea", - "version" : "5.1.0" + "revision" : "4bd96c33ba8d02d9e27190c5c7cedf09cfdfd656", + "version" : "6.0.3" } }, { @@ -87,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/socketio/socket.io-client-swift", "state" : { - "revision" : "af5ce97b755d964235348d96f6db5cbdcbe334a5", - "version" : "16.0.1" + "revision" : "175da8b5156f6b132436f0676cc84c2f6a766b6e", + "version" : "16.1.0" } }, { @@ -96,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/daltoniam/Starscream", "state" : { - "revision" : "df8d82047f6654d8e4b655d1b1525c64e1059d21", - "version" : "4.0.4" + "revision" : "ac6c0fc9da221873e01bd1a0d4818498a71eef33", + "version" : "4.0.6" } }, { @@ -105,8 +96,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-atomics.git", "state" : { - "revision" : "6c89474e62719ddcc1e9614989fff2f68208fe10", - "version" : "1.1.0" + "revision" : "cd142fd2f64be2100422d658e7411e39489da985", + "version" : "1.2.0" } }, { @@ -114,8 +105,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections.git", "state" : { - "revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", - "version" : "1.0.4" + "revision" : "3d2dc41a01f9e49d84f0a3925fb858bed64f702d", + "version" : "1.1.2" + } + }, + { + "identity" : "swift-http-types", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-types", + "state" : { + "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", + "version" : "1.3.0" } }, { @@ -123,8 +123,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-log.git", "state" : { - "revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed", - "version" : "1.5.3" + "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", + "version" : "1.6.1" } }, { @@ -132,8 +132,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "cf281631ff10ec6111f2761052aa81896a83a007", - "version" : "2.58.0" + "revision" : "e4abde8be0e49dc7d66e6eed651254accdcd9533", + "version" : "2.69.0" } }, { @@ -141,8 +141,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997", - "version" : "1.19.0" + "revision" : "05c36b57453d23ea63785d58a7dbc7b70ba1745e", + "version" : "1.23.0" + } + }, + { + "identity" : "swift-nio-http2", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-http2.git", + "state" : { + "revision" : "a0224f3d20438635dd59c9fcc593520d80d131d0", + "version" : "1.33.0" } }, { @@ -150,8 +159,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-ssl.git", "state" : { - "revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9", - "version" : "2.25.0" + "revision" : "2b09805797f21c380f7dc9bedaab3157c5508efb", + "version" : "2.27.0" } }, { @@ -159,8 +168,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-transport-services.git", "state" : { - "revision" : "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58", - "version" : "1.19.0" + "revision" : "38ac8221dd20674682148d6451367f89c2652980", + "version" : "1.21.0" + } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system.git", + "state" : { + "revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5", + "version" : "1.3.2" } }, { @@ -168,8 +186,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tkey/tkey-mpc-swift", "state" : { - "revision" : "195235357f36edec4ec87189c222e1992403ad4f", - "version" : "2.0.1" + "branch" : "update_features", + "revision" : "cc7b062745e82d114dd4fdec1c9641665727e539" } }, { @@ -178,16 +196,16 @@ "location" : "https://github.com/torusresearch/torus-utils-swift", "state" : { "revision" : "3fb829e71caa275556a067a1ffa1ca579bafbf8e", - "version" : "7.0.1" + "version" : "9.0.0" } }, { "identity" : "tss-client-swift", "kind" : "remoteSourceControl", - "location" : "https://github.com/torusresearch/tss-client-swift/", + "location" : "https://github.com/torusresearch/tss-client-swift.git", "state" : { - "revision" : "9590a1d784177d4679eca62d4dbfe781e9870c40", - "version" : "2.0.2" + "revision" : "e1262449b2810b10c7ac2b29215aebf4d8f422f7", + "version" : "1.0.15" } }, { @@ -195,8 +213,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tkey/web3-swift-mpc-provider/", "state" : { - "revision" : "4945e281822147b1faa2dea782ebe7b912343ddf", - "version" : "2.0.1" + "revision" : "162be0fa5c5130965ce98365fd9dd7b2503d76a9", + "version" : "1.0.1" } }, { @@ -204,8 +222,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/argentlabs/web3.swift", "state" : { - "revision" : "8ca33e700ed8de6137a0e1471017aa3b3c8de0db", - "version" : "1.6.0" + "revision" : "1e75f98a5738c470b23bbfffa9314e9f788df76b", + "version" : "1.6.1" } }, { @@ -213,8 +231,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/websocket-kit.git", "state" : { - "revision" : "53fe0639a98903858d0196b699720decb42aee7b", - "version" : "2.14.0" + "revision" : "4232d34efa49f633ba61afde365d3896fc7f8740", + "version" : "2.15.0" } } ], From 96393fa840c503b44f60edfee58b95b41fc4e236 Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:34:03 +0200 Subject: [PATCH 2/3] Update project.pbxproj --- tkey_ios.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tkey_ios.xcodeproj/project.pbxproj b/tkey_ios.xcodeproj/project.pbxproj index 56451a4..96e2ea0 100644 --- a/tkey_ios.xcodeproj/project.pbxproj +++ b/tkey_ios.xcodeproj/project.pbxproj @@ -910,8 +910,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/tkey/web3-swift-mpc-provider/"; requirement = { - kind = upToNextMajorVersion; - minimumVersion = 4.0.1; + branch = spm_fix_path; + kind = branch; }; }; /* End XCRemoteSwiftPackageReference section */ From 861a4c0e62e155e425b0dd31ff43773d7eb06f2e Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:46:01 +0200 Subject: [PATCH 3/3] cleanup --- Shared/LoginModel.swift | 5 ++-- Shared/ThresholdKeyView.swift | 5 +++- Shared/TssView.swift | 12 ++++----- .../xcshareddata/swiftpm/Package.resolved | 27 +++++++------------ 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Shared/LoginModel.swift b/Shared/LoginModel.swift index 4e58178..45d3d1b 100644 --- a/Shared/LoginModel.swift +++ b/Shared/LoginModel.swift @@ -1,9 +1,10 @@ import CustomAuth import Foundation +import FetchNodeDetails import TorusUtils let ClientID = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ" -let Network = TorusNetwork.sapphire(.SAPPHIRE_MAINNET) +let Network: TorusNetwork = .sapphire(.SAPPHIRE_MAINNET) let verifier = "w3a-google-demo" class LoginModel: ObservableObject { @@ -29,7 +30,7 @@ class LoginModel: ObservableObject { func loginWithCustomAuth() { Task { do { - let tdsdk = try CustomAuth(config: CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: ClientID)) + let tdsdk = try CustomAuth(config: CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: Network, enableOneKey: true, web3AuthClientId: ClientID)) let data = try await tdsdk.triggerLogin(args: SubVerifierDetails(typeOfLogin: .google, verifier: verifier, clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com", redirectURL: "https://scripts.toruswallet.io/redirect.html")) diff --git a/Shared/ThresholdKeyView.swift b/Shared/ThresholdKeyView.swift index 53fb295..d356c40 100644 --- a/Shared/ThresholdKeyView.swift +++ b/Shared/ThresholdKeyView.swift @@ -144,12 +144,15 @@ struct ThresholdKeyView: View { let postboxkey = finalKeyData.privKey + verifier = userData.singleVerifierResponse.userInfo.verifier + verifierId = userData.singleVerifierResponse.userInfo.verifierId + postboxkeyGlobal = postboxkey let sessionData = userData.torusKey.sessionData let sessionTokenData = sessionData.sessionTokenData signatures = sessionTokenData.map { token in - return [ "data": Data(hex: token!.token).base64EncodedString(), + return [ "data": token!.token, "sig": token!.signature ] } assert(signatures.isEmpty != true) diff --git a/Shared/TssView.swift b/Shared/TssView.swift index 97455fe..c055d5b 100644 --- a/Shared/TssView.swift +++ b/Shared/TssView.swift @@ -4,7 +4,7 @@ import FetchNodeDetails import Foundation import SwiftUI import TorusUtils -import tss_client_swift +import tssClientSwift import Web3SwiftMpcProvider import web3 import tkey @@ -375,7 +375,7 @@ struct TssView: View { let params = EthTssAccountParams(publicKey: fullAddress, factorKey: factorKey, tssNonce: tssNonce, tssShare: tssShare, tssIndex: tssIndex, selectedTag: selected_tag, verifier: verifier, verifierID: verifierId, nodeIndexes: [], tssEndpoints: tssEndpoints, authSigs: sigs) - let account = EthereumTssAccount(params: params) + let account = try EthereumTssAccount(params: params) let msg = "hello world" let signature = try account.sign(message: msg) @@ -383,8 +383,8 @@ struct TssView: View { let s = BigInt( sign: .plus, magnitude: BigUInt(signature.prefix(64).suffix(32))) let v = UInt8(signature.suffix(1).toHexString(), radix: 16 )! - let msgHash = TSSHelpers.hashMessage(message: msg) - if TSSHelpers.verifySignature(msgHash: msgHash, s: s, r: r, v: v, pubKey: Data(hex: fullAddress)) { + let msgHash = try TSSHelpers.hashMessage(message: msg) + if TSSHelpers.verifySignature(msgHash: msgHash, s: s, r: r, v: v, pubKey: Data(hex: fullAddress)!) { let sigHex = try TSSHelpers.hexSignature(s: s, r: r, v: v) alertContent = "Signature: " + sigHex showAlert = true @@ -427,7 +427,7 @@ struct TssView: View { let tssPubKeyPoint = try KeyPoint(address: finalPubKey) let fullTssPubKey = try tssPubKeyPoint.getPublicKey(format: PublicKeyEncoding.FullAddress) - let evmAddress = KeyUtil.generateAddress(from: Data(hex: fullTssPubKey).suffix(64) ) + let evmAddress = KeyUtil.generateAddress(from: Data(hex: fullTssPubKey)!.suffix(64) ) print(evmAddress.toChecksumAddress()) // step 2. getting signature @@ -435,7 +435,7 @@ struct TssView: View { let params = EthTssAccountParams(publicKey: fullTssPubKey, factorKey: factorKey, tssNonce: tssNonce, tssShare: tssShare, tssIndex: tssIndex, selectedTag: selected_tag, verifier: verifier, verifierID: verifierId, nodeIndexes: tssPublicAddressInfo.nodeIndexes, tssEndpoints: tssEndpoints, authSigs: sigs) - let tssAccount = EthereumTssAccount(params: params) + let tssAccount = try EthereumTssAccount(params: params) let RPC_URL = "https://rpc.sepolia.org" let chainID = 11155111 diff --git a/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b972e52..aac2c72 100644 --- a/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/tkey_ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -10,15 +10,6 @@ "version" : "5.4.1" } }, - { - "identity" : "cryptoswift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/krzyzanowskim/CryptoSwift.git", - "state" : { - "revision" : "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0", - "version" : "1.8.2" - } - }, { "identity" : "curvelib.swift", "kind" : "remoteSourceControl", @@ -69,8 +60,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/GigaBitcoin/secp256k1.swift.git", "state" : { - "revision" : "1a14e189def5eaa92f839afdd2faad8e43b61a6e", - "version" : "0.12.2" + "revision" : "9683e8e311c76d8114cd308b697dad2f9fc58fed", + "version" : "0.17.0" } }, { @@ -150,8 +141,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-http2.git", "state" : { - "revision" : "a0224f3d20438635dd59c9fcc593520d80d131d0", - "version" : "1.33.0" + "revision" : "b5f7062b60e4add1e8c343ba4eb8da2e324b3a94", + "version" : "1.34.0" } }, { @@ -195,7 +186,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/torusresearch/torus-utils-swift", "state" : { - "revision" : "3fb829e71caa275556a067a1ffa1ca579bafbf8e", + "revision" : "303dc2cf41db7c10f769855edad0e717ced2d554", "version" : "9.0.0" } }, @@ -204,8 +195,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/torusresearch/tss-client-swift.git", "state" : { - "revision" : "e1262449b2810b10c7ac2b29215aebf4d8f422f7", - "version" : "1.0.15" + "branch" : "4.0.1", + "revision" : "508e6df4ff34f7e40df99cec0f0a6dbc4e319aa7" } }, { @@ -213,8 +204,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tkey/web3-swift-mpc-provider/", "state" : { - "revision" : "162be0fa5c5130965ce98365fd9dd7b2503d76a9", - "version" : "1.0.1" + "branch" : "spm_fix_path", + "revision" : "bf6909974c278e791b803a189cee4ec1858141c3" } }, {