<commit_before><!DOCTYPE HTML>
<html>
<head>
	<title>Just-Dice Verifier</title>
	<script src="../js/jquery.js"></script>
	<link rel="stylesheet" href="../css/bootstrap.css">
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/hmac-sha512.js"></script>
	<script src="../js/sha512.js"></script>
	<script src="../js/enc-base64-min.js"></script>
	<script src="../js/sha256.js"></script>
</head>
<body>
	<div class="jumbotron">
		<h1>Verifier</h1>
	</div>
	<div class="container">
		<div class="well">
			<center>
				<h1>Just-Dice Verifier</h1>

				<div class="cont">
					<textarea class="form-control" id="randomize" placeholder="Paste from randomize textbox (Not for use with bets with a betid less than 145,000,000)"></textarea>
					<br>or
					<br>
					<textarea class="form-control" id="id" placeholder="Bet ID (Optional, for use with bets with a betid less than 145,000,000)"></textarea>
					<br>
					<textarea class="form-control" id="ssh" placeholder="Hash of server seed"></textarea>
					<br>
					<textarea class="form-control" id="ss" placeholder="Server seed"></textarea>
					<br>
					<textarea class="form-control" id="cs" placeholder="Client seed"></textarea>
					<br>
					<input class="form-control" id="sn" placeholder="Starting nonce (>=1)" type="number"></input>
					<br>
					<input class="form-control" id="nb" placeholder="Number of Bets (>=1)" type="number"></input>
					<br>
					<button class="btn btn-default" id="verify">Verify</button>
				</div>

				<h2>Results:</h2>

				<div class="cont">
					<p id="results"></p>
				</div>
			</center>
		</div>
	</div>
	<script type="text/javascript">
		function check(event, ignoreInput) {
			var randomize = document.getElementById('randomize').value;
			var id = document.getElementById('id').value;
			var ssh = document.getElementById('ssh').value;
			var ss = document.getElementById('ss').value;
			var cs = document.getElementById('cs').value;
			var sn = document.getElementById('sn').value;
			sn = parseInt(sn);
			var nb = document.getElementById('nb').value;
			nb = parseInt(nb);
	
			if (!ignoreInput && randomize.length > 0) {
				var pattern = /"(.+?)" "(.+?)" "(.+?)" "(.+?)"/;
				if (pattern.test(randomize)) {
					var result = pattern.exec(randomize);
					document.getElementById('ss').value = result[1];
					document.getElementById('ssh').value = result[2];
					document.getElementById('cs').value = result[3];
					document.getElementById('nb').value = result[4];
					document.getElementById('sn').value = '1';
					document.getElementById('randomize').value = '';
					check(event, true);
					return;
				}
			}
	
			document.getElementById('results').innerHTML = '';
			if (ssh != check.lastssh) { // Let's not repeat 'hash is correct' for the same hash.
				ssh2 = CryptoJS.SHA256(ss);
				if (ssh2 + '' == ssh) {
					println('<span class="label label-success">Server secret hash is correct</span>');
				} else {
					println('<span class="label label-danger">Server hash check failed!</span>');
					println('Purported hash: ' + ssh);
					println('Actual hash: ' + ssh2);
				}
			}
	
			for (j = sn + nb - 1; j >= sn; j--) {
				var gen = ""
				var ss2;
				if (id && id < 145000000) {
					gen = cs + ':' + j;
					ss2 = ss;
				} else {
					gen = j + ':' + cs + ':' + j;
					ss2 = j + ':' + ss + ':' + j;
				};
				hash = CryptoJS.HmacSHA512(gen, ss2).toString(CryptoJS.enc.Hex);
				i = 0;
				roll = -1;
				while (roll == -1) { // Non-reference implementation derived from the 'Fair?' description.
					if (i == 25) {
						l3 = hash.substring(125, 128);
						l3p = l3.parseInt(l3, 16);
						println('last 3: ' + l3 + ' as int: ' + l3p); // kept on because it's cool to get this far
						roll = l3p / 10000;
					} else {
						f5 = hash.substring(5 * i, 5 + 5 * i);
						f5p = parseInt(f5, 16);
						//println(f5 + ' as int: ' + f5p);
						if (f5p < 1000000) {
							roll = f5p / 10000;
						}
						i++;
					}
				}
				println(j + ': ' + roll);
			}
			check.lastssh = ssh;
		}
	
		function println(s) {
			results = document.getElementById('results');
			results.innerHTML = results.innerHTML + s + '<br>';
		}

		document.getElementById('verify').addEventListener('click', check);<commit_msg>All JD bets are generated using the same algorithm now, so betid doesn't matter.<commit_after><!DOCTYPE HTML>
