Bitrocket Verifier
MintDice's provably fair verifier for their bitrocket game. Learn more about cryptocurrency and bitcoin gambling here.
by Mint Dice
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha256.js"></script>
<h1> <span class="green">MintDice</span> Hash Chain Verifier</h1>
<h2>Bitrocket</h2>
<p>This is the <a href="https://www.mintdice.com" target="_blank" rel="noopener noreferrer">MintDice</a> hash chain verifier for their bitrocket game. To learn more about provably fair, <a href="https://provablyfair.org/" target="_blank" rel="noopener noreferrer">refer here</a>. </p>
<p>Bitrocket uses a hash chain to calculate the crash multipliers. The latest salt was generated from the 695,600 bitcoin block hash. You can read the announcement <a href="https://bitcointalk.org/index.php?topic=5353554.new#new" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p>Previously used salts are stored in the JS code for reference.</p>
<div class="inputs group">
<div>
<div class="input">
<label for="seed">Round Hash:</label>
<input type="text" id="hash">
</div>
<div class="input">
<label for="salt">Salt:</label>
<input type="text" id="salt" value="000000000000000000068639c00d15a48b1403708e71013846d910806045df4b">
</div>
<div class="input">
<label for="game-count">Chain Count:</label>
<input type="number" id="game-count" value="10">
</div>
</div>
<button class="calculate" id="button">
Calculate
</button>
</div>
<br />
<div class="outputs group">
<table id="table">
<thead class="output-headers">
<th>Hash</th>
<th>Multiplier</th>
</thead>
<tbody id="table-body"></tbody>
</table>
</div>
CSS
h1,
h2 {
text-align: center;
}
.green {
color: #37bd64;
}
.blue {
color: #4fafd9;
}
.input {
display: flex;
justify-content: space-between;
width: 650px;
margin: 2px 0px;
}
.group {
padding: 10px;
border: 3px solid black;
border-radius: 10px;
}
.inputs {
border-color: #37bd64;
display: flex;
}
.inputs label {
cursor: pointer;
}
.outputs {
border-color: #4fafd9;
}
.calculate {
margin-left: 10px;
cursor: pointer;
}
input {
width: 500px;
}
.radios input {
width: unset;
}
table, th, td {
width: 100%;
}
th {
text-align: left;
}
tr.values:hover {
background-color: #bcd6c3;
}
JavaScript
const OLD_SALT = '2ecee9b5a74b745a810d11eca97680f66e970d691e6fc02eaff57a805ed04468' // used until Aug. 8 2021
const brHouseEdge = .01;
document.getElementById('button').onclick = calculate;
const tBody = document.getElementById('table-body');
const table = document.getElementById('table');
function calculate() {
clearTable();
const seedHash = document.getElementById('hash').value.trim();
const salt = document.getElementById('salt').value.trim();
const count = Math.floor(document.getElementById('game-count').value.trim());
const values = [];
let currentHash = seedHash;
for (let i = 0; i < count; i++) {
const newValue = calculateValues(currentHash, salt);
values.push(newValue);
currentHash = CryptoJS.SHA256(currentHash).toString(CryptoJS.enc.Hex);
}
values.forEach(tableBodyAdder);
}
function clearTable() {
const rowCount = table.rows.length;
const headerCount = 1;
for (let i = headerCount; i < rowCount; i++) {
table.deleteRow(headerCount)
}
}
function calculateValues(hash, salt) {
const bits = 52;
const hmac = CryptoJS.HmacSHA256(CryptoJS.enc.Hex.parse(hash), salt);
const trimmedSeed = hmac.toString(CryptoJS.enc.Hex).slice(0, bits / 4);
return {
hash: hash,
multiplier: calculateMultiplier(trimmedSeed, bits)
};
}
function calculateMultiplier(trimmedSeed, bits) {
let multiplier = parseInt(trimmedSeed, 16) / 2 ** bits;
multiplier = ((1 - brHouseEdge) / (1 - multiplier)) * 100;
multiplier = Math.floor(multiplier);
return Math.max(1, multiplier / 100);
}
function tableBodyAdder({
hash,
multiplier
}) {
tBody.innerHTML += `
<tr class="values">
<td>${hash}</td>
<td>${multiplier}</td>
</tr>`
}