aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_tx_utils.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-03-14 16:04:10 +0200
committerRiccardo Spagni <ric@spagni.net>2018-03-14 16:04:10 +0200
commit102a51bcd48a3cd2cb794aab7dbe243393f155b3 (patch)
tree513aa5706a9ee849adab2f7cbe719de6741a8b43 /src/cryptonote_core/cryptonote_tx_utils.cpp
parenta03d34f4e1975a67702ae8b7fcad002bd90bc966 (diff)
parent4405e4fc731f0b1b8f194f6cb89f2b69bdf3ea9c (diff)
downloadmonzero-core-102a51bcd48a3cd2cb794aab7dbe243393f155b3.tar.gz
monzero-core-102a51bcd48a3cd2cb794aab7dbe243393f155b3.tar.xz
monzero-core-102a51bcd48a3cd2cb794aab7dbe243393f155b3.zip
Merge pull request #3350
4405e4fc wallet2: check_tx_key() shouldn't require hardware encryption (stoffu) 7dfa5e9e chacha: call prehashed version explicitly as generate_chacha_key_prehashed hash: add prehashed version cn_slow_hash_prehashed slow-hash: let cn_slow_hash take 4th parameter for deciding prehashed or not slow-hash: add support for prehashed version for the other 3 platforms (stoffu) b2d23b18 crypto: revert odd namespace changes made in #3303 (stoffu) 8705beaf keypair::generate: always require hw::device to avoid possible mistake (stoffu) 27a196b1 device: untangle cyclic depenency (stoffu) c9b38b47 device: made function prototypes consistent with pre-#3303 codebase (stoffu)
Diffstat (limited to 'src/cryptonote_core/cryptonote_tx_utils.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index df98feb5a..db4ab9e11 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -41,7 +41,6 @@ using namespace epee;
#include "crypto/hash.h"
#include "ringct/rctSigs.h"
#include "multisig/multisig.h"
-#include "device/device.hpp"
using namespace crypto;
@@ -79,7 +78,7 @@ namespace cryptonote
tx.vout.clear();
tx.extra.clear();
- keypair txkey = keypair::generate();
+ keypair txkey = keypair::generate(hw::get_device("default"));
add_tx_pub_key_to_extra(tx, txkey.pub);
if(!extra_nonce.empty())
if(!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
@@ -237,7 +236,7 @@ namespace cryptonote
return false;
}
- if (!encrypt_payment_id(payment_id, view_key_pub, tx_key, hwdev))
+ if (!hwdev.encrypt_payment_id(payment_id, view_key_pub, tx_key))
{
LOG_ERROR("Failed to encrypt payment id");
return false;
@@ -343,11 +342,11 @@ namespace cryptonote
// if this is a single-destination transfer to a subaddress, we set the tx pubkey to R=s*D
if (num_stdaddresses == 0 && num_subaddresses == 1)
{
- txkey_pub = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(single_dest_subaddress.m_spend_public_key), rct::sk2rct(tx_key), hwdev));
+ txkey_pub = rct::rct2pk(hwdev.scalarmultKey(rct::pk2rct(single_dest_subaddress.m_spend_public_key), rct::sk2rct(tx_key)));
}
else
{
- txkey_pub = rct::rct2pk(rct::scalarmultBase(rct::sk2rct(tx_key), hwdev));
+ txkey_pub = rct::rct2pk(hwdev.scalarmultBase(rct::sk2rct(tx_key)));
}
remove_field_from_tx_extra(tx.extra, typeid(tx_extra_pub_key));
add_tx_pub_key_to_extra(tx, txkey_pub);
@@ -376,22 +375,22 @@ namespace cryptonote
{
additional_txkey.sec = additional_tx_keys[output_index];
if (dst_entr.is_subaddress)
- additional_txkey.pub = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(dst_entr.addr.m_spend_public_key), rct::sk2rct(additional_txkey.sec),hwdev));
+ additional_txkey.pub = rct::rct2pk(hwdev.scalarmultKey(rct::pk2rct(dst_entr.addr.m_spend_public_key), rct::sk2rct(additional_txkey.sec)));
else
- additional_txkey.pub = rct::rct2pk(rct::scalarmultBase(rct::sk2rct(additional_txkey.sec), hwdev));
+ additional_txkey.pub = rct::rct2pk(hwdev.scalarmultBase(rct::sk2rct(additional_txkey.sec)));
}
bool r;
if (change_addr && dst_entr.addr == *change_addr)
{
// sending change to yourself; derivation = a*R
- r = crypto::generate_key_derivation(txkey_pub, sender_account_keys.m_view_secret_key, derivation, hwdev);
+ r = hwdev.generate_key_derivation(txkey_pub, sender_account_keys.m_view_secret_key, derivation);
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << txkey_pub << ", " << sender_account_keys.m_view_secret_key << ")");
}
else
{
// sending to the recipient; derivation = r*A (or s*C in the subaddress scheme)
- r = crypto::generate_key_derivation(dst_entr.addr.m_view_public_key, dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key, derivation, hwdev);
+ r = hwdev.generate_key_derivation(dst_entr.addr.m_view_public_key, dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key, derivation);
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << dst_entr.addr.m_view_public_key << ", " << (dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key) << ")");
}
@@ -403,10 +402,10 @@ namespace cryptonote
if (tx.version > 1)
{
crypto::secret_key scalar1;
- crypto::derivation_to_scalar(derivation, output_index, scalar1, hwdev);
+ hwdev.derivation_to_scalar(derivation, output_index, scalar1);
amount_keys.push_back(rct::sk2rct(scalar1));
}
- r = crypto::derive_public_key(derivation, output_index, dst_entr.addr.m_spend_public_key, out_eph_public_key, hwdev);
+ r = hwdev.derive_public_key(derivation, output_index, dst_entr.addr.m_spend_public_key, out_eph_public_key);
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to derive_public_key(" << derivation << ", " << output_index << ", "<< dst_entr.addr.m_spend_public_key << ")");
hwdev.add_output_key_mapping(dst_entr.addr.m_view_public_key, dst_entr.addr.m_spend_public_key, dst_entr.is_subaddress, output_index, amount_keys.back(), out_eph_public_key);