-
Notifications
You must be signed in to change notification settings - Fork 12
/
mindwallet_0.1_SHA256_8e30213e4e820816967618f098a94cf65b5222fb661544d0140878c100877c94.html
executable file
·18461 lines (15680 loc) · 508 KB
/
mindwallet_0.1_SHA256_8e30213e4e820816967618f098a94cf65b5222fb661544d0140878c100877c94.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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-112413074-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-112413074-1');
</script>
<meta charset="UTF-8" />
<title>MindWallet - deterministic bitcoin wallet generator for Ethereum, Monero, Litecoin and Bitcoin using argon2</title>
<style>
body {
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
font-size: 17px;
}
p {
line-height: 24px;
}
.content {
max-width: 800px;
width: 800px;
margin: 0 auto;
}
.form {
border: 1px solid #ccc;
padding: 20px;
border-radius: 4px;
background-color: #fff;
}
.alert {
background-color: #f2dede;
border-radius: 4px;
border: solid 0.75px #ebcccc;
color: #a94442;
padding: 12px 20px;
}
.info {
background-color: #d9edf7;
color: #31708f;
border-radius: 4px;
border: solid 0.75px #bcdff1;
padding: 12px 20px;
}
h2 {
text-align: center;
font-size:
}
h1 {
font-size: 40px;
letter-spacing: 2px;
margin: 20px 0;
}
.header {
margin: 0 0 50px 0;
text-align: center;
background-color: #222;
color: #fff;
padding: 20px;
}
.header h2 {
margin: 0 0 10px 0;
font-size: 20px;
}
.header h3 {
margin-top: 0;
font-size: 18px;
}
.form-label {
width: 300px;
float: left;
text-align: right;
padding-right: 10px;
}
.form-field {
width: 400px;
float: left;
}
.form-group {
padding-bottom: 15px;
overflow: hidden;
}
.form {
overflow: hidden;
}
input[type="email"], input[type="text"], input[type="password"] {
color:#464a4c;
border-radius:4px;
width: 300px;
border: .75px solid #0003;
margin:0;
padding:8px 12px
}
input:focus {
border-color: #5cb3fd;
}
.currency-selector {
text-align: center;
margin-bottom: 20px;
}
a {
text-decoration: none;
color: #0275d8;
}
a:hover {
background-color: #ccc;
}
.progress {
display: flex;
overflow: hidden;
font-size: .75rem;
line-height: 1rem;
text-align: center;
background-color: #eceeef;
border-radius: 4px;
}
.progress-bar {
height: 1rem;
background-color: #0275d8;
background-image: -webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);
background-image: -o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);
background-image: linear-gradient(45deg,#fff3 25%,transparent 25%,transparent 50%,#fff3 50%,#fff3 75%,transparent 75%,transparent);
-webkit-background-size: 1rem 1rem;
background-size: 1rem 1rem;
}
.btn {
color: #fff;
background-color: #0275d8;
border-color: #0275d8;
display: block;
font-weight: 400;
line-height: 1.25;
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
padding: .5rem 1rem;
font-size: 1rem;
border-radius: 4px;
margin: 10px auto;
cursor: pointer;
}
.btn:disabled {
background-color: #0275d8;
border-color: #0275d8;
cursor: not-allowed;
opacity: .65;
}
.brand {
font-size: 1.1em;
}
@media (min-width: 992px){
.lead {
width: 50%;
margin: auto;
}
}
</style>
</head>
<body>
<div class="header">
<h1>MindWallet</h1>
<div class=lead>
<h2>Have your mind on your wallet and your wallet on your mind.</h2>
<h4 id="lead">MindWallet allows you to store your bitcoin, ethereum, monero or litecoin wallet's private key in your mind easily and securely,
the only way to lose your wallet would be to either lose your mind or if <a href="https://xkcd.com/538/" target=_blank>someone spends $5 on a wrench to hurt you</a> but this one applies to other wallets as well.</h2>
<h4>MindWallet is heavily based on the great <a href="https://dvdbng.github.io/memwallet">MemWallet</a> project itself inspired by <a href="https://keybase.io/warp/">WarpWallet</a> whose authors are of keybase.io and okcupid fame.</h2>
<h4>MindWallet makes use of the argon2 hash function to generate your private keys, argon2 is harder to hack than scrypt which is also pretty secure.</h2>
<h4>To use offline just <a href="https://github.com/patcito/mindwallet#readme" target=_blank>clone</a> this page.</h3>
</div>
</div>
<div class="content">
<form class="form" autocomplete="off" onsubmit="return false;">
<div class="form-group currency-selector">
<label> <input name="coin" onclick="resetState()" checked value="bitcoin" type="radio"/> Bitcoin </label>
<label> <input name="coin" onclick="resetState()" value="ethereum" type="radio"/> Ethereum </label>
<label> <input name="coin" onclick="resetState()" value="litecoin" type="radio"/> Litecoin </label>
<label> <input name="coin" onclick="resetState()" value="monero" type="radio"/> Monero </label>
</div>
<div class="form-group">
<div class="form-label">Passphrase </div>
<div class="form-field">
<input type="password" id="passphrase" oninput="updateButton()" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
</div>
</div>
<div class="form-group">
<div class="form-label">Email: <a href="#" onclick="toggle('info')">[?]</a></div>
<div class="form-field">
<input type="email" id="salt" placeholder="use at least 8 character" required minlength="8" oninput="updateButton();" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
</div>
</div>
<div class="info" id="info" style="display: none">
<span class="brand">MindWallet</span> can use your email as salt to make your wallet stronger.
This forces bruteforce attackers to target only one user per hash (unless other users use the same email).
<a href="#" onclick="toggle('info')">[Close]</a>
</div>
<div id="progress" style="display: none">
<center>Running argon2... This may take up to 1 or 2 minutes. Use the Golang version for a faster version.</center>
<div class="progress">
<div id="progress-bar" class="progress-bar" style="width: 50%"> </div>
</div>
</div>
<button id="btn" class="btn" disabled="" onclick="generate()">Generate</button>
<h2 style="display: none" id="wallet-title"></h2>
<div class="form-group" id="cnt-public" style="display: none">
<div class="form-label" id="label-public" ></div>
<div class="form-field"><input type="text" id="result-public" /></div>
</div>
<div class="form-group" id="cnt-private" style="display: none">
<div class="form-label" id="label-private"></div>
<div class="form-field"><input type="text" id="result-private" /></div>
</div>
<div class="form-group" id="cnt-public-view" style="display: none">
<div class="form-label" id="label-public-view" ></div>
<div class="form-field"><input type="text" id="result-public-view" /></div>
</div>
<div class="form-group" id="cnt-private-view" style="display: none">
<div class="form-label" id="label-private-view" ></div>
<div class="form-field"><input type="text" id="result-private-view" /></div>
</div>
<div class="form-group" id="cnt-public-spend" style="display: none">
<div class="form-label" id="label-public-spend" ></div>
<div class="form-field"><input type="text" id="result-public-spend" /></div>
</div>
<div class="form-group" id="cnt-private-spend" style="display: none">
<div class="form-label" id="label-private-spend" ></div>
<div class="form-field"><input type="text" id="result-private-spend" /></div>
</div>
</form>
<p id="online-alert" class="alert"><strong>You are online.</strong> For maximum security is better that you <a href="https://github.com/patcito/mindwallet#readme" target=_blank>clone</a> this page and generate the address in a computer disconnected from the internet.</p>
<p id="js-alert" class="alert">Javascript is disabled. <span class="brand">MindWallet</span> needs javascript to work </p>
<script> document.getElementById('js-alert').style.display = 'none'; </script>
<p>
<span class="brand">MindWallet</span> is a deterministic cryptocurrency address generator, it is a fork of <a href="https://dvdbng.github.io/memwallet">MemWallet</a> which itself is inspired by
<a href="https://keybase.io/warp/">WarpWallet</a>, but it uses the Argon2 hashing function instead of scrypt.
You never have to save or store your private key anywhere. Just pick a really good password - many random words, for example - and never use it for anything else.
</p>
<p>Given the same Passphrase and Salt, <span class="brand">MindWallet</span> will always generate the same address and private key, so you only need to remember your password to access your funds.</p>
<p>
For more information on why this is safer than a regular brainwallet, see <a href="https://keybase.io/warp/">WarpWallet</a>'s help,
<span class="brand">MindWallet</span> uses MemWallet's re-implementation of WarpWallet, but with a different hash function algorithm.
MemWallet and <span class="brand">MindWallet</span> use the same algorithm, so MemWallet and <span class="brand">MindWallet</span> will generate
the same Bitcoin address for a given Passphrase and salt. However, because MindWallet uses a different algorithm, it will generate a different Bitcoin address.
MindWallet comes with a golang implementation largely based on MemWallet so you can double check that the JS version works, it is also much faster to run.
Have Fun!
</p>
<p>
Why a different algorithm? While scrypt is still pretty secure, there are
<a href="https://blog.ircmaxell.com/2014/03/why-i-dont-recommend-scrypt.html"
target=_blank>known issues</a> a
<a href="https://password-hashing.net/" target=_blank>
password hashing competition</a> was held to fix these known issues and the declared winner was
<a href="https://github.com/p-h-c/phc-winner-argon2" target=_blank>argon2</a> which has been out for more than 4 years now and
has been implemented in most languages including the <a href="https://github.com/golang/crypto/blob/master/argon2/argon2.go">golang standard crypto library</a>
used here. The JS version used here is the C version compiled to asm.js and wasm.js thanks to <a href="https://github.com/antelle/argon2-browser"
target=_blank>@antelle</a>.
</p>
The algorithm behind <span class="brand">MindWallet</span>:
<table class="table table-condensed" style="font-size: 0.7em; font-family: mono;">
<tr><td valign="top" align="right">b</td><td align="center" valign="top" width="20">=</td><td valign="top" align="left">1 for Bitcoin, 2 for Litecoin, 3 for Ethereum and 4 for Monero</td></tr>
<tr><td valign="top" align="right">seed<sub>1</sub></td><td align="center" valign="top" width="20">=</td><td valign="top" align="left">argon2(key=(passphrase||b), salt=(salt||b), N=2<sup>18</sup>, r=8, p=1, dkLen=32)</td></tr>
<tr><td valign="top" align="right">seed<sub>2</sub></td><td align="center" valign="top">=</td><td valign="top" align="left">pbkdf2(key=(passphrase||(b+1)), salt=(salt||(b+1)), c=2<sup>16</sup>, dkLen=32, prf=SHA256)</td></tr>
<tr><td valign="top" align="right">wallet</td><td align="center" valign="top">=</td><td valign="top" align="left">generate_wallet(seed=(seed<sub>1</sub> ⊕ seed<sub>2</sub>))</td></tr>
</table>
<p> </p>
<hr/>
<p> </p>
<center>
<p><span class="brand">MindWallet</span> was made with ♥ By <a href="https://twitter.com/patcito">Patrick Aljord</a> shamelessly re-using awesome code by
<a href="https://github.com/dvdbng">David Bengoa</a></p>
<p>Source code is in <a href="https://github.com/patcito/mindwallet">Github</a>, and so is a go implementation of the same algorithm.</p>
</center>
<p> </p>
<!--
Javascript is left un-minimized so it's easy to audit it offline
-->
<script>
function setKeyResult(name, show, label, value){
i('cnt-' + name).style.display = show ? 'block' : 'none';
i('label-' + name).textContent = show ? label : '';
i('result-' + name).value = show ? value : '';
}
function titleCase(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function generate() {
var passphrase = document.getElementById('passphrase').value;
var salt = document.getElementById('salt').value;
var currency = document.querySelector('[name=coin]:checked').value;
var progress_blk = i('progress');
var progress_bar = i('progress-bar');
for(var el of document.querySelectorAll('.form input')) el.disabled = true;
i('btn').style.display = 'none';
mw.generateWallet(passphrase, salt, currency, function(progress, result) {
progress_blk.style.display = !result ? 'block' : 'none';
progress_bar.style.width = progress*100 + '%';
if(result){
for(var el of document.querySelectorAll('.form input')) el.disabled = false;
i('wallet-title').style.display = 'block';
i('wallet-title').textContent = 'Your ' + titleCase(currency) + ' wallet',
setKeyResult('public', true, 'Public ' + titleCase(currency) + ' address', result.public);
setKeyResult('private', currency != 'monero', 'Private key', result.private);
setKeyResult('private-spend', currency == 'monero', 'Private Spend key', result.private_spend);
setKeyResult('public-spend', currency == 'monero', 'Public Spend key', result.public_spend);
setKeyResult('public-view', currency == 'monero', 'Public View key', result.public_view);
setKeyResult('private-view', currency == 'monero', 'Private View key', result.private_view);
}
});
}
function i(id){
return document.getElementById(id);
}
function updateButton(){
var passphrase = i('passphrase').value;
var salt = i('salt').value;
var button = i('btn');
resetState();
if(passphrase.length == 0 || salt.length <=7) {
button.disabled = true;
button.textContent = 'Generate';
} else if (passphrase.length < 12) {
button.disabled = false;
button.textContent = 'Consider a larger passpharase';
} else {
button.disabled = false;
button.textContent = 'Generate';
}
}
function resetState(){
if(passphrase.length == 0) {
button.disabled = true;
button.textContent = 'Generate';
} setKeyResult('public', false);
setKeyResult('private', false);
setKeyResult('private-spend', false);
setKeyResult('public-spend', false);
setKeyResult('public-view', false);
setKeyResult('private-view', false);
i('btn').style.display = 'block';
i('wallet-title').style.display = 'none';
}
function toggle(id) {
var el = i(id);
el.style.display = el.style.display == 'block' ? 'none' : 'block';
}
function updateOnline() {
document.getElementById('online-alert').style.display = navigator.onLine ? 'block' : 'none';
}
function init() {
window.addEventListener('online', updateOnline);
window.addEventListener('offline', updateOnline);
updateOnline();
if(location.hash.length > 3) {
var check = document.querySelector('input[name="coin"][value="' + location.hash.replace(/\W/g, '') + '"]');
if(check) check.checked = true;
}
}
init();
var mw =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 38);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
/* eslint-disable node/no-deprecated-api */
var buffer = __webpack_require__(7)
var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers
function copyProps (src, dst) {
for (var key in src) {
dst[key] = src[key]
}
}
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer
} else {
// Copy properties from require('buffer')
copyProps(buffer, exports)
exports.Buffer = SafeBuffer
}
function SafeBuffer (arg, encodingOrOffset, length) {
return Buffer(arg, encodingOrOffset, length)
}
// Copy static methods from Buffer
copyProps(Buffer, SafeBuffer)
SafeBuffer.from = function (arg, encodingOrOffset, length) {
if (typeof arg === 'number') {
throw new TypeError('Argument must not be a number')
}
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.alloc = function (size, fill, encoding) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
var buf = Buffer(size)
if (fill !== undefined) {
if (typeof encoding === 'string') {
buf.fill(fill, encoding)
} else {
buf.fill(fill)
}
} else {
buf.fill(0)
}
return buf
}
SafeBuffer.allocUnsafe = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return Buffer(size)
}
SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return buffer.SlowBuffer(size)
}
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var elliptic = exports;
elliptic.version = __webpack_require__(41).version;
elliptic.utils = __webpack_require__(42);
elliptic.rand = __webpack_require__(45);
elliptic.curve = __webpack_require__(13);
elliptic.curves = __webpack_require__(51);
// Protocols
elliptic.ec = __webpack_require__(59);
elliptic.eddsa = __webpack_require__(63);
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
'use strict';
// Utils
function assert (val, msg) {
if (!val) throw new Error(msg || 'Assertion failed');
}
// Could use `inherits` module, but don't want to move from single file
// architecture yet.
function inherits (ctor, superCtor) {
ctor.super_ = superCtor;
var TempCtor = function () {};
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
// BN
function BN (number, base, endian) {
if (BN.isBN(number)) {
return number;
}
this.negative = 0;
this.words = null;
this.length = 0;
// Reduction context
this.red = null;
if (number !== null) {
if (base === 'le' || base === 'be') {
endian = base;
base = 10;
}
this._init(number || 0, base || 10, endian || 'be');
}
}
if (typeof module === 'object') {
module.exports = BN;
} else {
exports.BN = BN;
}
BN.BN = BN;
BN.wordSize = 26;
var Buffer;
try {
Buffer = __webpack_require__(44).Buffer;
} catch (e) {
}
BN.isBN = function isBN (num) {
if (num instanceof BN) {
return true;
}
return num !== null && typeof num === 'object' &&
num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
};
BN.max = function max (left, right) {
if (left.cmp(right) > 0) return left;
return right;
};
BN.min = function min (left, right) {
if (left.cmp(right) < 0) return left;
return right;
};
BN.prototype._init = function init (number, base, endian) {
if (typeof number === 'number') {
return this._initNumber(number, base, endian);
}
if (typeof number === 'object') {
return this._initArray(number, base, endian);
}
if (base === 'hex') {
base = 16;
}
assert(base === (base | 0) && base >= 2 && base <= 36);
number = number.toString().replace(/\s+/g, '');
var start = 0;
if (number[0] === '-') {
start++;
}
if (base === 16) {
this._parseHex(number, start);
} else {
this._parseBase(number, base, start);
}
if (number[0] === '-') {
this.negative = 1;
}
this.strip();
if (endian !== 'le') return;
this._initArray(this.toArray(), base, endian);
};
BN.prototype._initNumber = function _initNumber (number, base, endian) {
if (number < 0) {
this.negative = 1;
number = -number;
}
if (number < 0x4000000) {
this.words = [ number & 0x3ffffff ];
this.length = 1;
} else if (number < 0x10000000000000) {
this.words = [
number & 0x3ffffff,
(number / 0x4000000) & 0x3ffffff
];
this.length = 2;
} else {
assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
this.words = [
number & 0x3ffffff,
(number / 0x4000000) & 0x3ffffff,
1
];
this.length = 3;
}
if (endian !== 'le') return;
// Reverse the bytes
this._initArray(this.toArray(), base, endian);
};
BN.prototype._initArray = function _initArray (number, base, endian) {
// Perhaps a Uint8Array
assert(typeof number.length === 'number');
if (number.length <= 0) {
this.words = [ 0 ];
this.length = 1;
return this;
}
this.length = Math.ceil(number.length / 3);
this.words = new Array(this.length);
for (var i = 0; i < this.length; i++) {
this.words[i] = 0;
}
var j, w;
var off = 0;
if (endian === 'be') {
for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
this.words[j] |= (w << off) & 0x3ffffff;
this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
off += 24;
if (off >= 26) {
off -= 26;
j++;
}
}
} else if (endian === 'le') {
for (i = 0, j = 0; i < number.length; i += 3) {
w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
this.words[j] |= (w << off) & 0x3ffffff;
this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
off += 24;
if (off >= 26) {
off -= 26;
j++;
}
}
}
return this.strip();
};
function parseHex (str, start, end) {
var r = 0;
var len = Math.min(str.length, end);
for (var i = start; i < len; i++) {
var c = str.charCodeAt(i) - 48;
r <<= 4;
// 'a' - 'f'
if (c >= 49 && c <= 54) {
r |= c - 49 + 0xa;
// 'A' - 'F'
} else if (c >= 17 && c <= 22) {
r |= c - 17 + 0xa;
// '0' - '9'
} else {
r |= c & 0xf;
}
}
return r;
}
BN.prototype._parseHex = function _parseHex (number, start) {
// Create possibly bigger array to ensure that it fits the number
this.length = Math.ceil((number.length - start) / 6);
this.words = new Array(this.length);
for (var i = 0; i < this.length; i++) {
this.words[i] = 0;
}
var j, w;
// Scan 24-bit chunks and add them to the number
var off = 0;
for (i = number.length - 6, j = 0; i >= start; i -= 6) {
w = parseHex(number, i, i + 6);
this.words[j] |= (w << off) & 0x3ffffff;
// NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
off += 24;
if (off >= 26) {
off -= 26;
j++;
}
}
if (i + 6 !== start) {
w = parseHex(number, start, i + 6);
this.words[j] |= (w << off) & 0x3ffffff;
this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
}
this.strip();
};
function parseBase (str, start, end, mul) {
var r = 0;
var len = Math.min(str.length, end);
for (var i = start; i < len; i++) {
var c = str.charCodeAt(i) - 48;
r *= mul;
// 'a'
if (c >= 49) {
r += c - 49 + 0xa;
// 'A'
} else if (c >= 17) {
r += c - 17 + 0xa;
// '0' - '9'
} else {
r += c;
}
}
return r;
}
BN.prototype._parseBase = function _parseBase (number, base, start) {
// Initialize as zero
this.words = [ 0 ];
this.length = 1;
// Find length of limb in base
for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
limbLen++;
}
limbLen--;
limbPow = (limbPow / base) | 0;
var total = number.length - start;
var mod = total % limbLen;
var end = Math.min(total, total - mod) + start;
var word = 0;
for (var i = start; i < end; i += limbLen) {
word = parseBase(number, i, i + limbLen, base);
this.imuln(limbPow);
if (this.words[0] + word < 0x4000000) {
this.words[0] += word;
} else {
this._iaddn(word);
}
}
if (mod !== 0) {
var pow = 1;
word = parseBase(number, i, number.length, base);
for (i = 0; i < mod; i++) {
pow *= base;
}
this.imuln(pow);
if (this.words[0] + word < 0x4000000) {
this.words[0] += word;
} else {
this._iaddn(word);
}
}
};
BN.prototype.copy = function copy (dest) {
dest.words = new Array(this.length);
for (var i = 0; i < this.length; i++) {
dest.words[i] = this.words[i];
}
dest.length = this.length;
dest.negative = this.negative;
dest.red = this.red;
};
BN.prototype.clone = function clone () {
var r = new BN(null);
this.copy(r);
return r;
};
BN.prototype._expand = function _expand (size) {
while (this.length < size) {
this.words[this.length++] = 0;
}
return this;
};
// Remove leading `0` from `this`
BN.prototype.strip = function strip () {
while (this.length > 1 && this.words[this.length - 1] === 0) {
this.length--;
}
return this._normSign();
};
BN.prototype._normSign = function _normSign () {
// -0 = 0
if (this.length === 1 && this.words[0] === 0) {
this.negative = 0;
}
return this;
};
BN.prototype.inspect = function inspect () {
return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
};
/*
var zeros = [];
var groupSizes = [];
var groupBases = [];
var s = '';
var i = -1;
while (++i < BN.wordSize) {
zeros[i] = s;
s += '0';
}
groupSizes[0] = 0;
groupSizes[1] = 0;
groupBases[0] = 0;
groupBases[1] = 0;
var base = 2 - 1;
while (++base < 36 + 1) {
var groupSize = 0;
var groupBase = 1;
while (groupBase < (1 << BN.wordSize) / base) {
groupBase *= base;
groupSize += 1;
}
groupSizes[base] = groupSize;
groupBases[base] = groupBase;
}
*/
var zeros = [
'',
'0',
'00',
'000',
'0000',
'00000',
'000000',
'0000000',
'00000000',
'000000000',
'0000000000',
'00000000000',
'000000000000',
'0000000000000',
'00000000000000',
'000000000000000',
'0000000000000000',
'00000000000000000',
'000000000000000000',
'0000000000000000000',
'00000000000000000000',
'000000000000000000000',
'0000000000000000000000',
'00000000000000000000000',
'000000000000000000000000',
'0000000000000000000000000'
];
var groupSizes = [
0, 0,
25, 16, 12, 11, 10, 9, 8,
8, 7, 7, 7, 7, 6, 6,