Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use mpc-signing-kit instead of tss-client #8

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 149 additions & 32 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"object": {
"pins": [
{
"package": "AnyCodable",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency should not be needed here.

"repositoryURL": "https://github.com/Flight-School/AnyCodable",
"state": {
"branch": null,
"revision": "862808b2070cd908cb04f9aafe7de83d35f81b05",
"version": "0.6.7"
}
},
{
"package": "BigInt",
"repositoryURL": "https://github.com/attaswift/BigInt.git",
Expand All @@ -12,20 +21,38 @@
},
{
"package": "CryptoSwift",
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package cannot be included, it has to be removed.

"state": {
"branch": null,
"revision": "32f641cf24fc7abc1c591a2025e9f2f572648b0f",
"version": "1.7.2"
"revision": "7892a123f7e8d0fe62f9f03728b17bbd4f94df5c",
"version": "1.8.1"
}
},
{
"package": "curvelib.swift",
"repositoryURL": "https://github.com/tkey/curvelib.swift",
"state": {
"branch": null,
"revision": "85d17cc4fcc9ccf5f444a51d163b2f1671862621",
"version": "0.1.0"
"revision": "7dad3bf1793de263f83406c08c18c9316abf082f",
"version": "0.1.2"
}
},
{
"package": "CustomAuth",
"repositoryURL": "https://github.com/torusresearch/customauth-swift-sdk",
"state": {
"branch": null,
"revision": "bb0c8249b6f0e2866e51e47bebdc801848fae45a",
"version": "9.0.0"
}
},
{
"package": "FetchNodeDetails",
"repositoryURL": "https://github.com/torusresearch/fetch-node-details-swift",
"state": {
"branch": null,
"revision": "d591af500f32ce3c88d04af9bb74d746585acfea",
"version": "5.1.0"
}
},
{
Expand All @@ -38,120 +65,210 @@
}
},
{
"package": "secp256k1",
"package": "JWTDecode",
"repositoryURL": "https://github.com/auth0/JWTDecode.swift.git",
"state": {
"branch": null,
"revision": "58af7278797871e460d79496621b3e5366b865b2",
"version": "3.1.0"
}
},
{
"package": "KeychainSwift",
"repositoryURL": "https://github.com/evgenyneu/keychain-swift.git",
"state": {
"branch": null,
"revision": "d108a1fa6189e661f91560548ef48651ed8d93b9",
"version": "20.0.0"
}
},
{
"package": "mpc-core-kit-swift",
"repositoryURL": "https://github.com/tkey/mpc-core-kit-swift",
"state": {
"branch": null,
"revision": "7f3b7ef03d71e602182747b8d656cccbb47394b7",
"version": "1.0.0-alpha"
}
},
{
"package": "secp256k1.swift",
"repositoryURL": "https://github.com/GigaBitcoin/secp256k1.swift.git",
"state": {
"branch": null,
"revision": "1a14e189def5eaa92f839afdd2faad8e43b61a6e",
"version": "0.12.2"
"revision": "347b84ed2aad2305a7233f2a48d76f41e52062a1",
"version": "0.16.0"
}
},
{
"package": "SessionManager",
"repositoryURL": "https://github.com/Web3Auth/session-manager-swift.git",
"state": {
"branch": null,
"revision": "c89d9205a1ce38cd6c6374b906a9039d9cc03f05",
"version": "3.1.1"
}
},
{
"package": "SingleFactorAuth",
"repositoryURL": "https://github.com/Web3Auth/single-factor-auth-swift",
"state": {
"branch": null,
"revision": "8baa2b8cf55b0a38cb98c412bea1c6597adb78ba",
"version": "4.0.0"
}
},
{
"package": "SocketIO",
"repositoryURL": "https://github.com/socketio/socket.io-client-swift",
"state": {
"branch": null,
"revision": "af5ce97b755d964235348d96f6db5cbdcbe334a5",
"version": "16.0.1"
"revision": "175da8b5156f6b132436f0676cc84c2f6a766b6e",
"version": "16.1.0"
}
},
{
"package": "Starscream",
"repositoryURL": "https://github.com/daltoniam/Starscream",
"state": {
"branch": null,
"revision": "df8d82047f6654d8e4b655d1b1525c64e1059d21",
"version": "4.0.4"
"revision": "ac6c0fc9da221873e01bd1a0d4818498a71eef33",
"version": "4.0.6"
}
},
{
"package": "swift-atomics",
"repositoryURL": "https://github.com/apple/swift-atomics.git",
"state": {
"branch": null,
"revision": "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version": "1.1.0"
"revision": "cd142fd2f64be2100422d658e7411e39489da985",
"version": "1.2.0"
}
},
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections.git",
"state": {
"branch": null,
"revision": "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version": "1.0.4"
"revision": "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version": "1.1.0"
}
},
{
"package": "swift-http-types",
"repositoryURL": "https://github.com/apple/swift-http-types",
"state": {
"branch": null,
"revision": "12358d55a3824bd5fed310b999ea8cf83a9a1a65",
"version": "1.0.3"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version": "1.5.3"
"revision": "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version": "1.5.4"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "cf281631ff10ec6111f2761052aa81896a83a007",
"version": "2.58.0"
"revision": "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982",
"version": "2.64.0"
}
},
{
"package": "swift-nio-extras",
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
"state": {
"branch": null,
"revision": "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
"version": "1.19.0"
"revision": "a3b640d7dc567225db7c94386a6e71aded1bfa63",
"version": "1.22.0"
}
},
{
"package": "swift-nio-http2",
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
"state": {
"branch": null,
"revision": "0904bf0feb5122b7e5c3f15db7df0eabe623dd87",
"version": "1.30.0"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version": "2.25.0"
"revision": "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version": "2.26.0"
}
},
{
"package": "swift-nio-transport-services",
"repositoryURL": "https://github.com/apple/swift-nio-transport-services.git",
"state": {
"branch": null,
"revision": "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58",
"version": "1.19.0"
"revision": "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce",
"version": "1.20.1"
}
},
{
"package": "swift-system",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of the rest of these dependencies should not be included here.

"repositoryURL": "https://github.com/apple/swift-system.git",
"state": {
"branch": null,
"revision": "025bcb1165deab2e20d4eaba79967ce73013f496",
"version": "1.2.1"
}
},
{
"package": "tkey-mpc-swift",
"repositoryURL": "https://github.com/tkey/tkey-mpc-swift",
"state": {
"branch": null,
"revision": "0b1020f2fe0c3790bc50aa133bb613ff1b55172f",
"version": "2.1.0"
}
},
{
"package": "TorusUtils",
"repositoryURL": "https://github.com/torusresearch/torus-utils-swift",
"state": {
"branch": null,
"revision": "4c17ef5166c162455d0a37115c033eeff8cb282d",
"version": "8.0.1"
}
},
{
"package": "tss-client-swift",
"repositoryURL": "https://github.com/torusresearch/tss-client-swift.git",
"state": {
"branch": null,
"revision": "d1a35e3849ec90a64752d9b82ec91052f861ad65",
"version": "2.0.0"
"revision": "9590a1d784177d4679eca62d4dbfe781e9870c40",
"version": "2.0.2"
}
},
{
"package": "web3.swift",
"repositoryURL": "https://github.com/argentlabs/web3.swift",
"state": {
"branch": null,
"revision": "8ca33e700ed8de6137a0e1471017aa3b3c8de0db",
"version": "1.6.0"
"revision": "1e75f98a5738c470b23bbfffa9314e9f788df76b",
"version": "1.6.1"
}
},
{
"package": "websocket-kit",
"repositoryURL": "https://github.com/vapor/websocket-kit.git",
"state": {
"branch": null,
"revision": "53fe0639a98903858d0196b699720decb42aee7b",
"version": "2.14.0"
"revision": "4232d34efa49f633ba61afde365d3896fc7f8740",
"version": "2.15.0"
}
}
]
Expand Down
32 changes: 22 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,39 @@ import PackageDescription

