mirror of
https://github.com/monero-project/monero.git
synced 2026-01-30 08:14:54 +01:00
Add view tags to outputs to reduce wallet scanning time
Implements view tags as proposed by @UkoeHB in MRL issue https://github.com/monero-project/research-lab/issues/73 At tx construction, the sender adds a 1-byte view tag to each output. The view tag is derived from the sender-receiver shared secret. When scanning for outputs, the receiver can check the view tag for a match, in order to reduce scanning time. When the view tag does not match, the wallet avoids the more expensive EC operations when deriving the output public key using the shared secret.
This commit is contained in:
@@ -563,6 +563,27 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_key& txout)
|
||||
GET_FROM_JSON_OBJECT(val, txout.key, key);
|
||||
}
|
||||
|
||||
void toJsonValue(rapidjson::Writer<epee::byte_stream>& dest, const cryptonote::txout_to_tagged_key& txout)
|
||||
{
|
||||
dest.StartObject();
|
||||
|
||||
INSERT_INTO_JSON_OBJECT(dest, key, txout.key);
|
||||
INSERT_INTO_JSON_OBJECT(dest, view_tag, txout.view_tag);
|
||||
|
||||
dest.EndObject();
|
||||
}
|
||||
|
||||
void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_tagged_key& txout)
|
||||
{
|
||||
if (!val.IsObject())
|
||||
{
|
||||
throw WRONG_TYPE("json object");
|
||||
}
|
||||
|
||||
GET_FROM_JSON_OBJECT(val, txout.key, key);
|
||||
GET_FROM_JSON_OBJECT(val, txout.view_tag, view_tag);
|
||||
}
|
||||
|
||||
void toJsonValue(rapidjson::Writer<epee::byte_stream>& dest, const cryptonote::tx_out& txout)
|
||||
{
|
||||
dest.StartObject();
|
||||
@@ -578,6 +599,10 @@ void toJsonValue(rapidjson::Writer<epee::byte_stream>& dest, const cryptonote::t
|
||||
{
|
||||
INSERT_INTO_JSON_OBJECT(dest, to_key, output);
|
||||
}
|
||||
void operator()(cryptonote::txout_to_tagged_key const& output) const
|
||||
{
|
||||
INSERT_INTO_JSON_OBJECT(dest, to_tagged_key, output);
|
||||
}
|
||||
void operator()(cryptonote::txout_to_script const& output) const
|
||||
{
|
||||
INSERT_INTO_JSON_OBJECT(dest, to_script, output);
|
||||
@@ -616,6 +641,12 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_out& txout)
|
||||
fromJsonValue(elem.value, tmpVal);
|
||||
txout.target = std::move(tmpVal);
|
||||
}
|
||||
else if (elem.name == "to_tagged_key")
|
||||
{
|
||||
cryptonote::txout_to_tagged_key tmpVal;
|
||||
fromJsonValue(elem.value, tmpVal);
|
||||
txout.target = std::move(tmpVal);
|
||||
}
|
||||
else if (elem.name == "to_script")
|
||||
{
|
||||
cryptonote::txout_to_script tmpVal;
|
||||
|
||||
Reference in New Issue
Block a user