A Dart implementation of NIP-44, providing encryption and decryption functionalities for the Nostr protocol.
NIP-44 specifies a protocol for end-to-end encrypted messages in the Nostr network. This library provides Dart developers with an easy-to-use interface to implement NIP-44 encryption and decryption in their applications.
- Encrypt messages according to the NIP-44 specification.
- Decrypt messages encrypted with NIP-44.
- Generate conversation keys using Elliptic Curve Diffie-Hellman (ECDH).
- Compatible with other NIP-44 implementations in different languages.
Add the following to your pubspec.yaml
:
dependencies:
nip44:
git:
url: https://github.com/chebizarro/dart-nip44.git
ref: master
Then run:
dart pub get
import 'package:nip44/nip44.dart';
import 'package:nip44/nip44.dart';
void main() async {
String plaintext = 'Hello, Nostr!';
String senderPrivateKey = 'your_private_key_hex';
String recipientPublicKey = 'recipient_public_key_hex';
String encryptedMessage = await Nip44.encryptMessage(
plaintext,
senderPrivateKey,
recipientPublicKey,
);
print('Encrypted Message: $encryptedMessage');
}
import 'package:nip44/nip44.dart';
void main() async {
String encryptedMessage = 'encrypted_message_from_sender';
String recipientPrivateKey = 'your_private_key_hex';
String senderPublicKey = 'sender_public_key_hex';
String decryptedMessage = await Nip44.decryptMessage(
encryptedMessage,
recipientPrivateKey,
senderPublicKey,
);
print('Decrypted Message: $decryptedMessage');
}
You can find more examples in the example
directory.
-
encryptMessage(String plaintext, String senderPrivateKey, String recipientPublicKey)
Encrypts a plaintext message using the NIP-44 specification.
-
decryptMessage(String encryptedMessage, String recipientPrivateKey, String senderPublicKey)
Decrypts an encrypted message using the NIP-44 specification.
Contributions are welcome! Please read the contribution guidelines first.
This project is licensed under the MIT License - see the LICENSE file for details.