diff --git a/book/snippets/swift/NostrSnippets/Sources/Nip44.swift b/book/snippets/swift/NostrSnippets/Sources/Nip44.swift new file mode 100644 index 000000000..ddf65d6d6 --- /dev/null +++ b/book/snippets/swift/NostrSnippets/Sources/Nip44.swift @@ -0,0 +1,14 @@ +import Foundation +import NostrSDK + +func nip44() throws { + let keys = Keys.generate() + + let publicKey = try PublicKey.fromHex(hex: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798") + + let ciphertext = try nip44Encrypt(secretKey: keys.secretKey(), publicKey: publicKey, content: "my message", version: Nip44Version.v2) + print("Encrypted: \(ciphertext)"); + + let plaintext = try nip44Decrypt(secretKey: keys.secretKey(), publicKey: publicKey, payload: ciphertext) + print("Decrypted: \(plaintext)"); +} diff --git a/book/snippets/swift/NostrSnippets/Sources/nip44.swift b/book/snippets/swift/NostrSnippets/Sources/nip44.swift deleted file mode 100644 index 056dbdd01..000000000 --- a/book/snippets/swift/NostrSnippets/Sources/nip44.swift +++ /dev/null @@ -1,6 +0,0 @@ -import NostrSDK -import Foundation - -func nip44() { - // TODO -} diff --git a/book/src/sdk/nips/44.md b/book/src/sdk/nips/44.md index 8e023da9f..cd3de02ee 100644 --- a/book/src/sdk/nips/44.md +++ b/book/src/sdk/nips/44.md @@ -40,7 +40,7 @@ TODO
```swift,ignore -{{#include ../../../snippets/swift/NostrSnippets/Sources/nip44.swift}} +{{#include ../../../snippets/swift/NostrSnippets/Sources/Nip44.swift}} ```