Skip to content

Commit

Permalink
refactor: mark NIP04 as deprecated to warn users about controversial …
Browse files Browse the repository at this point in the history
…discussions about its harmfullness
  • Loading branch information
ethicnology committed May 25, 2023
1 parent bfbe917 commit 3057122
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Message {
switch (type) {
case "EVENT":
message = Event.deserialize(data);
// ignore: deprecated_member_use_from_same_package
if (message.kind == 4) message = EncryptedDirectMessage(message);
break;
case "OK":
Expand Down
9 changes: 9 additions & 0 deletions lib/src/nips/nip_004.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ import 'package:nostr/src/utils.dart';
/// tags MAY contain an entry identifying the previous message in a conversation or a message we are explicitly replying to (such that contextual, more organized conversations may happen), in the form ["e", "event_id"].
///
/// Note: By default in the libsecp256k1 ECDH implementation, the secret is the SHA256 hash of the shared point (both X and Y coordinates). In Nostr, only the X coordinate of the shared point is used as the secret and it is NOT hashed. If using libsecp256k1, a custom function that copies the X coordinate must be passed as the hashfp argument in secp256k1_ecdh.
///
/// NIP-04 considered harmful, READ: https://github.com/ethicnology/dart-nostr/issues/15 and https://github.com/nostr-protocol/nips/issues/107
@Deprecated(
"""
NIP-04 a.k.a EncryptedDirectMessage is controversial, please READ:
- https://github.com/ethicnology/dart-nostr/issues/15
- https://github.com/nostr-protocol/nips/issues/107
""",
)
class EncryptedDirectMessage extends Event {
/// Default constructor
EncryptedDirectMessage(Event event, {verify = true})
Expand Down
2 changes: 2 additions & 0 deletions test/nips/nip_004_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:nostr/nostr.dart';
import 'package:test/test.dart';

Expand Down

0 comments on commit 3057122

Please sign in to comment.