Skip to content

Commit

Permalink
Update Method Signature for decryptedContent
Browse files Browse the repository at this point in the history
  • Loading branch information
joelklabo committed Aug 12, 2023
1 parent 4a74a2b commit 5475038
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/NostrSDK/Events/DirectMessageEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/NostrSDKTests/EventCreatingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/NostrSDKTests/EventDecodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5475038

Please sign in to comment.