Hello there.
I was watching your topic about the accusation of stake.. but im not sure where do you find the evidence they cheater.
Iterations for mine bets which you provided differes as it depends if mines are opened one by one or automatically (multiple field at once)
I have prepared some php code which you can use to verify outcome of the mine games with tool that stake provide.
<?php
// Example usage:
$nonce = 1;
$cursor = 0;
//we need 24 results for mines to generate as we have 24 possible mines
$count = 24;
$hashedServerSeed = 'def3a5cbd25b59adf1d26cfca8efa8e349240c6f5a7a9754a7bc3614a68a5283';
$clientSeed = 'Vl-f-FEmK7';
$serverSeed = 'd67cb6c65af339a914a82fbdc652fe13bd022da2c753bf445751a73a3eb4c6d9';
function verifyIfServerSeedIsTrue(string $hashedServerSeed, string $serverSeed): bool
{
//lets verify if my unhashedServerSeed is actually sha256 hashedServerSeed
return hash('sha256', $serverSeed) === $hashedServerSeed;
}
echo "lets verify if my unhashedServerSeed is actually sha256 hashedServerSeed , Result: => ";
var_dump(verifyIfServerSeedIsTrue($hashedServerSeed, $serverSeed));
$hmac_sha256 = [];
function byteGenerator(string $serverSeed, string $clientSeed, int $nonce, int$cursor): \Generator
{
// Setup cursor variables
$currentRound = floor($cursor / 32);
$currentRoundCursor = $cursor - ($currentRound * 32);
// Generate outputs until cursor requirement is fulfilled
while (true) {
// Calculate the HMAC
// Initialize the HMAC context
$msg = $clientSeed . ":" . $nonce . ":" . $currentRound;
$hmac = hash_hmac('sha256', $msg, $serverSeed, true);
$hmacBytes = str_split($hmac);
// Update cursor for the next iteration of the loop
while ($currentRoundCursor < 32) {
yield ord($hmacBytes[$currentRoundCursor]); // Yield the number
$currentRoundCursor += 1;
}
$currentRoundCursor = 0;
$currentRound += 1;
}
}
// Convert the hash output from the rng byteGenerator to floats
function generateFloats (string $serverSeed, string $clientSeed, int $nonce, int $cursor, int $count): array
{
// Random number generator function
$rng = byteGenerator($serverSeed, $clientSeed, $nonce, $cursor);
// Declare bytes as empty array
$bytes = [];
// Populate bytes array with sets of 4 from RNG output
while (count($bytes) < $count * 4) {
$bytes[] = $rng->current();
$rng->next();
}
// Chunk the array into sets of 4
$byteChunks = array_chunk($bytes, 4);
// Map and reduce each chunk to calculate floats
$result = array_map(function ($byteChunk) {
$partialResult = 0.0;
foreach ($byteChunk as $i => $value) {
$partialResult += $value / pow(256, $i + 1);
}
return $partialResult;
}, $byteChunks);
return $result;
};
function fisherYatesShuffle(array $array): array
{
$result = [];
$cells = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
for ($i=0; $i< count($array) ; $i++) {
$result[$i] = $cells[$array[$i]];
array_splice($cells, $array[$i], 1);
}
return $result;
}
$results = generateFloats($serverSeed, $clientSeed, $nonce, $cursor, $count);
$int_array = [];
foreach( $results as $result) {
$r = ($result * ($count+1));
$int_array[] = (int) $r;
$count = $count -1;
}
$mines_positions = fisherYatesShuffle($int_array);
echo "<br><b>Mines postions</b></br>";
echo "Game Nonce:" . $nonce;
foreach ($mines_positions as $key => $value) {
echo "</br>" . $key . " = " . $value;
};
?>