diff --git a/Package.resolved b/Package.resolved index c04146e2..f602b5e6 100644 --- a/Package.resolved +++ b/Package.resolved @@ -33,7 +33,7 @@ "repositoryURL": "https://github.com/torusresearch/fetch-node-details-swift", "state": { "branch": "feat/argentweb3", - "revision": "94e8385fafe8ecd52465043c12e9da38a98f7fa2", + "revision": "512c74b46b42d2c433cfe357af4fce6b5f60ad11", "version": null } }, @@ -60,8 +60,8 @@ "repositoryURL": "https://github.com/vapor/jwt-kit.git", "state": { "branch": null, - "revision": "df7955305940ea0fcd1626a0a6d1a1556623f95e", - "version": "4.2.3" + "revision": "7a9a04df93e71de10fa2e8d6e9430dd0a7924643", + "version": "4.2.4" } }, { diff --git a/Package.swift b/Package.swift index 69f1095c..ff98ddb0 100644 --- a/Package.swift +++ b/Package.swift @@ -32,6 +32,6 @@ let package = Package( dependencies: [.product(name: "FetchNodeDetails", package: "FetchNodeDetails"), "CryptoSwift", "web3.swift", "CryptorECC", "secp256k1", "PMKFoundation", "PromiseKit", "BestLogger"]), .testTarget( name: "torus-utils-swiftTests", - dependencies: ["TorusUtils", .product(name: "JWTKit", package: "jwt-kit"), .product(name: "FetchNodeDetails", package: "FetchNodeDetails"), "web3.swift", "PMKFoundation", "PromiseKit", "CryptorECC", "BestLogger"]), + dependencies: ["TorusUtils", .product(name: "JWTKit", package: "jwt-kit"), .product(name: "FetchNodeDetails", package: "FetchNodeDetails"), "web3.swift", .product(name: "PromiseKit", package: "PromiseKit"), "PMKFoundation", "CryptorECC", "BestLogger"]), ] ) diff --git a/Tests/torus-utils-swiftTests/unit_test.swift b/Tests/torus-utils-swiftTests/unit_test.swift deleted file mode 100644 index f9056b0e..00000000 --- a/Tests/torus-utils-swiftTests/unit_test.swift +++ /dev/null @@ -1,204 +0,0 @@ -import XCTest -import PromiseKit -import FetchNodeDetails -import CryptoSwift -import BigInt -import web3 -import secp256k1 - -/** - - cases to test - - Email provided but wrong token - - incorrect order of nodes - - interpolation - - All functions - - */ -@testable import TorusUtils - -@available(iOS 11.0, *) -final class torus_utils_swiftTests: XCTestCase { - -// let context = secp256k1_context_create(UInt32(SECP256K1_CONTEXT_SIGN|SECP256K1_CONTEXT_VERIFY)) -// let nodeList = ["https://teal-15-1.torusnode.com/jrpc", "https://teal-15-3.torusnode.com/jrpc", "https://teal-15-4.torusnode.com/jrpc", "https://teal-15-5.torusnode.com/jrpc", "https://teal-15-2.torusnode.com/jrpc"] -// let nodePubKeys : Array = [TorusNodePub(_X: "4086d123bd8b370db29e84604cd54fa9f1aeb544dba1cc9ff7c856f41b5bf269", _Y: "fde2ac475d8d2796aab2dea7426bc57571c26acad4f141463c036c9df3a8b8e8"),TorusNodePub(_X: "1d6ae1e674fdc1849e8d6dacf193daa97c5d484251aa9f82ff740f8277ee8b7d", _Y: "43095ae6101b2e04fa187e3a3eb7fbe1de706062157f9561b1ff07fe924a9528"),TorusNodePub(_X: "fd2af691fe4289ffbcb30885737a34d8f3f1113cbf71d48968da84cab7d0c262", _Y: "c37097edc6d6323142e0f310f0c2fb33766dbe10d07693d73d5d490c1891b8dc"),TorusNodePub(_X: "e078195f5fd6f58977531135317a0f8d3af6d3b893be9762f433686f782bec58", _Y: "843f87df076c26bf5d4d66120770a0aecf0f5667d38aa1ec518383d50fa0fb88"),TorusNodePub(_X: "a127de58df2e7a612fd256c42b57bb311ce41fd5d0ab58e6426fbf82c72e742f", _Y: "388842e57a4df814daef7dceb2065543dd5727f0ee7b40d527f36f905013fa96")] -// let verifierId = "shubham@tor.us" -// let verifier = "google-google" -// let token = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImMxNzcxODE0YmE2YTcwNjkzZmI5NDEyZGEzYzZlOTBjMmJmNWI5MjciLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIyMzg5NDE3NDY3MTMtcXFlNGE3cmR1dWsyNTZkOG9pNWwwcTM0cXR1OWdwZmcuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLC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"238941746713-qqe4a7rduuk256d8oi5l0q34qtu9gpfg.apps.googleusercontent.com", -// "typeOfLogin": "google", -// "verifier": "google-shubs",]] -// -// override class func setUp() { -// super.setUp() -//// let fnd = FetchNodeDetails() -//// let nodeDetails = fnd.getNodeDetails() -//// let nodeEndpoints = nodeDetails.getTorusNodeEndpoints() -//// let nodePubkeys = nodeDetails.getTorusNodePub() -// } -// -// func testKeyLookup() { -// let obj = TorusUtils() -// -// let exp1 = XCTestExpectation(description: "Do keylookup with success") -// let keyLookupSuccess = obj.keyLookup(endpoints: nodeList, verifier: self.verifier, verifierId: self.verifierId) -// keyLookupSuccess.done { data in -// XCTAssert(data["address"]=="0x5533572d0b2b69Ae31bfDeA351B67B1C05F724Bc", "Address verified") -// exp1.fulfill() -// }.catch{err in -// print(err) -// XCTFail() -// exp1.fulfill() -// } -// -// let exp2 = XCTestExpectation(description: "Do keylookup with failure") -// let keyLookupFailure = obj.keyLookup(endpoints: nodeList, verifier: self.verifier, verifierId: self.verifierId + "someRandomString") -// keyLookupFailure.done { data in -// XCTAssert(data["err"]=="keyLookupfailed", "error verified") -// exp2.fulfill() -// }.catch{err in -// print("keylookup failed", err) -// XCTFail() -// exp2.fulfill() -// } -// -// wait(for: [exp1, exp2], timeout: 5) -// } -// -// func testKeyAssign(){ -// let exp1 = XCTestExpectation(description: "Do keyAssign success") -// let obj = TorusUtils(nodePubKeys: nodePubKeys) -// let keyAssign = obj.keyAssign(endpoints: self.nodeList, torusNodePubs: nodePubKeys, verifier: verifier, verifierId: self.verifierId) -// keyAssign.done{ data in -// // print(data) -// XCTAssertNotNil(data) -// exp1.fulfill() -// }.catch{ err in -// print("keyAssign failed", err) -// XCTFail() -// exp1.fulfill() -// } -// wait(for: [exp1], timeout: 5) -// } -// -// func testGetPublicAddress(){ -// let exp1 = XCTestExpectation(description: "testing get public address") -// let obj = TorusUtils(nodePubKeys: nodePubKeys) -// let getpublicaddress = obj.getPublicAddress(endpoints: self.nodeList, torusNodePubs: nodePubKeys, verifier: "google", verifierId: self.verifierId, isExtended: true) -// getpublicaddress.done{ data in -// print("data", data) -// // Specific to address of shubham@tor.us. Change this to your public address for the above nodelist -// XCTAssert(data["address"]=="0x5533572d0b2b69Ae31bfDeA351B67B1C05F724Bc", "Address verified") -// exp1.fulfill() -// }.catch{ err in -// print("getpublicaddress failed", err) -// XCTFail() -// exp1.fulfill() -// } -// wait(for: [exp1], timeout: 10) -// } -// -// func testRetreiveShares(){ -// let exp1 = XCTestExpectation(description: "reterive privatekey") -// let obj = TorusUtils(nodePubKeys: nodePubKeys) -// -// let extraParams = ["verifieridentifier": verifier, "verifier_id":verifierId, "sub_verifier_ids":["google-shubs"], "verify_params": [["verifier_id": verifierId, "idtoken": token]]] as [String : Any] -// let extraParams2 = ["verifieridentifier": verifier, "verifier_id":verifierId] as [String : Any] -// -// let dataExample: Data = try! NSKeyedArchiver.archivedData(withRootObject: extraParams, requiringSecureCoding: false) -// let dataExample2: Data = try! NSKeyedArchiver.archivedData(withRootObject: extraParams2, requiringSecureCoding: false) -// -// -// let key = obj.retrieveShares(endpoints: self.nodeList, verifierIdentifier: verifier, verifierId: verifierId, idToken: token, extraParams: dataExample2) -// -// key.done{ data in -// print("data", data) -// XCTAssertEqual(64, data.count) -// exp1.fulfill() -// }.catch{err in -// print("testRetreiveShares failed", err) -// XCTFail() -// exp1.fulfill() -// } -// -// wait(for: [exp1], timeout: 10) -// } -// -// // 8b288671081621975c9d4af918a15a5358a793c7bea4c066c37effe2f0c8d1ee unused private key -// -//// generateMetadataParams(message, privateKey) { -//// const key = this.ec.keyFromPrivate(privateKey.toString('hex', 64)) -//// const setData = { -//// data: message, -//// timestamp: new BN(Date.now()).toString(16), -//// } -//// const sig = key.sign(keccak256(JSON.stringify(setData)).slice(2)) -//// return { -//// pub_key_X: key.getPublic().getX().toString('hex'), -//// pub_key_Y: key.getPublic().getY().toString('hex'), -//// set_data: setData, -//// signature: Buffer.from(sig.r.toString(16, 64) + sig.s.toString(16, 64) + new BN(sig.v).toString(16, 2), 'hex').toString('base64'), -//// } -//// } -// -// func testSetMetadata(){ -// -// let keystore = try! EthereumKeystoreV3(privateKey: Data(hex: "8b288671081621975c9d4af918a15a5358a793c7bea4c066c37effe2f0c8d1ee")) -// let setData = [ -// "data": "8", -// "timestamp": String(Int(Date().timeIntervalSince1970)) -// ] -// // print(try! JSONSerialization.data(withJSONObject: setData, options: [])) -// let setDataString = try! JSONSerialization.data(withJSONObject: setData, options: []) -// let hash = setDataString.sha3(.keccak256) -// let sign = SECP256K1.signForRecovery(hash: hash, privateKey: Data(hex: "8b288671081621975c9d4af918a15a5358a793c7bea4c066c37effe2f0c8d1ee")) -// let unmarshallSig = SECP256K1.unmarshalSignature(signatureData: sign.serializedSignature!)! -// print(String(data: unmarshallSig.r, encoding: .utf8)) -// -// let newData = [ -// "pub_key_X": "83ebc5515a6f3ad8d1d83c53b324afb7f88edc499e3bdbbd149492e460018292", -// "pub_key_Y": "a0de020d476f558d69e0b54ce83277df5f6305dbe065e337be313a51ad397958", -// "set_data": setData, -// "signature": "SECP256K1.unmarshalSignature(signatureData: sign)" -// ] as [String : Any] -// -// } -// -// func testSECPLib(){ -// let secp256k1N = BigInt("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", radix: 16)!; -// -// -// let privkey1 = "60a9a56b271e94cc2e8b52107fcb7c4698e7e2d0a4525a797dbe2330a074fdf6" -// let privkey2 = "f730f0a92f8d2b97bc7a1937afad3d2bb47f41418d697de8001797472225ee94" -// let privkey1Data = Data(hex: privkey1) -// let privkey2Data = Data(hex: privkey2) -// let publicKey1 = SECP256K1.privateToPublic(privateKey: privkey1Data, compressed: false) -// let publicKey2 = SECP256K1.privateToPublic(privateKey: privkey2Data, compressed: false) -// var keys: [Data] = [] -// -// keys.append(publicKey2!) -// keys.append(publicKey1!) -// -// let added = SECP256K1.combineSerializedPublicKeys(keys: keys) -// print(publicKey1?.toHexString(), publicKey2?.toHexString(), added?.toHexString()) -// -// let bigInt1 = BigInt(privkey1, radix: 16)! -// let bigInt2 = BigInt(privkey2, radix: 16)! -// let addedKeys = bigInt1 + bigInt2 -// let mod = BigUInt(addedKeys.modulus(secp256k1N)) -// let modData = mod.serialize() -// let publickey3 = SECP256K1.privateToPublic(privateKey: modData, compressed: false) -// -// print(publickey3?.toHexString()) -// -// } -// -// var allTests = [ -// ("testKeyLookup", testKeyLookup), -// ("testKeyAssign", testKeyAssign), -// ("testGetPublicAddress", testGetPublicAddress), -// ("testRetreiveShares", testRetreiveShares) -// ] -}