forked from mohrt/secretcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
281 lines (263 loc) · 12.9 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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Store your secrets securely.</title>
<meta name="Store your Secrets Securely." content="">
<meta name="mohrt" content="">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<link rel="stylesheet" href="css/skeleton-tabs.css">
<link rel="stylesheet" href="css/custom.css">
<!-- SCRIPTS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<script src="js/bitcore-lib.min.js"></script>
<script src="js/bitcore-mnemonic.min.js"></script>
<script src="js/jquery-3.2.1.slim.min.js"></script>
<script src="js/FileSaver.js"></script>
<script src="js/skeleton-tabs.js"></script>
<script src="js/vue.min.js"></script>
<script src="js/secrets.js"></script>
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div class="container" id="app">
<section class="header">
<h2>Store your secrets securely.</h2>
<img class="value-img" src="images/keys.svg">
</section>
<ul class="tab-nav">
<li>
<a class="button active" href="#about">About</a>
</li>
<li>
<a class="button" href="#generate">Generate</a>
</li>
<li>
<a class="button" href="#restore">Restore</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="about">
<div class="docs-section" id="intro">
<p>Storing sensitive data can be problematic. A 24 word BIP39 mnemonic for instance, is the "keys to the kingdom". If stolen, your addresses are compromised. If you make multiple copies, this increases the risk of being stolen or misplaced. If encrypted, you face the same problem storing the encryption key. Is there a safer way?
</p>
<p>
Secret Coin uses <a href="https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing">Shamir's Secret Sharing</a> algorithm to divide your secret into multiple (N) shares, and then you can restore the secret using a specified number of the shares (M of N). None of the shares contain identifiable information about the secret. If any share, or up to (M-1) shares are compromised, the secret is still safe.
</p>
<p>
All operations happen in your browser. You can disconnect from the network and use this web page. The source for this website is available on <a href="https://github.com/mohrt/secretcoin">GitHub</a>. <span class="red">It is highly recommended to download the source .zip and launch it on an off-line computer.</span> Instructions can be found at the <a href="https://github.com/mohrt/secretcoin">GitHub Repository</a>.
</p>
</div>
</div>
<div class="tab-pane" id="generate">
<div class="docs-section" id="form-generate">
<form @submit.prevent>
<div class="row">
<div class="twelve columns">
<label for="secretInput">Generate <a href="" @click.prevent="generateMnemonic(32 * 4)">12</a> or <a href="" @click.prevent="generateMnemonic(32 * 8)">24</a> word bip39 phrase</label>
<textarea class="u-full-width" type="text" placeholder="Enter a mnemonic phrase, private key, or any text you want kept secret." id="secretInput" v-model="secret" @keyup="validateMnemonic(secret)"></textarea> </div>
</div>
<div class="row">
<div class="twelve columns">
<i class="red" v-show="!mnemonicIsValid">Warning: invalid BIP39 phrase</i>
</div>
</div>
<div class="row">
<div class="four columns">
<label for="secretShares"># of shares</label>
<select class="u-full-width" id="secretShares" v-model.number="sharesTotal" type="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div class="four columns">
<label for="secretSharesRequired"># required shares to restore</label>
<select class="u-full-width" id="secretSharesRequired" v-model.number="sharesRequired" type="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div class="four columns">
<label for="downloadFilenamePrefix"># filename prefix</label>
<input class="u-full-width" type="text" placeholder="" id="downloadFilenamePrefix" v-model="downloadFilenamePrefix">
</div>
</div>
<div class="row">
<div class="two columns">
<input class="button-primary" type="submit" value="Generate" @click="generate">
</div>
</div>
<template v-for="(share,index) in shares">
<div class="row">
<div class="six columns">
<input class="u-full-width" type="text" v-model="shares[index]" :id="['share-' + index]" @focus="$event.target.select()">
</div>
<div class="two columns">
<input class="button" type="submit" value="download" @click="download(index)">
</div>
<div class="four columns centered">
<i>{{ downloadFilenamePrefix }}-{{ index }}.txt</i>
</div>
</div>
</template>
<div class="row" v-show="shares.length > 0">
<div class="four columns">
<input class="button" type="submit" value="Download All Single File" @click="downloadall">
</div>
<div class="eight columns center">
<i>{{ downloadFilenamePrefix }}-all-shares.txt</i>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane" id="restore">
<div class="docs-section" id="form-restore">
<form @submit.prevent>
<div class="row">
<div class="twelve columns">
<div class="docs-section" id="restore">
<p>Multi-select share files to restore your secret. Be sure to provide at least number of shares required.</p>
</div>
</div>
</div>
<div class="row">
<div class="six columns">
<input type="file" id="files" name="files[]" multiple @change="upload" />
</div>
<div class="six columns">
<input class="button-primary" type="submit" value="Restore" @click="restore">
</div>
</div>
<div class="row">
<div class="twelve columns">
<label for="secretRestored">Secret</label>
<textarea class="u-full-width" type="text" placeholder="" id="secretRestored" v-model="secretRestored" @focus="$event.target.select()"></textarea>
</div>
</div>
<div class="row" v-show="isErrorRestoring">
<div class="twelve columns">
<i class="red">There was an error restoring the secret. Check that your uploaded files are valid shares.</i>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var Mnemonic = require('bitcore-mnemonic')
var app = new Vue({
el: '#app',
data: {
secret: '',
secretRestored: '',
sharesTotal: 3,
sharesRequired: 2,
shares: [],
sharesRestore: [],
downloadFilenamePrefix: 'securecoin',
isErrorRestoring: false,
mnemonicIsValid: true
},
methods: {
generate: function() {
this.shares = secrets.share(secrets.str2hex(this.secret), this.sharesTotal, this.sharesRequired)
},
generateMnemonic: function (size) {
var code = new Mnemonic(size, Mnemonic.Words.ENGLISH)
this.secret = code.toString()
},
validateMnemonic: function (secret) {
try {
this.mnemonicIsValid = secret.length == 0 || Mnemonic.isValid(secret)
} catch (e) {
// do not throw error
}
},
restore: function() {
this.isErrorRestoring = false;
try {
this.secretRestored = secrets.hex2str(secrets.combine( this.sharesRestore ));
} catch (e) {
console.log('error!', e);
this.isErrorRestoring = true;
}
},
download: function (idx) {
var prefix = this.downloadFilenamePrefix.length > 0 ? this.downloadFilenamePrefix : 'securecoin';
saveTextAs(this.shares[idx], prefix + '-' + idx + '.txt' );
},
downloadall: function() {
var prefix = this.downloadFilenamePrefix.length > 0 ? this.downloadFilenamePrefix : 'securecoin';
saveTextAs(this.shares.join('\n'), prefix + '-all-shares.txt' );
},
upload: function(e) {
this.sharesRestore = [];
var files = e.target.files || e.dataTransfer.files;
if (!files.length)
return;
for (var i = 0, f; f = files[i]; i++) {
var fr = new FileReader();
var myshares = this.sharesRestore;
fr.onload = function(e) {
myshares.push(e.target.result);
};
fr.readAsText(files[i]);
}
}
},
watch: {
downloadFilenamePrefix: function (val) {
this.downloadFilenamePrefix = this.downloadFilenamePrefix.replace(/[^\w\-\.]/g,'')
}
}
})
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-105305471-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Document
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
</body>
</html>