├── .editorconfig
├── .gitignore
├── Gruntfile.js
├── LICENSE
├── README.md
├── app.css
├── app.html
├── app.js
├── bitcoin-networks.js
├── browserify.cmd
├── browserify.js
├── favicon.ico
├── images
└── fork-me-on-github-ribbon.png
├── index.html
├── libs
├── css
│ ├── bootstrap-horizon.css
│ ├── bootstrap-theme.min.css
│ ├── bootstrap.min.css
│ ├── ie10-viewport-bug-workaround.css
│ └── ladda-themeless.min.css
├── fonts
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
├── js
│ ├── angular-route.js
│ ├── angular.min.js
│ ├── bitcoin.js
│ ├── bootstrap.min.js
│ ├── d3.v3.min.js
│ ├── ie10-viewport-bug-workaround.js
│ ├── jquery.min.js
│ ├── ladda.min.js
│ ├── lodash.js
│ ├── moment.min.js
│ ├── qrcode.min.js
│ ├── sha256.js
│ └── spin.min.js
└── templates.js
├── package.json
├── pages
├── aezeed
│ ├── aezeed.html
│ └── aezeed.js
├── bitcoin-block
│ ├── bitcoin-block.html
│ └── bitcoin-block.js
├── ecc
│ ├── ecc.html
│ └── ecc.js
├── encoding-decoding
│ ├── encoding-decoding.html
│ └── encoding-decoding.js
├── hd-wallet
│ ├── hd-wallet.html
│ └── hd-wallet.js
├── intro
│ ├── intro.html
│ └── intro.js
├── macaroon
│ ├── id-protobuf.js
│ ├── id.proto
│ ├── macaroon.html
│ └── macaroon.js
├── mu-sig
│ ├── mu-sig.html
│ └── mu-sig.js
├── schnorr
│ ├── schnorr.html
│ └── schnorr.js
├── shamir-secret-sharing
│ ├── shamir-secret-sharing.html
│ └── shamir-secret-sharing.js
├── transaction-creator
│ ├── transaction-creator.html
│ └── transaction-creator.js
└── wallet-import
│ ├── wallet-import.html
│ └── wallet-import.js
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 |
3 | root = true
4 |
5 | [*]
6 | charset = utf-8
7 | indent_style = space
8 | indent_size = 2
9 | end_of_line = lf
10 | insert_final_newline = true
11 | trim_trailing_whitespace = true
12 | max_line_length = 140
13 |
14 | [*.{diff,md}]
15 | insert_final_newline = false
16 | trim_trailing_whitespace = false
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | node_modules
3 | yarn-error.log
4 | release
5 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | grunt.initConfig({
3 | ngtemplates: {
4 | app: {
5 | src: '**/*.html',
6 | dest: 'libs/templates.js'
7 | }
8 | }
9 | });
10 |
11 | grunt.loadNpmTasks('grunt-angular-templates');
12 | };
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Oliver Gugger
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cryptography Toolkit
2 |
3 | A web-based collection of cryptography tools for schemes/algorithms used in
4 | [Bitcoin](https://github.com/bitcoin/bitcoin) and [LND](https://github.com/lightningnetwork/lnd).
5 |
6 | **This toolkit has been built with educational purposes in mind!**
7 | It is meant to play around with different schemes and algorithms to understand how they work.
8 | However, you must be **extremely careful** when using real/live/mainnet data/keys/credentials!
9 | A web browser usually is not a safe environment to either create strong cryptographic keys and/or
10 | paste sensitive information into. So consider yourself warned.
11 |
12 | [Live version](https://guggero.github.io/cryptography-toolkit/)
13 |
14 | ## Tools
15 | * [Elliptic Curve Cryptography / Key Pair page](https://guggero.github.io/cryptography-toolkit/#!/ecc)
16 | * [Hierarchical Deterministic Wallet page](https://guggero.github.io/cryptography-toolkit/#!/hd-wallet)
17 | * [Bitcoin Block Parser page](https://guggero.github.io/cryptography-toolkit/#!/bitcoin-block)
18 | * [Shamir's Secret Sharing Scheme page](https://guggero.github.io/cryptography-toolkit/#!/shamir-secret-sharing)
19 | * [BIP Schnorr Signatures page](https://guggero.github.io/cryptography-toolkit/#!/schnorr)
20 | * [MuSig: Key Aggregation for Schnorr Signatures page](https://guggero.github.io/cryptography-toolkit/#!/mu-sig)
21 | * [Transaction Creator page](https://guggero.github.io/cryptography-toolkit/#!/transaction-creator)
22 | * [aezeed Cipher Seed Scheme page](https://guggero.github.io/cryptography-toolkit/#!/aezeed)
23 | * [Macaroons page](https://guggero.github.io/cryptography-toolkit/#!/macaroon)
24 | * [Wallet Import helper page](https://guggero.github.io/cryptography-toolkit/#!/wallet-import)
25 |
26 | ## Send Thanks
27 |
28 | Created by [Oliver Gugger](https://github.com/guggero):
29 | * BTC tip address: `bc1qfgua5vhwm6myajak9p4crhwmwm2k6mczf789eh`
30 |
--------------------------------------------------------------------------------
/app.css:
--------------------------------------------------------------------------------
1 | html {
2 | position: relative;
3 | min-height: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | font-family: 'Raleway', sans-serif;
9 | font-size: 16px;
10 | font-weight: 400;
11 | color: #888;
12 | line-height: 18px;
13 | }
14 |
15 | body app > .container {
16 | padding: 60px 15px 0;
17 | }
18 |
19 | .container .text-muted {
20 | margin: 20px 0;
21 | }
22 |
23 | body app > .container-fluid {
24 | padding: 60px 15px 0;
25 | }
26 |
27 | .container-fluid .text-muted {
28 | margin: 20px 0;
29 | }
30 |
31 | input, textarea, pre, .form-control {
32 | font-family: monospace;
33 | font-size: 13px;
34 | }
35 |
36 | block .well-sm {
37 | font-size: 14px;
38 | font-weight: 300;
39 | }
40 |
41 | .panel .panel-body, intro-page {
42 | line-height: 24px;
43 | }
44 |
45 | .well-success {
46 | transition: background 0.6s;
47 | background: rgba(147, 255, 75, 0.27);
48 | }
49 |
50 | .well-error {
51 | transition: background 0.6s;
52 | background: rgba(238, 4, 30, 0.21);
53 | }
54 |
55 | .github-ribbon {
56 | position: absolute;
57 | top: 0;
58 | left: 0;
59 | border: 0;
60 | z-index: 20000;
61 | }
62 |
63 | .navbar-text {
64 | margin-top: 10px;
65 | margin-bottom: 8px;
66 | }
67 |
68 | h1 chain-info, h3 peer-info {
69 | font-size: 14px;
70 | font-family: monospace;
71 | padding-left: 5px;
72 | }
73 |
74 | strong {
75 | font-weight: 700;
76 | }
77 |
78 | a, a:hover, a:focus {
79 | color: #89cc2d;
80 | text-decoration: none;
81 | -o-transition: all .6s;
82 | -moz-transition: all .6s;
83 | -webkit-transition: all .6s;
84 | -ms-transition: all .6s;
85 | transition: all .6s;
86 | cursor: pointer;
87 | }
88 |
89 | h1, h2 {
90 | margin-top: 10px;
91 | font-size: 36px;
92 | font-weight: 700;
93 | color: #5a4d45;
94 | line-height: 44px;
95 | }
96 |
97 | h3 {
98 | font-size: 22px;
99 | font-weight: 400;
100 | color: #5a4d45;
101 | line-height: 30px;
102 | }
103 |
104 | img {
105 | max-width: 100%;
106 | }
107 |
108 | .medium-paragraph {
109 | font-size: 18px;
110 | line-height: 32px;
111 | }
112 |
113 | ::-moz-selection {
114 | background: #89cc2d;
115 | color: #fff;
116 | text-shadow: none;
117 | }
118 |
119 | ::selection {
120 | background: #89cc2d;
121 | color: #fff;
122 | text-shadow: none;
123 | }
124 |
125 | .navbar {
126 | margin-bottom: 0;
127 | background: #5a4d45;
128 | border: 0;
129 | -moz-border-radius: 0;
130 | -webkit-border-radius: 0;
131 | border-radius: 0;
132 | -o-transition: all .6s;
133 | -moz-transition: all .6s;
134 | -webkit-transition: all .6s;
135 | -ms-transition: all .6s;
136 | transition: all .6s;
137 | }
138 |
139 | ul.navbar-nav {
140 | font-size: 15px;
141 | color: #fff;
142 | }
143 |
144 | .navbar-inverse ul.navbar-nav li a {
145 | color: #fff;
146 | opacity: 0.8;
147 | border: 0;
148 | }
149 |
150 | .navbar-inverse ul.navbar-nav li a:hover {
151 | color: #fff;
152 | opacity: 1;
153 | border: 0;
154 | }
155 |
156 | .navbar-inverse ul.navbar-nav li a:focus {
157 | color: #fff;
158 | outline: 0;
159 | opacity: 1;
160 | border: 0;
161 | }
162 |
163 | .dropdown-menu {
164 | background-color: #5a4d45;
165 | }
166 |
167 | .dropdown-menu > li > a:hover,
168 | .dropdown-menu > .active > a,
169 | .dropdown-menu > .active > a:hover {
170 | color: #fff;
171 | background: #000;
172 | }
173 |
174 | :not(.input-group-btn) > button.btn {
175 | height: 40px;
176 | margin: 0;
177 | padding: 0 15px;
178 | vertical-align: middle;
179 | background: #89cc2d;
180 | border: 0;
181 | font-family: 'Raleway', sans-serif;
182 | font-size: 15px;
183 | font-weight: 400;
184 | line-height: 40px;
185 | color: #fff;
186 | -moz-border-radius: 0;
187 | -webkit-border-radius: 0;
188 | border-radius: 0;
189 | text-shadow: none;
190 | -moz-box-shadow: none;
191 | -webkit-box-shadow: none;
192 | box-shadow: none;
193 | -o-transition: all .6s;
194 | -moz-transition: all .6s;
195 | -webkit-transition: all .6s;
196 | -ms-transition: all .6s;
197 | transition: all .6s;
198 | }
199 |
200 | .input-group-btn button.btn {
201 | font-family: 'Raleway', sans-serif;
202 | background: #89cc2d;
203 | color: #fff;
204 | border: 1px solid #89cc2d;
205 | text-shadow: none;
206 | -moz-box-shadow: none;
207 | -webkit-box-shadow: none;
208 | box-shadow: none;
209 | -o-transition: all .6s;
210 | -moz-transition: all .6s;
211 | -webkit-transition: all .6s;
212 | -ms-transition: all .6s;
213 | transition: all .6s;
214 | }
215 |
216 | .input-group[class*=col-] {
217 | padding-right: 15px;
218 | }
219 |
220 | span.input-group-addon {
221 | font-size: 13px;
222 | }
223 |
224 | .form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control, fieldset[readonly] .form-control {
225 | cursor: text;
226 | }
227 |
228 | button.btn:hover {
229 | opacity: 0.6;
230 | color: #fff;
231 | }
232 |
233 | button.btn:active {
234 | outline: 0;
235 | opacity: 0.6;
236 | color: #fff;
237 | -moz-box-shadow: none;
238 | -webkit-box-shadow: none;
239 | box-shadow: none;
240 | }
241 |
242 | button.btn:focus {
243 | outline: 0;
244 | opacity: 0.6;
245 | background: #89cc2d;
246 | color: #fff;
247 | }
248 |
249 | button.btn:active:focus, button.btn.active:focus {
250 | outline: 0;
251 | opacity: 0.6;
252 | background: #89cc2d;
253 | color: #fff;
254 | }
255 |
256 | button i {
257 | padding-left: 5px;
258 | vertical-align: middle;
259 | font-size: 20px;
260 | line-height: 20px;
261 | }
262 |
263 | .no-left-padding {
264 | padding-left: 0;
265 | }
266 |
267 | svg .link {
268 | fill: none;
269 | stroke: #ccc;
270 | stroke-width: 1.5px;
271 | }
272 |
273 | div.tooltip {
274 | position: absolute;
275 | min-width: 400px;
276 | min-height: 50px;
277 | pointer-events: none;
278 | }
279 |
280 | hr {
281 | color: black;
282 | border-bottom: 1px solid black;
283 | }
284 |
285 | div.as-block.input-group {
286 | display: inline-block;
287 | float: left;
288 | }
289 |
290 | div.as-block.input-group span {
291 | line-height: 20px;
292 | }
293 |
294 | div.as-block.input-group input,
295 | div.as-block.input-group span,
296 | div.as-block.input-group select.form-control {
297 | display: inline-block;
298 | float: left;
299 | }
300 |
--------------------------------------------------------------------------------
/app.html:
--------------------------------------------------------------------------------
1 |
70 |
72 |
74 |
75 |
TX ' + index + ': ' + shortHash(hash) + '' 123 | }; 124 | }); 125 | var nextLevel = []; 126 | do { 127 | for (var i = 0; i < bottom.length; i += 2) { 128 | var left = bottom[i]; 129 | var right = i + 1 === bottom.length ? angular.copy(left) : bottom[i + 1]; 130 | var hash = bitcoin.crypto.hash256(bitcoin.Buffer.concat([left.hash, right.hash])); 131 | nextLevel.push({ 132 | leave: false, 133 | hash: hash, 134 | name: shortHash(hash), 135 | info: '
sha256(\n sha256(\n ' + shortHash(left.hash) + ' + ' + shortHash(right.hash) + '\n )\n) = ' + shortHash(hash) + '', 136 | children: [left, right] 137 | }); 138 | } 139 | bottom = nextLevel; 140 | nextLevel = []; 141 | } while (bottom.length > 1); 142 | 143 | return bottom[0]; 144 | } 145 | 146 | function paintMerkleTree() { 147 | if (vm.decodedBlock.transactions > 200) { 148 | return; 149 | } 150 | var numLeaves = vm.decodedBlock.transactions.length; 151 | var width = (numLeaves * 100) + 200; 152 | var height = ((Math.log2(numLeaves) + 1) * 100) + 200; 153 | 154 | var svg = d3.select('#merkleTree') 155 | .html('') 156 | .append('svg:svg') 157 | .attr('width', width) 158 | .attr('height', height) 159 | .append('svg:g') 160 | .attr('transform', 'translate(-40, 30)'); 161 | 162 | var tree = d3.layout.tree().size([width - 100, height - 100]); 163 | var diagonal = d3.svg.diagonal(); 164 | 165 | var nodes = tree.nodes(calculateTree()); 166 | var links = tree.links(nodes); 167 | 168 | // Add tooltip div 169 | var div = d3.select('#tooltip').style('opacity', 1e-6); 170 | 171 | var link = svg.selectAll('pathlink') 172 | .data(links) 173 | .enter().append('svg:path') 174 | .attr('class', 'link') 175 | .attr('d', diagonal); 176 | 177 | var node = svg.selectAll('g.node') 178 | .data(nodes) 179 | .enter().append('svg:g') 180 | .attr('transform', function (d) { 181 | return 'translate(' + d.x + ',' + d.y + ')'; 182 | }); 183 | 184 | // Add the dot at every node 185 | node.append('svg:circle') 186 | .on('mouseover', function () { 187 | div.transition().duration(300).style('opacity', 1); 188 | }) 189 | .on('mousemove', function (d) { 190 | div.html(d.info).style('left', (d3.event.pageX + 20) + 'px').style('top', (d3.event.pageY + 20) + 'px'); 191 | }) 192 | .on('mouseout', function () { 193 | div.transition().duration(300).style('opacity', 1e-6); 194 | }) 195 | .attr('fill', 'red') 196 | .attr('r', 5.5); 197 | 198 | node.append('svg:text') 199 | .attr('dx', 8) 200 | .attr('dy', 3) 201 | .text(function (d) { 202 | return d.name; 203 | }); 204 | } 205 | 206 | function shortHash(hash) { 207 | return hash.toString('hex').substring(0, 16) + '...'; 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /pages/ecc/ecc.html: -------------------------------------------------------------------------------- 1 |
27 | by Oliver Gugger
28 | BTC tip address: bc1qfgua5vhwm6myajak9p4crhwmwm2k6mczf789eh
29 |
website
".website
" and can prove that cryptographically.
74 | After you have set up the key pairs, click the following button to step through the signing process.
75 | Observe how the public and private data changes after each step.
76 | To reset the demo, please reload the page.
77 |