Skip to main content

dostr_bip340 0.1.0 copy "dostr_bip340: ^0.1.0" to clipboard
dostr_bip340: ^0.1.0 copied to clipboard

Pure Dart BIP-340 Schnorr signing and verification for Nostr, with a signer and an event verifier.

dostr_bip340 #

BIP-340 Schnorr signatures for Nostr events, in pure Dart: a NostrSigner that holds a private key, an EventVerifier, and the Bip340 helpers under them.

Add it next to dostr_core to sign and verify events.

Install #

dependencies:
  dostr_bip340: ^0.1.0

Usage #

import 'package:dostr_bip340/dostr_bip340.dart';
import 'package:dostr_nip01/dostr_nip01.dart';

final signer = Bip340SignerFactory().createWithNewKeyPair();
final event = await signer.sign(
  Nip01Event(
    pubkey: signer.publicKey,
    kind: 1,
    tags: [],
    content: 'hello nostr',
  ),
);

final valid = await Bip340EventVerifier().verify(event);

Bip340EventVerifier verifies on the calling isolate. On mobile, the Rust verifier of dostr_rust_verifier is much faster.

Coming from ndk #

package:ndk/shared/nips/nip01/bip340.dart and the Bip340EventSigner and Bip340EventVerifier files are now all in package:dostr_bip340/dostr_bip340.dart. Bip340EventSigner and Bip340EventSignerFactory are now Bip340Signer and Bip340SignerFactory. Bip340Signer(privateKey) derives the public key, and Bip340Signer.readOnly(publicKey) replaces a signer without a private key. Bip340.generatePrivateKey is now Bip340.generateKeyPair, which returns a KeyPair record, and Bip340.sign and Bip340.verify take named parameters. Nip01Utils.signWithPrivateKey is now Bip340.signEvent, which throws for an event of another pubkey.

0
likes
160
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Pure Dart BIP-340 Schnorr signing and verification for Nostr, with a signer and an event verifier.

Repository (GitHub)
View/report issues

Topics

#nostr #dostr #schnorr

License

MIT (license)

Dependencies

dostr_nip01, dostr_nip44, dostr_secp256k1, dostr_signer

More

Packages that depend on dostr_bip340