From ede81225aec813acb1061c76ffbb2fcc6b07fea3 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 13 Sep 2024 13:22:24 -0600 Subject: [PATCH 1/3] update package --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a874b2a3..4d3d866a 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift.git", "state" : { - "revision" : "06e890646a32c3ae9b9ac78150a7ec4971e54c9d", - "version" : "0.5.8-beta3" + "revision" : "abd4f896f539e5bb090c85022177d775ad08dcb1", + "version" : "0.5.8-beta4" } }, { From bd15754cf5eddef2727e26f9cd9e9c78a04b605d Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 20 Nov 2024 19:46:31 -0800 Subject: [PATCH 2/3] bump the version --- Package.swift | 2 +- XMTP.podspec | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index 1ecb5bc9..abdaa5a0 100644 --- a/Package.swift +++ b/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(url: "https://github.com/tesseract-one/CSecp256k1.swift.git", from: "0.2.0"), .package(url: "https://github.com/bufbuild/connect-swift", exact: "1.0.0"), .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.3"), - .package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "3.0.3"), + .package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "3.0.4"), .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", exact: "1.8.3") ], targets: [ diff --git a/XMTP.podspec b/XMTP.podspec index 93f3dd12..79562e7c 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |spec| spec.dependency 'CSecp256k1', '~> 0.2' spec.dependency "Connect-Swift", "= 1.0.0" - spec.dependency 'LibXMTP', '= 3.0.3' + spec.dependency 'LibXMTP', '= 3.0.4' spec.dependency 'CryptoSwift', '= 1.8.3' spec.ios.deployment_target = '14.0' diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 21d422e2..f671b65c 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift.git", "state" : { - "revision" : "d44798db766bd82e93c4f49f9997b5369f927971", - "version" : "3.0.3" + "revision" : "3acbfd1ce362df2bd9dae1674bc9faff89281ae6", + "version" : "3.0.4" } }, { From 919865c4613ecc55fbb512a8c22d8758076ebd0c Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 21 Nov 2024 20:37:22 -0800 Subject: [PATCH 3/3] get on the latest version and write a test --- Package.swift | 2 +- Sources/XMTPiOS/Client.swift | 24 +++++++ Tests/XMTPTests/ClientTests.swift | 67 +++++++++++++++++++ XMTP.podspec | 4 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- 5 files changed, 96 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index abdaa5a0..4513363a 100644 --- a/Package.swift +++ b/Package.swift @@ -20,7 +20,7 @@ let package = Package( .package(url: "https://github.com/tesseract-one/CSecp256k1.swift.git", from: "0.2.0"), .package(url: "https://github.com/bufbuild/connect-swift", exact: "1.0.0"), .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.3"), - .package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "3.0.4"), + .package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "3.0.5"), .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", exact: "1.8.3") ], targets: [ diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index eb0a1e37..3fac8c1b 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -379,6 +379,30 @@ public final class Client { return try ffiClient.signWithInstallationKey(text: message) } + public func verifySignature(message: String, signature: Data) throws -> Bool + { + do { + try ffiClient.verifySignedWithInstallationKey( + signatureText: message, signatureBytes: signature) + return true + } catch { + return false + } + } + + public func verifySignatureWithInstallationId( + message: String, signature: Data, installationId: String + ) throws -> Bool { + do { + try ffiClient.verifySignedWithPublicKey( + signatureText: message, signatureBytes: signature, + publicKey: installationId.hexToData) + return true + } catch { + return false + } + } + public func findGroup(groupId: String) throws -> Group? { do { return Group( diff --git a/Tests/XMTPTests/ClientTests.swift b/Tests/XMTPTests/ClientTests.swift index 3a64a270..fa292697 100644 --- a/Tests/XMTPTests/ClientTests.swift +++ b/Tests/XMTPTests/ClientTests.swift @@ -398,4 +398,71 @@ class ClientTests: XCTestCase { )) } + func testSignatures() async throws { + let fixtures = try await fixtures() + + // Signing with installation key + let signature = try fixtures.alixClient.signWithInstallationKey( + message: "Testing") + XCTAssertTrue( + try fixtures.alixClient.verifySignature( + message: "Testing", signature: signature)) + XCTAssertFalse( + try fixtures.alixClient.verifySignature( + message: "Not Testing", signature: signature)) + + let alixInstallationId = fixtures.alixClient.installationID + + XCTAssertTrue( + try fixtures.alixClient.verifySignatureWithInstallationId( + message: "Testing", + signature: signature, + installationId: alixInstallationId + )) + XCTAssertFalse( + try fixtures.alixClient.verifySignatureWithInstallationId( + message: "Not Testing", + signature: signature, + installationId: alixInstallationId + )) + XCTAssertFalse( + try fixtures.alixClient.verifySignatureWithInstallationId( + message: "Testing", + signature: signature, + installationId: fixtures.boClient.installationID + )) + XCTAssertTrue( + try fixtures.boClient.verifySignatureWithInstallationId( + message: "Testing", + signature: signature, + installationId: alixInstallationId + )) + + try fixtures.alixClient.deleteLocalDatabase() + let key = try Crypto.secureRandomBytes(count: 32) + let options = ClientOptions.init( + api: .init(env: .local, isSecure: false), + dbEncryptionKey: key + ) + + // Creating a new client + let alixClient2 = try await Client.create( + account: fixtures.alix, + options: options + ) + + XCTAssertTrue( + try alixClient2.verifySignatureWithInstallationId( + message: "Testing", + signature: signature, + installationId: alixInstallationId + )) + XCTAssertFalse( + try alixClient2.verifySignatureWithInstallationId( + message: "Testing2", + signature: signature, + installationId: alixInstallationId + )) + } + } diff --git a/XMTP.podspec b/XMTP.podspec index 79562e7c..b1c63778 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "XMTP" - spec.version = "3.0.7" + spec.version = "3.0.8" spec.summary = "XMTP SDK Cocoapod" spec.description = <<-DESC @@ -22,7 +22,7 @@ Pod::Spec.new do |spec| spec.dependency 'CSecp256k1', '~> 0.2' spec.dependency "Connect-Swift", "= 1.0.0" - spec.dependency 'LibXMTP', '= 3.0.4' + spec.dependency 'LibXMTP', '= 3.0.5' spec.dependency 'CryptoSwift', '= 1.8.3' spec.ios.deployment_target = '14.0' diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f671b65c..14a2f437 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift.git", "state" : { - "revision" : "3acbfd1ce362df2bd9dae1674bc9faff89281ae6", - "version" : "3.0.4" + "revision" : "77fd4bb5a04281b30e887dcc8739497acaa7a3a6", + "version" : "3.0.5" } }, {