0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-11 12:31:07 +01:00

ircd:Ⓜ️:event: Split signature generating overload w/ custom sk/pk.

This commit is contained in:
Jason Volk 2023-03-14 20:51:46 -07:00
parent fb9b68b4e3
commit 684dd18497
2 changed files with 25 additions and 14 deletions

View file

@ -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 &);

View file

@ -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)