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 SchnorrRe-exports§
pub use signer_primitives;
Structs§
- Signer
- Nostr transaction signer.
Enums§
- Sign
Error - Errors from signing operations.
- Sign
Output - 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. - Sign
Message - Opt-in capability: sign an off-chain message with the chain’s own message-signing convention.