-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
208 lines (172 loc) · 9.29 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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Carbon Wallet Recovery</title>
</head>
<body>
<div class="container pt-3">
<div class="card mt-5 mb-5">
<div class="card-header">
Single Signature Wallets
</div>
<div class="card-body">
<form>
<div class="form-group">
<label for="browser-created-bip38">BIP38 Encrypted Key - Starts with a 6.</label>
<input type="text" class="form-control" id="browser-created-bip38" aria-describedby="emailHelp" placeholder="Enter BIP38 Key">
<small id="emailHelp" class="form-text text-muted">All processing is done client side.</small>
</div>
<div class="form-group">
<label for="passphrase">Password</label>
<input type="password" class="form-control" id="passphrase" placeholder="Password">
</div>
<div class="form-group">
<label for="passphrase">Number of Addresses</label>
<input type="number" class="form-control" id="count" value="1">
</div>
<button id="decrypt" type="submit" class="btn btn-primary">Decrypt</button>
</form>
<div id="results" class="d-none mt-5">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" href="#bitcoin" role="tab" data-toggle="tab">Bitcoin</a>
</li>
<li class="nav-item">
<a class="nav-link " href="#zcash" role="tab" data-toggle="tab">ZCash / ZClassic</a>
</li>
<li class="nav-item">
<a class="nav-link " href="#private" role="tab" data-toggle="tab">Bitcoin Private</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#ethereum" role="tab" data-toggle="tab">Ethereum</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#dash" role="tab" data-toggle="tab">Dash</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#litecoin" role="tab" data-toggle="tab">Litecoin</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="bitcoin">
<table id="bitcoin-table" class="mt-2 table table-sm table-striped table-responsive">
<tr><th>Bitcoin Address</th><th>Private Key</th></tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="zcash">
<table id="zcash-table" class="mt-2 table table-sm table-striped table-responsive">
<tr><th>Address</th><th>Private Key</th></tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="private">
<table id="private-table" class="mt-2 table table-sm table-striped table-responsive">
<tr><th>Bitcoin Private Address</th><th>Private Key</th></tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="ethereum">
<table id="ethereum-table" class="mt-2 table table-sm table-striped table-responsive">
<tr><th>Ethereum Address</th><th>Private Key</th></tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="dash">
<table id="dash-table" class="mt-2 table table-sm table-striped table-responsive">
<tr><th>Dash Address</th><th>Private Key</th></tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="litecoin">
<table id="litecoin-table" class="mt-2 table table-sm table-striped table-responsive">
<tr><th>Dash Address</th><th>Private Key</th></tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="bitcoinjs-lib.js?we-added-bitcoin-private"></script>
<script src="ethereumjs-util.js"></script>
<script type="text/javascript">
"use strict";
/* global $, bitcoin, ethUtil */
$(function() {
// Use fule whne I'm testing so I don't accidentily check my private
// key into a public git repository.
var key = getHashValue('key');
var password = getHashValue('password');
if(key != null) {
$('#browser-created-bip38').val(key);
}
if(password != null) {
$('#passphrase').val(password);
}
$('#decrypt').click(function() {
$('#decrypt').attr("disabled", "disabled");
$("#address-table").find("tr:gt(0)").remove();
decryptBip38Key($('#browser-created-bip38').val(),
$('#passphrase').val());
return false;
});
function decryptBip38Key(bip38, passphrase) {
// First we decrypt the bip38 key.
var worker = new Worker('bip38.js');
worker.addEventListener('message', function(e) {
var data = e.data;
if (data.status == 'done') {
$('#decrypt').removeAttr("disabled");
$('#decrypt').text('Decrypt');
const wif = data.result;
console.log(wif);
const count = parseInt($('#count').val(), 10);
var keyPair = bitcoin.ECPair.fromWIF(wif);
const hd_bitcoin = bitcoin.HDNode.fromSeedHex(keyPair.getPrivateKeyHex(), bitcoin.networks.bitcoin);
const hd_zcash = bitcoin.HDNode.fromSeedHex(keyPair.getPrivateKeyHex(), bitcoin.networks.zcash);
const hd_private = bitcoin.HDNode.fromSeedHex(keyPair.getPrivateKeyHex(), bitcoin.networks.bitcoin_private);
const hd_dash = bitcoin.HDNode.fromSeedHex(keyPair.getPrivateKeyHex(), bitcoin.networks.dash);
const hd_lite = bitcoin.HDNode.fromSeedHex(keyPair.getPrivateKeyHex(), bitcoin.networks.litecoin);
for(var i = 0; i < count; i++) {
var key = hd_bitcoin.derive(1).derive(i).keyPair;
$('#bitcoin-table').append('<tr><td>' + key.getAddress()
+ '</td><td>' + key.toWIF() + '</td></tr>');
key = hd_zcash.derive(1).derive(i).keyPair;
$('#zcash-table').append('<tr><td>' + key.getAddress()
+ '</td><td>' + key.toWIF() + '</td></tr>');
key = hd_private.derive(1).derive(i).keyPair;
$('#private-table').append('<tr><td>' + key.getAddress()
+ '</td><td>' + key.toWIF() + '</td></tr>');
var addressBuffer = ethUtil.privateToAddress('0x' + key.getPrivateKeyHex());
var hexAddress = ethUtil.toChecksumAddress(addressBuffer.toString('hex'));
$('#ethereum-table').append('<tr><td>' + hexAddress
+ '</td><td>' + key.toWIF() + '</td></tr>');
key = hd_dash.derive(1).derive(i).keyPair;
$('#dash-table').append('<tr><td>' + key.getAddress()
+ '</td><td>' + key.toWIF() + '</td></tr>');
key = hd_lite.derive(1).derive(i).keyPair;
$('#litecoin-table').append('<tr><td>' + key.getAddress()
+ '</td><td>' + key.toWIF() + '</td></tr>');
$('#results').removeClass('d-none');
}
}
if (data.status == 'working') {
$('#decrypt').text('Decrypting ' + (parseInt(data.percent) + 1) + "%")
}
}, false);
worker.postMessage({ cmd: 'decrypt', cipher: bip38, password: passphrase });
}
function getHashValue(key) {
var matches = window.location.hash.match(new RegExp(key+'=([^&]*)'));
return matches ? matches[1] : null;
}
});
</script>
</body>
</html>