aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp1
-rw-r--r--src/common/notify.cpp2
-rw-r--r--src/crypto/CMakeLists.txt9
-rw-r--r--src/crypto/CryptonightR_JIT.c102
-rw-r--r--src/crypto/CryptonightR_JIT.h18
-rw-r--r--src/crypto/CryptonightR_template.S1590
-rw-r--r--src/crypto/CryptonightR_template.h1039
-rw-r--r--src/crypto/slow-hash.c95
-rw-r--r--src/cryptonote_core/blockchain.cpp27
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp42
-rw-r--r--src/cryptonote_core/cryptonote_core.h2
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp45
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.h6
-rw-r--r--src/device/device.hpp10
-rw-r--r--src/device/device_default.cpp53
-rw-r--r--src/device/device_default.hpp9
-rw-r--r--src/device/device_ledger.cpp289
-rw-r--r--src/device/device_ledger.hpp19
-rw-r--r--src/device/log.cpp4
-rw-r--r--src/wallet/wallet2.cpp20
-rw-r--r--src/wallet/wallet2.h2
21 files changed, 3244 insertions, 140 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 00912a447..6abf0f54c 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -4787,6 +4787,7 @@ void BlockchainLMDB::migrate_2_3()
throw0(DB_ERROR(lmdb_error("Failed to delete old block_info table: ", result).c_str()));
RENAME_DB("block_infn");
+ mdb_dbi_close(m_env, m_block_info);
lmdb_db_open(txn, "block_info", MDB_INTEGERKEY | MDB_CREATE | MDB_DUPSORT | MDB_DUPFIXED, m_block_info, "Failed to open db handle for block_infn");
mdb_set_dupsort(txn, m_block_info, compare_uint64);
diff --git a/src/common/notify.cpp b/src/common/notify.cpp
index c3165fb05..e2df5096d 100644
--- a/src/common/notify.cpp
+++ b/src/common/notify.cpp
@@ -48,7 +48,7 @@ Notify::Notify(const char *spec)
{
CHECK_AND_ASSERT_THROW_MES(spec, "Null spec");
- boost::split(args, spec, boost::is_any_of(" "));
+ boost::split(args, spec, boost::is_any_of(" \t"), boost::token_compress_on);
CHECK_AND_ASSERT_THROW_MES(args.size() > 0, "Failed to parse spec");
if (strchr(spec, '\'') || strchr(spec, '\"') || strchr(spec, '\\'))
MWARNING("A notification spec contains a quote or backslash: note that these are handled verbatim, which may not be the intent");
diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt
index 0c635e7cb..5ce43be22 100644
--- a/src/crypto/CMakeLists.txt
+++ b/src/crypto/CMakeLists.txt
@@ -45,6 +45,8 @@ set(crypto_sources
random.c
skein.c
slow-hash.c
+ CryptonightR_JIT.c
+ CryptonightR_template.S
tree-hash.c)
set(crypto_headers)
@@ -66,7 +68,9 @@ set(crypto_private_headers
oaes_lib.h
random.h
skein.h
- skein_port.h)
+ skein_port.h
+ CryptonightR_JIT.h
+ CryptonightR_template.h)
monero_private_headers(cncrypto
${crypto_private_headers})
@@ -101,4 +105,5 @@ if (ANDROID OR IOS)
endif()
endif()
-
+# cheat because cmake and ccache hate each other
+set_property(SOURCE CryptonightR_template.S PROPERTY LANGUAGE C)
diff --git a/src/crypto/CryptonightR_JIT.c b/src/crypto/CryptonightR_JIT.c
new file mode 100644
index 000000000..9add65296
--- /dev/null
+++ b/src/crypto/CryptonightR_JIT.c
@@ -0,0 +1,102 @@
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "int-util.h"
+#include "hash-ops.h"
+#include "variant4_random_math.h"
+#include "CryptonightR_JIT.h"
+#include "CryptonightR_template.h"
+
+static const uint8_t prologue[] = {
+ 0x4C, 0x8B, 0xD7, // mov r10, rdi
+ 0x53, // push rbx
+ 0x55, // push rbp
+ 0x41, 0x57, // push r15
+ 0x4C, 0x8B, 0xDC, // mov r11, rsp
+ 0x41, 0x8B, 0x1A, // mov ebx, DWORD PTR [r10]
+ 0x41, 0x8B, 0x72, 0x04, // mov esi, DWORD PTR [r10+4]
+ 0x41, 0x8B, 0x7A, 0x08, // mov edi, DWORD PTR [r10+8]
+ 0x41, 0x8B, 0x6A, 0x0C, // mov ebp, DWORD PTR [r10+12]
+ 0x41, 0x8B, 0x62, 0x10, // mov esp, DWORD PTR [r10+16]
+ 0x45, 0x8B, 0x7A, 0x14, // mov r15d, DWORD PTR [r10+20]
+ 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]
+};
+
+static const uint8_t epilogue[] = {
+ 0x49, 0x8B, 0xE3, // mov rsp, r11
+ 0x41, 0x89, 0x1A, // mov DWORD PTR [r10], ebx
+ 0x41, 0x89, 0x72, 0x04, // mov DWORD PTR [r10+4], esi
+ 0x41, 0x89, 0x7A, 0x08, // mov DWORD PTR [r10+8], edi
+ 0x41, 0x89, 0x6A, 0x0C, // mov DWORD PTR [r10+12], ebp
+ 0x41, 0x5F, // pop r15
+ 0x5D, // pop rbp
+ 0x5B, // pop rbx
+ 0xC3, // ret
+};
+
+#define APPEND_CODE(src, size) \
+ do { \
+ if (JIT_code + (size) > JIT_code_end) \
+ return -1; \
+ memcpy(JIT_code, (src), (size)); \
+ JIT_code += (size); \
+ } while (0)
+
+int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_func buf, const size_t buf_size)
+{
+ uint8_t* JIT_code = (uint8_t*) buf;
+ const uint8_t* JIT_code_end = JIT_code + buf_size;
+
+ APPEND_CODE(prologue, sizeof(prologue));
+
+ uint32_t prev_rot_src = 0xFFFFFFFFU;
+
+ for (int i = 0;; ++i)
+ {
+ const struct V4_Instruction inst = code[i];
+ if (inst.opcode == RET)
+ break;
+
+ const uint8_t opcode = (inst.opcode == MUL) ? inst.opcode : (inst.opcode + 2);
+
+ const uint32_t a = inst.dst_index;
+ const uint32_t b = inst.src_index;
+ const uint8_t c = opcode | (inst.dst_index << V4_OPCODE_BITS) | (((inst.src_index == 8) ? inst.dst_index : inst.src_index) << (V4_OPCODE_BITS + V4_DST_INDEX_BITS));
+
+ switch (inst.opcode)
+ {
+ case ROR:
+ case ROL:
+ if (b != prev_rot_src)
+ {
+ prev_rot_src = b;
+ const uint8_t* p1 = (const uint8_t*) instructions_mov[c];
+ const uint8_t* p2 = (const uint8_t*) instructions_mov[c + 1];
+ APPEND_CODE(p1, p2 - p1);
+ }
+ break;
+ }
+
+ if (a == prev_rot_src)
+ prev_rot_src = 0xFFFFFFFFU;
+
+ const uint8_t* p1 = (const uint8_t*) instructions[c];
+ const uint8_t* p2 = (const uint8_t*) instructions[c + 1];
+ APPEND_CODE(p1, p2 - p1);
+
+ if (inst.opcode == ADD)
+ *(uint32_t*)(JIT_code - 4) = inst.C;
+ }
+
+ APPEND_CODE(epilogue, sizeof(epilogue));
+
+ __builtin___clear_cache((char*)buf, (char*)JIT_code);
+
+ return 0;
+}
diff --git a/src/crypto/CryptonightR_JIT.h b/src/crypto/CryptonightR_JIT.h
new file mode 100644
index 000000000..5f689b37b
--- /dev/null
+++ b/src/crypto/CryptonightR_JIT.h
@@ -0,0 +1,18 @@
+#ifndef CRYPTONIGHTR_JIT_H
+#define CRYPTONIGHTR_JIT_H
+
+// Minimalistic JIT code generator for random math sequence in CryptonightR
+//
+// Usage:
+// - Allocate writable and executable memory
+// - 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));
+
+// Given the random math sequence, generates machine code (x86-64) for it
+// Returns 0 if code was generated successfully
+// Returns -1 if provided buffer was too small
+int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_func buf, const size_t buf_size);
+
+#endif // CRYPTONIGHTR_JIT_H
diff --git a/src/crypto/CryptonightR_template.S b/src/crypto/CryptonightR_template.S
new file mode 100644
index 000000000..068de22ec
--- /dev/null
+++ b/src/crypto/CryptonightR_template.S
@@ -0,0 +1,1590 @@
+#ifdef __APPLE__
+# define ALIGN(x) .align 6
+#else
+# define ALIGN(x) .align 64
+#endif
+.intel_syntax noprefix
+#ifdef __APPLE__
+# define FN_PREFIX(fn) _ ## fn
+.text
+#else
+# define FN_PREFIX(fn) fn
+.section .text
+#endif
+
+#define PUBLIC .global
+
+PUBLIC FN_PREFIX(CryptonightR_instruction0)
+PUBLIC FN_PREFIX(CryptonightR_instruction1)
+PUBLIC FN_PREFIX(CryptonightR_instruction2)
+PUBLIC FN_PREFIX(CryptonightR_instruction3)
+PUBLIC FN_PREFIX(CryptonightR_instruction4)
+PUBLIC FN_PREFIX(CryptonightR_instruction5)
+PUBLIC FN_PREFIX(CryptonightR_instruction6)
+PUBLIC FN_PREFIX(CryptonightR_instruction7)
+PUBLIC FN_PREFIX(CryptonightR_instruction8)
+PUBLIC FN_PREFIX(CryptonightR_instruction9)
+PUBLIC FN_PREFIX(CryptonightR_instruction10)
+PUBLIC FN_PREFIX(CryptonightR_instruction11)
+PUBLIC FN_PREFIX(CryptonightR_instruction12)
+PUBLIC FN_PREFIX(CryptonightR_instruction13)
+PUBLIC FN_PREFIX(CryptonightR_instruction14)
+PUBLIC FN_PREFIX(CryptonightR_instruction15)
+PUBLIC FN_PREFIX(CryptonightR_instruction16)
+PUBLIC FN_PREFIX(CryptonightR_instruction17)
+PUBLIC FN_PREFIX(CryptonightR_instruction18)
+PUBLIC FN_PREFIX(CryptonightR_instruction19)
+PUBLIC FN_PREFIX(CryptonightR_instruction20)
+PUBLIC FN_PREFIX(CryptonightR_instruction21)
+PUBLIC FN_PREFIX(CryptonightR_instruction22)
+PUBLIC FN_PREFIX(CryptonightR_instruction23)
+PUBLIC FN_PREFIX(CryptonightR_instruction24)
+PUBLIC FN_PREFIX(CryptonightR_instruction25)
+PUBLIC FN_PREFIX(CryptonightR_instruction26)
+PUBLIC FN_PREFIX(CryptonightR_instruction27)
+PUBLIC FN_PREFIX(CryptonightR_instruction28)
+PUBLIC FN_PREFIX(CryptonightR_instruction29)
+PUBLIC FN_PREFIX(CryptonightR_instruction30)
+PUBLIC FN_PREFIX(CryptonightR_instruction31)
+PUBLIC FN_PREFIX(CryptonightR_instruction32)
+PUBLIC FN_PREFIX(CryptonightR_instruction33)
+PUBLIC FN_PREFIX(CryptonightR_instruction34)
+PUBLIC FN_PREFIX(CryptonightR_instruction35)
+PUBLIC FN_PREFIX(CryptonightR_instruction36)
+PUBLIC FN_PREFIX(CryptonightR_instruction37)
+PUBLIC FN_PREFIX(CryptonightR_instruction38)
+PUBLIC FN_PREFIX(CryptonightR_instruction39)
+PUBLIC FN_PREFIX(CryptonightR_instruction40)
+PUBLIC FN_PREFIX(CryptonightR_instruction41)
+PUBLIC FN_PREFIX(CryptonightR_instruction42)
+PUBLIC FN_PREFIX(CryptonightR_instruction43)
+PUBLIC FN_PREFIX(CryptonightR_instruction44)
+PUBLIC FN_PREFIX(CryptonightR_instruction45)
+PUBLIC FN_PREFIX(CryptonightR_instruction46)
+PUBLIC FN_PREFIX(CryptonightR_instruction47)
+PUBLIC FN_PREFIX(CryptonightR_instruction48)
+PUBLIC FN_PREFIX(CryptonightR_instruction49)
+PUBLIC FN_PREFIX(CryptonightR_instruction50)
+PUBLIC FN_PREFIX(CryptonightR_instruction51)
+PUBLIC FN_PREFIX(CryptonightR_instruction52)
+PUBLIC FN_PREFIX(CryptonightR_instruction53)
+PUBLIC FN_PREFIX(CryptonightR_instruction54)
+PUBLIC FN_PREFIX(CryptonightR_instruction55)
+PUBLIC FN_PREFIX(CryptonightR_instruction56)
+PUBLIC FN_PREFIX(CryptonightR_instruction57)
+PUBLIC FN_PREFIX(CryptonightR_instruction58)
+PUBLIC FN_PREFIX(CryptonightR_instruction59)
+PUBLIC FN_PREFIX(CryptonightR_instruction60)
+PUBLIC FN_PREFIX(CryptonightR_instruction61)
+PUBLIC FN_PREFIX(CryptonightR_instruction62)
+PUBLIC FN_PREFIX(CryptonightR_instruction63)
+PUBLIC FN_PREFIX(CryptonightR_instruction64)
+PUBLIC FN_PREFIX(CryptonightR_instruction65)
+PUBLIC FN_PREFIX(CryptonightR_instruction66)
+PUBLIC FN_PREFIX(CryptonightR_instruction67)
+PUBLIC FN_PREFIX(CryptonightR_instruction68)
+PUBLIC FN_PREFIX(CryptonightR_instruction69)
+PUBLIC FN_PREFIX(CryptonightR_instruction70)
+PUBLIC FN_PREFIX(CryptonightR_instruction71)
+PUBLIC FN_PREFIX(CryptonightR_instruction72)
+PUBLIC FN_PREFIX(CryptonightR_instruction73)
+PUBLIC FN_PREFIX(CryptonightR_instruction74)
+PUBLIC FN_PREFIX(CryptonightR_instruction75)
+PUBLIC FN_PREFIX(CryptonightR_instruction76)
+PUBLIC FN_PREFIX(CryptonightR_instruction77)
+PUBLIC FN_PREFIX(CryptonightR_instruction78)
+PUBLIC FN_PREFIX(CryptonightR_instruction79)
+PUBLIC FN_PREFIX(CryptonightR_instruction80)
+PUBLIC FN_PREFIX(CryptonightR_instruction81)
+PUBLIC FN_PREFIX(CryptonightR_instruction82)
+PUBLIC FN_PREFIX(CryptonightR_instruction83)
+PUBLIC FN_PREFIX(CryptonightR_instruction84)
+PUBLIC FN_PREFIX(CryptonightR_instruction85)
+PUBLIC FN_PREFIX(CryptonightR_instruction86)
+PUBLIC FN_PREFIX(CryptonightR_instruction87)
+PUBLIC FN_PREFIX(CryptonightR_instruction88)
+PUBLIC FN_PREFIX(CryptonightR_instruction89)
+PUBLIC FN_PREFIX(CryptonightR_instruction90)
+PUBLIC FN_PREFIX(CryptonightR_instruction91)
+PUBLIC FN_PREFIX(CryptonightR_instruction92)
+PUBLIC FN_PREFIX(CryptonightR_instruction93)
+PUBLIC FN_PREFIX(CryptonightR_instruction94)
+PUBLIC FN_PREFIX(CryptonightR_instruction95)
+PUBLIC FN_PREFIX(CryptonightR_instruction96)
+PUBLIC FN_PREFIX(CryptonightR_instruction97)
+PUBLIC FN_PREFIX(CryptonightR_instruction98)
+PUBLIC FN_PREFIX(CryptonightR_instruction99)
+PUBLIC FN_PREFIX(CryptonightR_instruction100)
+PUBLIC FN_PREFIX(CryptonightR_instruction101)
+PUBLIC FN_PREFIX(CryptonightR_instruction102)
+PUBLIC FN_PREFIX(CryptonightR_instruction103)
+PUBLIC FN_PREFIX(CryptonightR_instruction104)
+PUBLIC FN_PREFIX(CryptonightR_instruction105)
+PUBLIC FN_PREFIX(CryptonightR_instruction106)
+PUBLIC FN_PREFIX(CryptonightR_instruction107)
+PUBLIC FN_PREFIX(CryptonightR_instruction108)
+PUBLIC FN_PREFIX(CryptonightR_instruction109)
+PUBLIC FN_PREFIX(CryptonightR_instruction110)
+PUBLIC FN_PREFIX(CryptonightR_instruction111)
+PUBLIC FN_PREFIX(CryptonightR_instruction112)
+PUBLIC FN_PREFIX(CryptonightR_instruction113)
+PUBLIC FN_PREFIX(CryptonightR_instruction114)
+PUBLIC FN_PREFIX(CryptonightR_instruction115)
+PUBLIC FN_PREFIX(CryptonightR_instruction116)
+PUBLIC FN_PREFIX(CryptonightR_instruction117)
+PUBLIC FN_PREFIX(CryptonightR_instruction118)
+PUBLIC FN_PREFIX(CryptonightR_instruction119)
+PUBLIC FN_PREFIX(CryptonightR_instruction120)
+PUBLIC FN_PREFIX(CryptonightR_instruction121)
+PUBLIC FN_PREFIX(CryptonightR_instruction122)
+PUBLIC FN_PREFIX(CryptonightR_instruction123)
+PUBLIC FN_PREFIX(CryptonightR_instruction124)
+PUBLIC FN_PREFIX(CryptonightR_instruction125)
+PUBLIC FN_PREFIX(CryptonightR_instruction126)
+PUBLIC FN_PREFIX(CryptonightR_instruction127)
+PUBLIC FN_PREFIX(CryptonightR_instruction128)
+PUBLIC FN_PREFIX(CryptonightR_instruction129)
+PUBLIC FN_PREFIX(CryptonightR_instruction130)
+PUBLIC FN_PREFIX(CryptonightR_instruction131)
+PUBLIC FN_PREFIX(CryptonightR_instruction132)
+PUBLIC FN_PREFIX(CryptonightR_instruction133)
+PUBLIC FN_PREFIX(CryptonightR_instruction134)
+PUBLIC FN_PREFIX(CryptonightR_instruction135)
+PUBLIC FN_PREFIX(CryptonightR_instruction136)
+PUBLIC FN_PREFIX(CryptonightR_instruction137)
+PUBLIC FN_PREFIX(CryptonightR_instruction138)
+PUBLIC FN_PREFIX(CryptonightR_instruction139)
+PUBLIC FN_PREFIX(CryptonightR_instruction140)
+PUBLIC FN_PREFIX(CryptonightR_instruction141)
+PUBLIC FN_PREFIX(CryptonightR_instruction142)
+PUBLIC FN_PREFIX(CryptonightR_instruction143)
+PUBLIC FN_PREFIX(CryptonightR_instruction144)
+PUBLIC FN_PREFIX(CryptonightR_instruction145)
+PUBLIC FN_PREFIX(CryptonightR_instruction146)
+PUBLIC FN_PREFIX(CryptonightR_instruction147)
+PUBLIC FN_PREFIX(CryptonightR_instruction148)
+PUBLIC FN_PREFIX(CryptonightR_instruction149)
+PUBLIC FN_PREFIX(CryptonightR_instruction150)
+PUBLIC FN_PREFIX(CryptonightR_instruction151)
+PUBLIC FN_PREFIX(CryptonightR_instruction152)
+PUBLIC FN_PREFIX(CryptonightR_instruction153)
+PUBLIC FN_PREFIX(CryptonightR_instruction154)
+PUBLIC FN_PREFIX(CryptonightR_instruction155)
+PUBLIC FN_PREFIX(CryptonightR_instruction156)
+PUBLIC FN_PREFIX(CryptonightR_instruction157)
+PUBLIC FN_PREFIX(CryptonightR_instruction158)
+PUBLIC FN_PREFIX(CryptonightR_instruction159)
+PUBLIC FN_PREFIX(CryptonightR_instruction160)
+PUBLIC FN_PREFIX(CryptonightR_instruction161)
+PUBLIC FN_PREFIX(CryptonightR_instruction162)
+PUBLIC FN_PREFIX(CryptonightR_instruction163)
+PUBLIC FN_PREFIX(CryptonightR_instruction164)
+PUBLIC FN_PREFIX(CryptonightR_instruction165)
+PUBLIC FN_PREFIX(CryptonightR_instruction166)
+PUBLIC FN_PREFIX(CryptonightR_instruction167)
+PUBLIC FN_PREFIX(CryptonightR_instruction168)
+PUBLIC FN_PREFIX(CryptonightR_instruction169)
+PUBLIC FN_PREFIX(CryptonightR_instruction170)
+PUBLIC FN_PREFIX(CryptonightR_instruction171)
+PUBLIC FN_PREFIX(CryptonightR_instruction172)
+PUBLIC FN_PREFIX(CryptonightR_instruction173)
+PUBLIC FN_PREFIX(CryptonightR_instruction174)
+PUBLIC FN_PREFIX(CryptonightR_instruction175)
+PUBLIC FN_PREFIX(CryptonightR_instruction176)
+PUBLIC FN_PREFIX(CryptonightR_instruction177)
+PUBLIC FN_PREFIX(CryptonightR_instruction178)
+PUBLIC FN_PREFIX(CryptonightR_instruction179)
+PUBLIC FN_PREFIX(CryptonightR_instruction180)
+PUBLIC FN_PREFIX(CryptonightR_instruction181)
+PUBLIC FN_PREFIX(CryptonightR_instruction182)
+PUBLIC FN_PREFIX(CryptonightR_instruction183)
+PUBLIC FN_PREFIX(CryptonightR_instruction184)
+PUBLIC FN_PREFIX(CryptonightR_instruction185)
+PUBLIC FN_PREFIX(CryptonightR_instruction186)
+PUBLIC FN_PREFIX(CryptonightR_instruction187)
+PUBLIC FN_PREFIX(CryptonightR_instruction188)
+PUBLIC FN_PREFIX(CryptonightR_instruction189)
+PUBLIC FN_PREFIX(CryptonightR_instruction190)
+PUBLIC FN_PREFIX(CryptonightR_instruction191)
+PUBLIC FN_PREFIX(CryptonightR_instruction192)
+PUBLIC FN_PREFIX(CryptonightR_instruction193)
+PUBLIC FN_PREFIX(CryptonightR_instruction194)
+PUBLIC FN_PREFIX(CryptonightR_instruction195)
+PUBLIC FN_PREFIX(CryptonightR_instruction196)
+PUBLIC FN_PREFIX(CryptonightR_instruction197)
+PUBLIC FN_PREFIX(CryptonightR_instruction198)
+PUBLIC FN_PREFIX(CryptonightR_instruction199)
+PUBLIC FN_PREFIX(CryptonightR_instruction200)
+PUBLIC FN_PREFIX(CryptonightR_instruction201)
+PUBLIC FN_PREFIX(CryptonightR_instruction202)
+PUBLIC FN_PREFIX(CryptonightR_instruction203)
+PUBLIC FN_PREFIX(CryptonightR_instruction204)
+PUBLIC FN_PREFIX(CryptonightR_instruction205)
+PUBLIC FN_PREFIX(CryptonightR_instruction206)
+PUBLIC FN_PREFIX(CryptonightR_instruction207)
+PUBLIC FN_PREFIX(CryptonightR_instruction208)
+PUBLIC FN_PREFIX(CryptonightR_instruction209)
+PUBLIC FN_PREFIX(CryptonightR_instruction210)
+PUBLIC FN_PREFIX(CryptonightR_instruction211)
+PUBLIC FN_PREFIX(CryptonightR_instruction212)
+PUBLIC FN_PREFIX(CryptonightR_instruction213)
+PUBLIC FN_PREFIX(CryptonightR_instruction214)
+PUBLIC FN_PREFIX(CryptonightR_instruction215)
+PUBLIC FN_PREFIX(CryptonightR_instruction216)
+PUBLIC FN_PREFIX(CryptonightR_instruction217)
+PUBLIC FN_PREFIX(CryptonightR_instruction218)
+PUBLIC FN_PREFIX(CryptonightR_instruction219)
+PUBLIC FN_PREFIX(CryptonightR_instruction220)
+PUBLIC FN_PREFIX(CryptonightR_instruction221)
+PUBLIC FN_PREFIX(CryptonightR_instruction222)
+PUBLIC FN_PREFIX(CryptonightR_instruction223)
+PUBLIC FN_PREFIX(CryptonightR_instruction224)
+PUBLIC FN_PREFIX(CryptonightR_instruction225)
+PUBLIC FN_PREFIX(CryptonightR_instruction226)
+PUBLIC FN_PREFIX(CryptonightR_instruction227)
+PUBLIC FN_PREFIX(CryptonightR_instruction228)
+PUBLIC FN_PREFIX(CryptonightR_instruction229)
+PUBLIC FN_PREFIX(CryptonightR_instruction230)
+PUBLIC FN_PREFIX(CryptonightR_instruction231)
+PUBLIC FN_PREFIX(CryptonightR_instruction232)
+PUBLIC FN_PREFIX(CryptonightR_instruction233)
+PUBLIC FN_PREFIX(CryptonightR_instruction234)
+PUBLIC FN_PREFIX(CryptonightR_instruction235)
+PUBLIC FN_PREFIX(CryptonightR_instruction236)
+PUBLIC FN_PREFIX(CryptonightR_instruction237)
+PUBLIC FN_PREFIX(CryptonightR_instruction238)
+PUBLIC FN_PREFIX(CryptonightR_instruction239)
+PUBLIC FN_PREFIX(CryptonightR_instruction240)
+PUBLIC FN_PREFIX(CryptonightR_instruction241)
+PUBLIC FN_PREFIX(CryptonightR_instruction242)
+PUBLIC FN_PREFIX(CryptonightR_instruction243)
+PUBLIC FN_PREFIX(CryptonightR_instruction244)
+PUBLIC FN_PREFIX(CryptonightR_instruction245)
+PUBLIC FN_PREFIX(CryptonightR_instruction246)
+PUBLIC FN_PREFIX(CryptonightR_instruction247)
+PUBLIC FN_PREFIX(CryptonightR_instruction248)
+PUBLIC FN_PREFIX(CryptonightR_instruction249)
+PUBLIC FN_PREFIX(CryptonightR_instruction250)
+PUBLIC FN_PREFIX(CryptonightR_instruction251)
+PUBLIC FN_PREFIX(CryptonightR_instruction252)
+PUBLIC FN_PREFIX(CryptonightR_instruction253)
+PUBLIC FN_PREFIX(CryptonightR_instruction254)
+PUBLIC FN_PREFIX(CryptonightR_instruction255)
+PUBLIC FN_PREFIX(CryptonightR_instruction256)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov0)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov1)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov2)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov3)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov4)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov5)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov6)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov7)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov8)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov9)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov10)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov11)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov12)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov13)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov14)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov15)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov16)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov17)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov18)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov19)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov20)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov21)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov22)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov23)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov24)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov25)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov26)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov27)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov28)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov29)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov30)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov31)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov32)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov33)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov34)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov35)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov36)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov37)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov38)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov39)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov40)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov41)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov42)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov43)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov44)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov45)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov46)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov47)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov48)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov49)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov50)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov51)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov52)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov53)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov54)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov55)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov56)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov57)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov58)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov59)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov60)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov61)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov62)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov63)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov64)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov65)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov66)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov67)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov68)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov69)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov70)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov71)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov72)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov73)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov74)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov75)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov76)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov77)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov78)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov79)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov80)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov81)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov82)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov83)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov84)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov85)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov86)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov87)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov88)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov89)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov90)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov91)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov92)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov93)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov94)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov95)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov96)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov97)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov98)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov99)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov100)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov101)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov102)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov103)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov104)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov105)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov106)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov107)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov108)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov109)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov110)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov111)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov112)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov113)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov114)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov115)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov116)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov117)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov118)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov119)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov120)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov121)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov122)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov123)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov124)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov125)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov126)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov127)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov128)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov129)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov130)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov131)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov132)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov133)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov134)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov135)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov136)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov137)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov138)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov139)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov140)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov141)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov142)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov143)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov144)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov145)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov146)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov147)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov148)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov149)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov150)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov151)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov152)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov153)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov154)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov155)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov156)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov157)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov158)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov159)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov160)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov161)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov162)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov163)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov164)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov165)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov166)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov167)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov168)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov169)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov170)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov171)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov172)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov173)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov174)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov175)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov176)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov177)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov178)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov179)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov180)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov181)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov182)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov183)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov184)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov185)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov186)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov187)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov188)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov189)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov190)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov191)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov192)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov193)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov194)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov195)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov196)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov197)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov198)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov199)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov200)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov201)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov202)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov203)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov204)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov205)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov206)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov207)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov208)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov209)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov210)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov211)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov212)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov213)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov214)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov215)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov216)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov217)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov218)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov219)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov220)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov221)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov222)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov223)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov224)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov225)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov226)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov227)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov228)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov229)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov230)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov231)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov232)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov233)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov234)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov235)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov236)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov237)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov238)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov239)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov240)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov241)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov242)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov243)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov244)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov245)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov246)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov247)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov248)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov249)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov250)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov251)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov252)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov253)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov254)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov255)
+PUBLIC FN_PREFIX(CryptonightR_instruction_mov256)
+
+FN_PREFIX(CryptonightR_instruction0):
+ imul ebx, ebx
+FN_PREFIX(CryptonightR_instruction1):
+ imul ebx, ebx
+FN_PREFIX(CryptonightR_instruction2):
+ imul ebx, ebx
+FN_PREFIX(CryptonightR_instruction3):
+ add ebx, r9d
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction4):
+ sub ebx, r9d
+FN_PREFIX(CryptonightR_instruction5):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction6):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction7):
+ xor ebx, r9d
+FN_PREFIX(CryptonightR_instruction8):
+ imul esi, ebx
+FN_PREFIX(CryptonightR_instruction9):
+ imul esi, ebx
+FN_PREFIX(CryptonightR_instruction10):
+ imul esi, ebx
+FN_PREFIX(CryptonightR_instruction11):
+ add esi, ebx
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction12):
+ sub esi, ebx
+FN_PREFIX(CryptonightR_instruction13):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction14):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction15):
+ xor esi, ebx
+FN_PREFIX(CryptonightR_instruction16):
+ imul edi, ebx
+FN_PREFIX(CryptonightR_instruction17):
+ imul edi, ebx
+FN_PREFIX(CryptonightR_instruction18):
+ imul edi, ebx
+FN_PREFIX(CryptonightR_instruction19):
+ add edi, ebx
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction20):
+ sub edi, ebx
+FN_PREFIX(CryptonightR_instruction21):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction22):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction23):
+ xor edi, ebx
+FN_PREFIX(CryptonightR_instruction24):
+ imul ebp, ebx
+FN_PREFIX(CryptonightR_instruction25):
+ imul ebp, ebx
+FN_PREFIX(CryptonightR_instruction26):
+ imul ebp, ebx
+FN_PREFIX(CryptonightR_instruction27):
+ add ebp, ebx
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction28):
+ sub ebp, ebx
+FN_PREFIX(CryptonightR_instruction29):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction30):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction31):
+ xor ebp, ebx
+FN_PREFIX(CryptonightR_instruction32):
+ imul ebx, esi
+FN_PREFIX(CryptonightR_instruction33):
+ imul ebx, esi
+FN_PREFIX(CryptonightR_instruction34):
+ imul ebx, esi
+FN_PREFIX(CryptonightR_instruction35):
+ add ebx, esi
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction36):
+ sub ebx, esi
+FN_PREFIX(CryptonightR_instruction37):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction38):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction39):
+ xor ebx, esi
+FN_PREFIX(CryptonightR_instruction40):
+ imul esi, esi
+FN_PREFIX(CryptonightR_instruction41):
+ imul esi, esi
+FN_PREFIX(CryptonightR_instruction42):
+ imul esi, esi
+FN_PREFIX(CryptonightR_instruction43):
+ add esi, r9d
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction44):
+ sub esi, r9d
+FN_PREFIX(CryptonightR_instruction45):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction46):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction47):
+ xor esi, r9d
+FN_PREFIX(CryptonightR_instruction48):
+ imul edi, esi
+FN_PREFIX(CryptonightR_instruction49):
+ imul edi, esi
+FN_PREFIX(CryptonightR_instruction50):
+ imul edi, esi
+FN_PREFIX(CryptonightR_instruction51):
+ add edi, esi
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction52):
+ sub edi, esi
+FN_PREFIX(CryptonightR_instruction53):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction54):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction55):
+ xor edi, esi
+FN_PREFIX(CryptonightR_instruction56):
+ imul ebp, esi
+FN_PREFIX(CryptonightR_instruction57):
+ imul ebp, esi
+FN_PREFIX(CryptonightR_instruction58):
+ imul ebp, esi
+FN_PREFIX(CryptonightR_instruction59):
+ add ebp, esi
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction60):
+ sub ebp, esi
+FN_PREFIX(CryptonightR_instruction61):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction62):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction63):
+ xor ebp, esi
+FN_PREFIX(CryptonightR_instruction64):
+ imul ebx, edi
+FN_PREFIX(CryptonightR_instruction65):
+ imul ebx, edi
+FN_PREFIX(CryptonightR_instruction66):
+ imul ebx, edi
+FN_PREFIX(CryptonightR_instruction67):
+ add ebx, edi
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction68):
+ sub ebx, edi
+FN_PREFIX(CryptonightR_instruction69):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction70):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction71):
+ xor ebx, edi
+FN_PREFIX(CryptonightR_instruction72):
+ imul esi, edi
+FN_PREFIX(CryptonightR_instruction73):
+ imul esi, edi
+FN_PREFIX(CryptonightR_instruction74):
+ imul esi, edi
+FN_PREFIX(CryptonightR_instruction75):
+ add esi, edi
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction76):
+ sub esi, edi
+FN_PREFIX(CryptonightR_instruction77):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction78):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction79):
+ xor esi, edi
+FN_PREFIX(CryptonightR_instruction80):
+ imul edi, edi
+FN_PREFIX(CryptonightR_instruction81):
+ imul edi, edi
+FN_PREFIX(CryptonightR_instruction82):
+ imul edi, edi
+FN_PREFIX(CryptonightR_instruction83):
+ add edi, r9d
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction84):
+ sub edi, r9d
+FN_PREFIX(CryptonightR_instruction85):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction86):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction87):
+ xor edi, r9d
+FN_PREFIX(CryptonightR_instruction88):
+ imul ebp, edi
+FN_PREFIX(CryptonightR_instruction89):
+ imul ebp, edi
+FN_PREFIX(CryptonightR_instruction90):
+ imul ebp, edi
+FN_PREFIX(CryptonightR_instruction91):
+ add ebp, edi
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction92):
+ sub ebp, edi
+FN_PREFIX(CryptonightR_instruction93):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction94):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction95):
+ xor ebp, edi
+FN_PREFIX(CryptonightR_instruction96):
+ imul ebx, ebp
+FN_PREFIX(CryptonightR_instruction97):
+ imul ebx, ebp
+FN_PREFIX(CryptonightR_instruction98):
+ imul ebx, ebp
+FN_PREFIX(CryptonightR_instruction99):
+ add ebx, ebp
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction100):
+ sub ebx, ebp
+FN_PREFIX(CryptonightR_instruction101):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction102):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction103):
+ xor ebx, ebp
+FN_PREFIX(CryptonightR_instruction104):
+ imul esi, ebp
+FN_PREFIX(CryptonightR_instruction105):
+ imul esi, ebp
+FN_PREFIX(CryptonightR_instruction106):
+ imul esi, ebp
+FN_PREFIX(CryptonightR_instruction107):
+ add esi, ebp
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction108):
+ sub esi, ebp
+FN_PREFIX(CryptonightR_instruction109):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction110):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction111):
+ xor esi, ebp
+FN_PREFIX(CryptonightR_instruction112):
+ imul edi, ebp
+FN_PREFIX(CryptonightR_instruction113):
+ imul edi, ebp
+FN_PREFIX(CryptonightR_instruction114):
+ imul edi, ebp
+FN_PREFIX(CryptonightR_instruction115):
+ add edi, ebp
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction116):
+ sub edi, ebp
+FN_PREFIX(CryptonightR_instruction117):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction118):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction119):
+ xor edi, ebp
+FN_PREFIX(CryptonightR_instruction120):
+ imul ebp, ebp
+FN_PREFIX(CryptonightR_instruction121):
+ imul ebp, ebp
+FN_PREFIX(CryptonightR_instruction122):
+ imul ebp, ebp
+FN_PREFIX(CryptonightR_instruction123):
+ add ebp, r9d
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction124):
+ sub ebp, r9d
+FN_PREFIX(CryptonightR_instruction125):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction126):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction127):
+ xor ebp, r9d
+FN_PREFIX(CryptonightR_instruction128):
+ imul ebx, esp
+FN_PREFIX(CryptonightR_instruction129):
+ imul ebx, esp
+FN_PREFIX(CryptonightR_instruction130):
+ imul ebx, esp
+FN_PREFIX(CryptonightR_instruction131):
+ add ebx, esp
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction132):
+ sub ebx, esp
+FN_PREFIX(CryptonightR_instruction133):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction134):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction135):
+ xor ebx, esp
+FN_PREFIX(CryptonightR_instruction136):
+ imul esi, esp
+FN_PREFIX(CryptonightR_instruction137):
+ imul esi, esp
+FN_PREFIX(CryptonightR_instruction138):
+ imul esi, esp
+FN_PREFIX(CryptonightR_instruction139):
+ add esi, esp
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction140):
+ sub esi, esp
+FN_PREFIX(CryptonightR_instruction141):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction142):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction143):
+ xor esi, esp
+FN_PREFIX(CryptonightR_instruction144):
+ imul edi, esp
+FN_PREFIX(CryptonightR_instruction145):
+ imul edi, esp
+FN_PREFIX(CryptonightR_instruction146):
+ imul edi, esp
+FN_PREFIX(CryptonightR_instruction147):
+ add edi, esp
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction148):
+ sub edi, esp
+FN_PREFIX(CryptonightR_instruction149):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction150):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction151):
+ xor edi, esp
+FN_PREFIX(CryptonightR_instruction152):
+ imul ebp, esp
+FN_PREFIX(CryptonightR_instruction153):
+ imul ebp, esp
+FN_PREFIX(CryptonightR_instruction154):
+ imul ebp, esp
+FN_PREFIX(CryptonightR_instruction155):
+ add ebp, esp
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction156):
+ sub ebp, esp
+FN_PREFIX(CryptonightR_instruction157):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction158):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction159):
+ xor ebp, esp
+FN_PREFIX(CryptonightR_instruction160):
+ imul ebx, r15d
+FN_PREFIX(CryptonightR_instruction161):
+ imul ebx, r15d
+FN_PREFIX(CryptonightR_instruction162):
+ imul ebx, r15d
+FN_PREFIX(CryptonightR_instruction163):
+ add ebx, r15d
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction164):
+ sub ebx, r15d
+FN_PREFIX(CryptonightR_instruction165):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction166):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction167):
+ xor ebx, r15d
+FN_PREFIX(CryptonightR_instruction168):
+ imul esi, r15d
+FN_PREFIX(CryptonightR_instruction169):
+ imul esi, r15d
+FN_PREFIX(CryptonightR_instruction170):
+ imul esi, r15d
+FN_PREFIX(CryptonightR_instruction171):
+ add esi, r15d
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction172):
+ sub esi, r15d
+FN_PREFIX(CryptonightR_instruction173):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction174):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction175):
+ xor esi, r15d
+FN_PREFIX(CryptonightR_instruction176):
+ imul edi, r15d
+FN_PREFIX(CryptonightR_instruction177):
+ imul edi, r15d
+FN_PREFIX(CryptonightR_instruction178):
+ imul edi, r15d
+FN_PREFIX(CryptonightR_instruction179):
+ add edi, r15d
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction180):
+ sub edi, r15d
+FN_PREFIX(CryptonightR_instruction181):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction182):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction183):
+ xor edi, r15d
+FN_PREFIX(CryptonightR_instruction184):
+ imul ebp, r15d
+FN_PREFIX(CryptonightR_instruction185):
+ imul ebp, r15d
+FN_PREFIX(CryptonightR_instruction186):
+ imul ebp, r15d
+FN_PREFIX(CryptonightR_instruction187):
+ add ebp, r15d
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction188):
+ sub ebp, r15d
+FN_PREFIX(CryptonightR_instruction189):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction190):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction191):
+ xor ebp, r15d
+FN_PREFIX(CryptonightR_instruction192):
+ imul ebx, eax
+FN_PREFIX(CryptonightR_instruction193):
+ imul ebx, eax
+FN_PREFIX(CryptonightR_instruction194):
+ imul ebx, eax
+FN_PREFIX(CryptonightR_instruction195):
+ add ebx, eax
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction196):
+ sub ebx, eax
+FN_PREFIX(CryptonightR_instruction197):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction198):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction199):
+ xor ebx, eax
+FN_PREFIX(CryptonightR_instruction200):
+ imul esi, eax
+FN_PREFIX(CryptonightR_instruction201):
+ imul esi, eax
+FN_PREFIX(CryptonightR_instruction202):
+ imul esi, eax
+FN_PREFIX(CryptonightR_instruction203):
+ add esi, eax
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction204):
+ sub esi, eax
+FN_PREFIX(CryptonightR_instruction205):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction206):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction207):
+ xor esi, eax
+FN_PREFIX(CryptonightR_instruction208):
+ imul edi, eax
+FN_PREFIX(CryptonightR_instruction209):
+ imul edi, eax
+FN_PREFIX(CryptonightR_instruction210):
+ imul edi, eax
+FN_PREFIX(CryptonightR_instruction211):
+ add edi, eax
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction212):
+ sub edi, eax
+FN_PREFIX(CryptonightR_instruction213):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction214):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction215):
+ xor edi, eax
+FN_PREFIX(CryptonightR_instruction216):
+ imul ebp, eax
+FN_PREFIX(CryptonightR_instruction217):
+ imul ebp, eax
+FN_PREFIX(CryptonightR_instruction218):
+ imul ebp, eax
+FN_PREFIX(CryptonightR_instruction219):
+ add ebp, eax
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction220):
+ sub ebp, eax
+FN_PREFIX(CryptonightR_instruction221):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction222):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction223):
+ xor ebp, eax
+FN_PREFIX(CryptonightR_instruction224):
+ imul ebx, edx
+FN_PREFIX(CryptonightR_instruction225):
+ imul ebx, edx
+FN_PREFIX(CryptonightR_instruction226):
+ imul ebx, edx
+FN_PREFIX(CryptonightR_instruction227):
+ add ebx, edx
+ add ebx, 2147483647
+FN_PREFIX(CryptonightR_instruction228):
+ sub ebx, edx
+FN_PREFIX(CryptonightR_instruction229):
+ ror ebx, cl
+FN_PREFIX(CryptonightR_instruction230):
+ rol ebx, cl
+FN_PREFIX(CryptonightR_instruction231):
+ xor ebx, edx
+FN_PREFIX(CryptonightR_instruction232):
+ imul esi, edx
+FN_PREFIX(CryptonightR_instruction233):
+ imul esi, edx
+FN_PREFIX(CryptonightR_instruction234):
+ imul esi, edx
+FN_PREFIX(CryptonightR_instruction235):
+ add esi, edx
+ add esi, 2147483647
+FN_PREFIX(CryptonightR_instruction236):
+ sub esi, edx
+FN_PREFIX(CryptonightR_instruction237):
+ ror esi, cl
+FN_PREFIX(CryptonightR_instruction238):
+ rol esi, cl
+FN_PREFIX(CryptonightR_instruction239):
+ xor esi, edx
+FN_PREFIX(CryptonightR_instruction240):
+ imul edi, edx
+FN_PREFIX(CryptonightR_instruction241):
+ imul edi, edx
+FN_PREFIX(CryptonightR_instruction242):
+ imul edi, edx
+FN_PREFIX(CryptonightR_instruction243):
+ add edi, edx
+ add edi, 2147483647
+FN_PREFIX(CryptonightR_instruction244):
+ sub edi, edx
+FN_PREFIX(CryptonightR_instruction245):
+ ror edi, cl
+FN_PREFIX(CryptonightR_instruction246):
+ rol edi, cl
+FN_PREFIX(CryptonightR_instruction247):
+ xor edi, edx
+FN_PREFIX(CryptonightR_instruction248):
+ imul ebp, edx
+FN_PREFIX(CryptonightR_instruction249):
+ imul ebp, edx
+FN_PREFIX(CryptonightR_instruction250):
+ imul ebp, edx
+FN_PREFIX(CryptonightR_instruction251):
+ add ebp, edx
+ add ebp, 2147483647
+FN_PREFIX(CryptonightR_instruction252):
+ sub ebp, edx
+FN_PREFIX(CryptonightR_instruction253):
+ ror ebp, cl
+FN_PREFIX(CryptonightR_instruction254):
+ rol ebp, cl
+FN_PREFIX(CryptonightR_instruction255):
+ xor ebp, edx
+FN_PREFIX(CryptonightR_instruction256):
+ imul ebx, ebx
+FN_PREFIX(CryptonightR_instruction_mov0):
+
+FN_PREFIX(CryptonightR_instruction_mov1):
+
+FN_PREFIX(CryptonightR_instruction_mov2):
+
+FN_PREFIX(CryptonightR_instruction_mov3):
+
+FN_PREFIX(CryptonightR_instruction_mov4):
+
+FN_PREFIX(CryptonightR_instruction_mov5):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov6):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov7):
+
+FN_PREFIX(CryptonightR_instruction_mov8):
+
+FN_PREFIX(CryptonightR_instruction_mov9):
+
+FN_PREFIX(CryptonightR_instruction_mov10):
+
+FN_PREFIX(CryptonightR_instruction_mov11):
+
+FN_PREFIX(CryptonightR_instruction_mov12):
+
+FN_PREFIX(CryptonightR_instruction_mov13):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov14):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov15):
+
+FN_PREFIX(CryptonightR_instruction_mov16):
+
+FN_PREFIX(CryptonightR_instruction_mov17):
+
+FN_PREFIX(CryptonightR_instruction_mov18):
+
+FN_PREFIX(CryptonightR_instruction_mov19):
+
+FN_PREFIX(CryptonightR_instruction_mov20):
+
+FN_PREFIX(CryptonightR_instruction_mov21):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov22):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov23):
+
+FN_PREFIX(CryptonightR_instruction_mov24):
+
+FN_PREFIX(CryptonightR_instruction_mov25):
+
+FN_PREFIX(CryptonightR_instruction_mov26):
+
+FN_PREFIX(CryptonightR_instruction_mov27):
+
+FN_PREFIX(CryptonightR_instruction_mov28):
+
+FN_PREFIX(CryptonightR_instruction_mov29):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov30):
+ mov ecx, ebx
+FN_PREFIX(CryptonightR_instruction_mov31):
+
+FN_PREFIX(CryptonightR_instruction_mov32):
+
+FN_PREFIX(CryptonightR_instruction_mov33):
+
+FN_PREFIX(CryptonightR_instruction_mov34):
+
+FN_PREFIX(CryptonightR_instruction_mov35):
+
+FN_PREFIX(CryptonightR_instruction_mov36):
+
+FN_PREFIX(CryptonightR_instruction_mov37):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov38):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov39):
+
+FN_PREFIX(CryptonightR_instruction_mov40):
+
+FN_PREFIX(CryptonightR_instruction_mov41):
+
+FN_PREFIX(CryptonightR_instruction_mov42):
+
+FN_PREFIX(CryptonightR_instruction_mov43):
+
+FN_PREFIX(CryptonightR_instruction_mov44):
+
+FN_PREFIX(CryptonightR_instruction_mov45):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov46):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov47):
+
+FN_PREFIX(CryptonightR_instruction_mov48):
+
+FN_PREFIX(CryptonightR_instruction_mov49):
+
+FN_PREFIX(CryptonightR_instruction_mov50):
+
+FN_PREFIX(CryptonightR_instruction_mov51):
+
+FN_PREFIX(CryptonightR_instruction_mov52):
+
+FN_PREFIX(CryptonightR_instruction_mov53):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov54):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov55):
+
+FN_PREFIX(CryptonightR_instruction_mov56):
+
+FN_PREFIX(CryptonightR_instruction_mov57):
+
+FN_PREFIX(CryptonightR_instruction_mov58):
+
+FN_PREFIX(CryptonightR_instruction_mov59):
+
+FN_PREFIX(CryptonightR_instruction_mov60):
+
+FN_PREFIX(CryptonightR_instruction_mov61):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov62):
+ mov ecx, esi
+FN_PREFIX(CryptonightR_instruction_mov63):
+
+FN_PREFIX(CryptonightR_instruction_mov64):
+
+FN_PREFIX(CryptonightR_instruction_mov65):
+
+FN_PREFIX(CryptonightR_instruction_mov66):
+
+FN_PREFIX(CryptonightR_instruction_mov67):
+
+FN_PREFIX(CryptonightR_instruction_mov68):
+
+FN_PREFIX(CryptonightR_instruction_mov69):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov70):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov71):
+
+FN_PREFIX(CryptonightR_instruction_mov72):
+
+FN_PREFIX(CryptonightR_instruction_mov73):
+
+FN_PREFIX(CryptonightR_instruction_mov74):
+
+FN_PREFIX(CryptonightR_instruction_mov75):
+
+FN_PREFIX(CryptonightR_instruction_mov76):
+
+FN_PREFIX(CryptonightR_instruction_mov77):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov78):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov79):
+
+FN_PREFIX(CryptonightR_instruction_mov80):
+
+FN_PREFIX(CryptonightR_instruction_mov81):
+
+FN_PREFIX(CryptonightR_instruction_mov82):
+
+FN_PREFIX(CryptonightR_instruction_mov83):
+
+FN_PREFIX(CryptonightR_instruction_mov84):
+
+FN_PREFIX(CryptonightR_instruction_mov85):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov86):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov87):
+
+FN_PREFIX(CryptonightR_instruction_mov88):
+
+FN_PREFIX(CryptonightR_instruction_mov89):
+
+FN_PREFIX(CryptonightR_instruction_mov90):
+
+FN_PREFIX(CryptonightR_instruction_mov91):
+
+FN_PREFIX(CryptonightR_instruction_mov92):
+
+FN_PREFIX(CryptonightR_instruction_mov93):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov94):
+ mov ecx, edi
+FN_PREFIX(CryptonightR_instruction_mov95):
+
+FN_PREFIX(CryptonightR_instruction_mov96):
+
+FN_PREFIX(CryptonightR_instruction_mov97):
+
+FN_PREFIX(CryptonightR_instruction_mov98):
+
+FN_PREFIX(CryptonightR_instruction_mov99):
+
+FN_PREFIX(CryptonightR_instruction_mov100):
+
+FN_PREFIX(CryptonightR_instruction_mov101):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov102):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov103):
+
+FN_PREFIX(CryptonightR_instruction_mov104):
+
+FN_PREFIX(CryptonightR_instruction_mov105):
+
+FN_PREFIX(CryptonightR_instruction_mov106):
+
+FN_PREFIX(CryptonightR_instruction_mov107):
+
+FN_PREFIX(CryptonightR_instruction_mov108):
+
+FN_PREFIX(CryptonightR_instruction_mov109):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov110):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov111):
+
+FN_PREFIX(CryptonightR_instruction_mov112):
+
+FN_PREFIX(CryptonightR_instruction_mov113):
+
+FN_PREFIX(CryptonightR_instruction_mov114):
+
+FN_PREFIX(CryptonightR_instruction_mov115):
+
+FN_PREFIX(CryptonightR_instruction_mov116):
+
+FN_PREFIX(CryptonightR_instruction_mov117):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov118):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov119):
+
+FN_PREFIX(CryptonightR_instruction_mov120):
+
+FN_PREFIX(CryptonightR_instruction_mov121):
+
+FN_PREFIX(CryptonightR_instruction_mov122):
+
+FN_PREFIX(CryptonightR_instruction_mov123):
+
+FN_PREFIX(CryptonightR_instruction_mov124):
+
+FN_PREFIX(CryptonightR_instruction_mov125):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov126):
+ mov ecx, ebp
+FN_PREFIX(CryptonightR_instruction_mov127):
+
+FN_PREFIX(CryptonightR_instruction_mov128):
+
+FN_PREFIX(CryptonightR_instruction_mov129):
+
+FN_PREFIX(CryptonightR_instruction_mov130):
+
+FN_PREFIX(CryptonightR_instruction_mov131):
+
+FN_PREFIX(CryptonightR_instruction_mov132):
+
+FN_PREFIX(CryptonightR_instruction_mov133):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov134):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov135):
+
+FN_PREFIX(CryptonightR_instruction_mov136):
+
+FN_PREFIX(CryptonightR_instruction_mov137):
+
+FN_PREFIX(CryptonightR_instruction_mov138):
+
+FN_PREFIX(CryptonightR_instruction_mov139):
+
+FN_PREFIX(CryptonightR_instruction_mov140):
+
+FN_PREFIX(CryptonightR_instruction_mov141):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov142):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov143):
+
+FN_PREFIX(CryptonightR_instruction_mov144):
+
+FN_PREFIX(CryptonightR_instruction_mov145):
+
+FN_PREFIX(CryptonightR_instruction_mov146):
+
+FN_PREFIX(CryptonightR_instruction_mov147):
+
+FN_PREFIX(CryptonightR_instruction_mov148):
+
+FN_PREFIX(CryptonightR_instruction_mov149):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov150):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov151):
+
+FN_PREFIX(CryptonightR_instruction_mov152):
+
+FN_PREFIX(CryptonightR_instruction_mov153):
+
+FN_PREFIX(CryptonightR_instruction_mov154):
+
+FN_PREFIX(CryptonightR_instruction_mov155):
+
+FN_PREFIX(CryptonightR_instruction_mov156):
+
+FN_PREFIX(CryptonightR_instruction_mov157):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov158):
+ mov ecx, esp
+FN_PREFIX(CryptonightR_instruction_mov159):
+
+FN_PREFIX(CryptonightR_instruction_mov160):
+
+FN_PREFIX(CryptonightR_instruction_mov161):
+
+FN_PREFIX(CryptonightR_instruction_mov162):
+
+FN_PREFIX(CryptonightR_instruction_mov163):
+
+FN_PREFIX(CryptonightR_instruction_mov164):
+
+FN_PREFIX(CryptonightR_instruction_mov165):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov166):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov167):
+
+FN_PREFIX(CryptonightR_instruction_mov168):
+
+FN_PREFIX(CryptonightR_instruction_mov169):
+
+FN_PREFIX(CryptonightR_instruction_mov170):
+
+FN_PREFIX(CryptonightR_instruction_mov171):
+
+FN_PREFIX(CryptonightR_instruction_mov172):
+
+FN_PREFIX(CryptonightR_instruction_mov173):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov174):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov175):
+
+FN_PREFIX(CryptonightR_instruction_mov176):
+
+FN_PREFIX(CryptonightR_instruction_mov177):
+
+FN_PREFIX(CryptonightR_instruction_mov178):
+
+FN_PREFIX(CryptonightR_instruction_mov179):
+
+FN_PREFIX(CryptonightR_instruction_mov180):
+
+FN_PREFIX(CryptonightR_instruction_mov181):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov182):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov183):
+
+FN_PREFIX(CryptonightR_instruction_mov184):
+
+FN_PREFIX(CryptonightR_instruction_mov185):
+
+FN_PREFIX(CryptonightR_instruction_mov186):
+
+FN_PREFIX(CryptonightR_instruction_mov187):
+
+FN_PREFIX(CryptonightR_instruction_mov188):
+
+FN_PREFIX(CryptonightR_instruction_mov189):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov190):
+ mov ecx, r15d
+FN_PREFIX(CryptonightR_instruction_mov191):
+
+FN_PREFIX(CryptonightR_instruction_mov192):
+
+FN_PREFIX(CryptonightR_instruction_mov193):
+
+FN_PREFIX(CryptonightR_instruction_mov194):
+
+FN_PREFIX(CryptonightR_instruction_mov195):
+
+FN_PREFIX(CryptonightR_instruction_mov196):
+
+FN_PREFIX(CryptonightR_instruction_mov197):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov198):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov199):
+
+FN_PREFIX(CryptonightR_instruction_mov200):
+
+FN_PREFIX(CryptonightR_instruction_mov201):
+
+FN_PREFIX(CryptonightR_instruction_mov202):
+
+FN_PREFIX(CryptonightR_instruction_mov203):
+
+FN_PREFIX(CryptonightR_instruction_mov204):
+
+FN_PREFIX(CryptonightR_instruction_mov205):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov206):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov207):
+
+FN_PREFIX(CryptonightR_instruction_mov208):
+
+FN_PREFIX(CryptonightR_instruction_mov209):
+
+FN_PREFIX(CryptonightR_instruction_mov210):
+
+FN_PREFIX(CryptonightR_instruction_mov211):
+
+FN_PREFIX(CryptonightR_instruction_mov212):
+
+FN_PREFIX(CryptonightR_instruction_mov213):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov214):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov215):
+
+FN_PREFIX(CryptonightR_instruction_mov216):
+
+FN_PREFIX(CryptonightR_instruction_mov217):
+
+FN_PREFIX(CryptonightR_instruction_mov218):
+
+FN_PREFIX(CryptonightR_instruction_mov219):
+
+FN_PREFIX(CryptonightR_instruction_mov220):
+
+FN_PREFIX(CryptonightR_instruction_mov221):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov222):
+ mov ecx, eax
+FN_PREFIX(CryptonightR_instruction_mov223):
+
+FN_PREFIX(CryptonightR_instruction_mov224):
+
+FN_PREFIX(CryptonightR_instruction_mov225):
+
+FN_PREFIX(CryptonightR_instruction_mov226):
+
+FN_PREFIX(CryptonightR_instruction_mov227):
+
+FN_PREFIX(CryptonightR_instruction_mov228):
+
+FN_PREFIX(CryptonightR_instruction_mov229):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov230):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov231):
+
+FN_PREFIX(CryptonightR_instruction_mov232):
+
+FN_PREFIX(CryptonightR_instruction_mov233):
+
+FN_PREFIX(CryptonightR_instruction_mov234):
+
+FN_PREFIX(CryptonightR_instruction_mov235):
+
+FN_PREFIX(CryptonightR_instruction_mov236):
+
+FN_PREFIX(CryptonightR_instruction_mov237):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov238):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov239):
+
+FN_PREFIX(CryptonightR_instruction_mov240):
+
+FN_PREFIX(CryptonightR_instruction_mov241):
+
+FN_PREFIX(CryptonightR_instruction_mov242):
+
+FN_PREFIX(CryptonightR_instruction_mov243):
+
+FN_PREFIX(CryptonightR_instruction_mov244):
+
+FN_PREFIX(CryptonightR_instruction_mov245):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov246):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov247):
+
+FN_PREFIX(CryptonightR_instruction_mov248):
+
+FN_PREFIX(CryptonightR_instruction_mov249):
+
+FN_PREFIX(CryptonightR_instruction_mov250):
+
+FN_PREFIX(CryptonightR_instruction_mov251):
+
+FN_PREFIX(CryptonightR_instruction_mov252):
+
+FN_PREFIX(CryptonightR_instruction_mov253):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov254):
+ mov ecx, edx
+FN_PREFIX(CryptonightR_instruction_mov255):
+
+FN_PREFIX(CryptonightR_instruction_mov256):
diff --git a/src/crypto/CryptonightR_template.h b/src/crypto/CryptonightR_template.h
new file mode 100644
index 000000000..57eb92ebe
--- /dev/null
+++ b/src/crypto/CryptonightR_template.h
@@ -0,0 +1,1039 @@
+#ifndef CRYPTONIGHTR_TEMPLATE_H
+#define CRYPTONIGHTR_TEMPLATE_H
+
+void CryptonightR_instruction0(void);
+void CryptonightR_instruction1(void);
+void CryptonightR_instruction2(void);
+void CryptonightR_instruction3(void);
+void CryptonightR_instruction4(void);
+void CryptonightR_instruction5(void);
+void CryptonightR_instruction6(void);
+void CryptonightR_instruction7(void);
+void CryptonightR_instruction8(void);
+void CryptonightR_instruction9(void);
+void CryptonightR_instruction10(void);
+void CryptonightR_instruction11(void);
+void CryptonightR_instruction12(void);
+void CryptonightR_instruction13(void);
+void CryptonightR_instruction14(void);
+void CryptonightR_instruction15(void);
+void CryptonightR_instruction16(void);
+void CryptonightR_instruction17(void);
+void CryptonightR_instruction18(void);
+void CryptonightR_instruction19(void);
+void CryptonightR_instruction20(void);
+void CryptonightR_instruction21(void);
+void CryptonightR_instruction22(void);
+void CryptonightR_instruction23(void);
+void CryptonightR_instruction24(void);
+void CryptonightR_instruction25(void);
+void CryptonightR_instruction26(void);
+void CryptonightR_instruction27(void);
+void CryptonightR_instruction28(void);
+void CryptonightR_instruction29(void);
+void CryptonightR_instruction30(void);
+void CryptonightR_instruction31(void);
+void CryptonightR_instruction32(void);
+void CryptonightR_instruction33(void);
+void CryptonightR_instruction34(void);
+void CryptonightR_instruction35(void);
+void CryptonightR_instruction36(void);
+void CryptonightR_instruction37(void);
+void CryptonightR_instruction38(void);
+void CryptonightR_instruction39(void);
+void CryptonightR_instruction40(void);
+void CryptonightR_instruction41(void);
+void CryptonightR_instruction42(void);
+void CryptonightR_instruction43(void);
+void CryptonightR_instruction44(void);
+void CryptonightR_instruction45(void);
+void CryptonightR_instruction46(void);
+void CryptonightR_instruction47(void);
+void CryptonightR_instruction48(void);
+void CryptonightR_instruction49(void);
+void CryptonightR_instruction50(void);
+void CryptonightR_instruction51(void);
+void CryptonightR_instruction52(void);
+void CryptonightR_instruction53(void);
+void CryptonightR_instruction54(void);
+void CryptonightR_instruction55(void);
+void CryptonightR_instruction56(void);
+void CryptonightR_instruction57(void);
+void CryptonightR_instruction58(void);
+void CryptonightR_instruction59(void);
+void CryptonightR_instruction60(void);
+void CryptonightR_instruction61(void);
+void CryptonightR_instruction62(void);
+void CryptonightR_instruction63(void);
+void CryptonightR_instruction64(void);
+void CryptonightR_instruction65(void);
+void CryptonightR_instruction66(void);
+void CryptonightR_instruction67(void);
+void CryptonightR_instruction68(void);
+void CryptonightR_instruction69(void);
+void CryptonightR_instruction70(void);
+void CryptonightR_instruction71(void);
+void CryptonightR_instruction72(void);
+void CryptonightR_instruction73(void);
+void CryptonightR_instruction74(void);
+void CryptonightR_instruction75(void);
+void CryptonightR_instruction76(void);
+void CryptonightR_instruction77(void);
+void CryptonightR_instruction78(void);
+void CryptonightR_instruction79(void);
+void CryptonightR_instruction80(void);
+void CryptonightR_instruction81(void);
+void CryptonightR_instruction82(void);
+void CryptonightR_instruction83(void);
+void CryptonightR_instruction84(void);
+void CryptonightR_instruction85(void);
+void CryptonightR_instruction86(void);
+void CryptonightR_instruction87(void);
+void CryptonightR_instruction88(void);
+void CryptonightR_instruction89(void);
+void CryptonightR_instruction90(void);
+void CryptonightR_instruction91(void);
+void CryptonightR_instruction92(void);
+void CryptonightR_instruction93(void);
+void CryptonightR_instruction94(void);
+void CryptonightR_instruction95(void);
+void CryptonightR_instruction96(void);
+void CryptonightR_instruction97(void);
+void CryptonightR_instruction98(void);
+void CryptonightR_instruction99(void);
+void CryptonightR_instruction100(void);
+void CryptonightR_instruction101(void);
+void CryptonightR_instruction102(void);
+void CryptonightR_instruction103(void);
+void CryptonightR_instruction104(void);
+void CryptonightR_instruction105(void);
+void CryptonightR_instruction106(void);
+void CryptonightR_instruction107(void);
+void CryptonightR_instruction108(void);
+void CryptonightR_instruction109(void);
+void CryptonightR_instruction110(void);
+void CryptonightR_instruction111(void);
+void CryptonightR_instruction112(void);
+void CryptonightR_instruction113(void);
+void CryptonightR_instruction114(void);
+void CryptonightR_instruction115(void);
+void CryptonightR_instruction116(void);
+void CryptonightR_instruction117(void);
+void CryptonightR_instruction118(void);
+void CryptonightR_instruction119(void);
+void CryptonightR_instruction120(void);
+void CryptonightR_instruction121(void);
+void CryptonightR_instruction122(void);
+void CryptonightR_instruction123(void);
+void CryptonightR_instruction124(void);
+void CryptonightR_instruction125(void);
+void CryptonightR_instruction126(void);
+void CryptonightR_instruction127(void);
+void CryptonightR_instruction128(void);
+void CryptonightR_instruction129(void);
+void CryptonightR_instruction130(void);
+void CryptonightR_instruction131(void);
+void CryptonightR_instruction132(void);
+void CryptonightR_instruction133(void);
+void CryptonightR_instruction134(void);
+void CryptonightR_instruction135(void);
+void CryptonightR_instruction136(void);
+void CryptonightR_instruction137(void);
+void CryptonightR_instruction138(void);
+void CryptonightR_instruction139(void);
+void CryptonightR_instruction140(void);
+void CryptonightR_instruction141(void);
+void CryptonightR_instruction142(void);
+void CryptonightR_instruction143(void);
+void CryptonightR_instruction144(void);
+void CryptonightR_instruction145(void);
+void CryptonightR_instruction146(void);
+void CryptonightR_instruction147(void);
+void CryptonightR_instruction148(void);
+void CryptonightR_instruction149(void);
+void CryptonightR_instruction150(void);
+void CryptonightR_instruction151(void);
+void CryptonightR_instruction152(void);
+void CryptonightR_instruction153(void);
+void CryptonightR_instruction154(void);
+void CryptonightR_instruction155(void);
+void CryptonightR_instruction156(void);
+void CryptonightR_instruction157(void);
+void CryptonightR_instruction158(void);
+void CryptonightR_instruction159(void);
+void CryptonightR_instruction160(void);
+void CryptonightR_instruction161(void);
+void CryptonightR_instruction162(void);
+void CryptonightR_instruction163(void);
+void CryptonightR_instruction164(void);
+void CryptonightR_instruction165(void);
+void CryptonightR_instruction166(void);
+void CryptonightR_instruction167(void);
+void CryptonightR_instruction168(void);
+void CryptonightR_instruction169(void);
+void CryptonightR_instruction170(void);
+void CryptonightR_instruction171(void);
+void CryptonightR_instruction172(void);
+void CryptonightR_instruction173(void);
+void CryptonightR_instruction174(void);
+void CryptonightR_instruction175(void);
+void CryptonightR_instruction176(void);
+void CryptonightR_instruction177(void);
+void CryptonightR_instruction178(void);
+void CryptonightR_instruction179(void);
+void CryptonightR_instruction180(void);
+void CryptonightR_instruction181(void);
+void CryptonightR_instruction182(void);
+void CryptonightR_instruction183(void);
+void CryptonightR_instruction184(void);
+void CryptonightR_instruction185(void);
+void CryptonightR_instruction186(void);
+void CryptonightR_instruction187(void);
+void CryptonightR_instruction188(void);
+void CryptonightR_instruction189(void);
+void CryptonightR_instruction190(void);
+void CryptonightR_instruction191(void);
+void CryptonightR_instruction192(void);
+void CryptonightR_instruction193(void);
+void CryptonightR_instruction194(void);
+void CryptonightR_instruction195(void);
+void CryptonightR_instruction196(void);
+void CryptonightR_instruction197(void);
+void CryptonightR_instruction198(void);
+void CryptonightR_instruction199(void);
+void CryptonightR_instruction200(void);
+void CryptonightR_instruction201(void);
+void CryptonightR_instruction202(void);
+void CryptonightR_instruction203(void);
+void CryptonightR_instruction204(void);
+void CryptonightR_instruction205(void);
+void CryptonightR_instruction206(void);
+void CryptonightR_instruction207(void);
+void CryptonightR_instruction208(void);
+void CryptonightR_instruction209(void);
+void CryptonightR_instruction210(void);
+void CryptonightR_instruction211(void);
+void CryptonightR_instruction212(void);
+void CryptonightR_instruction213(void);
+void CryptonightR_instruction214(void);
+void CryptonightR_instruction215(void);
+void CryptonightR_instruction216(void);
+void CryptonightR_instruction217(void);
+void CryptonightR_instruction218(void);
+void CryptonightR_instruction219(void);
+void CryptonightR_instruction220(void);
+void CryptonightR_instruction221(void);
+void CryptonightR_instruction222(void);
+void CryptonightR_instruction223(void);
+void CryptonightR_instruction224(void);
+void CryptonightR_instruction225(void);
+void CryptonightR_instruction226(void);
+void CryptonightR_instruction227(void);
+void CryptonightR_instruction228(void);
+void CryptonightR_instruction229(void);
+void CryptonightR_instruction230(void);
+void CryptonightR_instruction231(void);
+void CryptonightR_instruction232(void);
+void CryptonightR_instruction233(void);
+void CryptonightR_instruction234(void);
+void CryptonightR_instruction235(void);
+void CryptonightR_instruction236(void);
+void CryptonightR_instruction237(void);
+void CryptonightR_instruction238(void);
+void CryptonightR_instruction239(void);
+void CryptonightR_instruction240(void);
+void CryptonightR_instruction241(void);
+void CryptonightR_instruction242(void);
+void CryptonightR_instruction243(void);
+void CryptonightR_instruction244(void);
+void CryptonightR_instruction245(void);
+void CryptonightR_instruction246(void);
+void CryptonightR_instruction247(void);
+void CryptonightR_instruction248(void);
+void CryptonightR_instruction249(void);
+void CryptonightR_instruction250(void);
+void CryptonightR_instruction251(void);
+void CryptonightR_instruction252(void);
+void CryptonightR_instruction253(void);
+void CryptonightR_instruction254(void);
+void CryptonightR_instruction255(void);
+void CryptonightR_instruction256(void);
+void CryptonightR_instruction_mov0(void);
+void CryptonightR_instruction_mov1(void);
+void CryptonightR_instruction_mov2(void);
+void CryptonightR_instruction_mov3(void);
+void CryptonightR_instruction_mov4(void);
+void CryptonightR_instruction_mov5(void);
+void CryptonightR_instruction_mov6(void);
+void CryptonightR_instruction_mov7(void);
+void CryptonightR_instruction_mov8(void);
+void CryptonightR_instruction_mov9(void);
+void CryptonightR_instruction_mov10(void);
+void CryptonightR_instruction_mov11(void);
+void CryptonightR_instruction_mov12(void);
+void CryptonightR_instruction_mov13(void);
+void CryptonightR_instruction_mov14(void);
+void CryptonightR_instruction_mov15(void);
+void CryptonightR_instruction_mov16(void);
+void CryptonightR_instruction_mov17(void);
+void CryptonightR_instruction_mov18(void);
+void CryptonightR_instruction_mov19(void);
+void CryptonightR_instruction_mov20(void);
+void CryptonightR_instruction_mov21(void);
+void CryptonightR_instruction_mov22(void);
+void CryptonightR_instruction_mov23(void);
+void CryptonightR_instruction_mov24(void);
+void CryptonightR_instruction_mov25(void);
+void CryptonightR_instruction_mov26(void);
+void CryptonightR_instruction_mov27(void);
+void CryptonightR_instruction_mov28(void);
+void CryptonightR_instruction_mov29(void);
+void CryptonightR_instruction_mov30(void);
+void CryptonightR_instruction_mov31(void);
+void CryptonightR_instruction_mov32(void);
+void CryptonightR_instruction_mov33(void);
+void CryptonightR_instruction_mov34(void);
+void CryptonightR_instruction_mov35(void);
+void CryptonightR_instruction_mov36(void);
+void CryptonightR_instruction_mov37(void);
+void CryptonightR_instruction_mov38(void);
+void CryptonightR_instruction_mov39(void);
+void CryptonightR_instruction_mov40(void);
+void CryptonightR_instruction_mov41(void);
+void CryptonightR_instruction_mov42(void);
+void CryptonightR_instruction_mov43(void);
+void CryptonightR_instruction_mov44(void);
+void CryptonightR_instruction_mov45(void);
+void CryptonightR_instruction_mov46(void);
+void CryptonightR_instruction_mov47(void);
+void CryptonightR_instruction_mov48(void);
+void CryptonightR_instruction_mov49(void);
+void CryptonightR_instruction_mov50(void);
+void CryptonightR_instruction_mov51(void);
+void CryptonightR_instruction_mov52(void);
+void CryptonightR_instruction_mov53(void);
+void CryptonightR_instruction_mov54(void);
+void CryptonightR_instruction_mov55(void);
+void CryptonightR_instruction_mov56(void);
+void CryptonightR_instruction_mov57(void);
+void CryptonightR_instruction_mov58(void);
+void CryptonightR_instruction_mov59(void);
+void CryptonightR_instruction_mov60(void);
+void CryptonightR_instruction_mov61(void);
+void CryptonightR_instruction_mov62(void);
+void CryptonightR_instruction_mov63(void);
+void CryptonightR_instruction_mov64(void);
+void CryptonightR_instruction_mov65(void);
+void CryptonightR_instruction_mov66(void);
+void CryptonightR_instruction_mov67(void);
+void CryptonightR_instruction_mov68(void);
+void CryptonightR_instruction_mov69(void);
+void CryptonightR_instruction_mov70(void);
+void CryptonightR_instruction_mov71(void);
+void CryptonightR_instruction_mov72(void);
+void CryptonightR_instruction_mov73(void);
+void CryptonightR_instruction_mov74(void);
+void CryptonightR_instruction_mov75(void);
+void CryptonightR_instruction_mov76(void);
+void CryptonightR_instruction_mov77(void);
+void CryptonightR_instruction_mov78(void);
+void CryptonightR_instruction_mov79(void);
+void CryptonightR_instruction_mov80(void);
+void CryptonightR_instruction_mov81(void);
+void CryptonightR_instruction_mov82(void);
+void CryptonightR_instruction_mov83(void);
+void CryptonightR_instruction_mov84(void);
+void CryptonightR_instruction_mov85(void);
+void CryptonightR_instruction_mov86(void);
+void CryptonightR_instruction_mov87(void);
+void CryptonightR_instruction_mov88(void);
+void CryptonightR_instruction_mov89(void);
+void CryptonightR_instruction_mov90(void);
+void CryptonightR_instruction_mov91(void);
+void CryptonightR_instruction_mov92(void);
+void CryptonightR_instruction_mov93(void);
+void CryptonightR_instruction_mov94(void);
+void CryptonightR_instruction_mov95(void);
+void CryptonightR_instruction_mov96(void);
+void CryptonightR_instruction_mov97(void);
+void CryptonightR_instruction_mov98(void);
+void CryptonightR_instruction_mov99(void);
+void CryptonightR_instruction_mov100(void);
+void CryptonightR_instruction_mov101(void);
+void CryptonightR_instruction_mov102(void);
+void CryptonightR_instruction_mov103(void);
+void CryptonightR_instruction_mov104(void);
+void CryptonightR_instruction_mov105(void);
+void CryptonightR_instruction_mov106(void);
+void CryptonightR_instruction_mov107(void);
+void CryptonightR_instruction_mov108(void);
+void CryptonightR_instruction_mov109(void);
+void CryptonightR_instruction_mov110(void);
+void CryptonightR_instruction_mov111(void);
+void CryptonightR_instruction_mov112(void);
+void CryptonightR_instruction_mov113(void);
+void CryptonightR_instruction_mov114(void);
+void CryptonightR_instruction_mov115(void);
+void CryptonightR_instruction_mov116(void);
+void CryptonightR_instruction_mov117(void);
+void CryptonightR_instruction_mov118(void);
+void CryptonightR_instruction_mov119(void);
+void CryptonightR_instruction_mov120(void);
+void CryptonightR_instruction_mov121(void);
+void CryptonightR_instruction_mov122(void);
+void CryptonightR_instruction_mov123(void);
+void CryptonightR_instruction_mov124(void);
+void CryptonightR_instruction_mov125(void);
+void CryptonightR_instruction_mov126(void);
+void CryptonightR_instruction_mov127(void);
+void CryptonightR_instruction_mov128(void);
+void CryptonightR_instruction_mov129(void);
+void CryptonightR_instruction_mov130(void);
+void CryptonightR_instruction_mov131(void);
+void CryptonightR_instruction_mov132(void);
+void CryptonightR_instruction_mov133(void);
+void CryptonightR_instruction_mov134(void);
+void CryptonightR_instruction_mov135(void);
+void CryptonightR_instruction_mov136(void);
+void CryptonightR_instruction_mov137(void);
+void CryptonightR_instruction_mov138(void);
+void CryptonightR_instruction_mov139(void);
+void CryptonightR_instruction_mov140(void);
+void CryptonightR_instruction_mov141(void);
+void CryptonightR_instruction_mov142(void);
+void CryptonightR_instruction_mov143(void);
+void CryptonightR_instruction_mov144(void);
+void CryptonightR_instruction_mov145(void);
+void CryptonightR_instruction_mov146(void);
+void CryptonightR_instruction_mov147(void);
+void CryptonightR_instruction_mov148(void);
+void CryptonightR_instruction_mov149(void);
+void CryptonightR_instruction_mov150(void);
+void CryptonightR_instruction_mov151(void);
+void CryptonightR_instruction_mov152(void);
+void CryptonightR_instruction_mov153(void);
+void CryptonightR_instruction_mov154(void);
+void CryptonightR_instruction_mov155(void);
+void CryptonightR_instruction_mov156(void);
+void CryptonightR_instruction_mov157(void);
+void CryptonightR_instruction_mov158(void);
+void CryptonightR_instruction_mov159(void);
+void CryptonightR_instruction_mov160(void);
+void CryptonightR_instruction_mov161(void);
+void CryptonightR_instruction_mov162(void);
+void CryptonightR_instruction_mov163(void);
+void CryptonightR_instruction_mov164(void);
+void CryptonightR_instruction_mov165(void);
+void CryptonightR_instruction_mov166(void);
+void CryptonightR_instruction_mov167(void);
+void CryptonightR_instruction_mov168(void);
+void CryptonightR_instruction_mov169(void);
+void CryptonightR_instruction_mov170(void);
+void CryptonightR_instruction_mov171(void);
+void CryptonightR_instruction_mov172(void);
+void CryptonightR_instruction_mov173(void);
+void CryptonightR_instruction_mov174(void);
+void CryptonightR_instruction_mov175(void);
+void CryptonightR_instruction_mov176(void);
+void CryptonightR_instruction_mov177(void);
+void CryptonightR_instruction_mov178(void);
+void CryptonightR_instruction_mov179(void);
+void CryptonightR_instruction_mov180(void);
+void CryptonightR_instruction_mov181(void);
+void CryptonightR_instruction_mov182(void);
+void CryptonightR_instruction_mov183(void);
+void CryptonightR_instruction_mov184(void);
+void CryptonightR_instruction_mov185(void);
+void CryptonightR_instruction_mov186(void);
+void CryptonightR_instruction_mov187(void);
+void CryptonightR_instruction_mov188(void);
+void CryptonightR_instruction_mov189(void);
+void CryptonightR_instruction_mov190(void);
+void CryptonightR_instruction_mov191(void);
+void CryptonightR_instruction_mov192(void);
+void CryptonightR_instruction_mov193(void);
+void CryptonightR_instruction_mov194(void);
+void CryptonightR_instruction_mov195(void);
+void CryptonightR_instruction_mov196(void);
+void CryptonightR_instruction_mov197(void);
+void CryptonightR_instruction_mov198(void);
+void CryptonightR_instruction_mov199(void);
+void CryptonightR_instruction_mov200(void);
+void CryptonightR_instruction_mov201(void);
+void CryptonightR_instruction_mov202(void);
+void CryptonightR_instruction_mov203(void);
+void CryptonightR_instruction_mov204(void);
+void CryptonightR_instruction_mov205(void);
+void CryptonightR_instruction_mov206(void);
+void CryptonightR_instruction_mov207(void);
+void CryptonightR_instruction_mov208(void);
+void CryptonightR_instruction_mov209(void);
+void CryptonightR_instruction_mov210(void);
+void CryptonightR_instruction_mov211(void);
+void CryptonightR_instruction_mov212(void);
+void CryptonightR_instruction_mov213(void);
+void CryptonightR_instruction_mov214(void);
+void CryptonightR_instruction_mov215(void);
+void CryptonightR_instruction_mov216(void);
+void CryptonightR_instruction_mov217(void);
+void CryptonightR_instruction_mov218(void);
+void CryptonightR_instruction_mov219(void);
+void CryptonightR_instruction_mov220(void);
+void CryptonightR_instruction_mov221(void);
+void CryptonightR_instruction_mov222(void);
+void CryptonightR_instruction_mov223(void);
+void CryptonightR_instruction_mov224(void);
+void CryptonightR_instruction_mov225(void);
+void CryptonightR_instruction_mov226(void);
+void CryptonightR_instruction_mov227(void);
+void CryptonightR_instruction_mov228(void);
+void CryptonightR_instruction_mov229(void);
+void CryptonightR_instruction_mov230(void);
+void CryptonightR_instruction_mov231(void);
+void CryptonightR_instruction_mov232(void);
+void CryptonightR_instruction_mov233(void);
+void CryptonightR_instruction_mov234(void);
+void CryptonightR_instruction_mov235(void);
+void CryptonightR_instruction_mov236(void);
+void CryptonightR_instruction_mov237(void);
+void CryptonightR_instruction_mov238(void);
+void CryptonightR_instruction_mov239(void);
+void CryptonightR_instruction_mov240(void);
+void CryptonightR_instruction_mov241(void);
+void CryptonightR_instruction_mov242(void);
+void CryptonightR_instruction_mov243(void);
+void CryptonightR_instruction_mov244(void);
+void CryptonightR_instruction_mov245(void);
+void CryptonightR_instruction_mov246(void);
+void CryptonightR_instruction_mov247(void);
+void CryptonightR_instruction_mov248(void);
+void CryptonightR_instruction_mov249(void);
+void CryptonightR_instruction_mov250(void);
+void CryptonightR_instruction_mov251(void);
+void CryptonightR_instruction_mov252(void);
+void CryptonightR_instruction_mov253(void);
+void CryptonightR_instruction_mov254(void);
+void CryptonightR_instruction_mov255(void);
+void CryptonightR_instruction_mov256(void);
+
+const void* instructions[257] = {
+ CryptonightR_instruction0,
+ CryptonightR_instruction1,
+ CryptonightR_instruction2,
+ CryptonightR_instruction3,
+ CryptonightR_instruction4,
+ CryptonightR_instruction5,
+ CryptonightR_instruction6,
+ CryptonightR_instruction7,
+ CryptonightR_instruction8,
+ CryptonightR_instruction9,
+ CryptonightR_instruction10,
+ CryptonightR_instruction11,
+ CryptonightR_instruction12,
+ CryptonightR_instruction13,
+ CryptonightR_instruction14,
+ CryptonightR_instruction15,
+ CryptonightR_instruction16,
+ CryptonightR_instruction17,
+ CryptonightR_instruction18,
+ CryptonightR_instruction19,
+ CryptonightR_instruction20,
+ CryptonightR_instruction21,
+ CryptonightR_instruction22,
+ CryptonightR_instruction23,
+ CryptonightR_instruction24,
+ CryptonightR_instruction25,
+ CryptonightR_instruction26,
+ CryptonightR_instruction27,
+ CryptonightR_instruction28,
+ CryptonightR_instruction29,
+ CryptonightR_instruction30,
+ CryptonightR_instruction31,
+ CryptonightR_instruction32,
+ CryptonightR_instruction33,
+ CryptonightR_instruction34,
+ CryptonightR_instruction35,
+ CryptonightR_instruction36,
+ CryptonightR_instruction37,
+ CryptonightR_instruction38,
+ CryptonightR_instruction39,
+ CryptonightR_instruction40,
+ CryptonightR_instruction41,
+ CryptonightR_instruction42,
+ CryptonightR_instruction43,
+ CryptonightR_instruction44,
+ CryptonightR_instruction45,
+ CryptonightR_instruction46,
+ CryptonightR_instruction47,
+ CryptonightR_instruction48,
+ CryptonightR_instruction49,
+ CryptonightR_instruction50,
+ CryptonightR_instruction51,
+ CryptonightR_instruction52,
+ CryptonightR_instruction53,
+ CryptonightR_instruction54,
+ CryptonightR_instruction55,
+ CryptonightR_instruction56,
+ CryptonightR_instruction57,
+ CryptonightR_instruction58,
+ CryptonightR_instruction59,
+ CryptonightR_instruction60,
+ CryptonightR_instruction61,
+ CryptonightR_instruction62,
+ CryptonightR_instruction63,
+ CryptonightR_instruction64,
+ CryptonightR_instruction65,
+ CryptonightR_instruction66,
+ CryptonightR_instruction67,
+ CryptonightR_instruction68,
+ CryptonightR_instruction69,
+ CryptonightR_instruction70,
+ CryptonightR_instruction71,
+ CryptonightR_instruction72,
+ CryptonightR_instruction73,
+ CryptonightR_instruction74,
+ CryptonightR_instruction75,
+ CryptonightR_instruction76,
+ CryptonightR_instruction77,
+ CryptonightR_instruction78,
+ CryptonightR_instruction79,
+ CryptonightR_instruction80,
+ CryptonightR_instruction81,
+ CryptonightR_instruction82,
+ CryptonightR_instruction83,
+ CryptonightR_instruction84,
+ CryptonightR_instruction85,
+ CryptonightR_instruction86,
+ CryptonightR_instruction87,
+ CryptonightR_instruction88,
+ CryptonightR_instruction89,
+ CryptonightR_instruction90,
+ CryptonightR_instruction91,
+ CryptonightR_instruction92,
+ CryptonightR_instruction93,
+ CryptonightR_instruction94,
+ CryptonightR_instruction95,
+ CryptonightR_instruction96,
+ CryptonightR_instruction97,
+ CryptonightR_instruction98,
+ CryptonightR_instruction99,
+ CryptonightR_instruction100,
+ CryptonightR_instruction101,
+ CryptonightR_instruction102,
+ CryptonightR_instruction103,
+ CryptonightR_instruction104,
+ CryptonightR_instruction105,
+ CryptonightR_instruction106,
+ CryptonightR_instruction107,
+ CryptonightR_instruction108,
+ CryptonightR_instruction109,
+ CryptonightR_instruction110,
+ CryptonightR_instruction111,
+ CryptonightR_instruction112,
+ CryptonightR_instruction113,
+ CryptonightR_instruction114,
+ CryptonightR_instruction115,
+ CryptonightR_instruction116,
+ CryptonightR_instruction117,
+ CryptonightR_instruction118,
+ CryptonightR_instruction119,
+ CryptonightR_instruction120,
+ CryptonightR_instruction121,
+ CryptonightR_instruction122,
+ CryptonightR_instruction123,
+ CryptonightR_instruction124,
+ CryptonightR_instruction125,
+ CryptonightR_instruction126,
+ CryptonightR_instruction127,
+ CryptonightR_instruction128,
+ CryptonightR_instruction129,
+ CryptonightR_instruction130,
+ CryptonightR_instruction131,
+ CryptonightR_instruction132,
+ CryptonightR_instruction133,
+ CryptonightR_instruction134,
+ CryptonightR_instruction135,
+ CryptonightR_instruction136,
+ CryptonightR_instruction137,
+ CryptonightR_instruction138,
+ CryptonightR_instruction139,
+ CryptonightR_instruction140,
+ CryptonightR_instruction141,
+ CryptonightR_instruction142,
+ CryptonightR_instruction143,
+ CryptonightR_instruction144,
+ CryptonightR_instruction145,
+ CryptonightR_instruction146,
+ CryptonightR_instruction147,
+ CryptonightR_instruction148,
+ CryptonightR_instruction149,
+ CryptonightR_instruction150,
+ CryptonightR_instruction151,
+ CryptonightR_instruction152,
+ CryptonightR_instruction153,
+ CryptonightR_instruction154,
+ CryptonightR_instruction155,
+ CryptonightR_instruction156,
+ CryptonightR_instruction157,
+ CryptonightR_instruction158,
+ CryptonightR_instruction159,
+ CryptonightR_instruction160,
+ CryptonightR_instruction161,
+ CryptonightR_instruction162,
+ CryptonightR_instruction163,
+ CryptonightR_instruction164,
+ CryptonightR_instruction165,
+ CryptonightR_instruction166,
+ CryptonightR_instruction167,
+ CryptonightR_instruction168,
+ CryptonightR_instruction169,
+ CryptonightR_instruction170,
+ CryptonightR_instruction171,
+ CryptonightR_instruction172,
+ CryptonightR_instruction173,
+ CryptonightR_instruction174,
+ CryptonightR_instruction175,
+ CryptonightR_instruction176,
+ CryptonightR_instruction177,
+ CryptonightR_instruction178,
+ CryptonightR_instruction179,
+ CryptonightR_instruction180,
+ CryptonightR_instruction181,
+ CryptonightR_instruction182,
+ CryptonightR_instruction183,
+ CryptonightR_instruction184,
+ CryptonightR_instruction185,
+ CryptonightR_instruction186,
+ CryptonightR_instruction187,
+ CryptonightR_instruction188,
+ CryptonightR_instruction189,
+ CryptonightR_instruction190,
+ CryptonightR_instruction191,
+ CryptonightR_instruction192,
+ CryptonightR_instruction193,
+ CryptonightR_instruction194,
+ CryptonightR_instruction195,
+ CryptonightR_instruction196,
+ CryptonightR_instruction197,
+ CryptonightR_instruction198,
+ CryptonightR_instruction199,
+ CryptonightR_instruction200,
+ CryptonightR_instruction201,
+ CryptonightR_instruction202,
+ CryptonightR_instruction203,
+ CryptonightR_instruction204,
+ CryptonightR_instruction205,
+ CryptonightR_instruction206,
+ CryptonightR_instruction207,
+ CryptonightR_instruction208,
+ CryptonightR_instruction209,
+ CryptonightR_instruction210,
+ CryptonightR_instruction211,
+ CryptonightR_instruction212,
+ CryptonightR_instruction213,
+ CryptonightR_instruction214,
+ CryptonightR_instruction215,
+ CryptonightR_instruction216,
+ CryptonightR_instruction217,
+ CryptonightR_instruction218,
+ CryptonightR_instruction219,
+ CryptonightR_instruction220,
+ CryptonightR_instruction221,
+ CryptonightR_instruction222,
+ CryptonightR_instruction223,
+ CryptonightR_instruction224,
+ CryptonightR_instruction225,
+ CryptonightR_instruction226,
+ CryptonightR_instruction227,
+ CryptonightR_instruction228,
+ CryptonightR_instruction229,
+ CryptonightR_instruction230,
+ CryptonightR_instruction231,
+ CryptonightR_instruction232,
+ CryptonightR_instruction233,
+ CryptonightR_instruction234,
+ CryptonightR_instruction235,
+ CryptonightR_instruction236,
+ CryptonightR_instruction237,
+ CryptonightR_instruction238,
+ CryptonightR_instruction239,
+ CryptonightR_instruction240,
+ CryptonightR_instruction241,
+ CryptonightR_instruction242,
+ CryptonightR_instruction243,
+ CryptonightR_instruction244,
+ CryptonightR_instruction245,
+ CryptonightR_instruction246,
+ CryptonightR_instruction247,
+ CryptonightR_instruction248,
+ CryptonightR_instruction249,
+ CryptonightR_instruction250,
+ CryptonightR_instruction251,
+ CryptonightR_instruction252,
+ CryptonightR_instruction253,
+ CryptonightR_instruction254,
+ CryptonightR_instruction255,
+ CryptonightR_instruction256,
+};
+
+const void* instructions_mov[257] = {
+ CryptonightR_instruction_mov0,
+ CryptonightR_instruction_mov1,
+ CryptonightR_instruction_mov2,
+ CryptonightR_instruction_mov3,
+ CryptonightR_instruction_mov4,
+ CryptonightR_instruction_mov5,
+ CryptonightR_instruction_mov6,
+ CryptonightR_instruction_mov7,
+ CryptonightR_instruction_mov8,
+ CryptonightR_instruction_mov9,
+ CryptonightR_instruction_mov10,
+ CryptonightR_instruction_mov11,
+ CryptonightR_instruction_mov12,
+ CryptonightR_instruction_mov13,
+ CryptonightR_instruction_mov14,
+ CryptonightR_instruction_mov15,
+ CryptonightR_instruction_mov16,
+ CryptonightR_instruction_mov17,
+ CryptonightR_instruction_mov18,
+ CryptonightR_instruction_mov19,
+ CryptonightR_instruction_mov20,
+ CryptonightR_instruction_mov21,
+ CryptonightR_instruction_mov22,
+ CryptonightR_instruction_mov23,
+ CryptonightR_instruction_mov24,
+ CryptonightR_instruction_mov25,
+ CryptonightR_instruction_mov26,
+ CryptonightR_instruction_mov27,
+ CryptonightR_instruction_mov28,
+ CryptonightR_instruction_mov29,
+ CryptonightR_instruction_mov30,
+ CryptonightR_instruction_mov31,
+ CryptonightR_instruction_mov32,
+ CryptonightR_instruction_mov33,
+ CryptonightR_instruction_mov34,
+ CryptonightR_instruction_mov35,
+ CryptonightR_instruction_mov36,
+ CryptonightR_instruction_mov37,
+ CryptonightR_instruction_mov38,
+ CryptonightR_instruction_mov39,
+ CryptonightR_instruction_mov40,
+ CryptonightR_instruction_mov41,
+ CryptonightR_instruction_mov42,
+ CryptonightR_instruction_mov43,
+ CryptonightR_instruction_mov44,
+ CryptonightR_instruction_mov45,
+ CryptonightR_instruction_mov46,
+ CryptonightR_instruction_mov47,
+ CryptonightR_instruction_mov48,
+ CryptonightR_instruction_mov49,
+ CryptonightR_instruction_mov50,
+ CryptonightR_instruction_mov51,
+ CryptonightR_instruction_mov52,
+ CryptonightR_instruction_mov53,
+ CryptonightR_instruction_mov54,
+ CryptonightR_instruction_mov55,
+ CryptonightR_instruction_mov56,
+ CryptonightR_instruction_mov57,
+ CryptonightR_instruction_mov58,
+ CryptonightR_instruction_mov59,
+ CryptonightR_instruction_mov60,
+ CryptonightR_instruction_mov61,
+ CryptonightR_instruction_mov62,
+ CryptonightR_instruction_mov63,
+ CryptonightR_instruction_mov64,
+ CryptonightR_instruction_mov65,
+ CryptonightR_instruction_mov66,
+ CryptonightR_instruction_mov67,
+ CryptonightR_instruction_mov68,
+ CryptonightR_instruction_mov69,
+ CryptonightR_instruction_mov70,
+ CryptonightR_instruction_mov71,
+ CryptonightR_instruction_mov72,
+ CryptonightR_instruction_mov73,
+ CryptonightR_instruction_mov74,
+ CryptonightR_instruction_mov75,
+ CryptonightR_instruction_mov76,
+ CryptonightR_instruction_mov77,
+ CryptonightR_instruction_mov78,
+ CryptonightR_instruction_mov79,
+ CryptonightR_instruction_mov80,
+ CryptonightR_instruction_mov81,
+ CryptonightR_instruction_mov82,
+ CryptonightR_instruction_mov83,
+ CryptonightR_instruction_mov84,
+ CryptonightR_instruction_mov85,
+ CryptonightR_instruction_mov86,
+ CryptonightR_instruction_mov87,
+ CryptonightR_instruction_mov88,
+ CryptonightR_instruction_mov89,
+ CryptonightR_instruction_mov90,
+ CryptonightR_instruction_mov91,
+ CryptonightR_instruction_mov92,
+ CryptonightR_instruction_mov93,
+ CryptonightR_instruction_mov94,
+ CryptonightR_instruction_mov95,
+ CryptonightR_instruction_mov96,
+ CryptonightR_instruction_mov97,
+ CryptonightR_instruction_mov98,
+ CryptonightR_instruction_mov99,
+ CryptonightR_instruction_mov100,
+ CryptonightR_instruction_mov101,
+ CryptonightR_instruction_mov102,
+ CryptonightR_instruction_mov103,
+ CryptonightR_instruction_mov104,
+ CryptonightR_instruction_mov105,
+ CryptonightR_instruction_mov106,
+ CryptonightR_instruction_mov107,
+ CryptonightR_instruction_mov108,
+ CryptonightR_instruction_mov109,
+ CryptonightR_instruction_mov110,
+ CryptonightR_instruction_mov111,
+ CryptonightR_instruction_mov112,
+ CryptonightR_instruction_mov113,
+ CryptonightR_instruction_mov114,
+ CryptonightR_instruction_mov115,
+ CryptonightR_instruction_mov116,
+ CryptonightR_instruction_mov117,
+ CryptonightR_instruction_mov118,
+ CryptonightR_instruction_mov119,
+ CryptonightR_instruction_mov120,
+ CryptonightR_instruction_mov121,
+ CryptonightR_instruction_mov122,
+ CryptonightR_instruction_mov123,
+ CryptonightR_instruction_mov124,
+ CryptonightR_instruction_mov125,
+ CryptonightR_instruction_mov126,
+ CryptonightR_instruction_mov127,
+ CryptonightR_instruction_mov128,
+ CryptonightR_instruction_mov129,
+ CryptonightR_instruction_mov130,
+ CryptonightR_instruction_mov131,
+ CryptonightR_instruction_mov132,
+ CryptonightR_instruction_mov133,
+ CryptonightR_instruction_mov134,
+ CryptonightR_instruction_mov135,
+ CryptonightR_instruction_mov136,
+ CryptonightR_instruction_mov137,
+ CryptonightR_instruction_mov138,
+ CryptonightR_instruction_mov139,
+ CryptonightR_instruction_mov140,
+ CryptonightR_instruction_mov141,
+ CryptonightR_instruction_mov142,
+ CryptonightR_instruction_mov143,
+ CryptonightR_instruction_mov144,
+ CryptonightR_instruction_mov145,
+ CryptonightR_instruction_mov146,
+ CryptonightR_instruction_mov147,
+ CryptonightR_instruction_mov148,
+ CryptonightR_instruction_mov149,
+ CryptonightR_instruction_mov150,
+ CryptonightR_instruction_mov151,
+ CryptonightR_instruction_mov152,
+ CryptonightR_instruction_mov153,
+ CryptonightR_instruction_mov154,
+ CryptonightR_instruction_mov155,
+ CryptonightR_instruction_mov156,
+ CryptonightR_instruction_mov157,
+ CryptonightR_instruction_mov158,
+ CryptonightR_instruction_mov159,
+ CryptonightR_instruction_mov160,
+ CryptonightR_instruction_mov161,
+ CryptonightR_instruction_mov162,
+ CryptonightR_instruction_mov163,
+ CryptonightR_instruction_mov164,
+ CryptonightR_instruction_mov165,
+ CryptonightR_instruction_mov166,
+ CryptonightR_instruction_mov167,
+ CryptonightR_instruction_mov168,
+ CryptonightR_instruction_mov169,
+ CryptonightR_instruction_mov170,
+ CryptonightR_instruction_mov171,
+ CryptonightR_instruction_mov172,
+ CryptonightR_instruction_mov173,
+ CryptonightR_instruction_mov174,
+ CryptonightR_instruction_mov175,
+ CryptonightR_instruction_mov176,
+ CryptonightR_instruction_mov177,
+ CryptonightR_instruction_mov178,
+ CryptonightR_instruction_mov179,
+ CryptonightR_instruction_mov180,
+ CryptonightR_instruction_mov181,
+ CryptonightR_instruction_mov182,
+ CryptonightR_instruction_mov183,
+ CryptonightR_instruction_mov184,
+ CryptonightR_instruction_mov185,
+ CryptonightR_instruction_mov186,
+ CryptonightR_instruction_mov187,
+ CryptonightR_instruction_mov188,
+ CryptonightR_instruction_mov189,
+ CryptonightR_instruction_mov190,
+ CryptonightR_instruction_mov191,
+ CryptonightR_instruction_mov192,
+ CryptonightR_instruction_mov193,
+ CryptonightR_instruction_mov194,
+ CryptonightR_instruction_mov195,
+ CryptonightR_instruction_mov196,
+ CryptonightR_instruction_mov197,
+ CryptonightR_instruction_mov198,
+ CryptonightR_instruction_mov199,
+ CryptonightR_instruction_mov200,
+ CryptonightR_instruction_mov201,
+ CryptonightR_instruction_mov202,
+ CryptonightR_instruction_mov203,
+ CryptonightR_instruction_mov204,
+ CryptonightR_instruction_mov205,
+ CryptonightR_instruction_mov206,
+ CryptonightR_instruction_mov207,
+ CryptonightR_instruction_mov208,
+ CryptonightR_instruction_mov209,
+ CryptonightR_instruction_mov210,
+ CryptonightR_instruction_mov211,
+ CryptonightR_instruction_mov212,
+ CryptonightR_instruction_mov213,
+ CryptonightR_instruction_mov214,
+ CryptonightR_instruction_mov215,
+ CryptonightR_instruction_mov216,
+ CryptonightR_instruction_mov217,
+ CryptonightR_instruction_mov218,
+ CryptonightR_instruction_mov219,
+ CryptonightR_instruction_mov220,
+ CryptonightR_instruction_mov221,
+ CryptonightR_instruction_mov222,
+ CryptonightR_instruction_mov223,
+ CryptonightR_instruction_mov224,
+ CryptonightR_instruction_mov225,
+ CryptonightR_instruction_mov226,
+ CryptonightR_instruction_mov227,
+ CryptonightR_instruction_mov228,
+ CryptonightR_instruction_mov229,
+ CryptonightR_instruction_mov230,
+ CryptonightR_instruction_mov231,
+ CryptonightR_instruction_mov232,
+ CryptonightR_instruction_mov233,
+ CryptonightR_instruction_mov234,
+ CryptonightR_instruction_mov235,
+ CryptonightR_instruction_mov236,
+ CryptonightR_instruction_mov237,
+ CryptonightR_instruction_mov238,
+ CryptonightR_instruction_mov239,
+ CryptonightR_instruction_mov240,
+ CryptonightR_instruction_mov241,
+ CryptonightR_instruction_mov242,
+ CryptonightR_instruction_mov243,
+ CryptonightR_instruction_mov244,
+ CryptonightR_instruction_mov245,
+ CryptonightR_instruction_mov246,
+ CryptonightR_instruction_mov247,
+ CryptonightR_instruction_mov248,
+ CryptonightR_instruction_mov249,
+ CryptonightR_instruction_mov250,
+ CryptonightR_instruction_mov251,
+ CryptonightR_instruction_mov252,
+ CryptonightR_instruction_mov253,
+ CryptonightR_instruction_mov254,
+ CryptonightR_instruction_mov255,
+ CryptonightR_instruction_mov256,
+};
+
+#endif // CRYPTONIGHTR_TEMPLATE_H
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c
index c1de253f2..2a8ddb59c 100644
--- a/src/crypto/slow-hash.c
+++ b/src/crypto/slow-hash.c
@@ -40,6 +40,10 @@
#include "oaes_lib.h"
#include "variant2_int_sqrt.h"
#include "variant4_random_math.h"
+#include "CryptonightR_JIT.h"
+
+#include <errno.h>
+#include <string.h>
#define MEMORY (1 << 21) // 2MB scratchpad
#define ITER (1 << 20)
@@ -51,6 +55,16 @@
extern void aesb_single_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey);
extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey);
+static void local_abort(const char *msg)
+{
+ fprintf(stderr, "%s\n", msg);
+#ifdef NDEBUG
+ _exit(1);
+#else
+ abort();
+#endif
+}
+
#define VARIANT1_1(p) \
do if (variant == 1) \
{ \
@@ -253,11 +267,18 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex
#define VARIANT4_RANDOM_MATH_INIT() \
v4_reg r[9]; \
struct V4_Instruction code[NUM_INSTRUCTIONS_MAX + 1]; \
+ int jit = use_v4_jit(); \
do if (variant >= 4) \
{ \
for (int i = 0; i < 4; ++i) \
V4_REG_LOAD(r + i, (uint8_t*)(state.hs.w + 12) + sizeof(v4_reg) * i); \
v4_random_math_init(code, height); \
+ if (jit) \
+ { \
+ int ret = v4_generate_JIT_code(code, hp_jitfunc, 4096); \
+ if (ret < 0) \
+ local_abort("Error generating CryptonightR code"); \
+ } \
} while (0)
#define VARIANT4_RANDOM_MATH(a, b, r, _b, _b1) \
@@ -279,7 +300,10 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex
V4_REG_LOAD(r + 7, _b1); \
V4_REG_LOAD(r + 8, (uint64_t*)(_b1) + 1); \
\
- v4_random_math(code, r); \
+ if (jit) \
+ (*hp_jitfunc)(r); \
+ else \
+ v4_random_math(code, r); \
\
memcpy(t, a, sizeof(uint64_t) * 2); \
\
@@ -409,6 +433,9 @@ union cn_slow_hash_state
THREADV uint8_t *hp_state = NULL;
THREADV int hp_allocated = 0;
+THREADV v4_random_math_JIT_func hp_jitfunc = NULL;
+THREADV uint8_t *hp_jitfunc_memory = NULL;
+THREADV int hp_jitfunc_allocated = 0;
#if defined(_MSC_VER)
#define cpuid(info,x) __cpuidex(info,x,0)
@@ -467,6 +494,31 @@ 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];
@@ -718,6 +770,33 @@ void slow_hash_allocate_state(void)
hp_allocated = 0;
hp_state = (uint8_t *) malloc(MEMORY);
}
+
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ hp_jitfunc_memory = (uint8_t *) VirtualAlloc(hp_jitfunc_memory, 4096 + 4095,
+ MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+#else
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
+ defined(__DragonFly__) || defined(__NetBSD__)
+ hp_jitfunc_memory = mmap(0, 4096 + 4095, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANON, 0, 0);
+#else
+ hp_jitfunc_memory = mmap(0, 4096 + 4095, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#endif
+ if(hp_jitfunc_memory == MAP_FAILED)
+ hp_jitfunc_memory = NULL;
+#endif
+ hp_jitfunc_allocated = 1;
+ if (hp_jitfunc_memory == NULL)
+ {
+ hp_jitfunc_allocated = 0;
+ hp_jitfunc_memory = malloc(4096 + 4095);
+ }
+ hp_jitfunc = (v4_random_math_JIT_func)((size_t)(hp_jitfunc_memory + 4095) & ~4095);
+#if !(defined(_MSC_VER) || defined(__MINGW32__))
+ mprotect(hp_jitfunc, 4096, PROT_READ | PROT_WRITE | PROT_EXEC);
+#endif
}
/**
@@ -740,8 +819,22 @@ void slow_hash_free_state(void)
#endif
}
+ if(!hp_jitfunc_allocated)
+ free(hp_jitfunc_memory);
+ else
+ {
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ VirtualFree(hp_jitfunc_memory, 0, MEM_RELEASE);
+#else
+ munmap(hp_jitfunc_memory, 4096 + 4095);
+#endif
+ }
+
hp_state = NULL;
hp_allocated = 0;
+ hp_jitfunc = NULL;
+ hp_jitfunc_memory = NULL;
+ hp_jitfunc_allocated = 0;
}
/**
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 42003921a..b0dbe1eb5 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -115,6 +115,12 @@ static const struct {
// version 9 starts from block 1686275, which is on or around the 19th of October, 2018. Fork time finalised on 2018-09-02.
{ 9, 1686275, 0, 1535889548 },
+
+ // version 10 starts from block 1788000, which is on or around the 9th of March, 2019. Fork time finalised on 2019-02-10.
+ { 10, 1788000, 0, 1549792439 },
+
+ // version 11 starts from block 1788720, which is on or around the 10th of March, 2019. Fork time finalised on 2019-02-15.
+ { 11, 1788720, 0, 1550225678 },
};
static const uint64_t mainnet_hard_fork_version_1_till = 1009826;
@@ -139,6 +145,8 @@ static const struct {
{ 7, 1057027, 0, 1512211236 },
{ 8, 1057058, 0, 1533211200 },
{ 9, 1057778, 0, 1533297600 },
+ { 10, 1154318, 0, 1550153694 },
+ { 11, 1155038, 0, 1550225678 },
};
static const uint64_t testnet_hard_fork_version_1_till = 624633;
@@ -160,6 +168,8 @@ static const struct {
{ 7, 37000, 0, 1521600000 },
{ 8, 176456, 0, 1537821770 },
{ 9, 177176, 0, 1537821771 },
+ { 10, 269000, 0, 1550153694 },
+ { 11, 269720, 0, 1550225678 },
};
//------------------------------------------------------------------
@@ -1056,6 +1066,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
}
// if we're to keep the disconnected blocks, add them as alternates
+ const size_t discarded_blocks = disconnected_chain.size();
if(!discard_disconnected_chain)
{
//pushing old chain as alternative chain
@@ -1083,7 +1094,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
std::shared_ptr<tools::Notify> reorg_notify = m_reorg_notify;
if (reorg_notify)
reorg_notify->notify("%s", std::to_string(split_height).c_str(), "%h", std::to_string(m_db->height()).c_str(),
- "%n", std::to_string(m_db->height() - split_height).c_str(), NULL);
+ "%n", std::to_string(m_db->height() - split_height).c_str(), "%d", std::to_string(discarded_blocks).c_str(), NULL);
MGINFO_GREEN("REORGANIZE SUCCESS! on height: " << split_height << ", new blockchain size: " << m_db->height());
return true;
@@ -2534,7 +2545,19 @@ bool Blockchain::check_tx_outputs(const transaction& tx, tx_verification_context
if (tx.version >= 2) {
if (tx.rct_signatures.type == rct::RCTTypeBulletproof2)
{
- MERROR_VER("Bulletproofs v2 are not allowed before v" << HF_VERSION_SMALLER_BP);
+ MERROR_VER("Ringct type " << (unsigned)rct::RCTTypeBulletproof2 << " is not allowed before v" << HF_VERSION_SMALLER_BP);
+ tvc.m_invalid_output = true;
+ return false;
+ }
+ }
+ }
+
+ // from v11, allow only bulletproofs v2
+ if (hf_version > HF_VERSION_SMALLER_BP) {
+ if (tx.version >= 2) {
+ if (tx.rct_signatures.type == rct::RCTTypeBulletproof)
+ {
+ MERROR_VER("Ringct type " << (unsigned)rct::RCTTypeBulletproof << " is not allowed from v" << (HF_VERSION_SMALLER_BP + 1));
tvc.m_invalid_output = true;
return false;
}
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index bc01e2435..599f42774 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -188,8 +188,21 @@ namespace cryptonote
static const command_line::arg_descriptor<std::string> arg_reorg_notify = {
"reorg-notify"
, "Run a program for each reorg, '%s' will be replaced by the split height, "
- "'%h' will be replaced by the new blockchain height, and '%n' will be "
- "replaced by the number of new blocks in the new chain"
+ "'%h' will be replaced by the new blockchain height, '%n' will be "
+ "replaced by the number of new blocks in the new chain, and '%d' will be "
+ "replaced by the number of blocks discarded from the old chain"
+ , ""
+ };
+ static const command_line::arg_descriptor<std::string> arg_block_rate_notify = {
+ "block-rate-notify"
+ , "Run a program when the block rate undergoes large fluctuations. This might "
+ "be a sign of large amounts of hash rate going on and off the Monero network, "
+ "and thus be of potential interest in predicting attacks. %t will be replaced "
+ "by the number of minutes for the observation window, %b by the number of "
+ "blocks observed within that window, and %e by the number of blocks that was "
+ "expected in that window. It is suggested that this notification is used to "
+ "automatically increase the number of confirmations required before a payment "
+ "is acted upon."
, ""
};
@@ -308,6 +321,7 @@ namespace cryptonote
command_line::add_arg(desc, arg_block_notify);
command_line::add_arg(desc, arg_prune_blockchain);
command_line::add_arg(desc, arg_reorg_notify);
+ command_line::add_arg(desc, arg_block_rate_notify);
miner::init_options(desc);
BlockchainDB::init_options(desc);
@@ -587,7 +601,7 @@ namespace cryptonote
}
catch (const std::exception &e)
{
- MERROR("Failed to parse block notify spec");
+ MERROR("Failed to parse block notify spec: " << e.what());
}
try
@@ -597,7 +611,17 @@ namespace cryptonote
}
catch (const std::exception &e)
{
- MERROR("Failed to parse reorg notify spec");
+ MERROR("Failed to parse reorg notify spec: " << e.what());
+ }
+
+ try
+ {
+ if (!command_line::is_arg_defaulted(vm, arg_block_rate_notify))
+ m_block_rate_notify.reset(new tools::Notify(command_line::get_arg(vm, arg_block_rate_notify).c_str()));
+ }
+ catch (const std::exception &e)
+ {
+ MERROR("Failed to parse block rate notify spec: " << e.what());
}
const std::pair<uint8_t, uint64_t> regtest_hard_forks[3] = {std::make_pair(1, 0), std::make_pair(Blockchain::get_hard_fork_heights(MAINNET).back().version, 1), std::make_pair(0, 0)};
@@ -1765,7 +1789,7 @@ namespace cryptonote
const time_t now = time(NULL);
const std::vector<time_t> timestamps = m_blockchain_storage.get_last_block_timestamps(60);
- static const unsigned int seconds[] = { 5400, 1800, 600 };
+ static const unsigned int seconds[] = { 5400, 3600, 1800, 1200, 600 };
for (size_t n = 0; n < sizeof(seconds)/sizeof(seconds[0]); ++n)
{
unsigned int b = 0;
@@ -1776,6 +1800,14 @@ namespace cryptonote
if (p < threshold)
{
MWARNING("There were " << b << " blocks in the last " << seconds[n] / 60 << " minutes, there might be large hash rate changes, or we might be partitioned, cut off from the Monero network or under attack. Or it could be just sheer bad luck.");
+
+ std::shared_ptr<tools::Notify> block_rate_notify = m_block_rate_notify;
+ if (block_rate_notify)
+ {
+ auto expected = seconds[n] / DIFFICULTY_TARGET_V2;
+ block_rate_notify->notify("%t", std::to_string(seconds[n] / 60).c_str(), "%b", std::to_string(b).c_str(), "%e", std::to_string(expected).c_str(), NULL);
+ }
+
break; // no need to look further
}
}
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 308924bb9..79d06662e 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -1062,6 +1062,8 @@ namespace cryptonote
bool m_fluffy_blocks_enabled;
bool m_offline;
bool m_pad_transactions;
+
+ std::shared_ptr<tools::Notify> m_block_rate_notify;
};
}
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index 0a04e0d38..c138c7854 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -405,49 +405,12 @@ namespace cryptonote
for(const tx_destination_entry& dst_entr: destinations)
{
CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount);
- crypto::key_derivation derivation;
crypto::public_key out_eph_public_key;
- // make additional tx pubkey if necessary
- keypair additional_txkey;
- if (need_additional_txkeys)
- {
- additional_txkey.sec = additional_tx_keys[output_index];
- if (dst_entr.is_subaddress)
- 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(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 = 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 = 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) << ")");
- }
-
- if (need_additional_txkeys)
- {
- additional_tx_public_keys.push_back(additional_txkey.pub);
- }
-
- if (tx.version > 1)
- {
- crypto::secret_key scalar1;
- hwdev.derivation_to_scalar(derivation, output_index, scalar1);
- amount_keys.push_back(rct::sk2rct(scalar1));
- }
- 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);
+ hwdev.generate_output_ephemeral_keys(tx.version,sender_account_keys, txkey_pub, tx_key,
+ dst_entr, change_addr, output_index,
+ need_additional_txkeys, additional_tx_keys,
+ additional_tx_public_keys, amount_keys, out_eph_public_key);
tx_out out;
out.amount = dst_entr.amount;
diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h
index 85061668b..ad3297951 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.h
+++ b/src/cryptonote_core/cryptonote_tx_utils.h
@@ -97,6 +97,12 @@ namespace cryptonote
bool construct_tx(const account_keys& sender_account_keys, std::vector<tx_source_entry> &sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, const std::vector<uint8_t> &extra, transaction& tx, uint64_t unlock_time);
bool construct_tx_with_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, const std::vector<uint8_t> &extra, transaction& tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, const rct::RCTConfig &rct_config = { rct::RangeProofBorromean, 0 }, rct::multisig_out *msout = NULL, bool shuffle_outs = true);
bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, const std::vector<uint8_t> &extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, const rct::RCTConfig &rct_config = { rct::RangeProofBorromean, 0 }, rct::multisig_out *msout = NULL);
+ bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
+ const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
+ const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
+ std::vector<crypto::public_key> &additional_tx_public_keys,
+ std::vector<rct::key> &amount_keys,
+ crypto::public_key &out_eph_public_key) ;
bool generate_genesis_block(
block& bl
diff --git a/src/device/device.hpp b/src/device/device.hpp
index bdb608907..408f64c8b 100644
--- a/src/device/device.hpp
+++ b/src/device/device.hpp
@@ -69,6 +69,7 @@ namespace cryptonote
struct account_public_address;
struct account_keys;
struct subaddress_index;
+ struct tx_destination_entry;
}
namespace hw {
@@ -211,9 +212,12 @@ namespace hw {
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;
- 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 generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
+ const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
+ const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
+ std::vector<crypto::public_key> &additional_tx_public_keys,
+ std::vector<rct::key> &amount_keys,
+ 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;
virtual bool mlsag_prepare(const rct::key &H, const rct::key &xx, rct::key &a, rct::key &aG, rct::key &aHP, rct::key &rvII) = 0;
diff --git a/src/device/device_default.cpp b/src/device/device_default.cpp
index cb2f4e266..fd15717a7 100644
--- a/src/device/device_default.cpp
+++ b/src/device/device_default.cpp
@@ -34,8 +34,10 @@
#include "int-util.h"
#include "cryptonote_basic/account.h"
#include "cryptonote_basic/subaddress_index.h"
+#include "cryptonote_core/cryptonote_tx_utils.h"
#include "ringct/rctOps.h"
+#include "log.hpp"
#define ENCRYPTED_PAYMENT_ID_TAIL 0x8d
#define CHACHA8_KEY_TAIL 0x8c
@@ -278,10 +280,55 @@ namespace hw {
return true;
}
+ bool device_default::generate_output_ephemeral_keys(const size_t tx_version,
+ const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
+ const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
+ const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
+ std::vector<crypto::public_key> &additional_tx_public_keys,
+ std::vector<rct::key> &amount_keys, crypto::public_key &out_eph_public_key) {
- 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;
+ crypto::key_derivation derivation;
+
+ // make additional tx pubkey if necessary
+ cryptonote::keypair additional_txkey;
+ if (need_additional_txkeys)
+ {
+ 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)));
+ else
+ additional_txkey.pub = rct::rct2pk(rct::scalarmultBase(rct::sk2rct(additional_txkey.sec)));
+ }
+
+ bool r;
+ if (change_addr && dst_entr.addr == *change_addr)
+ {
+ // sending change to yourself; derivation = a*R
+ r = 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 = 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) << ")");
+ }
+
+ if (need_additional_txkeys)
+ {
+ additional_tx_public_keys.push_back(additional_txkey.pub);
+ }
+
+ if (tx_version > 1)
+ {
+ crypto::secret_key scalar1;
+ derivation_to_scalar(derivation, output_index, scalar1);
+ amount_keys.push_back(rct::sk2rct(scalar1));
+ }
+ r = 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 << ")");
+
+ return r;
}
bool device_default::encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) {
diff --git a/src/device/device_default.hpp b/src/device/device_default.hpp
index 54d159b11..04b9b4234 100644
--- a/src/device/device_default.hpp
+++ b/src/device/device_default.hpp
@@ -114,9 +114,12 @@ namespace hw {
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;
- 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 generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
+ const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
+ const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
+ std::vector<crypto::public_key> &additional_tx_public_keys,
+ std::vector<rct::key> &amount_keys,
+ 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;
bool mlsag_prepare(const rct::key &H, const rct::key &xx, rct::key &a, rct::key &aG, rct::key &aHP, rct::key &rvII) override;
diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp
index 9daf62d37..1f91427f0 100644
--- a/src/device/device_ledger.cpp
+++ b/src/device/device_ledger.cpp
@@ -32,6 +32,7 @@
#include "ringct/rctOps.h"
#include "cryptonote_basic/account.h"
#include "cryptonote_basic/subaddress_index.h"
+#include "cryptonote_core/cryptonote_tx_utils.h"
#include <boost/thread/locks.hpp>
#include <boost/thread/lock_guard.hpp>
@@ -67,10 +68,12 @@ namespace hw {
/* === Keymap ==== */
/* ===================================================================== */
- ABPkeys::ABPkeys(const rct::key& A, const rct::key& B, const bool is_subaddr, const size_t real_output_index, const rct::key& P, const rct::key& AK) {
+ ABPkeys::ABPkeys(const rct::key& A, const rct::key& B, const bool is_subaddr, const bool is_change, const bool need_additional_txkeys, const size_t real_output_index, const rct::key& P, const rct::key& AK) {
Aout = A;
Bout = B;
is_subaddress = is_subaddr;
+ is_change_address = is_change;
+ additional_key = need_additional_txkeys;
index = real_output_index;
Pout = P;
AKout = AK;
@@ -80,6 +83,8 @@ namespace hw {
Aout = keys.Aout;
Bout = keys.Bout;
is_subaddress = keys.is_subaddress;
+ is_change_address = keys.is_change_address;
+ additional_key = keys.additional_key;
index = keys.index;
Pout = keys.Pout;
AKout = keys.AKout;
@@ -137,6 +142,8 @@ namespace hw {
static int device_id = 0;
+ #define PROTOCOL_VERSION 2
+
#define INS_NONE 0x00
#define INS_RESET 0x02
@@ -168,6 +175,7 @@ namespace hw {
#define INS_STEALTH 0x76
#define INS_BLIND 0x78
#define INS_UNBLIND 0x7A
+ #define INS_GEN_TXOUT_KEYS 0x7B
#define INS_VALIDATE 0x7C
#define INS_MLSAG 0x7E
#define INS_CLOSE_TX 0x80
@@ -268,7 +276,7 @@ namespace hw {
int device_ledger::set_command_header(unsigned char ins, unsigned char p1, unsigned char p2) {
reset_buffer();
int offset = 0;
- this->buffer_send[0] = 0x00;
+ this->buffer_send[0] = PROTOCOL_VERSION;
this->buffer_send[1] = ins;
this->buffer_send[2] = p1;
this->buffer_send[3] = p2;
@@ -508,11 +516,11 @@ namespace hw {
}
const std::size_t output_index_x = output_index;
crypto::public_key derived_pub_x;
- hw::ledger::log_hexbuffer("derive_subaddress_public_key: [[IN]] pub ", pub_x.data, 32);
- hw::ledger::log_hexbuffer("derive_subaddress_public_key: [[IN]] derivation", derivation_x.data, 32);
- hw::ledger::log_message ("derive_subaddress_public_key: [[IN]] index ", std::to_string((int)output_index_x));
+ log_hexbuffer("derive_subaddress_public_key: [[IN]] pub ", pub_x.data, 32);
+ log_hexbuffer("derive_subaddress_public_key: [[IN]] derivation", derivation_x.data, 32);
+ log_message ("derive_subaddress_public_key: [[IN]] index ", std::to_string((int)output_index_x));
this->controle_device->derive_subaddress_public_key(pub_x, derivation_x,output_index_x,derived_pub_x);
- hw::ledger::log_hexbuffer("derive_subaddress_public_key: [[OUT]] derived_pub", derived_pub_x.data, 32);
+ log_hexbuffer("derive_subaddress_public_key: [[OUT]] derived_pub", derived_pub_x.data, 32);
#endif
if ((this->mode == TRANSACTION_PARSE) && has_view_key) {
@@ -558,11 +566,11 @@ namespace hw {
const cryptonote::account_keys keys_x = hw::ledger::decrypt(keys);
const cryptonote::subaddress_index index_x = index;
crypto::public_key D_x;
- hw::ledger::log_hexbuffer("get_subaddress_spend_public_key: [[IN]] keys.m_view_secret_key ", keys_x.m_view_secret_key.data,32);
- hw::ledger::log_hexbuffer("get_subaddress_spend_public_key: [[IN]] keys.m_spend_secret_key", keys_x.m_spend_secret_key.data,32);
- hw::ledger::log_message ("get_subaddress_spend_public_key: [[IN]] index ", std::to_string(index_x.major)+"."+std::to_string(index_x.minor));
+ log_hexbuffer("get_subaddress_spend_public_key: [[IN]] keys.m_view_secret_key ", keys_x.m_view_secret_key.data,32);
+ log_hexbuffer("get_subaddress_spend_public_key: [[IN]] keys.m_spend_secret_key", keys_x.m_spend_secret_key.data,32);
+ log_message ("get_subaddress_spend_public_key: [[IN]] index ", std::to_string(index_x.major)+"."+std::to_string(index_x.minor));
D_x = this->controle_device->get_subaddress_spend_public_key(keys_x, index_x);
- hw::ledger::log_hexbuffer("get_subaddress_spend_public_key: [[OUT]] derivation ", D_x.data, 32);
+ log_hexbuffer("get_subaddress_spend_public_key: [[OUT]] derivation ", D_x.data, 32);
#endif
if (index.is_zero()) {
@@ -609,14 +617,14 @@ namespace hw {
const cryptonote::account_keys keys_x = hw::ledger::decrypt(keys);
const cryptonote::subaddress_index index_x = index;
cryptonote::account_public_address address_x;
- hw::ledger::log_hexbuffer("get_subaddress: [[IN]] keys.m_view_secret_key ", keys_x.m_view_secret_key.data, 32);
- hw::ledger::log_hexbuffer("get_subaddress: [[IN]] keys.m_view_public_key", keys_x.m_account_address.m_view_public_key.data, 32);
- hw::ledger::log_hexbuffer("get_subaddress: [[IN]] keys.m_view_secret_key ", keys_x.m_view_secret_key.data, 32);
- hw::ledger::log_hexbuffer("get_subaddress: [[IN]] keys.m_spend_public_key", keys_x.m_account_address.m_spend_public_key.data, 32);
- hw::ledger::log_message ("get_subaddress: [[IN]] index ", std::to_string(index_x.major)+"."+std::to_string(index_x.minor));
+ log_hexbuffer("get_subaddress: [[IN]] keys.m_view_secret_key ", keys_x.m_view_secret_key.data, 32);
+ log_hexbuffer("get_subaddress: [[IN]] keys.m_view_public_key", keys_x.m_account_address.m_view_public_key.data, 32);
+ log_hexbuffer("get_subaddress: [[IN]] keys.m_view_secret_key ", keys_x.m_view_secret_key.data, 32);
+ log_hexbuffer("get_subaddress: [[IN]] keys.m_spend_public_key", keys_x.m_account_address.m_spend_public_key.data, 32);
+ log_message ("get_subaddress: [[IN]] index ", std::to_string(index_x.major)+"."+std::to_string(index_x.minor));
address_x = this->controle_device->get_subaddress(keys_x, index_x);
- hw::ledger::log_hexbuffer("get_subaddress: [[OUT]] keys.m_view_public_key ", address_x.m_view_public_key.data, 32);
- hw::ledger::log_hexbuffer("get_subaddress: [[OUT]] keys.m_spend_public_key", address_x.m_spend_public_key.data, 32);
+ log_hexbuffer("get_subaddress: [[OUT]] keys.m_view_public_key ", address_x.m_view_public_key.data, 32);
+ log_hexbuffer("get_subaddress: [[OUT]] keys.m_spend_public_key", address_x.m_spend_public_key.data, 32);
#endif
if (index.is_zero()) {
@@ -652,10 +660,10 @@ namespace hw {
const crypto::secret_key sec_x = hw::ledger::decrypt(sec);
const cryptonote::subaddress_index index_x = index;
crypto::secret_key sub_sec_x;
- hw::ledger::log_message ("get_subaddress_secret_key: [[IN]] index ", std::to_string(index.major)+"."+std::to_string(index.minor));
- hw::ledger::log_hexbuffer("get_subaddress_secret_key: [[IN]] sec ", sec_x.data, 32);
+ log_message ("get_subaddress_secret_key: [[IN]] index ", std::to_string(index.major)+"."+std::to_string(index.minor));
+ log_hexbuffer("get_subaddress_secret_key: [[IN]] sec ", sec_x.data, 32);
sub_sec_x = this->controle_device->get_subaddress_secret_key(sec_x, index_x);
- hw::ledger::log_hexbuffer("get_subaddress_secret_key: [[OUT]] sub_sec", sub_sec_x.data, 32);
+ log_hexbuffer("get_subaddress_secret_key: [[OUT]] sub_sec", sub_sec_x.data, 32);
#endif
int offset = set_command_header_noopt(INS_GET_SUBADDRESS_SECRET_KEY);
@@ -717,10 +725,10 @@ namespace hw {
const rct::key P_x = P;
const rct::key a_x = hw::ledger::decrypt(a);
rct::key aP_x;
- hw::ledger::log_hexbuffer("scalarmultKey: [[IN]] P ", (char*)P_x.bytes, 32);
- hw::ledger::log_hexbuffer("scalarmultKey: [[IN]] a ", (char*)a_x.bytes, 32);
+ log_hexbuffer("scalarmultKey: [[IN]] P ", (char*)P_x.bytes, 32);
+ log_hexbuffer("scalarmultKey: [[IN]] a ", (char*)a_x.bytes, 32);
this->controle_device->scalarmultKey(aP_x, P_x, a_x);
- hw::ledger::log_hexbuffer("scalarmultKey: [[OUT]] aP", (char*)aP_x.bytes, 32);
+ log_hexbuffer("scalarmultKey: [[OUT]] aP", (char*)aP_x.bytes, 32);
#endif
int offset = set_command_header_noopt(INS_SECRET_SCAL_MUL_KEY);
@@ -752,9 +760,9 @@ namespace hw {
#ifdef DEBUG_HWDEVICE
const rct::key a_x = hw::ledger::decrypt(a);
rct::key aG_x;
- hw::ledger::log_hexbuffer("scalarmultKey: [[IN]] a ", (char*)a_x.bytes, 32);
+ log_hexbuffer("scalarmultKey: [[IN]] a ", (char*)a_x.bytes, 32);
this->controle_device->scalarmultBase(aG_x, a_x);
- hw::ledger::log_hexbuffer("scalarmultKey: [[OUT]] aG", (char*)aG_x.bytes, 32);
+ log_hexbuffer("scalarmultKey: [[OUT]] aG", (char*)aG_x.bytes, 32);
#endif
int offset = set_command_header_noopt(INS_SECRET_SCAL_MUL_BASE);
@@ -845,10 +853,10 @@ namespace hw {
const crypto::public_key pub_x = pub;
const crypto::secret_key sec_x = hw::ledger::decrypt(sec);
crypto::key_derivation derivation_x;
- hw::ledger::log_hexbuffer("generate_key_derivation: [[IN]] pub ", pub_x.data, 32);
- hw::ledger::log_hexbuffer("generate_key_derivation: [[IN]] sec ", sec_x.data, 32);
+ log_hexbuffer("generate_key_derivation: [[IN]] pub ", pub_x.data, 32);
+ log_hexbuffer("generate_key_derivation: [[IN]] sec ", sec_x.data, 32);
this->controle_device->generate_key_derivation(pub_x, sec_x, derivation_x);
- hw::ledger::log_hexbuffer("generate_key_derivation: [[OUT]] derivation", derivation_x.data, 32);
+ log_hexbuffer("generate_key_derivation: [[OUT]] derivation", derivation_x.data, 32);
#endif
if ((this->mode == TRANSACTION_PARSE) && has_view_key) {
@@ -914,10 +922,10 @@ namespace hw {
const crypto::key_derivation derivation_x = hw::ledger::decrypt(derivation);
const size_t output_index_x = output_index;
crypto::ec_scalar res_x;
- hw::ledger::log_hexbuffer("derivation_to_scalar: [[IN]] derivation ", derivation_x.data, 32);
- hw::ledger::log_message ("derivation_to_scalar: [[IN]] output_index ", std::to_string(output_index_x));
+ log_hexbuffer("derivation_to_scalar: [[IN]] derivation ", derivation_x.data, 32);
+ log_message ("derivation_to_scalar: [[IN]] output_index ", std::to_string(output_index_x));
this->controle_device->derivation_to_scalar(derivation_x, output_index_x, res_x);
- hw::ledger::log_hexbuffer("derivation_to_scalar: [[OUT]] res ", res_x.data, 32);
+ log_hexbuffer("derivation_to_scalar: [[OUT]] res ", res_x.data, 32);
#endif
int offset = set_command_header_noopt(INS_DERIVATION_TO_SCALAR);
@@ -954,11 +962,11 @@ namespace hw {
const std::size_t output_index_x = output_index;
const crypto::secret_key sec_x = hw::ledger::decrypt(sec);
crypto::secret_key derived_sec_x;
- hw::ledger::log_hexbuffer("derive_secret_key: [[IN]] derivation ", derivation_x.data, 32);
- hw::ledger::log_message ("derive_secret_key: [[IN]] index ", std::to_string(output_index_x));
- hw::ledger::log_hexbuffer("derive_secret_key: [[IN]] sec ", sec_x.data, 32);
+ log_hexbuffer("derive_secret_key: [[IN]] derivation ", derivation_x.data, 32);
+ log_message ("derive_secret_key: [[IN]] index ", std::to_string(output_index_x));
+ log_hexbuffer("derive_secret_key: [[IN]] sec ", sec_x.data, 32);
this->controle_device->derive_secret_key(derivation_x, output_index_x, sec_x, derived_sec_x);
- hw::ledger::log_hexbuffer("derive_secret_key: [[OUT]] derived_sec", derived_sec_x.data, 32);
+ log_hexbuffer("derive_secret_key: [[OUT]] derived_sec", derived_sec_x.data, 32);
#endif
int offset = set_command_header_noopt(INS_DERIVE_SECRET_KEY);
@@ -998,11 +1006,11 @@ namespace hw {
const std::size_t output_index_x = output_index;
const crypto::public_key pub_x = pub;
crypto::public_key derived_pub_x;
- hw::ledger::log_hexbuffer("derive_public_key: [[IN]] derivation ", derivation_x.data, 32);
- hw::ledger::log_message ("derive_public_key: [[IN]] output_index", std::to_string(output_index_x));
- hw::ledger::log_hexbuffer("derive_public_key: [[IN]] pub ", pub_x.data, 32);
+ log_hexbuffer("derive_public_key: [[IN]] derivation ", derivation_x.data, 32);
+ log_message ("derive_public_key: [[IN]] output_index", std::to_string(output_index_x));
+ log_hexbuffer("derive_public_key: [[IN]] pub ", pub_x.data, 32);
this->controle_device->derive_public_key(derivation_x, output_index_x, pub_x, derived_pub_x);
- hw::ledger::log_hexbuffer("derive_public_key: [[OUT]] derived_pub ", derived_pub_x.data, 32);
+ log_hexbuffer("derive_public_key: [[OUT]] derived_pub ", derived_pub_x.data, 32);
#endif
int offset = set_command_header_noopt(INS_DERIVE_PUBLIC_KEY);
@@ -1039,11 +1047,11 @@ namespace hw {
#ifdef DEBUG_HWDEVICE
const crypto::secret_key sec_x = hw::ledger::decrypt(sec);
crypto::public_key pub_x;
- hw::ledger::log_hexbuffer("secret_key_to_public_key: [[IN]] sec ", sec_x.data, 32);
+ log_hexbuffer("secret_key_to_public_key: [[IN]] sec ", sec_x.data, 32);
bool rc = this->controle_device->secret_key_to_public_key(sec_x, pub_x);
- hw::ledger::log_hexbuffer("secret_key_to_public_key: [[OUT]] pub", pub_x.data, 32);
+ log_hexbuffer("secret_key_to_public_key: [[OUT]] pub", pub_x.data, 32);
if (!rc){
- hw::ledger::log_message("secret_key_to_public_key", "secret_key rejected");
+ log_message("secret_key_to_public_key", "secret_key rejected");
}
#endif
@@ -1073,10 +1081,10 @@ namespace hw {
const crypto::public_key pub_x = pub;
const crypto::secret_key sec_x = hw::ledger::decrypt(sec);
crypto::key_image image_x;
- hw::ledger::log_hexbuffer("generate_key_image: [[IN]] pub ", pub_x.data, 32);
- hw::ledger::log_hexbuffer("generate_key_image: [[IN]] sec ", sec_x.data, 32);
+ log_hexbuffer("generate_key_image: [[IN]] pub ", pub_x.data, 32);
+ log_hexbuffer("generate_key_image: [[IN]] sec ", sec_x.data, 32);
this->controle_device->generate_key_image(pub_x, sec_x, image_x);
- hw::ledger::log_hexbuffer("generate_key_image: [[OUT]] image ", image_x.data, 32);
+ log_hexbuffer("generate_key_image: [[OUT]] image ", image_x.data, 32);
#endif
int offset = set_command_header_noopt(INS_GEN_KEY_IMAGE);
@@ -1160,10 +1168,139 @@ namespace hw {
return true;
}
- bool device_ledger::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) {
- AUTO_LOCK_CMD();
- key_map.add(ABPkeys(rct::pk2rct(Aout),rct::pk2rct(Bout), is_subaddress, real_output_index, rct::pk2rct(out_eph_public_key), amount_key));
+
+ bool device_ledger::generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
+ const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
+ const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
+ std::vector<crypto::public_key> &additional_tx_public_keys,
+ std::vector<rct::key> &amount_keys,
+ crypto::public_key &out_eph_public_key) {
+ AUTO_LOCK_CMD();
+
+ #ifdef DEBUG_HWDEVICE
+ const size_t &tx_version_x = tx_version;
+ 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;
+ 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;
+ this->controle_device->generate_output_ephemeral_keys(tx_version_x, sender_account_keys_x, txkey_pub_x, tx_key_x, dst_entr_x, change_addr_x, output_index_x, need_additional_txkeys_x, additional_tx_keys_x,
+ additional_tx_public_keys_x, amount_keys_x, out_eph_public_key_x);
+ #endif
+
+ // make additional tx pubkey if necessary
+ cryptonote::keypair additional_txkey;
+ if (need_additional_txkeys) {
+ additional_txkey.sec = additional_tx_keys[output_index];
+ }
+
+ //compute derivation, out_eph_public_key, and amount key in one shot on device, to ensure checkable link
+ const crypto::secret_key *sec;
+ bool is_change;
+
+ if (change_addr && dst_entr.addr == *change_addr)
+ {
+ // sending change to yourself; derivation = a*R
+ is_change = true;
+ sec = &sender_account_keys.m_view_secret_key;
+ }
+ else
+ {
+ is_change = false;
+ if (dst_entr.is_subaddress && need_additional_txkeys) {
+ sec = &additional_txkey.sec;
+ } else {
+ sec = &tx_key;
+ }
+ }
+
+ int offset = set_command_header_noopt(INS_GEN_TXOUT_KEYS);
+ //tx_version
+ this->buffer_send[offset+0] = tx_version>>24;
+ this->buffer_send[offset+1] = tx_version>>16;
+ this->buffer_send[offset+2] = tx_version>>8;
+ this->buffer_send[offset+3] = tx_version>>0;
+ offset += 4;
+ //tx_sec
+ memmove(&this->buffer_send[offset], sec->data, 32);
+ offset += 32;
+ //Aout
+ memmove(&this->buffer_send[offset], dst_entr.addr.m_view_public_key.data, 32);
+ offset += 32;
+ //Bout
+ memmove(&this->buffer_send[offset], dst_entr.addr.m_spend_public_key.data, 32);
+ offset += 32;
+ //output index
+ this->buffer_send[offset+0] = output_index>>24;
+ this->buffer_send[offset+1] = output_index>>16;
+ this->buffer_send[offset+2] = output_index>>8;
+ this->buffer_send[offset+3] = output_index>>0;
+ offset += 4;
+ //is_change,
+ this->buffer_send[offset] = is_change;
+ offset++;
+ //is_subaddress
+ this->buffer_send[offset] = dst_entr.is_subaddress;
+ offset++;
+ //need_additional_key
+ this->buffer_send[offset] = need_additional_txkeys;
+ offset++;
+
+ this->buffer_send[4] = offset-5;
+ this->length_send = offset;
+ this->exchange();
+
+ offset = 0;
+ unsigned int recv_len = this->length_recv;
+ if (need_additional_txkeys)
+ {
+ ASSERT_X(recv_len>=32, "Not enought data from device");
+ memmove(additional_txkey.pub.data, &this->buffer_recv[offset], 32);
+ additional_tx_public_keys.push_back(additional_txkey.pub);
+ offset += 32;
+ recv_len -= 32;
+ }
+ if (tx_version > 1)
+ {
+ ASSERT_X(recv_len>=32, "Not enought data from device");
+ crypto::secret_key scalar1;
+ memmove(scalar1.data, &this->buffer_recv[offset],32);
+ amount_keys.push_back(rct::sk2rct(scalar1));
+ offset += 32;
+ recv_len -= 32;
+ }
+ ASSERT_X(recv_len>=32, "Not enought data from device");
+ memmove(out_eph_public_key.data, &this->buffer_recv[offset], 32);
+ recv_len -= 32;
+
+ // add ABPkeys
+ this->add_output_key_mapping(dst_entr.addr.m_view_public_key, dst_entr.addr.m_spend_public_key, dst_entr.is_subaddress, is_change,
+ need_additional_txkeys, output_index,
+ amount_keys.back(), out_eph_public_key);
+
+ #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", "out_eph_public_key", out_eph_public_key_x.data, out_eph_public_key.data);
+ #endif
+
+ return true;
+ }
+
+ bool device_ledger::add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, const bool is_subaddress, const bool is_change,
+ const bool need_additional, const size_t real_output_index,
+ const rct::key &amount_key, const crypto::public_key &out_eph_public_key) {
+ key_map.add(ABPkeys(rct::pk2rct(Aout),rct::pk2rct(Bout), is_subaddress, is_change, need_additional, real_output_index, rct::pk2rct(out_eph_public_key), amount_key));
return true;
}
@@ -1176,7 +1313,10 @@ namespace hw {
this->controle_device->ecdhEncode(unmasked_x, AKout_x, short_amount);
#endif
- int offset = set_command_header_noopt(INS_BLIND);
+ int offset = set_command_header(INS_BLIND);
+ //options
+ this->buffer_send[offset] = short_amount?0x02:0x00;
+ offset += 1;
// AKout
memmove(this->buffer_send+offset, AKout.bytes, 32);
offset += 32;
@@ -1198,7 +1338,7 @@ namespace hw {
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);
- hw::ledger::log_hexbuffer("Blind AKV input", (char*)&this->buffer_recv[64], 3*32);
+ log_hexbuffer("Blind AKV input", (char*)&this->buffer_recv[64], 3*32);
#endif
return true;
@@ -1213,8 +1353,10 @@ namespace hw {
this->controle_device->ecdhDecode(masked_x, AKout_x, short_amount);
#endif
- int offset = set_command_header_noopt(INS_UNBLIND);
-
+ int offset = set_command_header(INS_UNBLIND);
+ //options
+ this->buffer_send[offset] = short_amount?0x02:0x00;
+ offset += 1;
// AKout
memmove(this->buffer_send+offset, AKout.bytes, 32);
offset += 32;
@@ -1310,7 +1452,11 @@ namespace hw {
// ====== Aout, Bout, AKout, C, v, k ======
kv_offset = data_offset;
- C_offset = kv_offset+ (32*2)*outputs_size;
+ if (type==rct::RCTTypeBulletproof2) {
+ C_offset = kv_offset+ (8)*outputs_size;
+ } else {
+ C_offset = kv_offset+ (32+32)*outputs_size;
+ }
for ( i = 0; i < outputs_size; i++) {
ABPkeys outKeys;
bool found;
@@ -1323,11 +1469,15 @@ namespace hw {
offset = set_command_header(INS_VALIDATE, 0x02, i+1);
//options
this->buffer_send[offset] = (i==outputs_size-1)? 0x00:0x80 ;
+ this->buffer_send[offset] |= (type==rct::RCTTypeBulletproof2)?0x02:0x00;
offset += 1;
if (found) {
//is_subaddress
this->buffer_send[offset] = outKeys.is_subaddress;
offset++;
+ //is_change_address
+ this->buffer_send[offset] = outKeys.is_change_address;
+ offset++;
//Aout
memmove(this->buffer_send+offset, outKeys.Aout.bytes, 32);
offset+=32;
@@ -1339,27 +1489,38 @@ namespace hw {
offset+=32;
} else {
// dummy: is_subaddress Aout Bout AKout
- offset += 1+32*3;
+ offset += 2+32*3;
}
//C
memmove(this->buffer_send+offset, data+C_offset,32);
offset += 32;
C_offset += 32;
- //k
- memmove(this->buffer_send+offset, data+kv_offset,32);
- offset += 32;
- //v
- kv_offset += 32;
- memmove(this->buffer_send+offset, data+kv_offset,32);
- offset += 32;
- kv_offset += 32;
+ if (type==rct::RCTTypeBulletproof2) {
+ //k
+ memset(this->buffer_send+offset, 0, 32);
+ offset += 32;
+ //v
+ memset(this->buffer_send+offset, 0, 32);
+ memmove(this->buffer_send+offset, data+kv_offset,8);
+ offset += 32;
+ kv_offset += 8;
+ } else {
+ //k
+ memmove(this->buffer_send+offset, data+kv_offset,32);
+ offset += 32;
+ kv_offset += 32;
+ //v
+ memmove(this->buffer_send+offset, data+kv_offset,32);
+ offset += 32;
+ kv_offset += 32;
+ }
this->buffer_send[4] = offset-5;
this->length_send = offset;
// check transaction user input
CHECK_AND_ASSERT_THROW_MES(this->exchange_wait_on_input() == 0, "Transaction denied on device.");
#ifdef DEBUG_HWDEVICE
- hw::ledger::log_hexbuffer("Prehash AKV input", (char*)&this->buffer_recv[64], 3*32);
+ log_hexbuffer("Prehash AKV input", (char*)&this->buffer_recv[64], 3*32);
#endif
}
diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp
index 584f1e096..3f470ee7c 100644
--- a/src/device/device_ledger.hpp
+++ b/src/device/device_ledger.hpp
@@ -56,12 +56,14 @@ namespace hw {
rct::key Aout;
rct::key Bout;
bool is_subaddress;
+ bool is_change_address;
+ bool additional_key ;
size_t index;
rct::key Pout;
rct::key AKout;
- ABPkeys(const rct::key& A, const rct::key& B, const bool is_subaddr, size_t index, const rct::key& P,const rct::key& AK);
+ ABPkeys(const rct::key& A, const rct::key& B, const bool is_subaddr, bool is_subaddress, bool is_change_address, size_t index, const rct::key& P,const rct::key& AK);
ABPkeys(const ABPkeys& keys) ;
- ABPkeys() {index=0;is_subaddress=false;}
+ ABPkeys() {index=0;is_subaddress=false;is_subaddress=false;is_change_address=false;}
};
class Keymap {
@@ -105,7 +107,9 @@ namespace hw {
device_mode mode;
// map public destination key to ephemeral destination key
Keymap key_map;
-
+ bool add_output_key_mapping(const crypto::public_key &Aout, const crypto::public_key &Bout, const bool is_subaddress, const bool is_change,
+ const bool need_additional, const size_t real_output_index,
+ const rct::key &amount_key, const crypto::public_key &out_eph_public_key);
// To speed up blockchain parsing the view key maybe handle here.
crypto::secret_key viewkey;
bool has_view_key;
@@ -194,9 +198,12 @@ namespace hw {
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;
- 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 generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
+ const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
+ const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
+ std::vector<crypto::public_key> &additional_tx_public_keys,
+ std::vector<rct::key> &amount_keys,
+ 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;
bool mlsag_prepare(const rct::key &H, const rct::key &xx, rct::key &a, rct::key &aG, rct::key &aHP, rct::key &rvII) override;
diff --git a/src/device/log.cpp b/src/device/log.cpp
index c9d3b551b..87505798b 100644
--- a/src/device/log.cpp
+++ b/src/device/log.cpp
@@ -66,7 +66,7 @@ namespace hw {
void decrypt(char* buf, size_t len) {
- #ifdef IODUMMYCRYPT_HWDEVICE
+ #if defined(IODUMMYCRYPT_HWDEVICE) || defined(IONOCRYPT_HWDEVICE)
size_t i;
if (len == 32) {
//view key?
@@ -86,11 +86,13 @@ namespace hw {
return;
}
}
+ #if defined(IODUMMYCRYPT_HWDEVICE)
//std decrypt: XOR.55h
for (i = 0; i<len;i++) {
buf[i] ^= 0x55;
}
#endif
+ #endif
}
crypto::key_derivation decrypt(const crypto::key_derivation &derivation) {
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index c02d10ab4..1491e50ac 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -373,7 +373,7 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
}
catch (const std::exception &e)
{
- MERROR("Failed to parse tx notify spec");
+ MERROR("Failed to parse tx notify spec: " << e.what());
}
return wallet;
@@ -1426,7 +1426,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, bool pool)
+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, bool pool)
{
THROW_WALLET_EXCEPTION_IF(i >= tx.vout.size(), error::wallet_internal_error, "Invalid vout index");
@@ -1459,11 +1459,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;
@@ -1641,7 +1644,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, pool);
+ scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs, pool);
}
}
}
@@ -1664,7 +1667,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, pool);
+ scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs, pool);
}
}
}
@@ -1680,7 +1683,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, pool);
+ scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs, pool);
}
}
}
@@ -11308,6 +11311,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;
@@ -11315,11 +11319,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;
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 3b2dd6076..df080be86 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -1292,7 +1292,7 @@ namespace tools
bool tx_add_fake_output(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked) 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, bool pool);
+ 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, bool pool);
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 std::unordered_set<crypto::public_key> &ignore_set, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const;