-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
343 lines (339 loc) · 14.2 KB
/
index.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<!--
Copyright (C) 2013 Volker Grabsch <[email protected]>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Bitcoinproof</title>
<style type="text/css">
body {
font-size: 11pt;
margin-left: auto;
margin-right: auto;
width: 550pt;
color: #000;
font-family: sans-serif;
}
h1 {
font-size: 16pt;
text-align: center;
background-color: #bef;
margin-top: 40pt;
margin-bottom: 0;
padding-top: 0.8em;
padding-bottom: 0.5em;
}
h2 {
font-size: 11pt;
text-align: center;
background-color: #bef;
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0.8em;
}
div, form {
background-color: #feb;
margin-top: 15pt;
margin-bottom: 15pt;
padding: 1em;
}
hr {
border: none;
height: 15pt;
background-color: #bef;
margin-left: 50pt;
margin-right: 50pt;
margin-top: 50pt;
margin-bottom: 15pt;
}
p, ul {
text-align: justify;
font-family: serif;
padding-right: 50pt;
}
p {
padding-left: 50pt;
}
ul {
padding-left: 80pt;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
fieldset {
border: none;
margin-top: 2pt;
margin-bottom: 2pt;
margin-left: 0;
margin-right: 0;
padding: 0;
}
input {
margin: 0;
}
input[type=text] {
width: 40em;
border: 1px solid #aaa;
padding-left: 1pt;
padding-right: 1pt;
}
input[readonly] {
background-color: #eee;
}
label {
float: left;
width: 9em;
}
#timestamp.verifying {
color: #f00;
}
#error, #create, #show {
display: none;
text-align: center;
}
#error {
color: #f00;
font-weight: bold;
}
#create a, #show span {
font-size: 16pt;
font-weight: bold;
}
#show {
background-color: #bfb;
}
footer {
position: absolute;
left: 0;
top: 0;
padding: 5px;
}
.ribbon {
position: absolute;
top: 0;
right: 0;
border: none;
}
</style>
<script type="text/javascript" src="vendor/CryptoJS/sha256.js"></script>
<script type="text/javascript" src="vendor/CryptoJS/ripemd160.js"></script>
<script type="text/javascript" src="src/Bitcoin.js"></script>
<script type="text/javascript">
var dataChanged = function() {
document.getElementById('sha256').value = '';
document.getElementById('sha256').readOnly = true;
cleanupResult();
Bitcoin.fromFile({
file: document.getElementById('data').files[0],
callback: setResult
});
};
var sha256Changed = function() {
document.getElementById('data').value = '';
cleanupResult();
try {
setResult(Bitcoin.fromSha256(document.getElementById('sha256').value));
} catch (e) {
document.getElementById('error').textContent = e.message;
document.getElementById('error').style.display = 'block';
}
};
var cleanupResult = function() {
document.getElementById('error').style.display = 'none';
document.getElementById('create').style.display = 'none';
document.getElementById('show').style.display = 'none';
document.getElementById('address').value = '';
document.getElementById('timestamp').classList.remove('verifying');
document.getElementById('timestamp').value = '';
};
var setResult = function(result) {
document.getElementById('sha256').value = result.sha256;
document.getElementById('sha256').readOnly = false;
document.getElementById('address').value = result.base58;
document.getElementById('payment').href = result.url;
document.getElementById('details').href = 'https://blockchain.info/address/' + result.base58;
document.getElementById('timestamp').classList.add('verifying');
document.getElementById('timestamp').value = 'Verifying ...';
Bitcoin.verifyResult({
result: result,
callback: setVerified
});
};
var setVerified = function(result) {
document.getElementById('timestamp').classList.remove('verifying');
if (result.timestamp === null) {
document.getElementById('timestamp').value = 'Unknown';
document.getElementById('create').style.display = 'block';
} else {
document.getElementById('timestamp').value = result.timestamp.toISOString();
document.getElementById('showTimestamp').textContent = result.timestamp.toString();
document.getElementById('show').style.display = 'block';
}
};
window.addEventListener('load', function() {
document.getElementById('data').addEventListener('change', dataChanged, false);
document.getElementById('sha256').addEventListener('change', sha256Changed, false);
}, false);
</script>
</head>
<body>
<h1>Bitcoinproof</h1>
<h2>Create a forgery-proof timestamp for your data, secured by the bitcoin network.</h2>
<form>
<fieldset>
<label for="data">Data</label><input type="file" id="data">
</fieldset>
<fieldset>
<label for="sha256">SHA-256</label><input type="text" id="sha256">
</fieldset>
<fieldset>
<label for="address">Bitcoin Address</label><input type="text" readonly id="address">
</fieldset>
<fieldset>
<label for="timestamp">Timestamp</label><input type="text" readonly id="timestamp">
</fieldset>
</form>
<div id="error"></div>
<div id="create">
<a href="#" id="payment">Create timestamp</a>
<br>
(via dummy payment)
</div>
<div id="show">
The bitcoin network proves that this data existed at:
<br>
<span id="showTimestamp"></span>
<br>
(<a href="#" id="details" target="_blank">Details</a>)
</div>
<hr>
<p>If you like this tool, feel free to donate to:</p>
<ul>
<li><a href="bitcoin:1HFydXpev8RVxYJ6UANmBdo9wwqivmkv97">1HFydXpev8RVxYJ6UANmBdo9wwqivmkv97</a>
</ul>
<p>Related projects and discussions:</p>
<ul>
<li>
<a href="https://github.com/ligi/SatoshiProof">Satoshi Proof</a>
by <a href="http://ligi.de/">ligi</a>
– Android app with a similar goal
<li>
<a href="http://bitcoin.org/">Bitcoin</a>
– An open source P2P digital currency
<li>
<a href="https://news.ycombinator.com/item?id=5796935">Discussion on Hacker News</a>
about using BitCoin as a public ledger
</ul>
<p>
Sometimes you want to prove
that a certain event happened <em>before</em> a certain point in time.
Maybe you want to prove
that the damage in your flat already existed when you settled in.
Or that you were in possession of this great artwork before it was published,
proving you are the author.
</p>
<p>
Of course,
on your computer all documents and photos have timestamps,
but those are easy to forge.
To get a proof that can stand up in court,
you need something better.
</p>
<p>
So what can you do?
Traditionally, you would consult a trusted authority such as a
<a href="https://en.wikipedia.org/wiki/Notary">notary</a>.
However, that's quite costly and takes a lot of time.
You could also use a digital
<a href="https://en.wikipedia.org/wiki/Trusted_timestamping">trusted timestamping</a>
service,
which is fast but still very costly
due to the special hardware and expensive audits
that such a company needs in order to stay trustworthy.
Or you could simply use the
<a href="https://en.wikipedia.org/wiki/Bitcoin">bitcoin network</a>,
which is cheap and doesn't require you to trust anyone.
There's just one issue:
The bitcoin network is designed to protect payment transactions,
not arbitrary data.
</p>
<p>
So how do you get the bitcoin network to timestamp your data?
You need to put a
<a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function">crypto hash</a>
of your data
somewhere into a valid payment transaction.
It would be easy if there was a <em>purpose</em> field,
but bitcoin transactions
have just <em>addresses</em> (account numbers) and <em>values</em>.
Encoding your crypto hash into those two fields
is a tricky task,
so people are tempted to make it
<a href="https://github.com/fireduck64/BitcoinTimestamp">more complicated</a>
than it has to be,
or <a href="https://github.com/goblin/chronobit">outright cumbersome</a>.
Luckily,
there is a
<a href="https://bitcointalk.org/index.php?topic=24605.msg306510#msg306510">simple solution</a>
that needs only one transaction to one address.
</p>
<p>
The solution is easily understood if you know
that a bitcoin <em>account</em> is a
<a href="https://en.wikipedia.org/wiki/Public-key_cryptography">public/private key pair</a>,
but its <em>address</em> (account number)
is just a crypto hash of the public key, not the public key itself.
And this crypto hash can be computed for any data, not just public keys.
In other words, you can safely make a bitcoin address from any data,
although it won't correspond to any real bitcoin account.
So be careful not to throw much money at such an address,
because you
<a href="https://bitcointalk.org/index.php?topic=8728.msg203511#msg203511">won't ever get it back</a>.
Ideally, you would send 0 BTC to that address,
which is a
<a href="https://en.bitcoin.it/wiki/Transactions#general_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout">valid transaction</a>,
but most likely unsupported by your bitcoin client.
Sending a tiny 0.00000001 BTC does the trick as well,
and is still negligible
compared to the additional transaction costs of currently 0.0005 BTC.
</p>
<p>
This sounds all well and good,
but of course it raises two moral questions:
First, isn't this a misuse of the bitcoin network?
Indeed this is a somewhat creative use of the network,
but it won't do any harm.
You are still paying the transaction fee
which goes directly to the
<a href="https://en.wikipedia.org/wiki/Bitcoin#Bitcoin_mining">people who secure the timestamps</a>.
Second, don't we damage the bitcoin currency if we destroy money?
Well, 100 million of these tiny transactions
will cause the same damage to the currency as
one unlucky guy owning 1 BTC and losing his wallet.
But if you are really worried,
you can use a specialized bitcoin client
that allows you to send exact 0 BTC.
</p>
<footer>
<a href="https://njh.eu/">← Not Just Hacking</a>
</footer>
<a href="https://github.com/vog/bitcoinproof" target="_blank">
<img class="ribbon" src="vendor/GitHub/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub">
</a>
</body>
</html>