aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_ledger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/device/device_ledger.cpp')
-rw-r--r--src/device/device_ledger.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp
index 51837b8a2..b3c0035a1 100644
--- a/src/device/device_ledger.cpp
+++ b/src/device/device_ledger.cpp
@@ -30,6 +30,8 @@
#include "device_ledger.hpp"
#include "log.hpp"
#include "ringct/rctOps.h"
+#include "cryptonote_basic/account.h"
+#include "cryptonote_basic/subaddress_index.h"
@@ -511,10 +513,10 @@ namespace hw {
char prekey[200];
memmove(prekey, &this->buffer_recv[0], 200);
- crypto::generate_chacha_key(&prekey[0], sizeof(prekey), key, 0, true);
+ crypto::generate_chacha_key_prehashed(&prekey[0], sizeof(prekey), key);
#ifdef DEBUG_HWDEVICE
- hw::ledger::check32("generate_chacha_key", "key", (char*)key_x.data(), (char*)key.data());
+ hw::ledger::check32("generate_chacha_key_prehashed", "key", (char*)key_x.data(), (char*)key.data());
#endif
unlock_device();
@@ -593,7 +595,8 @@ namespace hw {
return true;
}
- bool device_ledger::get_subaddress_spend_public_key(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index, crypto::public_key &D) {
+ crypto::public_key device_ledger::get_subaddress_spend_public_key(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index) {
+ crypto::public_key D;
lock_device();
try {
int offset =0;
@@ -646,21 +649,23 @@ namespace hw {
unlock_device();
throw;
}
- return true;
+ return D;
}
- bool device_ledger::get_subaddress_spend_public_keys(const cryptonote::account_keys &keys, uint32_t account, uint32_t begin, uint32_t end, std::vector<crypto::public_key> &pkeys) {
+ std::vector<crypto::public_key> device_ledger::get_subaddress_spend_public_keys(const cryptonote::account_keys &keys, uint32_t account, uint32_t begin, uint32_t end) {
+ std::vector<crypto::public_key> pkeys;
cryptonote::subaddress_index index = {account, begin};
crypto::public_key D;
for (uint32_t idx = begin; idx < end; ++idx) {
index.minor = idx;
- this->get_subaddress_spend_public_key(keys, index, D);
+ D = this->get_subaddress_spend_public_key(keys, index);
pkeys.push_back(D);
}
- return true;
+ return pkeys;
}
- bool device_ledger::get_subaddress(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index, cryptonote::account_public_address &address) {
+ cryptonote::account_public_address device_ledger::get_subaddress(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index) {
+ cryptonote::account_public_address address;
lock_device();
try {
int offset =0;
@@ -717,10 +722,11 @@ namespace hw {
unlock_device();
throw;
}
- return true;
+ return address;
}
- bool device_ledger::get_subaddress_secret_key(const crypto::secret_key &sec, const cryptonote::subaddress_index &index, crypto::secret_key &sub_sec) {
+ crypto::secret_key device_ledger::get_subaddress_secret_key(const crypto::secret_key &sec, const cryptonote::subaddress_index &index) {
+ crypto::secret_key sub_sec;
lock_device();
try {
int offset =0;
@@ -771,7 +777,7 @@ namespace hw {
unlock_device();
throw;
}
- return true;
+ return sub_sec;
}
/* ======================================================================= */
@@ -979,7 +985,7 @@ namespace hw {
return true;
}
- bool device_ledger::generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key, bool recover, crypto::secret_key &rng) {
+ crypto::secret_key device_ledger::generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key, bool recover) {
if (recover) {
throw std::runtime_error("device generate key does not support recover");
}
@@ -1030,7 +1036,7 @@ namespace hw {
unlock_device();
throw;
}
- return true;
+ return sec;
}
@@ -1457,7 +1463,7 @@ namespace hw {
return true;
}
- bool device_ledger::encrypt_payment_id(const crypto::public_key &public_key, const crypto::secret_key &secret_key, crypto::hash8 &payment_id) {
+ bool device_ledger::encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) {
lock_device();
try {
int offset =0;