pub struct Event {
pub id: String,
pub pubkey: String,
pub created_at: u64,
pub kind: u32,
pub tags: Vec<Vec<String>>,
pub content: String,
pub sig: String,
}Expand description
A signed event, as it travels on the wire and arrives from a relay.
Fields§
§id: StringThe event id: the SHA-256 of the NIP-01 serialisation, 64 hex characters.
pubkey: StringThe author’s x-only public key, 64 hex characters.
created_at: u64Unix seconds.
kind: u32The event kind.
Tags.
content: StringThe event body.
sig: StringThe BIP-340 Schnorr signature over the id, 128 hex characters.
Implementations§
Source§impl Event
impl Event
Sourcepub fn to_unsigned(&self) -> UnsignedEvent
pub fn to_unsigned(&self) -> UnsignedEvent
Strip the id and signature, recovering the template.
Sourcepub fn verify(&self) -> Result<(), Error>
pub fn verify(&self) -> Result<(), Error>
The reference kernel’s check (schema/codec/nostr.js verifyNostrEvent):
the id is the hash of the fields and the signature is BIP-340 over
the id under pubkey. Both, or Error::Signature. Nothing from a
relay is trusted before this passes (siding/lib/relay.mjs: “the event
signature is checked, then the transaction itself must validate”).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Event
Source§impl Serialize for Event
impl Serialize for Event
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.