Features

This package contains the bech32-encoding for Nostr entities as described in the NIP-19 so they can be used informatively in Nostr clients, preventing confusion between different types of entities like private keys, public keys, and other Nostr entities.

Getting started

Installation

In your pubspec.yaml file add:

dependencies:
  nip19: ^0.0.2

Usage

import 'package:nip19/nip19.dart';

final keyPair = KeyPair.generate();
print('nsec: ${keyPair.nsec}');

final keyPairFromNsec = KeyPair.fromNsec(keyPair.nsec);
print('privateKey: ${keyPairFromNsec.privateKey}');

final npubFromPublicKey = KeyPair.npubFromPublicKey(keyPair.publicKey);
print('npub: $npubFromPublicKey');

final npubToPublicKey = KeyPair.npubToPublicKey(npubFromPublicKey);
print('publicKey: $npubToPublicKey');

Additional information

This package is part of the Dartstr monorepo, which contains a set of modular and compatible Dart packages of different Nostr NIPS and utilities. Import just the packages of NIPS you need and keep your project lightweight. See the Dartstr monorepo for all available packages.

Libraries

nip19
Support for doing something awesome.