What is Nostr?
Nostr (Notes and Other Stuff Transmitted by Relays) is a decentralized protocol that enables censorship-resistant communication. At its core, Nostr consists of:- Events: Signed JSON objects that contain messages and data
- Relays: WebSocket servers that store and forward events
- Keys: Public/private keypairs for identity and encryption
Nostr events
All data in Nostr is transmitted as events. Each event has:- Kind: A number indicating the event type
- Content: The message or data payload
- Tags: Metadata like recipients, parent messages, and subjects
- Signature: Cryptographic proof of authenticity
- Kind 0: Profile metadata (name, avatar, bio)
- Kind 1: Short text notes
- Kind 1059: Gift-wrapped encrypted events
- Kind 2024: Hoot mail messages (custom)
Custom kind 2024 for mail
Hoot uses a custom event kind (2024) specifically designed for email-like messages. These events include:- To/CC/BCC recipients: Specified using
ptags - Subject: Stored in a subject tag
- Threading: Parent event IDs for conversation threads
- NIP-05 identifiers: Optional sender verification
Kind 2024 events are never sent in plain text. They are always wrapped using NIP-59 gift wrapping before being sent to relays.
How mail events are structured
When composing a message, Hoot creates a kind 2024 event with:- P tags: One for each recipient in the To field
- P tags with “cc” marker: For CC recipients
- E tags: References to parent events for threading
- Subject tag: The email subject line
- Content: The message body
src/mail_event.rs:28-38:
Event verification
Every event received from relays is cryptographically verified before processing. Fromsrc/event_processing.rs:295-298:
- The event was signed by the claimed public key
- The content hasn’t been tampered with
- The event ID correctly represents the event data
Event verification happens automatically for all incoming messages. Invalid events are rejected and never stored in the database.
Profile metadata events
Hoot uses standard Nostr kind 0 events for contact profiles. These events contain:- Display name
- Avatar image URL
- Bio/about text
- NIP-05 identifier (for verification)