0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-25 05:18:23 +02:00

ircd:Ⓜ️:event: Add bool argument to skip verify restringify.

This commit is contained in:
Jason Volk 2020-12-15 18:31:02 -08:00
parent 06ccb59a77
commit e1e8286436
2 changed files with 7 additions and 4 deletions

View file

@ -123,7 +123,7 @@ struct ircd::m::event
static bool my(const idx &);
static json::object preimage(const mutable_buffer &, const json::object &);
static void essential(json::iov &event, const json::iov &content, const closure_iov_mutable &);
static bool verify(const json::object &, const ed25519::pk &, const ed25519::sig &sig);
static bool verify(const json::object &, const ed25519::pk &, const ed25519::sig &sig, const bool &canonical = false);
static ed25519::sig sign(const string_view &, const ed25519::sk &);
static ed25519::sig sign(const string_view &);
static ed25519::sig sign(const json::object &, const ed25519::sk &);

View file

@ -629,11 +629,14 @@ ircd::m::verify(const event &event_,
bool
ircd::m::event::verify(const json::object &event,
const ed25519::pk &pk,
const ed25519::sig &sig)
const ed25519::sig &sig,
const bool &canonical)
{
const string_view preimage
const auto preimage
{
stringify(buf[3], event)
canonical?
string_view{event}:
stringify(buf[3], event)
};
return pk.verify(preimage, sig);