Skip to main content

Crate nostr_bbs_core

Crate nostr_bbs_core 

Source
Expand description

Shared Nostr protocol primitives for the nostr-bbs forum.

This crate provides the cryptographic and protocol building blocks shared between the WASM client bridge and the Rust Cloudflare Workers. It covers:

  • NIP-01 event creation, signing, and verification
  • NIP-44 encrypted direct messages (ChaCha20-Poly1305)
  • NIP-98 HTTP auth token creation and verification
  • DID:nostr document generation (delegates to solid_pod_rs::did_nostr_types)
  • Key management including HKDF derivation from WebAuthn PRF output
  • Value types (EventId, Timestamp, Tag, etc.)

Re-exports§

pub use event::compute_event_id;
pub use event::sign_event;
pub use event::sign_event_deterministic;
pub use event::sign_event_upstream;
pub use event::signing_key_to_upstream;
pub use event::verify_event;
pub use event::verify_event_strict;
pub use event::verify_events_batch;
pub use event::EventError;
pub use event::NostrEvent;
pub use event::PubkeyMismatch;
pub use event::UnsignedEvent;
pub use gift_wrap::gift_wrap;
pub use gift_wrap::unwrap_gift;
pub use gift_wrap::GiftWrapError;
pub use gift_wrap::UnwrappedGift;
pub use keys::derive_from_prf;
pub use keys::generate_keypair;
pub use keys::Keypair;
pub use keys::PublicKey;
pub use keys::SecretKey;
pub use keys::Signature;
pub use nip44::decrypt as nip44_decrypt;
pub use nip44::encrypt as nip44_encrypt;
pub use nip98::authorization_header as nip98_authorization_header;
pub use nip98::create_token as create_nip98_token;
pub use nip98::sign_request_header as nip98_sign_request_header;
pub use nip98::verify_nip98;
pub use nip98::verify_nip98_with_replay;
pub use nip98::verify_token as verify_nip98_token;
pub use nip98::verify_token_at as verify_nip98_token_at;
pub use nip98::verify_token_at_with_replay as verify_nip98_token_at_with_replay;
pub use nip98::verify_token_full as verify_nip98_token_full;
pub use nip98::Nip98Error;
pub use nip98::Nip98ReplayStore;
pub use nip98::Nip98Token as VerifiedToken;
pub use nip98::REPLAY_CACHE_TTL_SECS;
pub use nip98::TIMESTAMP_TOLERANCE as NIP98_TIMESTAMP_TOLERANCE;
pub use types::EventId;
pub use types::Tag;
pub use types::Timestamp;
pub use calendar::create_calendar_event;
pub use calendar::create_rsvp;
pub use calendar::CalendarError;
pub use calendar::RsvpStatus;
pub use moderation_events::build_ban;
pub use moderation_events::build_moderation_action;
pub use moderation_events::build_mute;
pub use moderation_events::build_report;
pub use moderation_events::build_unban;
pub use moderation_events::build_unmute;
pub use moderation_events::build_warning;
pub use moderation_events::d_tag_of;
pub use moderation_events::mute_expires_at;
pub use moderation_events::validate_moderation_event;
pub use moderation_events::ModerationEventError;
pub use moderation_events::ADMIN_ONLY_MOD_KINDS;
pub use moderation_events::KIND_BAN;
pub use moderation_events::KIND_MODERATION_ACTION;
pub use moderation_events::KIND_MUTE;
pub use moderation_events::KIND_REPORT;
pub use moderation_events::KIND_REPORT_NIP56;
pub use moderation_events::KIND_UNBAN;
pub use moderation_events::KIND_UNMUTE;
pub use moderation_events::KIND_WARNING;
pub use moderation_events::MOD_KINDS;
pub use did::did_nostr_uri;
pub use did::is_valid_hex_pubkey;
pub use did::render_did_document_tier1;
pub use did::render_did_document_tier3;
pub use did::verify_webid_tag;
pub use did::well_known_path;
pub use did::NostrPubkey;
pub use nip04::nip04_decrypt;
pub use nip04::nip04_encrypt;
pub use nip04::nip04_shared_secret;
pub use nip04::Nip04Error;
pub use nip19::decode_naddr;
pub use nip19::decode_nevent;
pub use nip19::decode_note;
pub use nip19::decode_nprofile;
pub use nip19::decode_npub;
pub use nip19::decode_nsec;
pub use nip19::encode_naddr;
pub use nip19::encode_nevent;
pub use nip19::encode_note;
pub use nip19::encode_nprofile;
pub use nip19::encode_npub;
pub use nip19::encode_nsec;
pub use nip19::NAddr;
pub use nip19::NEvent;
pub use nip19::NProfile;
pub use nip19::Nip19Error;
pub use nip26::validate_delegation_tag;
pub use nip26::Conditions;
pub use nip26::DelegationTag;
pub use nip26::DelegationToken;
pub use nip26::Nip26Error;
pub use nip90::is_job_request;
pub use nip90::is_job_result;
pub use nip90::parse_job_inputs;
pub use nip90::DvmCapabilityAd;
pub use nip90::DvmJobFeedback;
pub use nip90::DvmJobRequest;
pub use nip90::DvmJobResult;
pub use nip90::JobInput;
pub use nip90::JobStatus;
pub use nip90::Nip90Error;
pub use nip90::KIND_HANDLER_INFO;
pub use nip90::KIND_JOB_FEEDBACK;
pub use nip90::KIND_JOB_REQUEST_MAX;
pub use nip90::KIND_JOB_REQUEST_MIN;
pub use nip90::KIND_JOB_RESULT_MAX;
pub use nip90::KIND_JOB_RESULT_MIN;
pub use signer::PrfSigner;
pub use signer::Signer;
pub use signer::SignerError;
pub use governance::extract_d_tag;
pub use governance::extract_tag;
pub use governance::is_governance_kind;
pub use governance::ActionDef;
pub use governance::ActionPriority;
pub use governance::ActionRequest;
pub use governance::ActionResponse;
pub use governance::ActionStyle;
pub use governance::FieldDef;
pub use governance::FieldType;
pub use governance::LayoutHint;
pub use governance::PanelCapability;
pub use governance::PanelDefinition;
pub use governance::PanelSchema;
pub use governance::RegisteredAgent;
pub use governance::GOVERNANCE_KIND_RANGE;
pub use governance::KIND_ACTION_REQUEST;
pub use governance::KIND_ACTION_RESPONSE;
pub use governance::KIND_PANEL_DEFINITION;
pub use governance::KIND_PANEL_RETIRED;
pub use governance::KIND_PANEL_STATE;
pub use governance::KIND_PANEL_UPDATE;

