Skip to content

DreamLab-AI/nostr-bbs-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nostr-bbs-core

Pure Rust Nostr protocol primitives for BBS-style applications. Compiles to native and wasm32-unknown-unknown.

NIP Coverage

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

Usage

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));

WASM Support

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_decrypt
  • derive_keypair_from_prf
  • create_nip98_token / verify_nip98_token
  • compute_event_id
  • schnorr_sign / schnorr_verify
  • generate_keypair
cargo check --target wasm32-unknown-unknown

Feature Flags

No 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.

License

MIT

About

Pure Rust Nostr protocol primitives — NIP-01 events, NIP-44 encryption, NIP-98 HTTP auth, key management. Native + WASM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages