diff --git a/lib/nostr.dart b/lib/nostr.dart index 5bc4d95..2176da7 100644 --- a/lib/nostr.dart +++ b/lib/nostr.dart @@ -11,4 +11,4 @@ export 'src/close.dart'; export 'src/message.dart'; export 'src/utils.dart'; export 'src/nips/nip_002.dart'; -export 'src/nips/nip_004/event.dart'; +export 'src/nips/nip_004.dart'; diff --git a/lib/src/nips/nip_004/crypto.dart b/lib/src/crypto/nip_004.dart similarity index 98% rename from lib/src/nips/nip_004/crypto.dart rename to lib/src/crypto/nip_004.dart index 73385b4..6e49ae7 100644 --- a/lib/src/nips/nip_004/crypto.dart +++ b/lib/src/crypto/nip_004.dart @@ -5,7 +5,7 @@ import 'package:nostr/src/crypto/kepler.dart'; import 'package:pointycastle/export.dart'; /// NIP4 cipher -String cipher( +String nip4cipher( String privkey, String pubkey, String payload, diff --git a/lib/src/nips/nip_004/event.dart b/lib/src/nips/nip_004.dart similarity index 95% rename from lib/src/nips/nip_004/event.dart rename to lib/src/nips/nip_004.dart index c76a951..aec1fc4 100644 --- a/lib/src/nips/nip_004/event.dart +++ b/lib/src/nips/nip_004.dart @@ -1,11 +1,11 @@ import 'package:bip340/bip340.dart' as bip340; import 'package:nostr/src/event.dart'; -import 'package:nostr/src/nips/nip_004/crypto.dart'; +import 'package:nostr/src/crypto/nip_004.dart'; import 'package:nostr/src/utils.dart'; /// A special event with kind 4, meaning "encrypted direct message". /// -/// content MUST be equal to the base64-encoded, aes-256-cbc encrypted string of anything a user wants to write, encrypted using a shared cipher generated by combining the recipient's public-key with the sender's private-key; +/// content MUST be equal to the base64-encoded, aes-256-cbc encrypted string of anything a user wants to write, encrypted using a shared nip4cipher generated by combining the recipient's public-key with the sender's private-key; /// this appended by the base64-encoded initialization vector as if it was a querystring parameter named "iv". /// The format is the following: "content": "?iv=". /// @@ -58,7 +58,7 @@ class EncryptedDirectMessage extends Event { tags: [ ['p', receiverPubkey] ], - content: cipher( + content: nip4cipher( senderPrivkey, '02$receiverPubkey', message, @@ -87,7 +87,7 @@ class EncryptedDirectMessage extends Event { String ciphertext = content.split("?iv=")[0]; String plaintext; try { - plaintext = cipher( + plaintext = nip4cipher( privkey, "02$pubkey", ciphertext,