diff --git a/include/ircd/m/event/event.h b/include/ircd/m/event/event.h index 0bebfd6c0..e7c6324bb 100644 --- a/include/ircd/m/event/event.h +++ b/include/ircd/m/event/event.h @@ -41,11 +41,12 @@ namespace ircd::m size_t degree(const event &); bool before(const event &a, const event &b); - json::object hashes(const mutable_buffer &, const event &); - event signatures(const mutable_buffer &, const m::event &, const string_view &origin); - event signatures(const mutable_buffer &, const m::event &); event essential(event, const mutable_buffer &content, const bool &sigs = false); + event signatures(const mutable_buffer &, const event &, const string_view &origin, const ed25519::sk &, const string_view &pkid); + event signatures(const mutable_buffer &, const event &, const string_view &origin); + event signatures(const mutable_buffer &, const event &); + json::object hashes(const mutable_buffer &, const event &); bool verify_hash(const event &, const sha256::buf &); bool verify_hash(const event &); diff --git a/matrix/event.cc b/matrix/event.cc index bde8354e1..dc73c57e8 100644 --- a/matrix/event.cc +++ b/matrix/event.cc @@ -322,10 +322,30 @@ ircd::m::signatures(const mutable_buffer &out, return signatures(out, event, origin); } +ircd::m::event +ircd::m::signatures(const mutable_buffer &out, + const m::event &event, + const string_view &origin) +{ + const auto &secret_key + { + m::secret_key(my(origin)) + }; + + const string_view public_key_id + { + m::public_key_id(my(origin)) + }; + + return signatures(out, event, origin, secret_key, public_key_id); +} + ircd::m::event ircd::m::signatures(const mutable_buffer &out_, const m::event &event_, - const string_view &origin) + const string_view &origin, + const ed25519::sk &secret_key, + const string_view &public_key_id) { m::event event { @@ -337,16 +357,6 @@ ircd::m::signatures(const mutable_buffer &out_, stringify(event::buf[2], event) }; - const auto &secret_key - { - m::secret_key(my(origin)) - }; - - const string_view public_key_id - { - m::public_key_id(my(origin)) - }; - const ed25519::sig my_sig { event::sign(preimage, secret_key)