From a59ade344b54d658ba780b3f9e8979376371d653 Mon Sep 17 00:00:00 2001 From: Michael Jurkoic Date: Tue, 12 Mar 2024 09:51:04 -0500 Subject: Generate a valid ID while serializing an event --- include/nostr.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/nostr.hpp b/include/nostr.hpp index ce25446..fa407ef 100644 --- a/include/nostr.hpp +++ b/include/nostr.hpp @@ -54,6 +54,15 @@ private: * @remark The `createdAt` field defaults to the present if it is not already set. */ void validate(); + + /** + * @brief Generates an ID for the event. + * @param serializedData The serialized JSON string of all of the event data except the ID and + * the signature. + * @return A valid Nostr event ID. + * @remark The ID is a 32-bytes lowercase hex-encoded sha256 of the serialized event data. + */ + std::string generateId(std::string serializedData) const; }; /** -- cgit