Skip to main content

Crate signer_nostr

Crate signer_nostr 

Source
Expand description

Nostr transaction signer built on BIP-340 Schnorr over secp256k1.

Implements the signing side of the Nostr protocol (NIP-01) with NIP-19 bech32 key encoding (nsec for private keys, npub for x-only public keys).

Key derivation from a mnemonic is handled by kobe-nostr (NIP-06) — this crate is signing only.

§Examples

use signer_nostr::{Sign as _, Signer};

// NIP-06 test vector 1.
let signer = Signer::from_hex(
    "7f7ff03d123792d6ac594bfa67bf6d0c0ab55b6b1fdb6249303fe861f1ccba9a",
)
.unwrap();
assert!(signer.address().starts_with("npub1"));

// Sign a NIP-01 event id (32-byte SHA-256 of the canonical serialization).
let event_id = [0u8; 32];
let out = signer.sign_hash(&event_id).unwrap();
assert_eq!(out.to_bytes().len(), 64); // BIP-340 Schnorr

Re-exports§

pub use signer_primitives;

Structs§

Signer
Nostr transaction signer.

Enums§

SignError
Errors from signing operations.
SignOutput
Signature output across every scheme the workspace supports.

Constants§

NOTE_HRP
NIP-19 human-readable part for event ids.
NPUB_HRP
NIP-19 human-readable part for public keys.
NSEC_HRP
NIP-19 human-readable part for private keys.

Traits§

Sign
Primitive-level signing surface implemented by every chain-specific Signer.
SignMessage
Opt-in capability: sign an off-chain message with the chain’s own message-signing convention.