<html>
<head>
	<title>Just-Dice Verifier</title>
	<script src="../js/jquery.js"></script>
	<link rel="stylesheet" href="../css/bootstrap.css">
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/hmac-sha512.js"></script>
	<script src="../js/sha512.js"></script>
	<script src="../js/enc-base64-min.js"></script>
	<script src="../js/sha256.js"></script>
</head>
<body>
	<div class="jumbotron">
		<h1>Verifier</h1>
	</div>
	<div class="container">
		<div class="well">
			<center>
				<h1>Just-Dice Verifier</h1>

				<div class="cont">
					<textarea class="form-control" id="randomize" placeholder="Paste from randomize textbox"></textarea>
					<br>or
					<br>
					<textarea class="form-control" id="ssh" placeholder="Hash of server seed"></textarea>
					<br>
					<textarea class="form-control" id="ss" placeholder="Server seed"></textarea>
					<br>
					<textarea class="form-control" id="cs" placeholder="Client seed"></textarea>
					<br>
					<input class="form-control" id="sn" placeholder="Starting nonce (>=1)" type="number"></input>
					<br>
					<input class="form-control" id="nb" placeholder="Number of Bets (>=1)" type="number"></input>
					<br>
					<button class="btn btn-default" id="verify">Verify</button>
				</div>

				<h2>Results:</h2>

				<div class="cont">
					<p id="results"></p>
				</div>
			</center>
		</div>
	</div>
	<script type="text/javascript">
		function check(event, ignoreInput) {
			var randomize = document.getElementById('randomize').value;
			var ssh = document.getElementById('ssh').value;
			var ss = document.getElementById('ss').value;
			var cs = document.getElementById('cs').value;
			var sn = document.getElementById('sn').value;
			sn = parseInt(sn);
			var nb = document.getElementById('nb').value;
			nb = parseInt(nb);
	
			if (!ignoreInput && randomize.length > 0) {
				var pattern = /"(.+?)" "(.+?)" "(.+?)" "(.+?)"/;
				if (pattern.test(randomize)) {
					var result = pattern.exec(randomize);
					document.getElementById('ss').value = result[1];
					document.getElementById('ssh').value = result[2];
					document.getElementById('cs').value = result[3];
					document.getElementById('nb').value = result[4];
					document.getElementById('sn').value = '1';
					document.getElementById('randomize').value = '';
					check(event, true);
					return;
				}
			}
	
			document.getElementById('results').innerHTML = '';
			if (ssh != check.lastssh) { // Let's not repeat 'hash is correct' for the same hash.
				ssh2 = CryptoJS.SHA256(ss);
				if (ssh2 + '' == ssh) {
					println('<span class="label label-success">Server secret hash is correct</span>');
				} else {
					println('<span class="label label-danger">Server hash check failed!</span>');
					println('Purported hash: ' + ssh);
					println('Actual hash: ' + ssh2);
				}
			}
	
			for (j = sn + nb - 1; j >= sn; j--) {
				hash = CryptoJS.HmacSHA512(cs + ':' + j, ss).toString(CryptoJS.enc.Hex);
				i = 0;
				roll = -1;
				while (roll == -1) { // Non-reference implementation derived from the 'Fair?' description.
					if (i == 25) {
						l3 = hash.substring(125, 128);
						l3p = l3.parseInt(l3, 16);
						println('last 3: ' + l3 + ' as int: ' + l3p); // kept on because it's cool to get this far
						roll = l3p / 10000;
					} else {
						f5 = hash.substring(5 * i, 5 + 5 * i);
						f5p = parseInt(f5, 16);
						//println(f5 + ' as int: ' + f5p);
						if (f5p < 1000000) {
							roll = f5p / 10000;
						}
						i++;
					}
				}
				println(j + ': ' + roll);
			}
			check.lastssh = ssh;
		}
	
		function println(s) {
			results = document.getElementById('results');
			results.innerHTML = results.innerHTML + s + '<br>';
		}

		document.getElementById('verify').addEventListener('click', check);
{'fraction_non_alphanumeric': 0.19408502772643252, 'fraction_numerical': 0.02476894639556377, 'mean_word_length': 3.068170426065163, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 148, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6677568', 'n_tokens_mistral': 3488, 'n_tokens_neox': 2683, 'n_words': 614}