diff --git a/src/miner.cpp b/src/miner.cpp index e59bfa831..6d7a5aba4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1178,23 +1178,10 @@ void static RandomXMiner() char randomxHash[RANDOMX_HASH_SIZE]; fprintf(stderr,"RandomXMiner: created randomxHash of size %d\n", RANDOMX_HASH_SIZE); - // Initial randomx key is chain magic || ac_name which is >= 2^40 bits of entropy assuming strlen(ac_name) >= 1 - // For ac_name=DRAGONX we have 4 + 7 = 11 bytes or 2^88 bits of entropy - //int randomxKeySize = sizeof(randomxKey); // 4 + strlen(SMART_CHAIN_SYMBOL)]; - char randomxKey[] = "RANDOMX"; - //fprintf(stderr,"RandomXMiner: creating randomxKey of size %d\n", randomxKeySize); - /* - randomxKey[0] = ASSETCHAINS_MAGIC & 0xff; - randomxKey[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; - randomxKey[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; - randomxKey[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; - - for(int i=0; i++; i= 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); crypto_generichash_blake2b_state state; // Hash = blake2b( key || ac_name) @@ -1203,8 +1190,11 @@ void static RandomXMiner() //crypto_generichash_blake2b_update(&state, (unsigned char*)&SMART_CHAIN_SYMBOL[0], sizeof(SMART_CHAIN_SYMBOL)); //uchar randomxInput[32]; //crypto_generichash_blake2b_final(&state, randomxInput, 32); - unsigned char randomxInput[] = "RANDOMX"; - fprintf(stderr,"RandomXMiner: created randomxInput\n"); + //unsigned char randomxInput[] = "RANDOMX"; + char randomxInput[80]; + sprintf(randomxInput, "%08x", ASSETCHAINS_MAGIC); + + fprintf(stderr,"RandomXMiner: created randomxInput=%s\n", randomxInput); randomx_flags flags = randomx_get_flags(); randomx_cache *randomxCache = randomx_alloc_cache(flags); @@ -1237,7 +1227,7 @@ void static RandomXMiner() //crypto_generichash_blake2b_update(&new_state, (unsigned char *)&randomxBlockKey, 32); //crypto_generichash_blake2b_final(&new_state, randomxInput, 32); - randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxKey); + randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxBlockKey); fprintf(stderr,"RandomXMiner: initialized cache with randomxBlockKey=%s\n", randomxBlockKey.ToString().c_str()); } diff --git a/test_randomx b/test_randomx index 780db691d..90543998b 100755 --- a/test_randomx +++ b/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=RANDOMX3 -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=RANDOMX5 -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