This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
crash.html
239 lines (231 loc) · 8.37 KB
/
crash.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html>
<head>
<title>Crash - Game Verification Script</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script>
<style>
*, body, button, input, textarea, select {
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
margin:0;
padding:0;
}
table {
border-collapse:collapse;
border-spacing:0;
}
fieldset,img {
border:0;
}
address,caption,cite,code,dfn,em,strong,th,var {
font-style:normal;
font-weight:normal;
}
ol,ul {
list-style:none;
}
caption,th {
text-align:left;
}
h1,h2,h3,h4,h5,h6 {
font-size:100%;
font-weight:normal;
}
q:before,q:after {
content:'';
}
abbr,acronym { border:0;}
</style>
<style type="text/css">
table {
table-layout: fixed;
}
table thead tr th:first-child {
width: 80%;
}
table tbody tr td {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.is-first {
background-color: rgba(195, 111, 24, 0.2);
}
.is-over-median {
color: #44B39D;
}
.is-at-median {
color: #3B3C3D;
}
.is-under-median {
color: #BF4A67;
}
</style>
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title">Crash - Game Verification Script</h1>
<h2 class="subtitle">Third party script used to verify games on crash game.</h2>
</div>
<hr>
<div class="container">
<p>The following sites have purchased a non-distributable copy of the previous version of bc.game’s source code, exempting them from the requirements of the AGPL:</p>
<p><a target="_blank" href="https://bc.game">https://bc.game</a></p>
</div>
<hr>
<div class="container">
<p>We made the decision to update Crash using a salted hash as requested by our players in order to provide the most randomized and fair results possible after Bet <span class="has-text-info"># 2561902</span>. For further details, please visit <a target="_blank" href="https://bitcointalk.org/index.php?topic=5256606">https://bitcointalk.org/index.php?topic=5256606</a></p>
</div>
<hr>
<div class="container">
<div class="field">
<label class="label">Game's hash</label>
<p class="control has-icons-left">
<input class="input" type="text" id="game_hash_input" placeholder="Game's hash (SHA256)">
<span class="icon is-small is-left"><i class="fa fa-key"></i></span>
</p>
</div>
<div class="field">
<label class="label">Salt</label>
<p class="control has-icons-left">
<input class="input" type="text" id="game_salt_input" placeholder="Salt" value="0000000000000000000e3a66df611d6935b30632f352e4934c21059696117f28">
<span class="icon is-small is-left"><i class="fa fa-filter"></i></span>
</p>
</div>
<div class="field">
<label class="label">Amount of games</label>
<p class="control has-icons-left">
<input class="input" type="number" id="game_amount_input" min="1" max="100000" step="1" placeholder="Amount of games" value="10">
<span class="icon is-small is-left"><i class="fa fa-hashtag"></i></span>
</p>
</div>
<div class="field is-grouped">
<p class="control">
<a class="button is-primary" id="game_verify_submit">Verify</a>
</p>
</div>
</div>
<hr>
<div class="container">
<table class="table is-striped is-fullwidth is-hoverable is-narrow" style="display:table">
<thead>
<tr>
<th><b>Game's hash</b></th>
<th><b>Bust</b></th>
</tr>
</thead>
<tbody id="game_verify_table"></tbody>
</table>
</div>
</section>
<script type="text/javascript">
var isVerifying = false;
$('#game_verify_submit').on('click', () => {
if (isVerifying) return;
isVerifying = true;
$('#game_hash_input').parent().addClass('is-loading');
$('#game_verify_submit').addClass('is-loading');
$('#game_hash_input, #game_amount_input, #game_verify_submit').attr('disabled', 'disabled');
$('#game_verify_table').html('');
let prevHash = null;
for (let i = 0; i < $('#game_amount_input').val(); i++) {
let hash = String(prevHash ? CryptoJS.SHA256(String(prevHash)) : $('#game_hash_input').val());
let bust = gameResult(hash, $('#game_salt_input').val());
setTimeout(function() {
addTableRow(hash, bust, i)
}, i * 1);
prevHash = hash;
}
});
$('#game_amount_input').on('keyup', () => {
if ($('#game_amount_input').val() >= 10000) {
if ($('#game_verify_warning').length) return;
$('#game_verify_submit').parent().append(
$('<span/>').attr({
'id': 'game_verify_warning',
'class': 'tag is-warning'
}).text("Verifying a huge amount of games may consume more ressources from your CPU")
);
} else {
if ($('#game_verify_warning').length) {
$('#game_verify_warning').remove();
}
}
});
const addTableRow = (hash, bust, index) => {
$('<tr/>').attr({
'class': index === 0 ? 'is-first' : null
}).append(
$('<td/>').text(hash)
).append(
$('<td/>').text(bust).attr({
'class': bust === 1.98 ? 'is-at-median' : bust > 1.98 ? 'is-over-median' : 'is-under-median'
})
).appendToWithIndex($('#game_verify_table'), index);
if (index >= $('#game_amount_input').val() - 1) {
$('#game_hash_input').parent().removeClass('is-loading');
$('#game_verify_submit').removeClass('is-loading');
$('#game_hash_input, #game_amount_input, #game_verify_submit').removeAttr("disabled");
isVerifying = false;
}
};
const gameResult = (seed, salt) => {
const nBits = 52; // number of most significant bits to use
// 1. HMAC_SHA256(message=seed, key=salt)
if (salt) {
const hmac = CryptoJS.HmacSHA256(CryptoJS.enc.Hex.parse(seed), salt);
seed = hmac.toString(CryptoJS.enc.Hex);
}
// 2. r = 52 most significant bits
seed = seed.slice(0, nBits / 4);
const r = parseInt(seed, 16);
// 3. X = r / 2^52
let X = r / Math.pow(2, nBits); // uniformly distributed in [0; 1)
X = parseFloat(X.toPrecision(9));
// 4. X = 99 / (1-X)
X = 99 / (1 - X);
// 5. return max(trunc(X), 100)
const result = Math.floor(X);
return Math.max(1, result / 100);
};
$.fn.appendToWithIndex = function(to, index) {
if (!to instanceof jQuery) {
to = $(to);
};
if (index === 0) {
$(this).prependTo(to)
} else {
$(this).insertAfter(to.children().eq(index - 1));
}
};
var hash_url = window.location.search
if ((/nosalt/).test(hash_url)) {
$('#game_salt_input').val('');
}
if ((/hash=/).test(hash_url)) {
var hash = hash_url.match(/hash=[0-9a-zA-z]+/)[0].replace(/hash=/, '');
$('#game_hash_input').val(hash)
$('#game_verify_submit').click()
}
</script>
<script>
// tell the embed parent frame the height of the content
if (window.parent && window.parent.parent) {
window.parent.parent.postMessage(["resultsFrame", {
height: document.body.getBoundingClientRect().height,
slug: "nwu2ffkv"
}], "*")
}
</script>
</body>
</html>