-
Notifications
You must be signed in to change notification settings - Fork 0
/
verfity.html
executable file
·260 lines (246 loc) · 7.26 KB
/
verfity.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.3.2/sha256.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-sha512/0.2.2/sha512.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.19.1/URI.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/default.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<title>Document</title>
</head>
<script>
hljs.initHighlightingOnLoad();
</script>
<style>
body {background-color: #303E56;color: #fff;}
.container {
position: relative;padding-left: 10px;
}
.verfit-wrap {
width: 49%;padding-left: 50%;
}
hr {margin: 20px 0;}
.container .form-control {width: 96%;}
.code-wrap {
position: absolute;width: 48%;top: 70px;left: 10px;
background-color: #1a1a21;color: white;font-weight: 800;
}
pre {
margin: 0;
}
.hljs{
height: 280px;background-color: #323237;color: #a7925a;
}
.hljs-string {
color: #96b38a;
}
.hljs-number {
color: #809bbd;
}
.code-title{
font-size: 24px;padding: 5px;margin-bottom: -15px;
}
.hljs-title, .hljs-section {
color: #d0782a;
}
.form-group {
margin-bottom: 15px;
}
label {
display: inline-block;
max-width: 100%;
margin-bottom: 5px;
font-weight: 700;
}
.bcg-logo {
text-align: center;margin-top: 50px;
}
.bcg-img {
width: 100px;
}
.bcglink {
display: block;text-align: center;color: #fff;
font-size: 16px;font-weight: 800;
}
.form-control {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
@media (max-width: 440px) {
body{margin: 0}
h1 {
font-size: 22px;
}
.bcg-logo {
display: none;
}
.container {padding: 0 10px;}
.code-wrap {
position: static;width: auto;
}
.verfit-wrap {
width: auto;padding:0;
}
.container .form-control {
width: 92%;
}
}
</style>
<body>
<div class="container">
<h1>NanoGames Roll - Bet Verifier</h1>
<form class="verfit-wrap">
<div class="form-group">
<label for="serverSeed">Server Seed</label>
<input id="serverSeed" type="text" class="form-control">
</div>
<div class="form-group">
<label for="clientSeed">Client Seed</label>
<input id="clientSeed" type="text" class="form-control">
</div>
<div class="form-group">
<label for="nonce">Nonce</label>
<input id="nonce" type="text" class="form-control">
</div>
<hr>
<div class="form-group">
<label for="serverSeedHash">Server Seed (Hashed)</label>
<input id="serverSeedHash" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label for="roll">Roll</label>
<input id="roll" type="text" class="form-control" disabled>
</div>
</form>
<div class="code-wrap">
<div class="code-title">HTML</div>
<pre>
<code class="html">
<div class="container">
<h1>Bet Verifier</h1>
<form>
<div class="form-group">
<label for="serverSeed">Server Seed</label>
<input id="serverSeed" type="text" class="form-control">
</div>
<div class="form-group">
<label for="clientSeed">Client Seed</label>
<input id="clientSeed" type="text" class="form-control">
</div>
<div class="form-group">
<label for="nonce">Nonce</label>
<input id="nonce" type="text" class="form-control">
</div>
<hr>
<div class="form-group">
<label for="serverSeedHash">Server Seed (Hashed)</label>
<input id="serverSeedHash" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label for="roll">Roll</label>
<input id="roll" type="text" class="form-control" disabled>
</div>
</form>
</div>
</code>
</pre>
<div class="code-title" style="border-top: 1px solid gray;">JavaScript</div>
<pre class="javascript">
<code>
function getRoll(serverSeed, clientSeed, nonce) {
var hash = sha512(serverSeed + clientSeed + nonce);
var index = 0;
do {
var lucky = parseInt(hash.substr(index, 5), 16);
index += 5;
} while (lucky >= 1000000);
return lucky % 100000;
}
var $serverSeed = $('#serverSeed');
var $clientSeed = $('#clientSeed');
var $nonce = $('#nonce');
var $serverSeedHash = $('#serverSeedHash');
var $roll = $('#roll');
var query = URI(document.location.search).search(true)
$serverSeed.val(query.serverSeed);
$clientSeed.val(query.clientSeed);
$nonce.val(query.nonce);
$('form').keyup(function() {
var serverSeed = $serverSeed.val();
var clientSeed = $clientSeed.val();
var nonce = $nonce.val();
$serverSeedHash.val(serverSeed ? sha256(serverSeed) : '<Empty Server Seed>');
if (!serverSeed) {
$roll.val('<Empty Server Seed>');
} else if (!clientSeed) {
$roll.val('<Empty Client Seed>');
} else if (nonce === '') {
$roll.val('<Empty Nonce>');
} else {
$roll.val(getRoll(serverSeed, clientSeed, nonce));
}
}).keyup();
</code>
</pre>
</div>
</div>
</body>
<script>
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
function getRoll(serverSeed, clientSeed, nonce) {
var hash = sha512(serverSeed + clientSeed + nonce);
var index = 0;
do {
var lucky = parseInt(hash.substr(index, 5), 16);
index += 5;
} while (lucky >= 1000000);
return lucky % 100000;
}
var $serverSeed = $('#serverSeed');
var $clientSeed = $('#clientSeed');
var $nonce = $('#nonce');
var $serverSeedHash = $('#serverSeedHash');
var $roll = $('#roll');
var query = URI(document.location.search).search(true)
$serverSeed.val(query.serverSeed);
$clientSeed.val(query.clientSeed);
$nonce.val(query.nonce);
$('form').keyup(function() {
var serverSeed = $serverSeed.val();
var clientSeed = $clientSeed.val();
var nonce = $nonce.val();
$serverSeedHash.val(serverSeed ? sha256(serverSeed) : '<Empty Server Seed>');
if (!serverSeed) {
$roll.val('<Empty Server Seed>');
} else if (!clientSeed) {
$roll.val('<Empty Client Seed>');
} else if (nonce === '') {
$roll.val('<Empty Nonce>');
} else {
$roll.val(getRoll(serverSeed, clientSeed, nonce));
}
}).keyup();
</script>
</html>