pub struct MessageEnvelope {
pub sender: String,
pub encrypted_header: String,
pub ciphertext: String,
}Expand description
A ready-to-publish encrypted message: the NIP-44-encrypted header and the double-ratcheted ciphertext, plus the sender DH pubkey the recipient uses to locate the chain.
Fields§
§sender: StringSender’s current DH public key (x-only hex).
encrypted_header: StringNIP-44 v2 encrypted, base64 Header JSON.
ciphertext: StringBase64 NIP-44 v2 ciphertext of the message payload.
Implementations§
Source§impl MessageEnvelope
impl MessageEnvelope
Sourcepub fn to_event<S: NostrSigner>(
&self,
signer: &S,
created_at: i64,
) -> Result<NostrNote, Nip104Error>
pub fn to_event<S: NostrSigner>( &self, signer: &S, created_at: i64, ) -> Result<NostrNote, Nip104Error>
Render this envelope as a signed kind-MESSAGE_EVENT_KIND Nostr event.
signer must be the sender’s current ephemeral keypair (its public key
must equal self.sender); the reference implementation
signs ratchet messages with that key, and the recipient locates the
chain by the event’s pubkey.
§Errors
Returns Nip104Error::Signer if signing fails.
Sourcepub fn from_event(event: &NostrNote) -> Result<Self, Nip104Error>
pub fn from_event(event: &NostrNote) -> Result<Self, Nip104Error>
Parse and verify a kind-MESSAGE_EVENT_KIND Nostr event into an
envelope. The event’s pubkey becomes the sender,
its content the ciphertext, and the ["header", …] tag the encrypted
header.
§Errors
Nip104Error::InvalidHeader if the kind is wrong, the signature is
invalid, or the header tag is missing.
Trait Implementations§
Source§impl Clone for MessageEnvelope
impl Clone for MessageEnvelope
Source§fn clone(&self) -> MessageEnvelope
fn clone(&self) -> MessageEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more