Skip to content

Commit

Permalink
Ledger HW Bug fixes
Browse files Browse the repository at this point in the history
Fix the way the REAL mode is handle:
  Let create_transactions_2 and create_transactions_from construct the vector of transactions.
  Then iterate on it and resign.
  We just need to add 'outs' list in the TX struct for that.

Fix default secret keys value when DEBUG_HWDEVICE mode is off
  The magic value (00...00 for view key and FF..FF for spend key) was not correctly set
  when DEBUG_HWDEVICE was off. Both was set to 00...00.

Add sub-address info in ABP map in order to correctly display destination sub-address on device

Fix DEBUG_HWDEVICE mode:
   - Fix compilation errors.
   - Fix control device init in ledger device.
   - Add more log.

Fix sub addr control

Fix debug Info
  • Loading branch information
cslashm committed Mar 12, 2018
1 parent e9f41e4 commit 73dd883
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 139 deletions.
2 changes: 0 additions & 2 deletions src/cryptonote_basic/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ DISABLE_VS_WARNINGS(4244 4345)
hwdev.init();
hwdev.connect();
hwdev.get_public_address(m_keys.m_account_address);
#ifdef DEBUG_HWDEVICE
hwdev.get_secret_keys(m_keys.m_view_secret_key, m_keys.m_spend_secret_key);
#endif
struct tm timestamp = {0};
timestamp.tm_year = 2014 - 1900; // year 2014
timestamp.tm_mon = 4 - 1; // month april
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/cryptonote_tx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ namespace cryptonote
r = crypto::derive_public_key(derivation, output_index, dst_entr.addr.m_spend_public_key, out_eph_public_key, hwdev);
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, output_index, amount_keys.back(), out_eph_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);

tx_out out;
out.amount = dst_entr.amount;
Expand Down
2 changes: 1 addition & 1 deletion src/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ namespace hw {
return *device->second;
}

}
}
18 changes: 16 additions & 2 deletions src/device/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
//


/* Note about debug:
* To debug Device you can def the following :
* #define DEBUG_HWDEVICE
* Activate debug mechanism:
* - Add more trace
* - All computation done by device are checked by default device.
* Required IODUMMYCRYPT_HWDEVICE or IONOCRYPT_HWDEVICE for fully working
* #define IODUMMYCRYPT_HWDEVICE 1
* - It assumes sensitive data encryption is is off on device side. a XOR with 0x55. This allow Ledger Class to make check on clear value
* #define IONOCRYPT_HWDEVICE 1
* - It assumes sensitive data encryption is off on device side.
*/


#pragma once

#include "cryptonote_basic/cryptonote_basic.h"
Expand Down Expand Up @@ -128,8 +142,8 @@ namespace hw {
virtual bool ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec) = 0;
virtual bool ecdhDecode(rct::ecdhTuple & masked, const rct::key & sharedSec) = 0;

virtual bool add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, size_t real_output_index,
const rct::key &amount_key, const crypto::public_key &out_eph_public_key) = 0;
virtual bool add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, const bool is_subaddress, const size_t real_output_index,
const rct::key &amount_key, const crypto::public_key &out_eph_public_key) = 0;


virtual bool mlsag_prehash(const std::string &blob, size_t inputs_size, size_t outputs_size, const rct::keyV &hashes, const rct::ctkeyV &outPk, rct::key &prehash) = 0;
Expand Down
5 changes: 0 additions & 5 deletions src/device/device_declare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@

#pragma once


//#define DEBUG_HWDEVICE
//#define IODUMMYCRYPT 1
//#define IONOCRYPT 1

namespace hw {
class device;

Expand Down
2 changes: 1 addition & 1 deletion src/device/device_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace hw {
}


bool device_default::add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, size_t real_output_index,
bool device_default::add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, const bool is_subaddress, const size_t real_output_index,
const rct::key &amount_key, const crypto::public_key &out_eph_public_key) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/device/device_default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ namespace hw {
bool ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec) override;
bool ecdhDecode(rct::ecdhTuple & masked, const rct::key & sharedSec) override;

bool add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, size_t real_output_index,
const rct::key &amount_key, const crypto::public_key &out_eph_public_key) override;
bool add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, const bool is_subaddress, const size_t real_output_index,
const rct::key &amount_key, const crypto::public_key &out_eph_public_key) override;


bool mlsag_prehash(const std::string &blob, size_t inputs_size, size_t outputs_size, const rct::keyV &hashes, const rct::ctkeyV &outPk, rct::key &prehash) override;
Expand Down
Loading

0 comments on commit 73dd883

Please sign in to comment.