From c9aaf341aeaf82fcbb5926c2f6477e6b0455fac9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Feb 2022 23:20:15 -0500 Subject: [PATCH] Use randomxInput = blake2b(randomXkey || ac_name) --- src/miner.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f1920f7c5..3b0335a2b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1134,7 +1134,7 @@ void static RandomXMiner() hashTarget = HASHTarget; char randomxHash[RANDOMX_HASH_SIZE]; - // TODO: decide on real RandomX key and input + // Initial randomx key is chain magic + first letter of chain name which is 2^40 bits of entropy char randomxKey[5]; randomxKey[0] = ASSETCHAINS_MAGIC & 0xff; randomxKey[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; @@ -1142,19 +1142,18 @@ void static RandomXMiner() 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); + crypto_generichash_blake2b_state state; + // Hash = blake2b( key || ac_name) + crypto_generichash_blake2b_update(&state, (unsigned char*)&randomxKey[0], 5); + crypto_generichash_blake2b_update(&state, (unsigned char*)&SMART_CHAIN_SYMBOL[0], strlen(SMART_CHAIN_SYMBOL)); + uchar randomxInput[32]; + crypto_generichash_blake2b_final(&state, randomxInput, 32); - const char randomxInput[] = "testing"; // blakehash[32]; randomx_flags flags = randomx_get_flags(); randomx_cache *randomxCache = randomx_alloc_cache(flags); - if(Mining_height > 1) { + if(Mining_height > 1024 && (Mining_height % 1024 == 64)) { + // At block height 1024*N+64 we should use the blockhash of block 1024*N as key // use blockchain data to set a new key+input for a group of blocks // randomxKey = ... // randomxInput = ...