From 00d951b591dfe459760095638b55b135870dcbcc Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 12 Jul 2024 13:45:07 +0530 Subject: [PATCH 1/2] update getKey function to return evmAddress rather than publicKey and inprove unit-tests --- Package.resolved | 86 ------------------- .../SingleFactorAuth/SingleFactorAuth.swift | 2 +- Tests/SingleFactorAuthTests/AquaTest.swift | 4 +- Tests/SingleFactorAuthTests/CyanTest.swift | 4 +- .../SingleFactorAuthTests.swift | 4 +- 5 files changed, 7 insertions(+), 93 deletions(-) delete mode 100644 Package.resolved diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index cfd5629..0000000 --- a/Package.resolved +++ /dev/null @@ -1,86 +0,0 @@ -{ - "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", - "state" : { - "revision" : "0ed110f7555c34ff468e72e1686e59721f2b0da6", - "version" : "5.3.0" - } - }, - { - "identity" : "curvelib.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/tkey/curvelib.swift", - "state" : { - "revision" : "9f88bd5e56d1df443a908f7a7e81ae4f4d9170ea", - "version" : "1.0.1" - } - }, - { - "identity" : "fetch-node-details-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/torusresearch/fetch-node-details-swift.git", - "state" : { - "revision" : "5f67cd080c26cf38ae91e7fe63e6217c6e401c07", - "version" : "6.0.2" - } - }, - { - "identity" : "jwt-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/jwt-kit.git", - "state" : { - "revision" : "e05513b5aec24f88012b6e3034115b6bc915356a", - "version" : "4.13.2" - } - }, - { - "identity" : "keychain-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/evgenyneu/keychain-swift.git", - "state" : { - "revision" : "d108a1fa6189e661f91560548ef48651ed8d93b9", - "version" : "20.0.0" - } - }, - { - "identity" : "session-manager-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Web3Auth/session-manager-swift.git", - "state" : { - "revision" : "20cc7bff065d7fe53164d17e7714a3f17d4cea2a", - "version" : "4.0.2" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb", - "version" : "3.3.0" - } - }, - { - "identity" : "torus-utils-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/torusresearch/torus-utils-swift", - "state" : { - "revision" : "ff85c3e96bfa29013309b487875c4d9383e4ac80", - "version" : "8.1.1" - } - } - ], - "version" : 2 -} diff --git a/Sources/SingleFactorAuth/SingleFactorAuth.swift b/Sources/SingleFactorAuth/SingleFactorAuth.swift index 2e75c9b..cf0c130 100644 --- a/Sources/SingleFactorAuth/SingleFactorAuth.swift +++ b/Sources/SingleFactorAuth/SingleFactorAuth.swift @@ -93,7 +93,7 @@ public class SingleFactorAuth { public func getKey(loginParams: LoginParams) async throws -> TorusSFAKey { let torusKey = try await self.getTorusKey(loginParams: loginParams) - let publicAddress = (torusKey.finalKeyData?.X ?? "") + (torusKey.finalKeyData?.Y ?? "") + let publicAddress = torusKey.finalKeyData?.evmAddress ?? "" let privateKey = torusKey.finalKeyData?.privKey ?? "" let torusSfaKey = TorusSFAKey(privateKey: privateKey, publicAddress: publicAddress) diff --git a/Tests/SingleFactorAuthTests/AquaTest.swift b/Tests/SingleFactorAuthTests/AquaTest.swift index a0ef98a..f5d5c8f 100644 --- a/Tests/SingleFactorAuthTests/AquaTest.swift +++ b/Tests/SingleFactorAuthTests/AquaTest.swift @@ -24,7 +24,7 @@ final class AquaTest: XCTestCase { let requiredPrivateKey = "d8204e9f8c270647294c54acd8d49ee208789f981a7503158e122527d38626d8" XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey()) - XCTAssertEqual(torusKey.publicAddress, torusKey.getPublicAddress()) + XCTAssertEqual("0x8b32926cD9224fec3B296aA7250B049029434807", torusKey.getPublicAddress()) } func testInitialise() async throws { @@ -44,6 +44,6 @@ final class AquaTest: XCTestCase { let requiredPrivateKey = "6f8b884f19975fb0d138ed21b22a6a7e1b79e37f611d0a29f1442b34efc6bacd" XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey()) - XCTAssertEqual(torusKey.publicAddress, torusKey.getPublicAddress()) + XCTAssertEqual("0x62BaCa60f48C2b2b7e3074f7B7b4795EeF2afD2e", torusKey.getPublicAddress()) } } diff --git a/Tests/SingleFactorAuthTests/CyanTest.swift b/Tests/SingleFactorAuthTests/CyanTest.swift index 31d6707..910a8d1 100644 --- a/Tests/SingleFactorAuthTests/CyanTest.swift +++ b/Tests/SingleFactorAuthTests/CyanTest.swift @@ -24,7 +24,7 @@ final class CyanTest: XCTestCase { let requiredPrivateKey = "223d982054fa1ad27d1497560521e4cce5b8c6438c38533c7bad27ff21ce0546" XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey()) - XCTAssertEqual(torusKey.publicAddress, torusKey.getPublicAddress()) + XCTAssertEqual("0x6b902fBCEb0E0374e5eB9eDFe68cD4B888c32150", torusKey.getPublicAddress()) } func testInitialise() async throws { @@ -44,6 +44,6 @@ final class CyanTest: XCTestCase { let requiredPrivateKey = "66af498ea82c95d52fdb8c8dedd44cf2f758424a0eecab7ac3dd8721527ea2d4" XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey()) - XCTAssertEqual(torusKey.publicAddress, torusKey.getPublicAddress()) + XCTAssertEqual("0xFF4c4A0Aa5D633302B5711C3047D7D5967884521", torusKey.getPublicAddress()) } } diff --git a/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift b/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift index 83917cb..9f10ab4 100644 --- a/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift +++ b/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift @@ -23,7 +23,7 @@ final class SingleFactorAuthTests: XCTestCase { let torusKey = try await singleFactoreAuth.getKey(loginParams: loginParams) let requiredPrivateKey = "296045a5599afefda7afbdd1bf236358baff580a0fe2db62ae5c1bbe817fbae4" XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey()) - XCTAssertEqual(torusKey.publicAddress, torusKey.getPublicAddress()) + XCTAssertEqual("0x53010055542cCc0f2b6715a5c53838eC4aC96EF7", torusKey.getPublicAddress()) } func testInitialise() async throws { @@ -43,6 +43,6 @@ final class SingleFactorAuthTests: XCTestCase { let requiredPrivateKey = "ad47959db4cb2e63e641bac285df1b944f54d1a1cecdaeea40042b60d53c35d2" XCTAssertEqual(requiredPrivateKey, torusKey.getPrivateKey()) - XCTAssertEqual(torusKey.publicAddress, torusKey.getPublicAddress()) + XCTAssertEqual("0xE1155dB406dAD89DdeE9FB9EfC29C8EedC2A0C8B", torusKey.getPublicAddress()) } } From 021bec8051330c7998568024660fd74b660ae16c Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 12 Jul 2024 14:13:34 +0530 Subject: [PATCH 2/2] update unit-tests --- Package.resolved | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Package.resolved diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..bee738a --- /dev/null +++ b/Package.resolved @@ -0,0 +1,86 @@ +{ + "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", + "state" : { + "revision" : "0ed110f7555c34ff468e72e1686e59721f2b0da6", + "version" : "5.3.0" + } + }, + { + "identity" : "curvelib.swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/tkey/curvelib.swift", + "state" : { + "revision" : "9f88bd5e56d1df443a908f7a7e81ae4f4d9170ea", + "version" : "1.0.1" + } + }, + { + "identity" : "fetch-node-details-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/torusresearch/fetch-node-details-swift.git", + "state" : { + "revision" : "4bd96c33ba8d02d9e27190c5c7cedf09cfdfd656", + "version" : "6.0.3" + } + }, + { + "identity" : "jwt-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/jwt-kit.git", + "state" : { + "revision" : "e05513b5aec24f88012b6e3034115b6bc915356a", + "version" : "4.13.2" + } + }, + { + "identity" : "keychain-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/evgenyneu/keychain-swift.git", + "state" : { + "revision" : "d108a1fa6189e661f91560548ef48651ed8d93b9", + "version" : "20.0.0" + } + }, + { + "identity" : "session-manager-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Web3Auth/session-manager-swift.git", + "state" : { + "revision" : "20cc7bff065d7fe53164d17e7714a3f17d4cea2a", + "version" : "4.0.2" + } + }, + { + "identity" : "swift-crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-crypto.git", + "state" : { + "revision" : "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb", + "version" : "3.3.0" + } + }, + { + "identity" : "torus-utils-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/torusresearch/torus-utils-swift", + "state" : { + "revision" : "608c28404c506983bfec7bbd957632fc0544db8c", + "version" : "8.1.2" + } + } + ], + "version" : 2 +}