From 2a5e6c7bb9c838a904760fe9418c8e118e3445e4 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Wed, 27 Nov 2024 18:42:49 +0100 Subject: [PATCH] book: add `Nip44.swift` snippet Signed-off-by: Yuki Kishimoto --- .../swift/NostrSnippets/Sources/Nip44.swift | 14 ++++++++++++++ .../swift/NostrSnippets/Sources/nip44.swift | 6 ------ book/src/sdk/nips/44.md | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 book/snippets/swift/NostrSnippets/Sources/Nip44.swift delete mode 100644 book/snippets/swift/NostrSnippets/Sources/nip44.swift diff --git a/book/snippets/swift/NostrSnippets/Sources/Nip44.swift b/book/snippets/swift/NostrSnippets/Sources/Nip44.swift new file mode 100644 index 000000000..d66b7f027 --- /dev/null +++ b/book/snippets/swift/NostrSnippets/Sources/Nip44.swift @@ -0,0 +1,14 @@ +import Foundation +import NostrSDK + +func nip44() { + let keys = Keys.generate() + + let pk = try PublicKey.fromHex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798") + + let ciphertext = try nip44Encrypt(secretKey: keys.secretKey(), publicKey: pk, content: "my message", version: Nip44Version.V2) + print("Encrypted: \(ciphertext)"); + + let plaintext = try nip44Decrypt(secretKey: keys.secret_key(), publicKey: pk, 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}} ```