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

ircd::json: Remove redundant.

This commit is contained in:
Jason Volk 2018-03-23 00:42:24 -07:00
parent 429095636f
commit e60370de75

View file

@ -1216,77 +1216,6 @@ const
}; };
} }
template<class tuple>
enable_if_tuple<tuple, ed25519::sig>
sign(const tuple &t,
const ed25519::sk &sk)
{
//TODO: XXX
const auto preimage
{
json::strung(t)
};
return ed25519::sig
{
[&sk, &preimage](auto &buf)
{
sk.sign(buf, const_buffer{preimage});
}
};
}
template<class tuple>
enable_if_tuple<tuple, bool>
verify(const tuple &t,
const ed25519::pk &pk,
const ed25519::sig &sig,
std::nothrow_t)
noexcept try
{
//TODO: XXX
const auto preimage
{
json::strung(t)
};
return pk.verify(const_buffer{preimage}, sig);
}
catch(const std::exception &e)
{
log::error("Verification of json::tuple unexpected failure: %s", e.what());
return false;
}
template<class tuple>
enable_if_tuple<tuple, void>
verify(const tuple &t,
const ed25519::pk &pk,
const ed25519::sig &sig)
{
if(!verify(t, pk, sig, std::nothrow))
throw ed25519::bad_sig{"Verification failed"};
}
template<class tuple>
enable_if_tuple<tuple, void>
verify(const tuple &t,
const ed25519::pk &pk)
{
const ed25519::sig sig
{
[&t](auto &buf)
{
b64decode(buf, at<"signatures"_>(t));
}
};
auto copy(t);
at<"signatures"_>(copy) = string_view{};
if(!verify(copy, pk, sig, std::nothrow))
throw ed25519::bad_sig{"Verification failed"};
}
template<class... T> template<class... T>
tuple<T...>::operator tuple<T...>::operator
json::value() json::value()