From ad754cf2f059d9323e0f5d8d3f26a40c2bdc496f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Feb 2022 21:55:34 -0500 Subject: [PATCH] Use chain magic as a unique starting value for randomx key --- src/miner.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index da4af7a66..f1920f7c5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1135,11 +1135,31 @@ void static RandomXMiner() char randomxHash[RANDOMX_HASH_SIZE]; // TODO: decide on real RandomX key and input - const char randomxKey[] = "HUSH RandomX testing key"; - const char randomxInput[] = "HUSH RandomX testing input"; + char randomxKey[5]; + randomxKey[0] = ASSETCHAINS_MAGIC & 0xff; + randomxKey[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; + randomxKey[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; + randomxKey[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; + randomxKey[4] = SMART_CHAIN_SYMBOL[0]; + + // crypto_generichash_blake2b_state state; + // CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + // ss << randomxKey; + // ss << SMART_CHAIN_SYMBOL; + // crypto_generichash_blake2b_update(&state, (unsigned char*)&ss[0], ss.size()); + // char blakehash[32]; + // crypto_generichash_blake2b_final(&state, blakehash, 32); + + const char randomxInput[] = "testing"; // blakehash[32]; randomx_flags flags = randomx_get_flags(); randomx_cache *randomxCache = randomx_alloc_cache(flags); + if(Mining_height > 1) { + // use blockchain data to set a new key+input for a group of blocks + // randomxKey = ... + // randomxInput = ... + } + if (randomxCache == NULL) { LogPrintf("RandomX cache is null, something is wrong, cannot mine!\n"); return;