Skip to content

Commit 65ae7f3

Browse files
committed
feat: remove crypto swift
1 parent ef2d280 commit 65ae7f3

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

Package.resolved

Lines changed: 6 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ let package = Package(
1414
targets: ["CustomAuth"])
1515
],
1616
dependencies: [
17-
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "8.0.0"),
17+
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "8.0.2"),
1818
.package(name: "jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
19-
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0")
19+
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0"),
20+
.package(url: "https://github.com/tkey/curvelib.swift", from: "1.0.0"),
2021
],
2122
targets: [
2223
.target(
2324
name: "CustomAuth",
24-
dependencies: ["JWTDecode", .product(name: "TorusUtils", package: "torus-utils-swift")]),
25+
dependencies: ["JWTDecode", .product(name: "curveSecp256k1", package: "curvelib.swift"), .product(name: "TorusUtils", package: "torus-utils-swift")]),
2526
.testTarget(
2627
name: "CustomAuthTests",
2728
dependencies: ["CustomAuth", .product(name: "JWTKit", package: "jwt-kit")])

Sources/CustomAuth/CustomAuth.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Foundation
1010
import OSLog
1111
import TorusUtils
1212
import UIKit
13+
import curveSecp256k1
1314
import CommonSources
1415

1516
// Global variable
@@ -245,15 +246,15 @@ open class CustomAuth {
245246
/// - Returns: A promise that resolve with a Dictionary that contain at least `privateKey` and `publicAddress` field..
246247
open func getAggregateTorusKey(verifier: String, verifierId: String, idToken: String, subVerifierDetails: SubVerifierDetails, userData: [String: Any] = [:]) async throws -> TorusKey {
247248
let extraParams = ["verifieridentifier": verifier, "verifier_id": verifierId, "sub_verifier_ids": [subVerifierDetails.verifier], "verify_params": [["verifier_id": verifierId, "idtoken": idToken]]] as [String: Codable]
248-
let hashedOnce = idToken.sha3(.keccak256)
249+
let hashedOnce = try keccak256(data: Data(idToken.utf8))
249250

250251
let verifierParams = VerifierParams(verifier_id: verifierId)
251252

252253
do {
253254
let nodeDetails = try await getNodeDetailsFromContract(verifier: verifier, verfierID: verifierId)
254255

255256
// retrieveShares internall checks if network is legacy and calls getPublicAddress if required.
256-
let responseFromRetrieveShares :TorusKey = try await self.torusUtils.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.torusNodePub, indexes: nodeDetails.torusIndexes, verifier: verifier, verifierParams: verifierParams, idToken: hashedOnce, extraParams: extraParams)
257+
let responseFromRetrieveShares :TorusKey = try await self.torusUtils.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.torusNodePub, indexes: nodeDetails.torusIndexes, verifier: verifier, verifierParams: verifierParams, idToken: hashedOnce.toHexString(), extraParams: extraParams)
257258

258259
return responseFromRetrieveShares
259260
} catch {

Tests/CustomAuthTests/StubURLProtocolTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public class StubMockTorusUtils: TorusUtils {
1717

1818
open func generatePrivateKeyData() -> Data? {
1919
let ret = Data(base64Encoded: "FBz7bssmbsV6jBWoOJpkVOu14+6/Xgyt1pxTycODG08=")
20-
21-
print("[StubMockTorusUtils] generatePrivateKeyData(): ", ret!.bytes.toBase64())
2220
return ret
2321
}
2422
}

0 commit comments

Comments
 (0)