Browse Source

Make our initial randomx key longer, at least 9 bytes of entropy

pull/151/head
Duke Leto 2 years ago
parent
commit
5a742dfc9d
  1. 19
      src/miner.cpp
  2. 2
      test_randomx

19
src/miner.cpp

@ -1167,9 +1167,10 @@ void static RandomXMiner()
gotinvalid = 0;
while (true)
{
fprintf(stderr,"RandomXMiner: gotinvalid=%d\n",gotinvalid);
if ( gotinvalid != 0 )
if ( gotinvalid != 0 ) {
fprintf(stderr,"RandomXMiner: gotinvalid=%d\n",gotinvalid);
break;
}
hush_longestchain();
fprintf(stderr,"RandomXMiner: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str());
@ -1177,16 +1178,16 @@ void static RandomXMiner()
hashTarget = HASHTarget;
char randomxHash[RANDOMX_HASH_SIZE];
fprintf(stderr,"RandomXMiner: created randomxHash of size %d\n", RANDOMX_HASH_SIZE);
// Initial randomx key is ac_name which is >= 2^40 bits of entropy assuming strlen(ac_name) >= 5
// For ac_name=DRAGONX we have 7 bytes or 2^56 bits of entropy
char randomxKey[65]; // randomx spec says keysize of >60 bytes is implementation-specific
strncpy(randomxKey, SMART_CHAIN_SYMBOL, 65);
//fprintf(stderr,"RandomXMiner: created randomxHash of size %d\n", RANDOMX_HASH_SIZE);
char randomxKey[82]; // randomx spec says keysize of >60 bytes is implementation-specific
// initial randomx key is unique to every Hush Smart Chain, and has at least 9 bytes (2^128 bits) of entropy
// since magic is 4 bytes, rpc port is 4 bytes and smart chain symbol must be at least 1 character long
snprintf(randomxKey, 81, "%08x%s%08x", ASSETCHAINS_MAGIC, SMART_CHAIN_SYMBOL, ASSETCHAINS_RPCPORT);
char randomxInput[80];
sprintf(randomxInput, "%08x Extreme Privacy Hush Smart Chain %08x", ASSETCHAINS_MAGIC, ASSETCHAINS_MAGIC);
fprintf(stderr,"RandomXMiner: created randomxInput=%s\n", randomxInput);
fprintf(stderr,"RandomXMiner: created randomxKey=%s , randomxInput=%s\n", randomxKey, randomxInput);
randomx_flags flags = randomx_get_flags();
randomx_cache *randomxCache = randomx_alloc_cache(flags);
@ -1194,7 +1195,7 @@ void static RandomXMiner()
LogPrintf("RandomX cache is null, something is wrong, cannot mine!\n");
return;
}
fprintf(stderr,"RandomXMiner: created randomx flags + cache\n");
// fprintf(stderr,"RandomXMiner: created randomx flags + cache\n");
// With the defaults of 1024 and 64
// the key block will change every ~21.3 hours with a 75s block time

2
test_randomx

@ -1,6 +1,6 @@
#!/bin/bash
./src/hushd -ac_randomx_interval=10 -ac_randomx_lag=3 -ac_halving=20 -ac_algo=randomx -ac_name=RANDOMX6 -ac_private=1 -ac_blocktime=20 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1
./src/hushd -ac_randomx_interval=10 -ac_randomx_lag=3 -ac_halving=20 -ac_algo=randomx -ac_name=RANDOMX8 -ac_private=1 -ac_blocktime=20 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1
# to run via the debugger
# type "run" when gdb prompt appears

Loading…
Cancel
Save