diff options
| author | Riccardo Spagni <ric@spagni.net> | 2018-04-12 14:41:51 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2018-04-12 14:41:51 +0200 |
| commit | 079dd5dfefbb6da1e86d4dec2ad0d9a8acc0e593 (patch) | |
| tree | dfc70af05997d97a5ad43ef77a364b8f86ade611 /src/device/device_ledger.cpp | |
| parent | 5e08fd89ea9cd36ad00b7f6ba17be75f27e5c57e (diff) | |
| parent | 94b899db26b4e50953e4c258dc4d28a550aa4301 (diff) | |
| download | monzero-core-079dd5dfefbb6da1e86d4dec2ad0d9a8acc0e593.tar.gz monzero-core-079dd5dfefbb6da1e86d4dec2ad0d9a8acc0e593.tar.xz monzero-core-079dd5dfefbb6da1e86d4dec2ad0d9a8acc0e593.zip | |
Merge pull request #3616
94b899db Use 'boost' mutex instead of 'std' mutex (cslashm)
2c274e05 Fix sub-address tx scan. (cslashm)
Diffstat (limited to 'src/device/device_ledger.cpp')
| -rw-r--r-- | src/device/device_ledger.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index ee1497438..3b9ab6744 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -56,6 +56,7 @@ namespace hw { #define ASSERT_RV(rv) CHECK_AND_ASSERT_THROW_MES((rv)==SCARD_S_SUCCESS, "Fail SCard API : (" << (rv) << ") "<< pcsc_stringify_error(rv)<<" Device="<<this->id<<", hCard="<<hCard<<", hContext="<<hContext); #define ASSERT_SW(sw,ok,msk) CHECK_AND_ASSERT_THROW_MES(((sw)&(mask))==(ok), "Wrong Device Status : SW=" << std::hex << (sw) << " (EXPECT=" << std::hex << (ok) << ", MASK=" << std::hex << (mask) << ")") ; #define ASSERT_T0(exp) CHECK_AND_ASSERT_THROW_MES(exp, "Protocol assert failure: "#exp ) ; + #define ASSERT_X(exp,msg) CHECK_AND_ASSERT_THROW_MES(exp, msg); #ifdef DEBUG_HWDEVICE crypto::secret_key dbg_viewkey; @@ -125,6 +126,10 @@ namespace hw { return sec == crypto::null_skey; } + bool operator==(const crypto::key_derivation &d0, const crypto::key_derivation &d1) { + return !memcmp(&d0, &d1, sizeof(d0)); + } + /* ===================================================================== */ /* === Device ==== */ /* ===================================================================== */ @@ -1094,6 +1099,24 @@ namespace hw { return r; } + bool device_ledger::conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) { + const crypto::public_key *pkey=NULL; + if (derivation == main_derivation) { + pkey = &tx_pub_key; + MDEBUG("conceal derivation with main tx pub key"); + } else { + for(size_t n=0; n < additional_derivations.size();++n) { + if(derivation == additional_derivations[n]) { + pkey = &additional_tx_pub_keys[n]; + MDEBUG("conceal derivation with additionnal tx pub key"); + break; + } + } + } + ASSERT_X(pkey, "Mismatched derivation on scan info"); + return this->generate_key_derivation(*pkey, crypto::null_skey, derivation); + } + bool device_ledger::derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) { AUTO_LOCK_CMD(); int offset; |
