Skip to content

Commit

Permalink
chore: rename/reorganize files from #25 & #26
Browse files Browse the repository at this point in the history
  • Loading branch information
ethicnology committed Apr 20, 2023
1 parent 0ca4cc8 commit 75a9731
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/nostr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/nips/nip_004/event.dart → lib/src/nips/nip_004.dart
Original file line number Diff line number Diff line change
@@ -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": "<encrypted_text>?iv=<initialization_vector>".
///
Expand Down Expand Up @@ -58,7 +58,7 @@ class EncryptedDirectMessage extends Event {
tags: [
['p', receiverPubkey]
],
content: cipher(
content: nip4cipher(
senderPrivkey,
'02$receiverPubkey',
message,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 75a9731

Please sign in to comment.