-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathbullet.html
More file actions
124 lines (115 loc) · 3.88 KB
/
bullet.html
File metadata and controls
124 lines (115 loc) · 3.88 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Bullet verify (simple)</title>
<link rel="stylesheet" href="./lib/main.css"/>
<link rel="stylesheet" href="./lib/bootstrap/css/bootstrap.min.css"/>
<script src="./lib/vue.min.js"></script>
<script src="./lib/crypto-js.js"></script>
<script src="./lib/tools.js"></script>
<script src="./lib/utils.js"></script>
<style>
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
.main { max-width: 760px; margin: 24px auto; }
.muted { color: #6c757d; }
</style>
</head>
<body>
<div id="app" class="main">
<h1 class="text-center pb-3">Bullet verify</h1>
<p class="text-center muted">Outputs the random number and the 6-slot sequence.</p>
<hr/>
<!-- Inputs -->
<form class="py-3">
<h2 class="text-center">Input</h2>
<div class="form-group">
<input class="form-control" placeholder="Server Seed"
:value="server_seed" @input="server_seed = $event.target.value"/>
</div>
<div class="form-group">
<input class="form-control" placeholder="Client Seed"
:value="client_seed" @input="client_seed = $event.target.value"/>
</div>
<div class="form-group">
<input class="form-control" placeholder="Nonce"
:value="nonce" @input="nonce = normalizeInt($event.target.value, 0)"/>
</div>
</form>
<hr/>
<!-- Outputs -->
<form class="py-3">
<h2 class="text-center">Output</h2>
<div class="form-group">
<label>Random number (spinChamber [1..6])</label>
<input class="form-control" readonly :value="spinChamberDisplay"/>
</div>
<div class="form-group">
<label>Sequence (6 slots starting from spinChamber)</label>
<input class="form-control" readonly :value="sequenceDisplay"/>
</div>
</form>
<hr/>
<!-- Explanation -->
<section class="py-3">
<h2 class="text-center">Fair Verification Result Explanation</h2>
<div class="mt-2">
<p>
Numbers 1–6 represent the revolver’s chambers. Chamber 1 always has a bullet, while chambers 2 and 3 may also have bullets depending on difficulty.
</p>
<p>
The result only sets the first chamber; shots then follow in order (e.g., if the first is 5, then 6→1→2→3→4). In this example, the third shot will definitely hit.
</p>
</div>
</section>
</div>
<script>
const qs = tools.queryString();
new Vue({
el: '#app',
data: {
server_seed: qs.s || '',
client_seed: qs.c || '',
nonce: Number.isFinite(parseInt(qs.n)) ? parseInt(qs.n) : 0,
},
computed: {
hmacHex() {
if (!this.server_seed || !this.client_seed) return '';
return CryptoJS.HmacSHA256(`${this.client_seed}:${this.nonce}`, this.server_seed).toString();
},
// spinChamber = slideWindowNumber(hmac, 6) + 1 → [1..6]
spinChamber() {
if (!this.hmacHex) return null;
// slideWindowNumber(hash, 6) is expected from ./lib/utils.js
const v = Math.floor(slideWindowNumber(this.hmacHex, 6)) + 1;
return v;
},
spinChamberDisplay() {
return this.spinChamber == null ? '-' : String(this.spinChamber);
},
// e.g. spinChamber=2 → [2,3,4,5,6,1]
sequence() {
if (this.spinChamber == null) return [];
const arr = [];
for (let i = 0; i < 6; i++) {
const x = ((this.spinChamber - 1 + i) % 6) + 1;
arr.push(x);
}
return arr;
},
sequenceDisplay() {
return this.sequence.length ? `[${this.sequence.join(',')}]` : '-';
}
},
methods: {
normalizeInt(v, def) {
const n = parseInt(v, 10);
return Number.isFinite(n) ? n : def;
}
}
});
</script>
</body>
</html>