aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-02-06 00:29:32 -0800
committerAlexander Blair <snipa@jagtech.io>2020-02-06 00:29:32 -0800
commit3b224bb99db27971f4fc02b77390340c54bb6c99 (patch)
tree952d3e4e712f3acc611855d3f250e83d155c6d48 /src/wallet/wallet2.cpp
parentMerge pull request #6053 (diff)
parentwallet: allow message sign/verify for subaddresses (diff)
downloadmonero-3b224bb99db27971f4fc02b77390340c54bb6c99.tar.xz
Merge pull request #6069
d64e5aa7 wallet: allow message sign/verify for subaddresses (moneromooo-monero)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 438c61370..b39762b4f 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -11823,13 +11823,27 @@ void wallet2::set_account_tag_description(const std::string& tag, const std::str
m_account_tags.first[tag] = description;
}
-std::string wallet2::sign(const std::string &data) const
+std::string wallet2::sign(const std::string &data, cryptonote::subaddress_index index) const
{
crypto::hash hash;
crypto::cn_fast_hash(data.data(), data.size(), hash);
const cryptonote::account_keys &keys = m_account.get_keys();
crypto::signature signature;
- crypto::generate_signature(hash, keys.m_account_address.m_spend_public_key, keys.m_spend_secret_key, signature);
+ crypto::secret_key skey;
+ crypto::public_key pkey;
+ if (index.is_zero())
+ {
+ skey = keys.m_spend_secret_key;
+ pkey = keys.m_account_address.m_spend_public_key;
+ }
+ else
+ {
+ skey = keys.m_spend_secret_key;
+ crypto::secret_key m = m_account.get_device().get_subaddress_secret_key(keys.m_view_secret_key, index);
+ sc_add((unsigned char*)&skey, (unsigned char*)&m, (unsigned char*)&skey);
+ secret_key_to_public_key(skey, pkey);
+ }
+ crypto::generate_signature(hash, pkey, skey, signature);
return std::string("SigV1") + tools::base58::encode(std::string((const char *)&signature, sizeof(signature)));
}