Skip to content

Commit

Permalink
book: add Nip44.swift snippet
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
  • Loading branch information
yukibtc committed Nov 28, 2024
1 parent 4a6e7f3 commit 74f3893
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 14 additions & 0 deletions book/snippets/swift/NostrSnippets/Sources/Nip44.swift
Original file line number Diff line number Diff line change
@@ -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)");
}
6 changes: 0 additions & 6 deletions book/snippets/swift/NostrSnippets/Sources/nip44.swift

This file was deleted.

2 changes: 1 addition & 1 deletion book/src/sdk/nips/44.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TODO
<section>

```swift,ignore
{{#include ../../../snippets/swift/NostrSnippets/Sources/nip44.swift}}
{{#include ../../../snippets/swift/NostrSnippets/Sources/Nip44.swift}}
```

</section>
Expand Down

0 comments on commit 74f3893

Please sign in to comment.