let package = Package(
name: "Web3SwiftMpcProvider",
platforms: [.iOS(.v13), .macOS(.v11)],
platforms: [.iOS(.v14), .macOS(.v11)],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is needed in v14?

products: [
.library(
name: "Web3SwiftMpcProvider",
targets: ["Web3SwiftMpcProvider"]),
name: "MPCEthereumProvider",
targets: ["MPCEthereumProvider"]),
.library(
name: "MPCBitcoinProvider",
targets: ["MPCBitcoinProvider"]),
Comment on lines 10 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have to be condensed into single export for cocoapods



],
dependencies: [
.package(url: "https://github.com/argentlabs/web3.swift", from:"1.6.0"),
.package(url: "https://github.com/torusresearch/tss-client-swift.git", from: "2.0.0"),
.package(url: "https://github.com/tkey/mpc-core-kit-swift", .exact("1.0.0-alpha")),
Comment on lines -17 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inverts the dependencies.

This library is supposed to be consumed by mpc-core-kit, not the other way round.

Since you'll not get an optional import of multiple providers, they will be bundled together, I'd suggest looking into the facade design pattern in swift for how to properly wrap this in mpc-core-kit. This will also eliminate problems as seen in #10

You also need to tag the releases with a semver version, the "-alpha" tag will cause issues.

],
targets: [

.target(
name: "Web3SwiftMpcProvider",
dependencies: ["web3.swift", "tss-client-swift"],
path: "Sources/Web3SwiftMpcProvider"
name: "MPCEthereumProvider",
dependencies: ["web3.swift",
.product(name: "mpc-core-kit-swift", package: "mpc-core-kit-swift")
],
path: "Sources/EthereumProvider"
),
.target(
name: "MPCBitcoinProvider",
dependencies: [.product(name: "mpc-core-kit-swift", package: "mpc-core-kit-swift")],
path: "Sources/BitcoinProvider"
),
.testTarget(
name: "Web3SwiftMpcProviderTests",
dependencies: ["Web3SwiftMpcProvider"],
dependencies: ["MPCEthereumProvider"],
path: "Tests"),
],
swiftLanguageVersions: [.v5]
]
// swiftLanguageVersions: [.v5]
)
32 changes: 32 additions & 0 deletions Sources/BitcoinProvider/BitcoinKitSigner.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// File.swift
//
//
// Created by CW Lee on 25/01/2024.
//

import Foundation
import mpc_core_kit_swift

public protocol ISigner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using a fork of the horizontalsystems repo for this?

func sign( message: Data ) -> Data
func schnorrSign(message: Data, publicKey: Data) -> Data
var publicKey : Data { get }
}


extension MpcCoreKit : ISigner {
public func sign(message: Data) -> Data {
let data = self.tssSign(message: message)
return data
}

public func schnorrSign(message: Data, publicKey: Data) -> Data {
return Data()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd need to implement this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not until frost is implemented in rust

}

public var publicKey: Data {
return self.getTssPubKey()
}

}
Loading