Use randomxInput = blake2b(randomXkey || ac_name)

This commit is contained in:
Duke Leto
2022-02-20 23:20:15 -05:00
parent ad754cf2f0
commit c9aaf341ae

View File

@@ -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 = ...