Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
radix_relay::nostr::protocol::event_data Struct Reference

Nostr event data structure. More...

#include <protocol.hpp>

Inheritance diagram for radix_relay::nostr::protocol::event_data:
radix_relay::nostr::events::incoming::bundle_announcement radix_relay::nostr::events::incoming::encrypted_message radix_relay::nostr::events::incoming::identity_announcement radix_relay::nostr::events::incoming::node_status radix_relay::nostr::events::incoming::session_request radix_relay::nostr::events::incoming::unknown_message radix_relay::nostr::events::outgoing::bundle_announcement radix_relay::nostr::events::outgoing::encrypted_message radix_relay::nostr::events::outgoing::identity_announcement radix_relay::nostr::events::outgoing::session_request

Public Member Functions

auto serialize () const -> std::vector< std::byte >
 Serializes event data to byte array.
 
auto is_radix_message () const -> bool
 Checks if event is a Radix-specific message type.
 
auto get_kind () const -> std::optional< enum kind >
 Returns the event kind.
 

Static Public Member Functions

static auto deserialize (std::span< const std::byte > bytes) -> std::optional< event_data >
 Deserializes event data from byte array.
 
static auto deserialize (const std::string &json) -> std::optional< event_data >
 Deserializes event data from JSON string.
 
static auto create_identity_announcement (const std::string &sender_pubkey, std::uint64_t timestamp, const std::string &signal_fingerprint, const std::string &capabilities="mesh,nostr") -> event_data
 Creates an identity announcement event.
 
static auto create_bundle_announcement (const std::string &sender_pubkey, std::uint64_t timestamp, const std::string &bundle_hex) -> event_data
 Creates a bundle announcement event.
 
static auto create_encrypted_message (std::uint64_t timestamp, const std::string &recipient_pubkey, const std::string &encrypted_payload) -> event_data
 Creates an encrypted message event.
 
static auto create_session_request (const std::string &sender_pubkey, std::uint64_t timestamp, const std::string &recipient_pubkey, const std::string &prekey_bundle) -> event_data
 Creates a session establishment request event.
 

Public Attributes

std::string id
 Event ID (32-byte hex hash)
 
std::string pubkey
 Public key of event creator (32-byte hex)
 
std::uint64_t created_at {}
 Unix timestamp.
 
std::vector< std::vector< std::string > > tags
 Event tags (arbitrary string arrays)
 
std::string content
 Event content.
 
std::string sig
 Schnorr signature (64-byte hex)
 

Detailed Description

Nostr event data structure.

Represents a complete Nostr event with all required fields per NIP-01.

Definition at line 43 of file protocol.hpp.

Member Function Documentation

◆ create_bundle_announcement()

static auto radix_relay::nostr::protocol::event_data::create_bundle_announcement ( const std::string &  sender_pubkey,
std::uint64_t  timestamp,
const std::string &  bundle_hex 
) -> event_data
static

Creates a bundle announcement event.

Parameters
sender_pubkeyNostr public key of sender
timestampUnix timestamp
bundle_hexHex-encoded prekey bundle
Returns
Constructed event_data

◆ create_encrypted_message()

static auto radix_relay::nostr::protocol::event_data::create_encrypted_message ( std::uint64_t  timestamp,
const std::string &  recipient_pubkey,
const std::string &  encrypted_payload 
) -> event_data
static

Creates an encrypted message event.

Parameters
timestampUnix timestamp
recipient_pubkeyNostr public key of recipient
encrypted_payloadEncrypted message content
Returns
Constructed event_data

◆ create_identity_announcement()

static auto radix_relay::nostr::protocol::event_data::create_identity_announcement ( const std::string &  sender_pubkey,
std::uint64_t  timestamp,
const std::string &  signal_fingerprint,
const std::string &  capabilities = "mesh,nostr" 
) -> event_data
static

Creates an identity announcement event.

Parameters
sender_pubkeyNostr public key of sender
timestampUnix timestamp
signal_fingerprintRDX fingerprint
capabilitiesComma-separated capability list
Returns
Constructed event_data

◆ create_session_request()

static auto radix_relay::nostr::protocol::event_data::create_session_request ( const std::string &  sender_pubkey,
std::uint64_t  timestamp,
const std::string &  recipient_pubkey,
const std::string &  prekey_bundle 
) -> event_data
static

Creates a session establishment request event.

Parameters
sender_pubkeyNostr public key of sender
timestampUnix timestamp
recipient_pubkeyNostr public key of recipient
prekey_bundlePrekey bundle data
Returns
Constructed event_data

◆ deserialize() [1/2]

static auto radix_relay::nostr::protocol::event_data::deserialize ( const std::string &  json) -> std::optional< event_data >
static

Deserializes event data from JSON string.

Parameters
jsonJSON string
Returns
Parsed event_data or std::nullopt on failure

◆ deserialize() [2/2]

static auto radix_relay::nostr::protocol::event_data::deserialize ( std::span< const std::byte >  bytes) -> std::optional< event_data >
static

Deserializes event data from byte array.

Parameters
bytesRaw bytes containing JSON event data
Returns
Parsed event_data or std::nullopt on failure

◆ get_kind()

auto radix_relay::nostr::protocol::event_data::get_kind ( ) const -> std::optional< enum kind >

Returns the event kind.

Returns
Event kind or std::nullopt if invalid

◆ is_radix_message()

auto radix_relay::nostr::protocol::event_data::is_radix_message ( ) const -> bool

Checks if event is a Radix-specific message type.

Returns
true if kind is 40001-40004, false otherwise

◆ serialize()

auto radix_relay::nostr::protocol::event_data::serialize ( ) const -> std::vector< std::byte >

Serializes event data to byte array.

Returns
Serialized event as byte vector

Member Data Documentation

◆ content

std::string radix_relay::nostr::protocol::event_data::content

◆ created_at

std::uint64_t radix_relay::nostr::protocol::event_data::created_at {}

◆ id

std::string radix_relay::nostr::protocol::event_data::id

◆ pubkey

std::string radix_relay::nostr::protocol::event_data::pubkey

◆ sig

std::string radix_relay::nostr::protocol::event_data::sig

◆ tags

std::vector<std::vector<std::string> > radix_relay::nostr::protocol::event_data::tags

The documentation for this struct was generated from the following file: