diff --git a/Sources/NostrSDK/Events/DirectMessageEvent.swift b/Sources/NostrSDK/Events/DirectMessageEvent.swift index a4afe16..d50369e 100644 --- a/Sources/NostrSDK/Events/DirectMessageEvent.swift +++ b/Sources/NostrSDK/Events/DirectMessageEvent.swift @@ -12,7 +12,7 @@ import Foundation /// > Note: [NIP-04 Specification](https://github.com/nostr-protocol/nips/blob/master/04.md) public final class DirectMessageEvent: NostrEvent, DirectMessageEncrypting { - public func decryptedContent(keypair: Keypair) throws -> String { + public func decryptedContent(using privateKey: PrivateKey) throws -> String { let recipient = tags.first { tag in tag.name == .pubkey } @@ -21,7 +21,7 @@ public final class DirectMessageEvent: NostrEvent, DirectMessageEncrypting { fatalError() } - let decryptedContent = try decrypt(encryptedContent: content, privateKey: keypair.privateKey, publicKey: recipientPublicKey) + let decryptedContent = try decrypt(encryptedContent: content, privateKey: privateKey, publicKey: recipientPublicKey) return decryptedContent } diff --git a/Tests/NostrSDKTests/EventCreatingTests.swift b/Tests/NostrSDKTests/EventCreatingTests.swift index da0f1ca..4295b24 100644 --- a/Tests/NostrSDKTests/EventCreatingTests.swift +++ b/Tests/NostrSDKTests/EventCreatingTests.swift @@ -26,7 +26,7 @@ final class EventCreatingTests: XCTestCase, EventCreating, EventVerifying { XCTAssertEqual(tag, recipientTag) // Content should be decryptable - XCTAssertEqual(try event.decryptedContent(keypair: Keypair.test), content) + XCTAssertEqual(try event.decryptedContent(using: Keypair.test.privateKey), content) try verifyEvent(event) } diff --git a/Tests/NostrSDKTests/EventDecodingTests.swift b/Tests/NostrSDKTests/EventDecodingTests.swift index 322706a..7830ad4 100644 --- a/Tests/NostrSDKTests/EventDecodingTests.swift +++ b/Tests/NostrSDKTests/EventDecodingTests.swift @@ -75,7 +75,7 @@ final class EventDecodingTests: XCTestCase, FixtureLoading { ] XCTAssertEqual(expectedTags, event.tags) - XCTAssertEqual(try event.decryptedContent(keypair: Keypair.test), "Secret message.") + XCTAssertEqual(try event.decryptedContent(using: Keypair.test.privateKey), "Secret message.") } func testDecodeRecommendServer() throws {