Home

Awesome

NIP-44 Dart Library

License

A Dart implementation of NIP-44, providing encryption and decryption functionalities for the Nostr protocol.

Table of Contents

Introduction

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.

Features

Installation

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

Usage

Import the Package

import 'package:nip44/nip44.dart';

Encrypting a Message

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');
}

Decrypting a Message

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');
}

Examples

You can find more examples in the example directory.

API Reference

Nip44 Class

Contributing

Contributions are welcome! Please read the contribution guidelines first.

License

This project is licensed under the MIT License - see the LICENSE file for details.