diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 867e601..c0fc46f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,7 +2,6 @@ on: push: branches: - main - - alpha pull_request: types: - opened @@ -20,4 +19,4 @@ jobs: with: xcode-version: "14.2.0" - name: package - run: xcodebuild test -scheme tkey_pkg -destination "platform=iOS Simulator,OS=16.2,name=iPhone 14" COMPILER_INDEX_STORE_ENABLE=NO \ No newline at end of file + run: xcodebuild test -scheme tkey-mpc-swift -destination "platform=iOS Simulator,OS=16.2,name=iPhone 14" COMPILER_INDEX_STORE_ENABLE=NO \ No newline at end of file diff --git a/Package.swift b/Package.swift index a131d3f..27d38bd 100644 --- a/Package.swift +++ b/Package.swift @@ -4,20 +4,20 @@ import PackageDescription let package = Package( - name: "tkey_pkg", + name: "tkey-mpc-swift", platforms: [ - .iOS(SupportedPlatform.IOSVersion.v14), + .iOS(.v13), .macOS(.v10_15) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( - name: "ThresholdKey", - targets: ["tkey-pkg"]), + name: "tkey-mpc-swift", + targets: ["tkey-mpc-swift"]), ], 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: "6.1.0"), + .package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift" , from: "7.0.0"), // dev dependencies only .package(name:"CryptoSwift", url: "https://github.com/krzyzanowskim/CryptoSwift.git",from: "1.5.1"), .package(name:"jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"), @@ -28,18 +28,18 @@ let package = Package( .binaryTarget(name: "libtkey", path: "Sources/libtkey/libtkey.xcframework" ), - .target(name: "lib", + .target(name: "tkey", dependencies: ["libtkey"], path: "Sources/libtkey" ), .target( - name: "tkey-pkg", - dependencies: ["lib", "TorusUtils"], + name: "tkey-mpc-swift", + dependencies: ["tkey", "TorusUtils"], path: "Sources/ThresholdKey" ), .testTarget( name: "tkey-pkgTests", - dependencies: ["tkey-pkg", "CryptoSwift", .product(name: "JWTKit", package: "jwt-kit")], + dependencies: ["tkey-mpc-swift", "CryptoSwift", .product(name: "JWTKit", package: "jwt-kit")], path: "Tests/tkeypkgTests" ), ] diff --git a/Sources/ThresholdKey/Common/KeyPoint.swift b/Sources/ThresholdKey/Common/KeyPoint.swift index c83a1a1..dabe7ae 100644 --- a/Sources/ThresholdKey/Common/KeyPoint.swift +++ b/Sources/ThresholdKey/Common/KeyPoint.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif @@ -150,7 +150,7 @@ public final class KeyPoint: Equatable { key_point_encode(pointer, encoder_format, error) }) guard errorCode == 0 else { - throw RuntimeError("Error in KeyPoint, getAsCompressedPublicKey") + throw RuntimeError("Error in KeyPoint, getPublicKey") } let compressed = String.init(cString: result!) string_free(result) diff --git a/Sources/ThresholdKey/Common/NodeDetails.swift b/Sources/ThresholdKey/Common/NodeDetails.swift index b3ec4ac..6eb9b3e 100644 --- a/Sources/ThresholdKey/Common/NodeDetails.swift +++ b/Sources/ThresholdKey/Common/NodeDetails.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) -import lib +#if canImport(tkey) +import tkey #endif public final class NodeDetails { diff --git a/Sources/ThresholdKey/Common/PrivateKey.swift b/Sources/ThresholdKey/Common/PrivateKey.swift index f05dcdf..a00644d 100644 --- a/Sources/ThresholdKey/Common/PrivateKey.swift +++ b/Sources/ThresholdKey/Common/PrivateKey.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class PrivateKey { diff --git a/Sources/ThresholdKey/Common/ShareStore.swift b/Sources/ThresholdKey/Common/ShareStore.swift index 9bcf6ad..e2db1a1 100644 --- a/Sources/ThresholdKey/Common/ShareStore.swift +++ b/Sources/ThresholdKey/Common/ShareStore.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareStore { diff --git a/Sources/ThresholdKey/Common/TssOptions.swift b/Sources/ThresholdKey/Common/TssOptions.swift index 4cd3479..a4a43f8 100644 --- a/Sources/ThresholdKey/Common/TssOptions.swift +++ b/Sources/ThresholdKey/Common/TssOptions.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) -import lib +#if canImport(tkey) +import tkey #endif public final class TssOptions { diff --git a/Sources/ThresholdKey/GenerateShareStoreResult.swift b/Sources/ThresholdKey/GenerateShareStoreResult.swift index 046ff77..c057260 100644 --- a/Sources/ThresholdKey/GenerateShareStoreResult.swift +++ b/Sources/ThresholdKey/GenerateShareStoreResult.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class GenerateShareStoreResult { diff --git a/Sources/ThresholdKey/KeyDetails.swift b/Sources/ThresholdKey/KeyDetails.swift index 7a1ed9c..1c3b462 100644 --- a/Sources/ThresholdKey/KeyDetails.swift +++ b/Sources/ThresholdKey/KeyDetails.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class KeyDetails { diff --git a/Sources/ThresholdKey/KeyPointArray.swift b/Sources/ThresholdKey/KeyPointArray.swift index 57ca029..5c50203 100644 --- a/Sources/ThresholdKey/KeyPointArray.swift +++ b/Sources/ThresholdKey/KeyPointArray.swift @@ -1,7 +1,7 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public class KeyPointArray { diff --git a/Sources/ThresholdKey/KeyReconstructionDetails.swift b/Sources/ThresholdKey/KeyReconstructionDetails.swift index 088e439..138d785 100644 --- a/Sources/ThresholdKey/KeyReconstructionDetails.swift +++ b/Sources/ThresholdKey/KeyReconstructionDetails.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class KeyReconstructionDetails: Codable { diff --git a/Sources/ThresholdKey/LocalMetadataTransitions.swift b/Sources/ThresholdKey/LocalMetadataTransitions.swift index 1ed97d2..5620970 100644 --- a/Sources/ThresholdKey/LocalMetadataTransitions.swift +++ b/Sources/ThresholdKey/LocalMetadataTransitions.swift @@ -1,7 +1,7 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class LocalMetadataTransitions { diff --git a/Sources/ThresholdKey/Metadata.swift b/Sources/ThresholdKey/Metadata.swift index bcfd3ed..fa5e94c 100644 --- a/Sources/ThresholdKey/Metadata.swift +++ b/Sources/ThresholdKey/Metadata.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class Metadata { diff --git a/Sources/ThresholdKey/Modules/PrivateKeysModule.swift b/Sources/ThresholdKey/Modules/PrivateKeysModule.swift index e7f6b71..c7a3396 100644 --- a/Sources/ThresholdKey/Modules/PrivateKeysModule.swift +++ b/Sources/ThresholdKey/Modules/PrivateKeysModule.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public struct KeyData: Decodable { diff --git a/Sources/ThresholdKey/Modules/SecurityQuestionModule.swift b/Sources/ThresholdKey/Modules/SecurityQuestionModule.swift index a374d46..f4917c1 100644 --- a/Sources/ThresholdKey/Modules/SecurityQuestionModule.swift +++ b/Sources/ThresholdKey/Modules/SecurityQuestionModule.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class SecurityQuestionModule { diff --git a/Sources/ThresholdKey/Modules/SeedPhraseModule.swift b/Sources/ThresholdKey/Modules/SeedPhraseModule.swift index 25da1a6..b18034d 100644 --- a/Sources/ThresholdKey/Modules/SeedPhraseModule.swift +++ b/Sources/ThresholdKey/Modules/SeedPhraseModule.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public struct SeedPhrase: Codable { diff --git a/Sources/ThresholdKey/Modules/ShareSerializationModule.swift b/Sources/ThresholdKey/Modules/ShareSerializationModule.swift index 590e40c..32a51ea 100644 --- a/Sources/ThresholdKey/Modules/ShareSerializationModule.swift +++ b/Sources/ThresholdKey/Modules/ShareSerializationModule.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareSerializationModule { diff --git a/Sources/ThresholdKey/Modules/ShareTransferModule.swift b/Sources/ThresholdKey/Modules/ShareTransferModule.swift index a1dfa17..04a11cf 100644 --- a/Sources/ThresholdKey/Modules/ShareTransferModule.swift +++ b/Sources/ThresholdKey/Modules/ShareTransferModule.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareTransferModule { diff --git a/Sources/ThresholdKey/Modules/TssModule.swift b/Sources/ThresholdKey/Modules/TssModule.swift index 32670e6..b266e89 100644 --- a/Sources/ThresholdKey/Modules/TssModule.swift +++ b/Sources/ThresholdKey/Modules/TssModule.swift @@ -1,8 +1,8 @@ import Foundation import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif import CommonSources import FetchNodeDetails diff --git a/Sources/ThresholdKey/Polynomial.swift b/Sources/ThresholdKey/Polynomial.swift index 164765e..926f5bc 100644 --- a/Sources/ThresholdKey/Polynomial.swift +++ b/Sources/ThresholdKey/Polynomial.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) -import lib +#if canImport(tkey) +import tkey #endif public final class Polynomial { diff --git a/Sources/ThresholdKey/PublicPolynomial.swift b/Sources/ThresholdKey/PublicPolynomial.swift index 877427e..88f3a79 100644 --- a/Sources/ThresholdKey/PublicPolynomial.swift +++ b/Sources/ThresholdKey/PublicPolynomial.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) -import lib +#if canImport(tkey) +import tkey #endif public final class PublicPolynomial { diff --git a/Sources/ThresholdKey/RssComm.swift b/Sources/ThresholdKey/RssComm.swift index 4a5b142..0b41ba5 100644 --- a/Sources/ThresholdKey/RssComm.swift +++ b/Sources/ThresholdKey/RssComm.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) -import lib +#if canImport(tkey) +import tkey #endif public final class RssComm { diff --git a/Sources/ThresholdKey/ServiceProvider.swift b/Sources/ThresholdKey/ServiceProvider.swift index 0ca0063..dde8266 100644 --- a/Sources/ThresholdKey/ServiceProvider.swift +++ b/Sources/ThresholdKey/ServiceProvider.swift @@ -1,7 +1,7 @@ import Foundation import TorusUtils -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif import FetchNodeDetails import CommonSources diff --git a/Sources/ThresholdKey/ShareMap.swift b/Sources/ThresholdKey/ShareMap.swift index 4103f42..0a62922 100644 --- a/Sources/ThresholdKey/ShareMap.swift +++ b/Sources/ThresholdKey/ShareMap.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareMap { diff --git a/Sources/ThresholdKey/ShareStoreArray.swift b/Sources/ThresholdKey/ShareStoreArray.swift index c921a09..074646d 100644 --- a/Sources/ThresholdKey/ShareStoreArray.swift +++ b/Sources/ThresholdKey/ShareStoreArray.swift @@ -1,7 +1,7 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public class ShareStoreArray { diff --git a/Sources/ThresholdKey/ShareStoreMap.swift b/Sources/ThresholdKey/ShareStoreMap.swift index 7a40ec9..518082d 100644 --- a/Sources/ThresholdKey/ShareStoreMap.swift +++ b/Sources/ThresholdKey/ShareStoreMap.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareStoreMap { diff --git a/Sources/ThresholdKey/ShareStorePolyIdIndexMap.swift b/Sources/ThresholdKey/ShareStorePolyIdIndexMap.swift index 1df3084..945f068 100644 --- a/Sources/ThresholdKey/ShareStorePolyIdIndexMap.swift +++ b/Sources/ThresholdKey/ShareStorePolyIdIndexMap.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareStorePolyIdIndexMap { diff --git a/Sources/ThresholdKey/ShareTransferStore.swift b/Sources/ThresholdKey/ShareTransferStore.swift index b2f7310..dd98148 100644 --- a/Sources/ThresholdKey/ShareTransferStore.swift +++ b/Sources/ThresholdKey/ShareTransferStore.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif public final class ShareTransferStore { diff --git a/Sources/ThresholdKey/StorageLayer.swift b/Sources/ThresholdKey/StorageLayer.swift index 92ce5ee..fc457a7 100644 --- a/Sources/ThresholdKey/StorageLayer.swift +++ b/Sources/ThresholdKey/StorageLayer.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif diff --git a/Sources/ThresholdKey/ThresholdKey.swift b/Sources/ThresholdKey/ThresholdKey.swift index aaf3721..020a7b7 100644 --- a/Sources/ThresholdKey/ThresholdKey.swift +++ b/Sources/ThresholdKey/ThresholdKey.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif import CommonSources import TorusUtils diff --git a/Sources/ThresholdKey/Version.swift b/Sources/ThresholdKey/Version.swift index 754415b..2ae82ea 100644 --- a/Sources/ThresholdKey/Version.swift +++ b/Sources/ThresholdKey/Version.swift @@ -1,6 +1,6 @@ import Foundation -#if canImport(lib) - import lib +#if canImport(tkey) + import tkey #endif /// Returns the library version. diff --git a/Sources/libtkey/libtkey.xcframework/Info.plist b/Sources/libtkey/libtkey.xcframework/Info.plist index d14a1c2..4957386 100644 --- a/Sources/libtkey/libtkey.xcframework/Info.plist +++ b/Sources/libtkey/libtkey.xcframework/Info.plist @@ -8,7 +8,7 @@ BinaryPath libtkey.a LibraryIdentifier - macos-arm64_x86_64 + ios-arm64_x86_64-simulator LibraryPath libtkey.a SupportedArchitectures @@ -17,13 +17,15 @@ x86_64 SupportedPlatform - macos + ios + SupportedPlatformVariant + simulator BinaryPath libtkey.a LibraryIdentifier - ios-arm64_x86_64-simulator + macos-arm64_x86_64 LibraryPath libtkey.a SupportedArchitectures @@ -32,9 +34,7 @@ x86_64 SupportedPlatform - ios - SupportedPlatformVariant - simulator + macos CFBundlePackageType diff --git a/Sources/libtkey/libtkey.xcframework/ios-arm64/libtkey.a b/Sources/libtkey/libtkey.xcframework/ios-arm64/libtkey.a deleted file mode 100644 index 4d89a2b..0000000 Binary files a/Sources/libtkey/libtkey.xcframework/ios-arm64/libtkey.a and /dev/null differ diff --git a/Sources/libtkey/libtkey.xcframework/ios-arm64_x86_64-simulator/libtkey.a b/Sources/libtkey/libtkey.xcframework/ios-arm64_x86_64-simulator/libtkey.a index 68a4bcc..d5fb571 100644 Binary files a/Sources/libtkey/libtkey.xcframework/ios-arm64_x86_64-simulator/libtkey.a and b/Sources/libtkey/libtkey.xcframework/ios-arm64_x86_64-simulator/libtkey.a differ diff --git a/Sources/libtkey/libtkey.xcframework/macos-arm64_x86_64/libtkey.a b/Sources/libtkey/libtkey.xcframework/macos-arm64_x86_64/libtkey.a index cc4907d..c6961e2 100644 Binary files a/Sources/libtkey/libtkey.xcframework/macos-arm64_x86_64/libtkey.a and b/Sources/libtkey/libtkey.xcframework/macos-arm64_x86_64/libtkey.a differ diff --git a/Tests/tkeypkgTests/IntegrationTests.swift b/Tests/tkeypkgTests/IntegrationTests.swift index 1c07a5a..e8b14e5 100644 --- a/Tests/tkeypkgTests/IntegrationTests.swift +++ b/Tests/tkeypkgTests/IntegrationTests.swift @@ -1,9 +1,9 @@ import CommonSources import FetchNodeDetails import Foundation +@testable import tkey_mpc_swift import TorusUtils import XCTest -@testable import tkey_pkg final class integrationTests: XCTestCase { func test_TssModule() async throws { @@ -21,11 +21,14 @@ final class integrationTests: XCTestCase { 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 signature = retrievedShare.sessionData?.sessionTokenData - let signatures = signature!.compactMap { item in - item?.signature + + let signature_collection = retrievedShare.sessionData!.sessionTokenData.map { token in + ["data": Data(hex: token!.token).base64EncodedString(), + "sig": token!.signature] } + let sigs: [String] = try signature_collection.map { String(decoding: try JSONSerialization.data(withJSONObject: $0), as: UTF8.self) } + 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, useTss: true, verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, nodeDetails: nodeDetail) @@ -47,7 +50,7 @@ final class integrationTests: XCTestCase { let factorKey = try PrivateKey.generate() let factorPub = try factorKey.toPublic() try TssModule.backup_share_with_factor_key(threshold_key: threshold, shareIndex: shareIndex.hex, factorKey: factorKey.hex) - + try await TssModule.create_tagged_tss_share(threshold_key: threshold, tss_tag: tssTag, deviceTssShare: nil, factorPub: factorPub, deviceTssIndex: 2, nodeDetails: nodeDetail, torusUtils: torusUtils) let (tss_index, tss_share) = try await TssModule.get_tss_share(threshold_key: threshold, tss_tag: tssTag, factorKey: factorKey.hex) @@ -57,7 +60,7 @@ final class integrationTests: XCTestCase { let newFactorKey = try PrivateKey.generate() let newFactorPub = try newFactorKey.toPublic() // 2/2 -> 2/3 tss - try await TssModule.generate_tss_share(threshold_key: threshold, tss_tag: tssTag, input_tss_share: tss_share, tss_input_index: Int32(tss_index)!, auth_signatures: signatures, new_factor_pub: newFactorPub, new_tss_index: 3, nodeDetails: nodeDetail, torusUtils: torusUtils) + try await TssModule.generate_tss_share(threshold_key: threshold, tss_tag: tssTag, input_tss_share: tss_share, tss_input_index: Int32(tss_index)!, auth_signatures: sigs, new_factor_pub: newFactorPub, new_tss_index: 3, nodeDetails: nodeDetail, torusUtils: torusUtils) let (tss_index3, tss_share3) = try await TssModule.get_tss_share(threshold_key: threshold, tss_tag: tssTag, factorKey: newFactorKey.hex) let (_, tss_share_updated) = try await TssModule.get_tss_share(threshold_key: threshold, tss_tag: tssTag, factorKey: factorKey.hex) @@ -74,7 +77,7 @@ final class integrationTests: XCTestCase { manual_sync: false ) _ = try! await threshold2.initialize() - + try await threshold2.input_factor_key(factorKey: factorKey.hex) _ = try! await threshold2.reconstruct() @@ -91,7 +94,7 @@ final class integrationTests: XCTestCase { XCTAssertEqual(tss_index3, tss_index2_3) // 2/3 -> 2/2 tss - try await TssModule.delete_tss_share(threshold_key: threshold, tss_tag: tssTag, input_tss_share: tss_share3, tss_input_index: Int32(tss_index3)!, auth_signatures: signatures, delete_factor_pub: newFactorPub, nodeDetails: nodeDetail, torusUtils: torusUtils) + try await TssModule.delete_tss_share(threshold_key: threshold, tss_tag: tssTag, input_tss_share: tss_share3, tss_input_index: Int32(tss_index3)!, auth_signatures: sigs, delete_factor_pub: newFactorPub, nodeDetails: nodeDetail, torusUtils: torusUtils) // XCTAssertThrowsError( try await TssModule.get_tss_share(threshold_key: threshold, tss_tag: tssTag, factorKey: newFactorKey.hex) ) let (tss_index_updated2, tss_share_updated2) = try await TssModule.get_tss_share(threshold_key: threshold, tss_tag: tssTag, factorKey: factorKey.hex) @@ -101,10 +104,10 @@ final class integrationTests: XCTestCase { XCTAssertNotEqual(tss_share_updated, tss_share_updated2) // 2/2 -> 2/3 tss - try await TssModule.add_factor_pub(threshold_key: threshold, tss_tag: tssTag, factor_key: factorKey.hex, auth_signatures: signatures, new_factor_pub: newFactorPub, new_tss_index: 3, nodeDetails: nodeDetail, torusUtils: torusUtils) + try await TssModule.add_factor_pub(threshold_key: threshold, tss_tag: tssTag, factor_key: factorKey.hex, auth_signatures: sigs, new_factor_pub: newFactorPub, new_tss_index: 3, nodeDetails: nodeDetail, torusUtils: torusUtils) // 2/3 -> 2/2 tss - try await TssModule.delete_factor_pub(threshold_key: threshold, tss_tag: tssTag, factor_key: factorKey.hex, auth_signatures: signatures, delete_factor_pub: newFactorPub, nodeDetails: nodeDetail, torusUtils: torusUtils) + try await TssModule.delete_factor_pub(threshold_key: threshold, tss_tag: tssTag, factor_key: factorKey.hex, auth_signatures: sigs, delete_factor_pub: newFactorPub, nodeDetails: nodeDetail, torusUtils: torusUtils) } func test_TssModule_multi_tag() async throws { @@ -125,12 +128,14 @@ final class integrationTests: XCTestCase { 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) - print(retrievedShare) - let signature = retrievedShare.sessionData!.sessionTokenData - let signatures = signature.compactMap { item in - item?.signature + + let signature_collection = retrievedShare.sessionData!.sessionTokenData.map { token in + ["data": Data(hex: token!.token).base64EncodedString(), + "sig": token!.signature] } + let sigs: [String] = try signature_collection.map { String(decoding: try JSONSerialization.data(withJSONObject: $0), as: UTF8.self) } + 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, useTss: true, verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL, nodeDetails: nodeDetail) @@ -149,9 +154,10 @@ final class integrationTests: XCTestCase { let share = try threshold.output_share(shareIndex: shareIndex.hex) print(share) + // TODO: This requires further investigation // Too much tags with too much shares cause the ios complaint // `Receive failed with error "Message too long"` - let testTags = ["tag1", "tag2", "tag3", "tags4"] + let testTags = ["tag1", "tag2", "tag3"] var tssMods: [(ThresholdKey, String)] = [] @@ -190,7 +196,7 @@ final class integrationTests: XCTestCase { newFactorKeys.append(newFactorKey) newFactorPubs.append(newFactorPub) - try await TssModule.add_factor_pub(threshold_key: threshold, tss_tag: tag, factor_key: factorKeys[index].hex, auth_signatures: signatures, new_factor_pub: newFactorPub, new_tss_index: 3, nodeDetails: nodeDetail, torusUtils: torusUtils) + try await TssModule.add_factor_pub(threshold_key: threshold, tss_tag: tag, factor_key: factorKeys[index].hex, auth_signatures: sigs, new_factor_pub: newFactorPub, new_tss_index: 3, nodeDetails: nodeDetail, torusUtils: torusUtils) try await threshold.sync_local_metadata_transistions() @@ -257,7 +263,7 @@ final class integrationTests: XCTestCase { newFactorKeys2.append(newFactorKey2) newFactorPubs2.append(newFactorPub2) - try await TssModule.delete_factor_pub(threshold_key: threshold, tss_tag: tag, factor_key: newFactorKeys[index].hex, auth_signatures: signatures, delete_factor_pub: newFactorPubs[index], nodeDetails: nodeDetail, torusUtils: torusUtils) + try await TssModule.delete_factor_pub(threshold_key: threshold, tss_tag: tag, factor_key: newFactorKeys[index].hex, auth_signatures: sigs, delete_factor_pub: newFactorPubs[index], nodeDetails: nodeDetail, torusUtils: torusUtils) } try await threshold.sync_local_metadata_transistions() print(try threshold.get_all_tss_tags()) diff --git a/Tests/tkeypkgTests/modules/tkey_pkgPrivateKeysModuleTests.swift b/Tests/tkeypkgTests/modules/tkey_pkgPrivateKeysModuleTests.swift index 47fcfb1..b54c4c6 100644 --- a/Tests/tkeypkgTests/modules/tkey_pkgPrivateKeysModuleTests.swift +++ b/Tests/tkeypkgTests/modules/tkey_pkgPrivateKeysModuleTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgPrivateKeyModuleTests: XCTestCase { diff --git a/Tests/tkeypkgTests/modules/tkey_pkgSecurityQuestionModuleTests.swift b/Tests/tkeypkgTests/modules/tkey_pkgSecurityQuestionModuleTests.swift index 396f16c..3ec78ca 100644 --- a/Tests/tkeypkgTests/modules/tkey_pkgSecurityQuestionModuleTests.swift +++ b/Tests/tkeypkgTests/modules/tkey_pkgSecurityQuestionModuleTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgSecurityQuestionModuleTests: XCTestCase { diff --git a/Tests/tkeypkgTests/modules/tkey_pkgSeedPhraseModuleTests.swift b/Tests/tkeypkgTests/modules/tkey_pkgSeedPhraseModuleTests.swift index 1376c9f..e0e0333 100644 --- a/Tests/tkeypkgTests/modules/tkey_pkgSeedPhraseModuleTests.swift +++ b/Tests/tkeypkgTests/modules/tkey_pkgSeedPhraseModuleTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgSeedPhraseModuleTests: XCTestCase { diff --git a/Tests/tkeypkgTests/modules/tkey_pkgShareSerializationModuleTests.swift b/Tests/tkeypkgTests/modules/tkey_pkgShareSerializationModuleTests.swift index 5520cf2..c6ff2b7 100644 --- a/Tests/tkeypkgTests/modules/tkey_pkgShareSerializationModuleTests.swift +++ b/Tests/tkeypkgTests/modules/tkey_pkgShareSerializationModuleTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgShareSerializationModuleTests: XCTestCase { diff --git a/Tests/tkeypkgTests/modules/tkey_pkgShareTransferModuleTests.swift b/Tests/tkeypkgTests/modules/tkey_pkgShareTransferModuleTests.swift index 16b16de..06e23ee 100644 --- a/Tests/tkeypkgTests/modules/tkey_pkgShareTransferModuleTests.swift +++ b/Tests/tkeypkgTests/modules/tkey_pkgShareTransferModuleTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgShareTransferModuleTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_base.swift b/Tests/tkeypkgTests/tkey_base.swift index c100cf4..da98a90 100644 --- a/Tests/tkeypkgTests/tkey_base.swift +++ b/Tests/tkeypkgTests/tkey_base.swift @@ -8,7 +8,7 @@ import Foundation import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import TorusUtils class tkey_baseTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgGenerateShareStoreResultTests.swift b/Tests/tkeypkgTests/tkey_pkgGenerateShareStoreResultTests.swift index 05cfa47..1834045 100644 --- a/Tests/tkeypkgTests/tkey_pkgGenerateShareStoreResultTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgGenerateShareStoreResultTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgGenerateShareStoreResultTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgKeyDetailsTest.swift b/Tests/tkeypkgTests/tkey_pkgKeyDetailsTest.swift index 84ba9a1..ed0777c 100644 --- a/Tests/tkeypkgTests/tkey_pkgKeyDetailsTest.swift +++ b/Tests/tkeypkgTests/tkey_pkgKeyDetailsTest.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgKeyDetailsTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgKeyPointArrayTests.swift b/Tests/tkeypkgTests/tkey_pkgKeyPointArrayTests.swift index 89b51e2..16992fc 100644 --- a/Tests/tkeypkgTests/tkey_pkgKeyPointArrayTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgKeyPointArrayTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgKeyPointArrayTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgKeyPointTests.swift b/Tests/tkeypkgTests/tkey_pkgKeyPointTests.swift index d6f49ed..7384f09 100644 --- a/Tests/tkeypkgTests/tkey_pkgKeyPointTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgKeyPointTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgKeyPointTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgKeyReconstructionDetailsTests.swift b/Tests/tkeypkgTests/tkey_pkgKeyReconstructionDetailsTests.swift index 035395a..bac4944 100644 --- a/Tests/tkeypkgTests/tkey_pkgKeyReconstructionDetailsTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgKeyReconstructionDetailsTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgKeyReconstructionDetailsTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgLocalMetadataTransitionsTests.swift b/Tests/tkeypkgTests/tkey_pkgLocalMetadataTransitionsTests.swift index 34825db..d74fc08 100644 --- a/Tests/tkeypkgTests/tkey_pkgLocalMetadataTransitionsTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgLocalMetadataTransitionsTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgLocalMetadataTransitionsTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgMetadataTests.swift b/Tests/tkeypkgTests/tkey_pkgMetadataTests.swift index 92a1ec2..fb029cf 100644 --- a/Tests/tkeypkgTests/tkey_pkgMetadataTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgMetadataTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgMetadataTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgNodeDetailsTests.swift b/Tests/tkeypkgTests/tkey_pkgNodeDetailsTests.swift index 5f8b486..f325a4c 100644 --- a/Tests/tkeypkgTests/tkey_pkgNodeDetailsTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgNodeDetailsTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgNodeDetailsTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgPolynomialTests.swift b/Tests/tkeypkgTests/tkey_pkgPolynomialTests.swift index a0313f6..51372fe 100644 --- a/Tests/tkeypkgTests/tkey_pkgPolynomialTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgPolynomialTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgPolynomialTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgPrivateKeyTests.swift b/Tests/tkeypkgTests/tkey_pkgPrivateKeyTests.swift index 2e44f20..2d33d73 100644 --- a/Tests/tkeypkgTests/tkey_pkgPrivateKeyTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgPrivateKeyTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgPrivateKeyTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgPublicPolynomialTests.swift b/Tests/tkeypkgTests/tkey_pkgPublicPolynomialTests.swift index 82894e4..0a34349 100644 --- a/Tests/tkeypkgTests/tkey_pkgPublicPolynomialTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgPublicPolynomialTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgPublicPolynomialTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgServiceProviderTests.swift b/Tests/tkeypkgTests/tkey_pkgServiceProviderTests.swift index 9421fbe..07fdee9 100644 --- a/Tests/tkeypkgTests/tkey_pkgServiceProviderTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgServiceProviderTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgServiceProviderTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgShareStoreArrayTests.swift b/Tests/tkeypkgTests/tkey_pkgShareStoreArrayTests.swift index 5d4d491..0d65220 100644 --- a/Tests/tkeypkgTests/tkey_pkgShareStoreArrayTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgShareStoreArrayTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgShareStoreArrayTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgShareStoreMapTests.swift b/Tests/tkeypkgTests/tkey_pkgShareStoreMapTests.swift index 0d8afa9..fbae2c3 100644 --- a/Tests/tkeypkgTests/tkey_pkgShareStoreMapTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgShareStoreMapTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgShareStoreMapTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgShareStorePolyIdIndexMapTests.swift b/Tests/tkeypkgTests/tkey_pkgShareStorePolyIdIndexMapTests.swift index 0b01ef0..b49f9d2 100644 --- a/Tests/tkeypkgTests/tkey_pkgShareStorePolyIdIndexMapTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgShareStorePolyIdIndexMapTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgShareStorePolyIdIndexMapTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgShareStoreTests.swift b/Tests/tkeypkgTests/tkey_pkgShareStoreTests.swift index fe50bff..be2a0ed 100644 --- a/Tests/tkeypkgTests/tkey_pkgShareStoreTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgShareStoreTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgShareStoreTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgStorageLayerTests.swift b/Tests/tkeypkgTests/tkey_pkgStorageLayerTests.swift index 263dd9f..d52e46f 100644 --- a/Tests/tkeypkgTests/tkey_pkgStorageLayerTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgStorageLayerTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgStorageLayerTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgThresholdKeyTests.swift b/Tests/tkeypkgTests/tkey_pkgThresholdKeyTests.swift index 1dd4215..2a78f9d 100644 --- a/Tests/tkeypkgTests/tkey_pkgThresholdKeyTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgThresholdKeyTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift final class tkey_pkgThresholdKeyTests: XCTestCase { func test_basic_threshold_key_reconstruct() async { diff --git a/Tests/tkeypkgTests/tkey_pkgTssOptionsTests.swift b/Tests/tkeypkgTests/tkey_pkgTssOptionsTests.swift index d36c0ed..ba34f43 100644 --- a/Tests/tkeypkgTests/tkey_pkgTssOptionsTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgTssOptionsTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift import Foundation final class tkey_pkgTssOptionsTests: XCTestCase { diff --git a/Tests/tkeypkgTests/tkey_pkgVersionTests.swift b/Tests/tkeypkgTests/tkey_pkgVersionTests.swift index f25f3ae..e3dbe46 100644 --- a/Tests/tkeypkgTests/tkey_pkgVersionTests.swift +++ b/Tests/tkeypkgTests/tkey_pkgVersionTests.swift @@ -1,6 +1,6 @@ import XCTest import Foundation -@testable import tkey_pkg +@testable import tkey_mpc_swift final class tkey_pkgVersionTests: XCTestCase { func test_library_version() {