Pure Rust Nostr protocol primitives for BBS-style applications. Compiles to native and wasm32-unknown-unknown.
| NIP | Module | Description |
|---|---|---|
| 01 | event |
Event creation, ID computation (SHA-256 canonical JSON), Schnorr signing/verification |
| 07 | wasm_bridge |
WASM bridge for browser key operations |
| 09 | deletion |
Kind 5 deletion request events |
| 29 | groups |
Relay-based groups (kind 9/9000/9001/9005/9021/9024/39000) |
| 33 | calendar |
Parameterized replaceable events (via d tag) |
| 40 | types |
Channel/group metadata types |
| 42 | types |
Channel message types |
| 44 | nip44 |
Encrypted DMs (ChaCha20-Poly1305, ECDH + HKDF) |
| 45 | types |
COUNT message types |
| 50 | types |
Search filter types |
| 52 | calendar |
Calendar events (kind 31923) and RSVPs (kind 31925) |
| 98 | nip98 |
HTTP auth tokens (kind 27235), create + verify |
use nostr_bbs_core::{sign_event, verify_event, UnsignedEvent};
use k256::schnorr::SigningKey;
// Create a signing key
let sk = SigningKey::from_bytes(&[0x01u8; 32]).unwrap();
let pubkey = hex::encode(sk.verifying_key().to_bytes());
// Build and sign an event
let unsigned = UnsignedEvent {
pubkey,
created_at: 1700000000,
kind: 1,
tags: vec![],
content: "Hello Nostr!".to_string(),
};
let signed = sign_event(unsigned, &sk).unwrap();
assert!(verify_event(&signed));The crate compiles to wasm32-unknown-unknown with a JS bridge module (wasm_bridge) that exposes functions to JavaScript via wasm-bindgen:
nip44_encrypt/nip44_decryptderive_keypair_from_prfcreate_nip98_token/verify_nip98_tokencompute_event_idschnorr_sign/schnorr_verifygenerate_keypair
cargo check --target wasm32-unknown-unknownNo feature flags are required for basic usage. WASM-specific dependencies (wasm-bindgen, js-sys) are conditionally compiled only for wasm32 targets.
The getrandom dependency is configured with the js feature to support both native and browser environments.
MIT