mirror of
https://github.com/monero-project/monero.git
synced 2025-12-18 10:19:31 -08:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cadbdcd2d | ||
|
|
57930281ff | ||
|
|
171f5aacf3 | ||
|
|
c0057d1f62 | ||
|
|
3a23d2ae0d | ||
|
|
5776829080 | ||
|
|
e37767aadd | ||
|
|
e439ca7634 | ||
|
|
20f732cd86 | ||
|
|
470527138a | ||
|
|
48f721748a | ||
|
|
15e0b28348 | ||
|
|
8f0318d790 | ||
|
|
43d03c1050 | ||
|
|
cc618f2fe4 | ||
|
|
5941a47819 | ||
|
|
84c76cbfcd | ||
|
|
587a295389 | ||
|
|
b2b71d3ad2 | ||
|
|
b8af6ee471 | ||
|
|
5aac057dc6 | ||
|
|
fcb524bea6 | ||
|
|
997830f31b | ||
|
|
49896e5c63 | ||
|
|
7c863a9fa5 | ||
|
|
685259082a | ||
|
|
2e5ac23e2a | ||
|
|
0ec360b41d | ||
|
|
348320a3d4 | ||
|
|
3c1c249922 | ||
|
|
3dfef479d8 | ||
|
|
773509ddd8 | ||
|
|
0cb6a763c1 |
@@ -115,6 +115,9 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
|
||||
# to identify the target architecture, to direct logic in this cmake script.
|
||||
# Since ARCH is a cached variable, it will not be set on first cmake invocation.
|
||||
if (NOT ARCH OR ARCH STREQUAL "" OR ARCH STREQUAL "native" OR ARCH STREQUAL "default")
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "")
|
||||
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
else()
|
||||
set(ARCH_ID "${ARCH}")
|
||||
|
||||
@@ -180,7 +180,7 @@ invokes cmake commands as needed.
|
||||
* Change to the root of the source code directory, change to the most recent release branch, and build:
|
||||
|
||||
cd monero
|
||||
git checkout v0.14.0.0
|
||||
git checkout v0.14.0.1
|
||||
make
|
||||
|
||||
*Optional*: If your machine has several cores and enough memory, enable
|
||||
@@ -242,7 +242,7 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (
|
||||
```
|
||||
git clone https://github.com/monero-project/monero.git
|
||||
cd monero
|
||||
git checkout tags/v0.14.0.0
|
||||
git checkout tags/v0.14.0.1
|
||||
```
|
||||
* Build:
|
||||
```
|
||||
@@ -339,9 +339,9 @@ application.
|
||||
|
||||
cd monero
|
||||
|
||||
* If you would like a specific [version/tag](https://github.com/monero-project/monero/tags), do a git checkout for that version. eg. 'v0.14.0.0'. If you dont care about the version and just want binaries from master, skip this step:
|
||||
* If you would like a specific [version/tag](https://github.com/monero-project/monero/tags), do a git checkout for that version. eg. 'v0.14.0.1'. If you dont care about the version and just want binaries from master, skip this step:
|
||||
|
||||
git checkout v0.14.0.0
|
||||
git checkout v0.14.0.1
|
||||
|
||||
* If you are on a 64-bit system, run:
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target
|
||||
|
||||
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR} CACHE STRING "" FORCE)
|
||||
|
||||
# specify the cross compiler to be used. Darwin uses clang provided by the SDK.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
SET(CMAKE_C_COMPILER @prefix@/native/bin/clang)
|
||||
@@ -85,6 +87,11 @@ endif()
|
||||
|
||||
if(ARCHITECTURE STREQUAL "i686" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
SET(LINUX_32 ON)
|
||||
SET(ARCH_ID "i386")
|
||||
endif()
|
||||
|
||||
if(ARCHITECTURE STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
SET(ARCH_ID "x86_64")
|
||||
endif()
|
||||
|
||||
#Create a new global cmake flag that indicates building with depends
|
||||
|
||||
@@ -46,9 +46,12 @@ set(crypto_sources
|
||||
skein.c
|
||||
slow-hash.c
|
||||
CryptonightR_JIT.c
|
||||
CryptonightR_template.S
|
||||
tree-hash.c)
|
||||
|
||||
if(ARCH_ID STREQUAL "x86_64" OR ARCH_ID STREQUAL "x86-64")
|
||||
list(APPEND crypto_sources CryptonightR_template.S)
|
||||
endif()
|
||||
|
||||
set(crypto_headers)
|
||||
|
||||
set(crypto_private_headers
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "CryptonightR_template.h"
|
||||
|
||||
static const uint8_t prologue[] = {
|
||||
#if defined __x86_64__
|
||||
0x4C, 0x8B, 0xD7, // mov r10, rdi
|
||||
0x53, // push rbx
|
||||
0x55, // push rbp
|
||||
@@ -26,9 +27,11 @@ static const uint8_t prologue[] = {
|
||||
0x41, 0x8B, 0x42, 0x18, // mov eax, DWORD PTR [r10+24]
|
||||
0x41, 0x8B, 0x52, 0x1C, // mov edx, DWORD PTR [r10+28]
|
||||
0x45, 0x8B, 0x4A, 0x20, // mov r9d, DWORD PTR [r10+32]
|
||||
#endif
|
||||
};
|
||||
|
||||
static const uint8_t epilogue[] = {
|
||||
#if defined __x86_64__
|
||||
0x49, 0x8B, 0xE3, // mov rsp, r11
|
||||
0x41, 0x89, 0x1A, // mov DWORD PTR [r10], ebx
|
||||
0x41, 0x89, 0x72, 0x04, // mov DWORD PTR [r10+4], esi
|
||||
@@ -38,6 +41,7 @@ static const uint8_t epilogue[] = {
|
||||
0x5D, // pop rbp
|
||||
0x5B, // pop rbx
|
||||
0xC3, // ret
|
||||
#endif
|
||||
};
|
||||
|
||||
#define APPEND_CODE(src, size) \
|
||||
@@ -50,6 +54,7 @@ static const uint8_t epilogue[] = {
|
||||
|
||||
int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_func buf, const size_t buf_size)
|
||||
{
|
||||
#if defined __x86_64__
|
||||
uint8_t* JIT_code = (uint8_t*) buf;
|
||||
const uint8_t* JIT_code_end = JIT_code + buf_size;
|
||||
|
||||
@@ -99,4 +104,7 @@ int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_f
|
||||
__builtin___clear_cache((char*)buf, (char*)JIT_code);
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
// - Call v4_generate_JIT_code with "buf" pointed to memory allocated on previous step
|
||||
// - Call the generated code instead of "v4_random_math(code, r)", omit the "code" parameter
|
||||
|
||||
typedef void (*v4_random_math_JIT_func)(uint32_t* r) __attribute__((sysv_abi));
|
||||
typedef void (*v4_random_math_JIT_func)(uint32_t* r)
|
||||
#if defined __x86_64__
|
||||
__attribute__((sysv_abi))
|
||||
#endif
|
||||
;
|
||||
|
||||
// Given the random math sequence, generates machine code (x86-64) for it
|
||||
// Returns 0 if code was generated successfully
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef CRYPTONIGHTR_TEMPLATE_H
|
||||
#define CRYPTONIGHTR_TEMPLATE_H
|
||||
|
||||
#if defined __i386 || defined __x86_64__
|
||||
|
||||
void CryptonightR_instruction0(void);
|
||||
void CryptonightR_instruction1(void);
|
||||
void CryptonightR_instruction2(void);
|
||||
@@ -1036,4 +1038,6 @@ const void* instructions_mov[257] = {
|
||||
CryptonightR_instruction_mov256,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CRYPTONIGHTR_TEMPLATE_H
|
||||
|
||||
@@ -65,6 +65,31 @@ static void local_abort(const char *msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
volatile int use_v4_jit_flag = -1;
|
||||
|
||||
static inline int use_v4_jit(void)
|
||||
{
|
||||
#if defined(__x86_64__)
|
||||
|
||||
if (use_v4_jit_flag != -1)
|
||||
return use_v4_jit_flag;
|
||||
|
||||
const char *env = getenv("MONERO_USE_CNV4_JIT");
|
||||
if (!env) {
|
||||
use_v4_jit_flag = 0;
|
||||
}
|
||||
else if (!strcmp(env, "0") || !strcmp(env, "no")) {
|
||||
use_v4_jit_flag = 0;
|
||||
}
|
||||
else {
|
||||
use_v4_jit_flag = 1;
|
||||
}
|
||||
return use_v4_jit_flag;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define VARIANT1_1(p) \
|
||||
do if (variant == 1) \
|
||||
{ \
|
||||
@@ -494,31 +519,6 @@ STATIC INLINE int force_software_aes(void)
|
||||
return use;
|
||||
}
|
||||
|
||||
volatile int use_v4_jit_flag = -1;
|
||||
|
||||
STATIC INLINE int use_v4_jit(void)
|
||||
{
|
||||
#if defined(__x86_64__)
|
||||
|
||||
if (use_v4_jit_flag != -1)
|
||||
return use_v4_jit_flag;
|
||||
|
||||
const char *env = getenv("MONERO_USE_CNV4_JIT");
|
||||
if (!env) {
|
||||
use_v4_jit_flag = 0;
|
||||
}
|
||||
else if (!strcmp(env, "0") || !strcmp(env, "no")) {
|
||||
use_v4_jit_flag = 0;
|
||||
}
|
||||
else {
|
||||
use_v4_jit_flag = 1;
|
||||
}
|
||||
return use_v4_jit_flag;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE int check_aes_hw(void)
|
||||
{
|
||||
int cpuid_results[4];
|
||||
@@ -1029,6 +1029,8 @@ void slow_hash_free_state(void)
|
||||
|
||||
#define U64(x) ((uint64_t *) (x))
|
||||
|
||||
#define hp_jitfunc ((v4_random_math_JIT_func)NULL)
|
||||
|
||||
STATIC INLINE void xor64(uint64_t *a, const uint64_t b)
|
||||
{
|
||||
*a ^= b;
|
||||
@@ -1574,6 +1576,8 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int
|
||||
#else
|
||||
// Portable implementation as a fallback
|
||||
|
||||
#define hp_jitfunc ((v4_random_math_JIT_func)NULL)
|
||||
|
||||
void slow_hash_allocate_state(void)
|
||||
{
|
||||
// Do nothing, this is just to maintain compatibility with the upgraded slow-hash.c
|
||||
|
||||
@@ -332,7 +332,7 @@ int HardFork::get_voted_fork_index(uint64_t height) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
uint32_t accumulated_votes = 0;
|
||||
for (unsigned int n = heights.size() - 1; n > current_fork_index; --n) {
|
||||
for (int n = heights.size() - 1; n >= 0; --n) {
|
||||
uint8_t v = heights[n].version;
|
||||
accumulated_votes += last_versions[v];
|
||||
uint32_t threshold = (window_size * heights[n].threshold + 99) / 100;
|
||||
|
||||
@@ -3675,13 +3675,23 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti
|
||||
{
|
||||
const uint64_t block_weight = m_db->get_block_weight(db_height - 1);
|
||||
|
||||
std::vector<uint64_t> weights;
|
||||
const uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
|
||||
weights.resize(nblocks);
|
||||
for (uint64_t h = 0; h < nblocks; ++h)
|
||||
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h - 1);
|
||||
std::vector<uint64_t> new_weights = weights;
|
||||
uint64_t long_term_median = epee::misc_utils::median(weights);
|
||||
std::vector<uint64_t> weights, new_weights;
|
||||
uint64_t long_term_median;
|
||||
if (db_height == 1)
|
||||
{
|
||||
long_term_median = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64_t nblocks = std::min<uint64_t>(m_long_term_block_weights_window, db_height);
|
||||
if (nblocks == db_height)
|
||||
--nblocks;
|
||||
weights.resize(nblocks);
|
||||
for (uint64_t h = 0; h < nblocks; ++h)
|
||||
weights[h] = m_db->get_block_long_term_weight(db_height - nblocks + h - 1);
|
||||
new_weights = weights;
|
||||
long_term_median = epee::misc_utils::median(weights);
|
||||
}
|
||||
m_long_term_effective_median_block_weight = std::max<uint64_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5, long_term_median);
|
||||
|
||||
uint64_t short_term_constraint = m_long_term_effective_median_block_weight + m_long_term_effective_median_block_weight * 2 / 5;
|
||||
|
||||
@@ -944,13 +944,15 @@ namespace cryptonote
|
||||
bool ok = true;
|
||||
it = tx_blobs.begin();
|
||||
for (size_t i = 0; i < tx_blobs.size(); i++, ++it) {
|
||||
if (already_have[i])
|
||||
continue;
|
||||
if (!results[i].res)
|
||||
{
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
if (keeped_by_block)
|
||||
get_blockchain_storage().on_new_tx_from_block(results[i].tx);
|
||||
if (already_have[i])
|
||||
continue;
|
||||
|
||||
const size_t weight = get_transaction_weight(results[i].tx, it->size());
|
||||
ok &= add_new_tx(results[i].tx, results[i].hash, results[i].prefix_hash, weight, tvc[i], keeped_by_block, relayed, do_not_relay);
|
||||
@@ -1181,9 +1183,6 @@ namespace cryptonote
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::add_new_tx(transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t tx_weight, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
|
||||
{
|
||||
if (keeped_by_block)
|
||||
get_blockchain_storage().on_new_tx_from_block(tx);
|
||||
|
||||
if(m_mempool.have_tx(tx_hash))
|
||||
{
|
||||
LOG_PRINT_L2("tx " << tx_hash << "already have transaction in tx_pool");
|
||||
|
||||
@@ -79,5 +79,6 @@ target_link_libraries(device
|
||||
ringct_basic
|
||||
${OPENSSL_CRYPTO_LIBRARIES}
|
||||
PRIVATE
|
||||
version
|
||||
${Blocks}
|
||||
${EXTRA_LIBRARIES})
|
||||
|
||||
@@ -189,6 +189,8 @@ namespace hw {
|
||||
return encrypt_payment_id(payment_id, public_key, secret_key);
|
||||
}
|
||||
|
||||
virtual rct::key genCommitmentMask(const rct::key &amount_key) = 0;
|
||||
|
||||
virtual bool ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec, bool short_amount) = 0;
|
||||
virtual bool ecdhDecode(rct::ecdhTuple & masked, const rct::key & sharedSec, bool short_amount) = 0;
|
||||
|
||||
|
||||
@@ -349,6 +349,10 @@ namespace hw {
|
||||
return true;
|
||||
}
|
||||
|
||||
rct::key device_default::genCommitmentMask(const rct::key &amount_key) {
|
||||
return rct::genCommitmentMask(amount_key);
|
||||
}
|
||||
|
||||
bool device_default::ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec, bool short_amount) {
|
||||
rct::ecdhEncode(unmasked, sharedSec, short_amount);
|
||||
return true;
|
||||
|
||||
@@ -111,6 +111,8 @@ namespace hw {
|
||||
|
||||
bool encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) override;
|
||||
|
||||
rct::key genCommitmentMask(const rct::key &amount_key) override;
|
||||
|
||||
bool ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec, bool short_amount) override;
|
||||
bool ecdhDecode(rct::ecdhTuple & masked, const rct::key & sharedSec, bool short_amount) override;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "version.h"
|
||||
#include "device_ledger.hpp"
|
||||
#include "log.hpp"
|
||||
#include "ringct/rctOps.h"
|
||||
@@ -173,6 +174,7 @@ namespace hw {
|
||||
#define INS_SET_SIGNATURE_MODE 0x72
|
||||
#define INS_GET_ADDITIONAL_KEY 0x74
|
||||
#define INS_STEALTH 0x76
|
||||
#define INS_GEN_COMMITMENT_MASK 0x77
|
||||
#define INS_BLIND 0x78
|
||||
#define INS_UNBLIND 0x7A
|
||||
#define INS_GEN_TXOUT_KEYS 0x7B
|
||||
@@ -295,8 +297,14 @@ namespace hw {
|
||||
}
|
||||
|
||||
bool device_ledger::reset() {
|
||||
send_simple(INS_RESET);
|
||||
return true;
|
||||
reset_buffer();
|
||||
int offset = set_command_header_noopt(INS_RESET);
|
||||
memmove(this->buffer_send+offset, MONERO_VERSION, strlen(MONERO_VERSION));
|
||||
offset += strlen(MONERO_VERSION);
|
||||
this->buffer_send[4] = offset-5;
|
||||
this->length_send = offset;
|
||||
this->exchange();
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int device_ledger::exchange(unsigned int ok, unsigned int mask) {
|
||||
@@ -307,9 +315,9 @@ namespace hw {
|
||||
|
||||
this->length_recv -= 2;
|
||||
this->sw = (this->buffer_recv[length_recv]<<8) | this->buffer_recv[length_recv+1];
|
||||
logRESP();
|
||||
ASSERT_SW(this->sw,ok,msk);
|
||||
|
||||
logRESP();
|
||||
return this->sw;
|
||||
}
|
||||
|
||||
@@ -1157,13 +1165,18 @@ namespace hw {
|
||||
const cryptonote::account_keys sender_account_keys_x = sender_account_keys;
|
||||
memmove((void*)sender_account_keys_x.m_view_secret_key.data, dbg_viewkey.data, 32);
|
||||
|
||||
const crypto::public_key &txkey_pub_x = txkey_pub;
|
||||
const crypto::secret_key &tx_key_x = tx_key;
|
||||
const cryptonote::tx_destination_entry &dst_entr_x = dst_entr;
|
||||
const boost::optional<cryptonote::account_public_address> &change_addr_x = change_addr;
|
||||
const size_t &output_index_x = output_index;
|
||||
const bool &need_additional_txkeys_x = need_additional_txkeys;
|
||||
const std::vector<crypto::secret_key> &additional_tx_keys_x = additional_tx_keys;
|
||||
const crypto::public_key txkey_pub_x = txkey_pub;
|
||||
const crypto::secret_key tx_key_x = hw::ledger::decrypt(tx_key);
|
||||
const cryptonote::tx_destination_entry dst_entr_x = dst_entr;
|
||||
const boost::optional<cryptonote::account_public_address> change_addr_x = change_addr;
|
||||
const size_t output_index_x = output_index;
|
||||
const bool need_additional_txkeys_x = need_additional_txkeys;
|
||||
|
||||
std::vector<crypto::secret_key> additional_tx_keys_x;
|
||||
for (const auto k: additional_tx_keys) {
|
||||
additional_tx_keys_x.push_back(hw::ledger::decrypt(k));
|
||||
}
|
||||
|
||||
std::vector<crypto::public_key> additional_tx_public_keys_x;
|
||||
std::vector<rct::key> amount_keys_x;
|
||||
crypto::public_key out_eph_public_key_x;
|
||||
@@ -1207,6 +1220,9 @@ namespace hw {
|
||||
//tx_sec
|
||||
memmove(&this->buffer_send[offset], sec->data, 32);
|
||||
offset += 32;
|
||||
//tx_pub
|
||||
memmove(&this->buffer_send[offset], txkey_pub.data, 32);
|
||||
offset += 32;
|
||||
//Aout
|
||||
memmove(&this->buffer_send[offset], dst_entr.addr.m_view_public_key.data, 32);
|
||||
offset += 32;
|
||||
@@ -1264,7 +1280,7 @@ namespace hw {
|
||||
#ifdef DEBUG_HWDEVICE
|
||||
hw::ledger::check32("generate_output_ephemeral_keys", "amount_key", (const char*)amount_keys_x.back().bytes, (const char*)hw::ledger::decrypt(amount_keys.back()).bytes);
|
||||
if (need_additional_txkeys) {
|
||||
hw::ledger::check32("generate_output_ephemeral_keys", "additional_tx_key", additional_tx_keys_x.back().data, additional_tx_keys.back().data);
|
||||
hw::ledger::check32("generate_output_ephemeral_keys", "additional_tx_key", additional_tx_public_keys_x.back().data, additional_tx_public_keys.back().data);
|
||||
}
|
||||
hw::ledger::check32("generate_output_ephemeral_keys", "out_eph_public_key", out_eph_public_key_x.data, out_eph_public_key.data);
|
||||
#endif
|
||||
@@ -1279,6 +1295,32 @@ namespace hw {
|
||||
return true;
|
||||
}
|
||||
|
||||
rct::key device_ledger::genCommitmentMask(const rct::key &AKout) {
|
||||
#ifdef DEBUG_HWDEVICE
|
||||
const rct::key AKout_x = hw::ledger::decrypt(AKout);
|
||||
rct::key mask_x;
|
||||
mask_x = this->controle_device->genCommitmentMask(AKout_x);
|
||||
#endif
|
||||
|
||||
rct::key mask;
|
||||
int offset = set_command_header_noopt(INS_GEN_COMMITMENT_MASK);
|
||||
// AKout
|
||||
memmove(this->buffer_send+offset, AKout.bytes, 32);
|
||||
offset += 32;
|
||||
|
||||
this->buffer_send[4] = offset-5;
|
||||
this->length_send = offset;
|
||||
this->exchange();
|
||||
|
||||
memmove(mask.bytes, &this->buffer_recv[0], 32);
|
||||
|
||||
#ifdef DEBUG_HWDEVICE
|
||||
hw::ledger::check32("genCommitmentMask", "mask", (const char*)mask_x.bytes, (const char*)mask.bytes);
|
||||
#endif
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool device_ledger::ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & AKout, bool short_amount) {
|
||||
AUTO_LOCK_CMD();
|
||||
|
||||
@@ -1310,6 +1352,7 @@ namespace hw {
|
||||
memmove(unmasked.mask.bytes, &this->buffer_recv[32], 32);
|
||||
|
||||
#ifdef DEBUG_HWDEVICE
|
||||
MDEBUG("ecdhEncode: Akout: "<<AKout_x);
|
||||
hw::ledger::check32("ecdhEncode", "amount", (char*)unmasked_x.amount.bytes, (char*)unmasked.amount.bytes);
|
||||
hw::ledger::check32("ecdhEncode", "mask", (char*)unmasked_x.mask.bytes, (char*)unmasked.mask.bytes);
|
||||
|
||||
@@ -1350,6 +1393,7 @@ namespace hw {
|
||||
memmove(masked.mask.bytes, &this->buffer_recv[32], 32);
|
||||
|
||||
#ifdef DEBUG_HWDEVICE
|
||||
MDEBUG("ecdhEncode: Akout: "<<AKout_x);
|
||||
hw::ledger::check32("ecdhDecode", "amount", (char*)masked_x.amount.bytes, (char*)masked.amount.bytes);
|
||||
hw::ledger::check32("ecdhDecode", "mask", (char*)masked_x.mask.bytes,(char*) masked.mask.bytes);
|
||||
#endif
|
||||
|
||||
@@ -194,6 +194,8 @@ namespace hw {
|
||||
|
||||
bool encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) override;
|
||||
|
||||
rct::key genCommitmentMask(const rct::key &amount_key) override;
|
||||
|
||||
bool ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec, bool short_format) override;
|
||||
bool ecdhDecode(rct::ecdhTuple & masked, const rct::key & sharedSec, bool short_format) override;
|
||||
|
||||
|
||||
@@ -45,12 +45,12 @@ using namespace std;
|
||||
#define CHECK_AND_ASSERT_MES_L1(expr, ret, message) {if(!(expr)) {MCERROR("verify", message); return ret;}}
|
||||
|
||||
namespace rct {
|
||||
Bulletproof proveRangeBulletproof(keyV &C, keyV &masks, const std::vector<uint64_t> &amounts, const std::vector<key> &sk)
|
||||
Bulletproof proveRangeBulletproof(keyV &C, keyV &masks, const std::vector<uint64_t> &amounts, const std::vector<key> &sk, hw::device &hwdev)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(amounts.size() == sk.size(), "Invalid amounts/sk sizes");
|
||||
masks.resize(amounts.size());
|
||||
for (size_t i = 0; i < masks.size(); ++i)
|
||||
masks[i] = genCommitmentMask(sk[i]);
|
||||
masks[i] = hwdev.genCommitmentMask(sk[i]);
|
||||
Bulletproof proof = bulletproof_PROVE(amounts, masks);
|
||||
CHECK_AND_ASSERT_THROW_MES(proof.V.size() == amounts.size(), "V does not have the expected size");
|
||||
C = proof.V;
|
||||
@@ -757,7 +757,7 @@ namespace rct {
|
||||
{
|
||||
rct::keyV C, masks;
|
||||
const std::vector<key> keys(amount_keys.begin(), amount_keys.end());
|
||||
rv.p.bulletproofs.push_back(proveRangeBulletproof(C, masks, outamounts, keys));
|
||||
rv.p.bulletproofs.push_back(proveRangeBulletproof(C, masks, outamounts, keys, hwdev));
|
||||
#ifdef DBG
|
||||
CHECK_AND_ASSERT_THROW_MES(verBulletproof(rv.p.bulletproofs.back()), "verBulletproof failed on newly created proof");
|
||||
#endif
|
||||
@@ -780,7 +780,7 @@ namespace rct {
|
||||
std::vector<key> keys(batch_size);
|
||||
for (size_t j = 0; j < batch_size; ++j)
|
||||
keys[j] = amount_keys[amounts_proved + j];
|
||||
rv.p.bulletproofs.push_back(proveRangeBulletproof(C, masks, batch_amounts, keys));
|
||||
rv.p.bulletproofs.push_back(proveRangeBulletproof(C, masks, batch_amounts, keys, hwdev));
|
||||
#ifdef DBG
|
||||
CHECK_AND_ASSERT_THROW_MES(verBulletproof(rv.p.bulletproofs.back()), "verBulletproof failed on newly created proof");
|
||||
#endif
|
||||
|
||||
@@ -1347,7 +1347,8 @@ namespace cryptonote
|
||||
error_resp.message = "Internal error: can't get last block.";
|
||||
return false;
|
||||
}
|
||||
bool response_filled = fill_block_header_response(last_block, false, last_block_height, last_block_hash, res.block_header, req.fill_pow_hash);
|
||||
const bool restricted = m_restricted;
|
||||
bool response_filled = fill_block_header_response(last_block, false, last_block_height, last_block_hash, res.block_header, req.fill_pow_hash && !restricted);
|
||||
if (!response_filled)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
@@ -1388,7 +1389,8 @@ namespace cryptonote
|
||||
return false;
|
||||
}
|
||||
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
|
||||
bool response_filled = fill_block_header_response(blk, orphan, block_height, block_hash, res.block_header, req.fill_pow_hash);
|
||||
const bool restricted = m_restricted;
|
||||
bool response_filled = fill_block_header_response(blk, orphan, block_height, block_hash, res.block_header, req.fill_pow_hash && !restricted);
|
||||
if (!response_filled)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
@@ -1437,7 +1439,8 @@ namespace cryptonote
|
||||
return false;
|
||||
}
|
||||
res.headers.push_back(block_header_response());
|
||||
bool response_filled = fill_block_header_response(blk, false, block_height, block_hash, res.headers.back(), req.fill_pow_hash);
|
||||
const bool restricted = m_restricted;
|
||||
bool response_filled = fill_block_header_response(blk, false, block_height, block_hash, res.headers.back(), req.fill_pow_hash && !restricted);
|
||||
if (!response_filled)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
@@ -1470,7 +1473,8 @@ namespace cryptonote
|
||||
error_resp.message = "Internal error: can't get block by height. Height = " + std::to_string(req.height) + '.';
|
||||
return false;
|
||||
}
|
||||
bool response_filled = fill_block_header_response(blk, false, req.height, block_hash, res.block_header, req.fill_pow_hash);
|
||||
const bool restricted = m_restricted;
|
||||
bool response_filled = fill_block_header_response(blk, false, req.height, block_hash, res.block_header, req.fill_pow_hash && !restricted);
|
||||
if (!response_filled)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
@@ -1524,7 +1528,8 @@ namespace cryptonote
|
||||
return false;
|
||||
}
|
||||
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
|
||||
bool response_filled = fill_block_header_response(blk, orphan, block_height, block_hash, res.block_header, req.fill_pow_hash);
|
||||
const bool restricted = m_restricted;
|
||||
bool response_filled = fill_block_header_response(blk, orphan, block_height, block_hash, res.block_header, req.fill_pow_hash && !restricted);
|
||||
if (!response_filled)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
|
||||
#define DEF_MONERO_VERSION "0.14.0.0"
|
||||
#define DEF_MONERO_VERSION "0.14.0.2"
|
||||
#define DEF_MONERO_RELEASE_NAME "Boron Butterfly"
|
||||
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ void SubaddressAccountImpl::refresh()
|
||||
{
|
||||
m_rows.push_back(new SubaddressAccountRow(
|
||||
i,
|
||||
m_wallet->m_wallet->get_subaddress_as_str({i,0}).substr(0,6),
|
||||
m_wallet->m_wallet->get_subaddress_as_str({i,0}),
|
||||
m_wallet->m_wallet->get_subaddress_label({i,0}),
|
||||
cryptonote::print_money(m_wallet->m_wallet->balance(i)),
|
||||
cryptonote::print_money(m_wallet->m_wallet->unlocked_balance(i))
|
||||
|
||||
@@ -941,6 +941,12 @@ uint64_t WalletImpl::approximateBlockChainHeight() const
|
||||
{
|
||||
return m_wallet->get_approximate_blockchain_height();
|
||||
}
|
||||
|
||||
uint64_t WalletImpl::estimateBlockChainHeight() const
|
||||
{
|
||||
return m_wallet->estimate_blockchain_height();
|
||||
}
|
||||
|
||||
uint64_t WalletImpl::daemonBlockChainHeight() const
|
||||
{
|
||||
if(m_wallet->light_wallet()) {
|
||||
|
||||
@@ -109,6 +109,7 @@ public:
|
||||
uint64_t unlockedBalance(uint32_t accountIndex = 0) const override;
|
||||
uint64_t blockChainHeight() const override;
|
||||
uint64_t approximateBlockChainHeight() const override;
|
||||
uint64_t estimateBlockChainHeight() const override;
|
||||
uint64_t daemonBlockChainHeight() const override;
|
||||
uint64_t daemonBlockChainTargetHeight() const override;
|
||||
bool synchronized() const override;
|
||||
|
||||
@@ -574,6 +574,12 @@ struct Wallet
|
||||
*/
|
||||
virtual uint64_t approximateBlockChainHeight() const = 0;
|
||||
|
||||
/**
|
||||
* @brief estimateBlockChainHeight - returns estimate blockchain height. More accurate than approximateBlockChainHeight,
|
||||
* uses daemon height and falls back to calculation from date/time
|
||||
* @return
|
||||
**/
|
||||
virtual uint64_t estimateBlockChainHeight() const = 0;
|
||||
/**
|
||||
* @brief daemonBlockChainHeight - returns daemon blockchain height
|
||||
* @return 0 - in case error communicating with the daemon.
|
||||
|
||||
@@ -127,6 +127,8 @@ Wallet *WalletManagerImpl::createWalletFromDevice(const std::string &path,
|
||||
WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
|
||||
if(restoreHeight > 0){
|
||||
wallet->setRefreshFromBlockHeight(restoreHeight);
|
||||
} else {
|
||||
wallet->setRefreshFromBlockHeight(wallet->estimateBlockChainHeight());
|
||||
}
|
||||
auto lookahead = tools::parse_subaddress_lookahead(subaddressLookahead);
|
||||
if (lookahead)
|
||||
|
||||
@@ -1296,7 +1296,7 @@ static uint64_t decodeRct(const rct::rctSig & rv, const crypto::key_derivation &
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::scan_output(const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs)
|
||||
void wallet2::scan_output(const cryptonote::transaction &tx, bool miner_tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs)
|
||||
{
|
||||
THROW_WALLET_EXCEPTION_IF(i >= tx.vout.size(), error::wallet_internal_error, "Invalid vout index");
|
||||
|
||||
@@ -1329,11 +1329,14 @@ void wallet2::scan_output(const cryptonote::transaction &tx, const crypto::publi
|
||||
error::wallet_internal_error, "key_image generated ephemeral public key not matched with output_key");
|
||||
}
|
||||
|
||||
THROW_WALLET_EXCEPTION_IF(std::find(outs.begin(), outs.end(), i) != outs.end(), error::wallet_internal_error, "Same output cannot be added twice");
|
||||
outs.push_back(i);
|
||||
if (tx_scan_info.money_transfered == 0)
|
||||
if (tx_scan_info.money_transfered == 0 && !miner_tx)
|
||||
{
|
||||
tx_scan_info.money_transfered = tools::decodeRct(tx.rct_signatures, tx_scan_info.received->derivation, i, tx_scan_info.mask, m_account.get_device());
|
||||
}
|
||||
THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs[tx_scan_info.received->index] >= std::numeric_limits<uint64_t>::max() - tx_scan_info.money_transfered,
|
||||
error::wallet_internal_error, "Overflow in received amounts");
|
||||
tx_money_got_in_outs[tx_scan_info.received->index] += tx_scan_info.money_transfered;
|
||||
tx_scan_info.amount = tx_scan_info.money_transfered;
|
||||
++num_vouts_received;
|
||||
@@ -1512,7 +1515,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
if (tx_scan_info[i].received)
|
||||
{
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys.data, derivation, additional_derivations);
|
||||
scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1535,7 +1538,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
if (tx_scan_info[i].received)
|
||||
{
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys.data, derivation, additional_derivations);
|
||||
scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1551,7 +1554,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
hwdev.set_mode(hw::device::NONE);
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys.data, derivation, additional_derivations);
|
||||
scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9093,7 +9096,7 @@ bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks) const
|
||||
result = m_node_rpc_proxy.get_earliest_height(version, earliest_height);
|
||||
throw_on_rpc_response_error(result, "get_hard_fork_info");
|
||||
|
||||
bool close_enough = height >= earliest_height - early_blocks; // start using the rules that many blocks beforehand
|
||||
bool close_enough = height >= earliest_height - early_blocks && earliest_height != std::numeric_limits<uint64_t>::max(); // start using the rules that many blocks beforehand
|
||||
if (close_enough)
|
||||
LOG_PRINT_L2("Using v" << (unsigned)version << " rules");
|
||||
else
|
||||
@@ -10697,6 +10700,7 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to generate key derivation");
|
||||
}
|
||||
size_t output_index = 0;
|
||||
bool miner_tx = cryptonote::is_coinbase(spent_tx);
|
||||
for (const cryptonote::tx_out& out : spent_tx.vout)
|
||||
{
|
||||
tx_scan_info_t tx_scan_info;
|
||||
@@ -10704,11 +10708,13 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
|
||||
THROW_WALLET_EXCEPTION_IF(tx_scan_info.error, error::wallet_internal_error, "check_acc_out_precomp failed");
|
||||
if (tx_scan_info.received)
|
||||
{
|
||||
if (tx_scan_info.money_transfered == 0)
|
||||
if (tx_scan_info.money_transfered == 0 && !miner_tx)
|
||||
{
|
||||
rct::key mask;
|
||||
tx_scan_info.money_transfered = tools::decodeRct(spent_tx.rct_signatures, tx_scan_info.received->derivation, output_index, mask, hwdev);
|
||||
}
|
||||
THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs >= std::numeric_limits<uint64_t>::max() - tx_scan_info.money_transfered,
|
||||
error::wallet_internal_error, "Overflow in received amounts");
|
||||
tx_money_got_in_outs += tx_scan_info.money_transfered;
|
||||
}
|
||||
++output_index;
|
||||
|
||||
@@ -1239,7 +1239,7 @@ namespace tools
|
||||
crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const;
|
||||
bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector<size_t> &unused_transfers_indices, const std::vector<size_t> &unused_dust_indices) const;
|
||||
std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
|
||||
void scan_output(const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs);
|
||||
void scan_output(const cryptonote::transaction &tx, bool miner_tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs);
|
||||
void trim_hashchain();
|
||||
crypto::key_image get_multisig_composite_key_image(size_t n) const;
|
||||
rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const crypto::public_key &ignore, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const;
|
||||
|
||||
@@ -56,7 +56,6 @@ add_test(
|
||||
add_executable(cnv4-jit-tests cnv4-jit.c)
|
||||
target_link_libraries(cnv4-jit-tests
|
||||
PRIVATE
|
||||
crypto
|
||||
common
|
||||
${EXTRA_LIBRARIES})
|
||||
set_property(TARGET cnv4-jit-tests
|
||||
|
||||
Reference in New Issue
Block a user