Nice work. How did you figure out that this is what they're doing to HMac256(server, client)? Just curious since I tried and failed.
let hash = CryptoJS.HmacSHA256(serverSeed, clientSeed).toString();
let PRNGSeed = parseInt(`0x${hash.substr(hash.length - 8)}`);
mt.srand(PRNGSeed);
document.getElementById("resultBox").className = "card mt-3 bg-success"
document.getElementById("resultText").innerHTML = `Roll: ${mt.rand(0, 10000)}`;
(Not familiar with the JSMTRand package)
From the
gamebetr/provable repository, we can find their PHP implementation to set the PRNG seed:
private function generateSeedInteger(): int
{
return hexdec(substr(hash_hmac('sha256', $this->getServerSeed(), $this->getClientSeed()), -8, 8));
}
Then they just use PHP's built in mt_rand method to get the random number. JSMTRand was a package I found that specifically mentioned having the same Mersenne Twister implementation as PHP, so it would generate the same random numbers given the same seed.