Modules§

calendar
NIP-52: Calendar Events — time-based and date-based calendar events with RSVPs.
d1_helpers
Cloudflare D1 helpers shared by worker crates.
deletion
NIP-09: Event Deletion — kind 5 deletion request events.
did
did:nostr DID Document generation and verification.
event
Nostr event types and NIP-01 canonical serialization.
gift_wrap
NIP-59 Gift Wrap: Triple-layered encrypted direct messages.
governance
Agent Control Surface Protocol — governance types for the nostr-bbs relay.
groups
NIP-29: Relay-based Groups — group event constructors.
keys
Nostr keypair management, HKDF key derivation from WebAuthn PRF, and BIP-340 Schnorr signing.
moderation_events
Moderation event kinds for forum operation (parameterized-replaceable).
nip04
NIP-04: Encrypted Direct Messages — delegated to upstream nostr crate.
nip19
NIP-19: bech32-encoded entities.
nip26
NIP-26: Delegated Event Signing.
nip44
NIP-44 v2: Encrypted Direct Messages — delegated to upstream nostr crate.
nip90
NIP-90: Data Vending Machines (DVMs).
nip98
NIP-98: HTTP Auth via Nostr events (kind 27235).
signer
NIP-46 / generic Signer trait for nostr-bbs.
types

Functions§

format_multibase_schnorr
Build a publicKeyMultibase string for a secp256k1 x-only pubkey.