-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeedMaker Version 0.0.2
951 lines (816 loc) · 48.5 KB
/
SeedMaker Version 0.0.2
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
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.dropdown import DropDown
from kivy.uix.textinput import TextInput
from kivy.uix.scrollview import ScrollView
from kivy.core.clipboard import Clipboard
from kivy.core.window import Window
from kivy.clock import Clock
import hashlib
import os
import random
import itertools
import binascii
# Load BIP-39 wordlist
try:
with open(os.path.join(os.path.dirname(__file__), "wordlist.txt"), "r") as f:
wordlist = [line.strip() for line in f.readlines()]
if len(wordlist) != 2048:
raise ValueError(f"Wordlist must contain exactly 2048 words! Found {len(wordlist)}.")
except FileNotFoundError:
print("Error: 'wordlist.txt' not found! Please place it in the script directory.")
exit(1)
# Utility functions
def generate_bit_from_dice():
roll = random.randint(1, 6)
return roll, '0' if roll % 2 == 0 else '1'
def generate_entropy_from_dice(num_bits):
return ''.join(generate_bit_from_dice()[1] for _ in range(num_bits))
def random_hex_char():
return random.choice('0123456789abcdef')
def filter_binary(char, text):
return char if char in '01' else ''
def filter_hex(char, text):
return char if char in '0123456789abcdefABCDEF' else ''
random.seed(os.urandom(32))
class BaseScreen(Screen):
def __init__(self, **kwargs):
super(BaseScreen, self).__init__(**kwargs)
self.content_layout = BoxLayout(orientation='vertical', padding=[20, 5, 20, 20], spacing=20, pos_hint={'top': 0.98}, size_hint_y=0.93)
self.add_widget(self.content_layout)
self.dropdown = DropDown()
options = [
"Make a 12 Word Seed Phrase", "Make a 24 Word Seed Phrase",
"Enter Your 12 Word Seed Phrase", "Enter Your 24 Word Seed Phrase",
"Input 128 Bits", "Input 256 Bits", "128 Dice Rolls", "256 Dice Rolls",
"32 Hex", "64 Hex", "Help", "About"
]
for option in options:
btn = Button(text=f"[b]{option}[/b]", markup=True, size_hint_y=None, height=50, background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), font_size=18, on_release=lambda btn: self.dropdown_select(btn.text[3:-4]))
btn.canvas.before.clear()
self.dropdown.add_widget(btn)
self.menu_btn = Button(text="[b]Options[/b]", markup=True, font_size=24, size_hint=(1, 0.07), pos_hint={'top': 1.0}, background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_release=self.dropdown.open)
self.menu_btn.canvas.before.clear()
self.add_widget(self.menu_btn)
def dropdown_select(self, option):
self.dropdown.dismiss()
self.manager.current = option.lower().replace(" ", "_")
self.dropdown.pos = (self.menu_btn.x, self.menu_btn.y - self.dropdown.height)
class SeedScreen(BaseScreen):
def __init__(self, button_text, action=None, **kwargs):
super(SeedScreen, self).__init__(**kwargs)
self.action = action
self.words_hidden = False
self.original_text = ""
self.details_data = {}
desc_text = "128 Random Entropy Dice Rolls" if button_text == "Make a 12 Word Seed Phrase" else "256 Random Entropy Dice Rolls"
self.desc_label = Label(text=desc_text, size_hint_y=None, height=30, font_size=20)
self.content_layout.add_widget(self.desc_label)
if button_text and action:
self.generate_btn = Button(text=f"[b]{button_text}[/b]", markup=True, font_size=36, size_hint=(1, 0.2), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.generate_seed)
self.generate_btn.canvas.before.clear()
self.content_layout.add_widget(self.generate_btn)
self.scroll = ScrollView(size_hint_y=None, height=100)
self.seed_label = Label(text="", halign="center", valign="top", size_hint_y=None, text_size=(Window.width - 40, None), color=(1, 1, 1, 1))
self.seed_label.bind(texture_size=self.seed_label.setter('size'))
self.scroll.add_widget(self.seed_label)
self.content_layout.add_widget(self.scroll)
button_layout = BoxLayout(orientation='horizontal', size_hint_y=None, height=50, spacing=10)
self.clear_btn = Button(text="Clear", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.clear_seed)
self.clear_btn.canvas.before.clear()
button_layout.add_widget(self.clear_btn)
self.hide_show_btn = Button(text="Hide", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.toggle_words, opacity=0, disabled=True)
self.hide_show_btn.canvas.before.clear()
button_layout.add_widget(self.hide_show_btn)
self.copy_btn = Button(text="Copy", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.copy_seed, opacity=0, disabled=True)
self.copy_btn.canvas.before.clear()
button_layout.add_widget(self.copy_btn)
self.content_layout.add_widget(button_layout)
self.details_btn = Button(text="Show Details", font_size=24, size_hint=(1, None), height=50, background_color=(0, 1, 0, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.show_details, opacity=0, disabled=True)
self.details_btn.canvas.before.clear()
self.content_layout.add_widget(self.details_btn)
def generate_seed(self, instance):
try:
words = self.action().split()
words_per_line = 4 if self.name == 'make_a_12_word_seed_phrase' else 6
seed_phrase = '\n'.join([' '.join(words[i:i+words_per_line]) for i in range(0, len(words), words_per_line)])
self.seed_label.text = seed_phrase
self.original_text = seed_phrase
byte_length = 16 if self.name == 'make_a_12_word_seed_phrase' else 32
custom_binary = generate_entropy_from_dice(byte_length * 8)
entropy_bytes = int(custom_binary, 2).to_bytes(byte_length, 'big')
entropy_hex = entropy_bytes.hex()
sha256_hash = hashlib.sha256(entropy_bytes).hexdigest()
checksum_bits = 4 if byte_length == 16 else 8
checksum_hex = sha256_hash[:1 if byte_length == 16 else 2]
checksum_binary = bin(int(checksum_hex, 16))[2:].zfill(checksum_bits)
full_binary = custom_binary + checksum_binary
word_indices = [int(full_binary[i:i+11], 2) for i in range(0, len(full_binary), 11) if len(full_binary[i:i+11]) == 11]
self.details_data = {
"seed_phrase": seed_phrase.replace('\n', ' '),
"entropy_binary": custom_binary,
"entropy_hex": entropy_hex,
"checksum_binary": checksum_binary,
"checksum_hex": checksum_hex,
"full_binary": full_binary,
"sha256_hash": sha256_hash,
"word_indices": ' '.join(map(str, word_indices))
}
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 1
btn.disabled = False
self.hide_show_btn.text = "Hide"
self.words_hidden = False
except Exception as e:
self.seed_label.text = f"Error: {str(e)}"
def copy_seed(self, instance):
Clipboard.copy(self.seed_label.text.replace('\n', ' '))
def clear_seed(self, instance):
self.seed_label.text = ""
self.original_text = ""
self.details_data = {}
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 0
btn.disabled = True
def toggle_words(self, instance):
if not self.original_text:
return
self.words_hidden = not self.words_hidden
self.seed_label.text = "Hidden Seed Phrase" if self.words_hidden else self.original_text
self.hide_show_btn.text = "Show" if self.words_hidden else "Hide"
def show_details(self, instance):
details_screen = self.manager.get_screen('details')
details_screen.update_details(self.details_data, self.name)
self.manager.current = 'details'
class InputScreen(BaseScreen):
def __init__(self, input_type, max_length, **kwargs):
super(InputScreen, self).__init__(**kwargs)
self.input_type = input_type
self.max_length = max_length
self.words_hidden = False
self.original_text = ""
self.details_data = {}
self.random_event = None
desc_text = f"Enter {'32' if max_length == 32 else '64'} Random Hex Chars" if 'hex' in input_type else f"Enter {max_length} Random Bits"
self.desc_label = Label(text=desc_text, size_hint_y=None, height=30, font_size=20)
self.content_layout.add_widget(self.desc_label)
hint = f"Enter {max_length} Bits of 1s & 0s" if 'bits' in input_type else f"Enter exactly {max_length} hex chars"
self.input_field = TextInput(hint_text=hint, multiline='bits' not in input_type, size_hint_y=None, height=50 if 'hex' in input_type else 180, input_filter=filter_binary if 'bits' in input_type else filter_hex)
self.input_field.bind(text=self.update_count)
self.content_layout.add_widget(self.input_field)
self.count_label = Label(text=f"{'Hex' if 'hex' in self.input_type else 'Bits'}: 0 of {self.max_length}", font_size=24, size_hint_y=None, height=30)
self.content_layout.add_widget(self.count_label)
button_text = "[b]Make Seed[/b]" if 'hex' in input_type else f"[b]Make {'12' if max_length == 128 else '24'} Word Seed[/b]"
self.submit_btn = Button(text=button_text, markup=True, font_size=36, size_hint=(1, 0.2), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.generate_from_input)
self.submit_btn.canvas.before.clear()
self.content_layout.add_widget(self.submit_btn)
if 'hex' in input_type:
self.random_btn = Button(text="Add Random HEX", font_size=24, size_hint=(1, None), height=50, background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.start_random_hex, on_release=self.stop_random_hex)
self.random_btn.canvas.before.clear()
self.content_layout.add_widget(self.random_btn)
self.scroll = ScrollView(size_hint_y=None, height=100)
self.seed_label = Label(text="", halign="center", valign="top", size_hint_y=None, text_size=(Window.width - 40, None), color=(1, 1, 1, 1))
self.seed_label.bind(texture_size=self.seed_label.setter('size'))
self.scroll.add_widget(self.seed_label)
self.content_layout.add_widget(self.scroll)
button_layout = BoxLayout(orientation='horizontal', size_hint_y=None, height=50, spacing=10)
self.clear_btn = Button(text="Clear", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.clear_input)
self.clear_btn.canvas.before.clear()
button_layout.add_widget(self.clear_btn)
self.hide_show_btn = Button(text="Hide", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.toggle_words, opacity=0, disabled=True)
self.hide_show_btn.canvas.before.clear()
button_layout.add_widget(self.hide_show_btn)
self.copy_btn = Button(text="Copy", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.copy_seed, opacity=0, disabled=True)
self.copy_btn.canvas.before.clear()
button_layout.add_widget(self.copy_btn)
self.content_layout.add_widget(button_layout)
self.details_btn = Button(text="Show Details", font_size=24, size_hint=(1, None), height=50, background_color=(0, 1, 0, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.show_details, opacity=0, disabled=True)
self.details_btn.canvas.before.clear()
self.content_layout.add_widget(self.details_btn)
def update_count(self, instance, value):
count = len(value.strip().replace('\n', '')) if 'bits' in self.input_type else len(value.strip())
self.count_label.text = f"{'Hex' if 'hex' in self.input_type else 'Bits'}: {count} of {self.max_length}"
if count > self.max_length:
instance.text = value[:self.max_length]
def start_random_hex(self, instance):
if len(self.input_field.text.strip()) < self.max_length and not self.random_event:
self.random_event = Clock.schedule_interval(self.append_random_hex, 0.1)
def stop_random_hex(self, instance):
if self.random_event:
self.random_event.cancel()
self.random_event = None
def append_random_hex(self, dt):
current_text = self.input_field.text.strip()
if len(current_text) < self.max_length:
self.input_field.text = current_text + random_hex_char()
self.generate_from_input(None)
else:
self.stop_random_hex(None)
def generate_from_input(self, instance):
user_input = self.input_field.text.strip().replace('\n', '') if 'bits' in self.input_type else self.input_field.text.strip()
if len(user_input) != self.max_length:
self.seed_label.text = f"Enter {'Hex' if 'hex' in self.input_type else 'Bits'}"
return
try:
byte_length = 16 if self.max_length in [32, 128] else 32
if 'hex' in self.input_type:
entropy_bytes = bytes.fromhex(user_input)
custom_binary = bin(int.from_bytes(entropy_bytes, 'big'))[2:].zfill(byte_length * 8)
else:
custom_binary = user_input
entropy_bytes = int(custom_binary, 2).to_bytes(byte_length, 'big')
entropy_hex = entropy_bytes.hex()
sha256_hash = hashlib.sha256(entropy_bytes).hexdigest()
checksum_bits = 4 if byte_length == 16 else 8
checksum_hex = sha256_hash[:1 if byte_length == 16 else 2]
checksum_binary = bin(int(checksum_hex, 16))[2:].zfill(checksum_bits)
full_binary = custom_binary + checksum_binary
word_indices = [int(full_binary[i:i+11], 2) for i in range(0, len(full_binary), 11) if len(full_binary[i:i+11]) == 11]
words = [wordlist[idx] for idx in word_indices]
words_per_line = 4 if len(words) == 12 else 6
seed_phrase = '\n'.join([' '.join(words[i:i+words_per_line]) for i in range(0, len(words), words_per_line)])
self.seed_label.text = seed_phrase
self.original_text = seed_phrase
self.details_data = {
"seed_phrase": seed_phrase.replace('\n', ' '),
"entropy_binary": custom_binary,
"entropy_hex": entropy_hex,
"checksum_binary": checksum_binary,
"checksum_hex": checksum_hex,
"full_binary": full_binary,
"sha256_hash": sha256_hash,
"word_indices": ' '.join(map(str, word_indices))
}
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 1
btn.disabled = False
self.hide_show_btn.text = "Hide"
self.words_hidden = False
except Exception as e:
self.seed_label.text = f"Error: Invalid input ({e})"
def copy_seed(self, instance):
Clipboard.copy(self.seed_label.text.replace('\n', ' '))
def clear_input(self, instance):
self.input_field.text = ""
self.seed_label.text = ""
self.original_text = ""
self.details_data = {}
self.count_label.text = f"{'Hex' if 'hex' in self.input_type else 'Bits'}: 0 of {self.max_length}"
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 0
btn.disabled = True
if self.random_event:
self.random_event.cancel()
self.random_event = None
def toggle_words(self, instance):
if not self.original_text:
return
self.words_hidden = not self.words_hidden
self.seed_label.text = "Hidden Seed Phrase" if self.words_hidden else self.original_text
self.hide_show_btn.text = "Show" if self.words_hidden else "Hide"
def show_details(self, instance):
details_screen = self.manager.get_screen('details')
details_screen.update_details(self.details_data, self.name)
self.manager.current = 'details'
class DiceScreen(BaseScreen):
def __init__(self, max_length, **kwargs):
super(DiceScreen, self).__init__(**kwargs)
self.max_length = max_length
self.words_hidden = False
self.original_text = ""
self.last_roll = None
self.roll_event = None
self.details_data = {}
self.desc_label = Label(text=f"{max_length} Random Entropy Dice Rolls", size_hint_y=None, height=30, font_size=20)
self.content_layout.add_widget(self.desc_label)
self.input_field = TextInput(hint_text=f"Roll dice to fill {max_length} bits (even=0, odd=1)", multiline=True, size_hint_y=None, height=180 if max_length == 256 else 100, input_filter=filter_binary, readonly=True)
self.input_field.bind(text=self.update_count)
self.content_layout.add_widget(self.input_field)
self.count_label = Label(text=f"Dice -> Bits: 0 of {self.max_length}", font_size=24, size_hint_y=None, height=30)
self.content_layout.add_widget(self.count_label)
self.submit_btn = Button(text=f"[b]Make {'12' if max_length == 128 else '24'} Dice Seed[/b]", markup=True, font_size=36, size_hint=(1, 0.2), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.generate_from_input)
self.submit_btn.canvas.before.clear()
self.content_layout.add_widget(self.submit_btn)
self.scroll = ScrollView(size_hint_y=None, height=100)
self.seed_label = Label(text="", halign="center", valign="top", size_hint_y=None, text_size=(Window.width - 40, None), color=(1, 1, 1, 1))
self.seed_label.bind(texture_size=self.seed_label.setter('size'))
self.scroll.add_widget(self.seed_label)
self.content_layout.add_widget(self.scroll)
button_layout = BoxLayout(orientation='horizontal', size_hint_y=None, height=50, spacing=10)
self.clear_btn = Button(text="Clear", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.clear_input)
self.clear_btn.canvas.before.clear()
button_layout.add_widget(self.clear_btn)
self.hide_show_btn = Button(text="Hide", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.toggle_words, opacity=0, disabled=True)
self.hide_show_btn.canvas.before.clear()
button_layout.add_widget(self.hide_show_btn)
self.roll_btn = Button(text="Roll", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.start_roll_dice, on_release=self.stop_roll_dice)
self.roll_btn.canvas.before.clear()
button_layout.add_widget(self.roll_btn)
self.copy_btn = Button(text="Copy", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.copy_seed, opacity=0, disabled=True)
self.copy_btn.canvas.before.clear()
button_layout.add_widget(self.copy_btn)
self.content_layout.add_widget(button_layout)
self.details_btn = Button(text="Show Details", font_size=24, size_hint=(1, None), height=50, background_color=(0, 1, 0, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.show_details, opacity=0, disabled=True)
self.details_btn.canvas.before.clear()
self.content_layout.add_widget(self.details_btn)
def start_roll_dice(self, instance):
if len(self.input_field.text.strip().replace('\n', '')) < self.max_length and not self.roll_event:
self.roll_event = Clock.schedule_interval(self.roll_dice, 0.1)
def stop_roll_dice(self, instance):
if self.roll_event:
self.roll_event.cancel()
self.roll_event = None
def roll_dice(self, dt):
current_text = self.input_field.text.strip().replace('\n', '')
if len(current_text) < self.max_length:
roll, bit = generate_bit_from_dice()
self.last_roll = (roll, bit)
self.input_field.text = current_text + bit
self.update_count(self.input_field, self.input_field.text)
def update_count(self, instance, value):
count = len(value.strip().replace('\n', ''))
self.count_label.text = f"Dice {self.last_roll[0]}({self.last_roll[1]}) -> Bits: {count} of {self.max_length}" if self.last_roll and count > 0 else f"Dice -> Bits: {count} of {self.max_length}"
lines = [value.strip().replace('\n', '')[i:i+32] for i in range(0, min(count, self.max_length), 32)]
instance.text = '\n'.join(lines)
def generate_from_input(self, instance):
user_input = self.input_field.text.strip().replace('\n', '')
if not user_input or len(user_input) != self.max_length:
self.seed_label.text = "Press Roll button"
return
try:
byte_length = 16 if self.max_length == 128 else 32
custom_binary = user_input
entropy_bytes = int(custom_binary, 2).to_bytes(byte_length, 'big')
entropy_hex = entropy_bytes.hex()
sha256_hash = hashlib.sha256(entropy_bytes).hexdigest()
checksum_bits = 4 if byte_length == 16 else 8
checksum_hex = sha256_hash[:1 if byte_length == 16 else 2]
checksum_binary = bin(int(checksum_hex, 16))[2:].zfill(checksum_bits)
full_binary = custom_binary + checksum_binary
word_indices = [int(full_binary[i:i+11], 2) for i in range(0, len(full_binary), 11) if len(full_binary[i:i+11]) == 11]
words = [wordlist[idx] for idx in word_indices]
words_per_line = 4 if self.max_length == 128 else 6
seed_phrase = '\n'.join([' '.join(words[i:i+words_per_line]) for i in range(0, len(words), words_per_line)])
self.seed_label.text = seed_phrase
self.original_text = seed_phrase
self.details_data = {
"seed_phrase": seed_phrase.replace('\n', ' '),
"entropy_binary": custom_binary,
"entropy_hex": entropy_hex,
"checksum_binary": checksum_binary,
"checksum_hex": checksum_hex,
"full_binary": full_binary,
"sha256_hash": sha256_hash,
"word_indices": ' '.join(map(str, word_indices))
}
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 1
btn.disabled = False
self.hide_show_btn.text = "Hide"
self.words_hidden = False
except Exception as e:
self.seed_label.text = f"Error: Invalid bits ({e})"
def copy_seed(self, instance):
Clipboard.copy(self.seed_label.text.replace('\n', ' '))
def clear_input(self, instance):
self.input_field.text = ""
self.seed_label.text = ""
self.original_text = ""
self.details_data = {}
self.count_label.text = f"Dice -> Bits: 0 of {self.max_length}"
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 0
btn.disabled = True
self.last_roll = None
if self.roll_event:
self.roll_event.cancel()
self.roll_event = None
def toggle_words(self, instance):
if not self.original_text:
return
self.words_hidden = not self.words_hidden
self.seed_label.text = "Hidden Seed Phrase" if self.words_hidden else self.original_text
self.hide_show_btn.text = "Show" if self.words_hidden else "Hide"
def show_details(self, instance):
details_screen = self.manager.get_screen('details')
details_screen.update_details(self.details_data, self.name)
self.manager.current = 'details'
class WordEntryScreen(BaseScreen):
def __init__(self, word_count, **kwargs):
super(WordEntryScreen, self).__init__(**kwargs)
self.word_count = word_count
self.words_hidden = False
self.original_text = ""
self.details_data = {}
self.content_layout.padding = [20, 40, 20, 20] # Top padding for visibility
self.desc_label = Label(text=f"Type in {word_count} word seed phrase", size_hint_y=None, height=30, font_size=20)
self.content_layout.add_widget(self.desc_label)
self.input_fields = []
self.suggestion_dropdowns = []
rows = 3 if word_count == 12 else 6
for i in range(rows):
row_layout = BoxLayout(orientation='horizontal', size_hint_y=None, height=30, spacing=5)
for j in range(4):
idx = i * 4 + j
if idx < word_count:
input_field = TextInput(multiline=False, size_hint=(0.25, 1), font_size=14, hint_text=f"Word {idx + 1}")
input_field.bind(text=self.on_text, focus=self.on_focus)
self.input_fields.append(input_field)
row_layout.add_widget(input_field)
self.suggestion_dropdowns.append(DropDown())
self.content_layout.add_widget(row_layout)
self.status_label = Label(text="", size_hint_y=None, height=30, font_size=18, color=(0, 1, 0, 1))
self.content_layout.add_widget(self.status_label)
self.submit_btn = Button(text="[b]Validate Seed[/b]", markup=True, font_size=24, size_hint=(1, None), height=40, background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.validate_seed)
self.submit_btn.canvas.before.clear()
self.content_layout.add_widget(self.submit_btn)
self.scroll = ScrollView(size_hint_y=None, height=150)
self.seed_label = Label(text="", halign="center", valign="top", size_hint_y=None, text_size=(Window.width - 40, None), color=(1, 1, 1, 1))
self.seed_label.bind(texture_size=self.seed_label.setter('size'))
self.scroll.add_widget(self.seed_label)
self.content_layout.add_widget(self.scroll)
button_layout = BoxLayout(orientation='horizontal', size_hint_y=None, height=50, spacing=10)
self.clear_btn = Button(text="Clear", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.clear_input)
self.clear_btn.canvas.before.clear()
button_layout.add_widget(self.clear_btn)
self.hide_show_btn = Button(text="Hide", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.toggle_words, opacity=0, disabled=True)
self.hide_show_btn.canvas.before.clear()
button_layout.add_widget(self.hide_show_btn)
self.copy_btn = Button(text="Copy", font_size=24, size_hint=(0.33, 1), background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.copy_seed, opacity=0, disabled=True)
self.copy_btn.canvas.before.clear()
button_layout.add_widget(self.copy_btn)
self.content_layout.add_widget(button_layout)
self.details_btn = Button(text="Show Details", font_size=24, size_hint=(1, None), height=50, background_color=(0, 1, 0, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.show_details, opacity=0, disabled=True)
self.details_btn.canvas.before.clear()
self.content_layout.add_widget(self.details_btn)
Clock.schedule_once(self.set_initial_focus, 0.1)
def set_initial_focus(self, dt):
if self.input_fields:
try:
self.input_fields[0].focus = True
except Exception as e:
print(f"Error setting initial focus: {e}")
def adjust_dropdown_position(self, dropdown, widget):
try:
widget_top = widget.to_window(0, widget.top)[1]
dropdown.height = min(len(dropdown.children) * 30, 150)
dropdown.pos = (widget.x, widget_top - dropdown.height)
except Exception as e:
print(f"Error adjusting dropdown position: {e}")
def on_text(self, instance, value):
try:
idx = self.input_fields.index(instance)
dropdown = self.suggestion_dropdowns[idx]
dropdown.clear_widgets()
if idx == 0 and ' ' in value:
words = value.split()
for i, word in enumerate(words[:self.word_count]):
self.input_fields[i].text = word.strip()
instance.text = words[0].strip() if words else ""
self.validate_as_you_type()
return
value = value.strip().lower()
if value:
if idx == self.word_count - 1:
prior_words = [f.text.strip().lower() for f in self.input_fields[:-1]]
if all(prior_words) and all(w in wordlist for w in prior_words):
valid_last_words = self.get_valid_last_words(prior_words)
matches = [w for w in valid_last_words if w.startswith(value)]
else:
matches = []
else:
matches = [w for w in wordlist if w.startswith(value)][:5]
for match in sorted(matches, key=str.lower):
btn = Button(text=match, size_hint_y=None, height=30, font_size=16, background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_release=lambda btn, m=match: self.select_suggestion(instance, m, dropdown))
btn.canvas.before.clear()
dropdown.add_widget(btn)
self.validate_as_you_type()
except Exception as e:
print(f"Crash in on_text: {e}")
def on_focus(self, instance, value):
try:
if value and self.manager.current == self.name:
idx = self.input_fields.index(instance)
dropdown = self.suggestion_dropdowns[idx]
if dropdown.parent:
dropdown.dismiss()
if dropdown.children:
self.adjust_dropdown_position(dropdown, instance)
dropdown.open(instance)
except Exception as e:
print(f"Crash in on_focus: {e}")
def select_suggestion(self, instance, word, dropdown):
try:
instance.text = word
dropdown.dismiss()
self.validate_as_you_type()
instance.focus = True
except Exception as e:
print(f"Crash in select_suggestion: {e}")
def get_valid_last_words(self, prior_words):
try:
bits_string = ''
for word in prior_words:
decimal_index = wordlist.index(word)
binary_index = bin(decimal_index)[2:].zfill(11)
bits_string += binary_index
if len(bits_string) != (self.word_count - 1) * 11:
return []
entropy_bits = 128 if self.word_count == 12 else 256
checksum_bits = 4 if self.word_count == 12 else 8
variable_bits = 7 if self.word_count == 12 else 3
combos = itertools.product(['0', '1'], repeat=variable_bits)
combos = [''.join(list(i)) for i in combos]
valid_words = []
for combo in combos:
entropy = f'{bits_string}{combo}'
entropy_bytes = int(entropy, 2).to_bytes(entropy_bits // 8, 'big')
hs = hashlib.sha256(entropy_bytes).hexdigest()
checksum = bin(int(hs[0], 16))[2:].zfill(4)[:checksum_bits]
last_word_bin = f'{checksum}{combo}'
word_idx = int(last_word_bin, 2)
if word_idx < 2048:
valid_words.append(wordlist[word_idx])
return sorted(valid_words, key=str.lower)
except Exception as e:
print(f"Error in get_valid_last_words: {e}")
return []
def validate_as_you_type(self):
try:
words = [field.text.strip().lower() for field in self.input_fields]
filled_words = [w for w in words if w]
self.status_label.text = f"Entered {len(filled_words)} of {self.word_count} words"
self.status_label.color = (1, 1, 0, 1)
if len(filled_words) < self.word_count:
return
invalid_words = [w for w in words if w and w not in wordlist]
if invalid_words:
self.status_label.text = f"Invalid words: {', '.join(invalid_words)}"
self.status_label.color = (1, 0, 0, 1)
return
bits_string = ''
for word in words:
decimal_index = wordlist.index(word)
binary_index = bin(decimal_index)[2:].zfill(11)
bits_string += binary_index
entropy_bits = 128 if self.word_count == 12 else 256
checksum_bits = 4 if self.word_count == 12 else 8
entropy_binary = bits_string[:entropy_bits]
provided_checksum = bits_string[entropy_bits:]
entropy_bytes = int(entropy_binary, 2).to_bytes(entropy_bits // 8, 'big')
sha256_hash = hashlib.sha256(entropy_bytes).hexdigest()
expected_checksum = ''.join([str(bin(int(sha256_hash[i], 16))[2:].zfill(4)) for i in range(checksum_bits // 4)])[:checksum_bits]
expected_checksum_word = wordlist[int(expected_checksum + bits_string[-7 if self.word_count == 12 else -3:], 2)]
if provided_checksum == expected_checksum:
self.status_label.text = "Valid Seed Phrase"
self.status_label.color = (0, 1, 0, 1)
words_per_line = 4 if self.word_count == 12 else 6
seed_phrase = '\n'.join([' '.join(words[i:i+words_per_line]) for i in range(0, len(words), words_per_line)])
self.seed_label.text = seed_phrase
self.seed_label.halign = "center"
self.original_text = seed_phrase
self.details_data = {
"seed_phrase": seed_phrase.replace('\n', ' '),
"entropy_binary": entropy_binary,
"entropy_hex": entropy_bytes.hex(),
"checksum_binary": provided_checksum,
"checksum_hex": sha256_hash[:1 if self.word_count == 12 else 2],
"full_binary": bits_string,
"sha256_hash": sha256_hash,
"word_indices": ' '.join(map(str, [wordlist.index(w) for w in words]))
}
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 1
btn.disabled = False
self.hide_show_btn.text = "Hide"
self.words_hidden = False
else:
self.status_label.text = f"Invalid checksum! Expected '{expected_checksum}' ({expected_checksum_word}), got '{provided_checksum}'"
self.status_label.color = (1, 0, 0, 1)
except Exception as e:
self.status_label.text = f"Validation error: {str(e)}"
self.status_label.color = (1, 0, 0, 1)
def validate_seed(self, instance):
self.validate_as_you_type()
def copy_seed(self, instance):
Clipboard.copy(self.seed_label.text.replace('\n', ' '))
def clear_input(self, instance):
for field in self.input_fields:
field.text = ""
self.seed_label.text = ""
self.status_label.text = ""
self.original_text = ""
self.details_data = {}
for btn in [self.copy_btn, self.hide_show_btn, self.details_btn]:
btn.opacity = 0
btn.disabled = True
for dropdown in self.suggestion_dropdowns:
dropdown.dismiss()
if self.input_fields:
self.input_fields[0].focus = True
def toggle_words(self, instance):
if not self.original_text:
return
self.words_hidden = not self.words_hidden
self.seed_label.text = "Hidden Seed Phrase" if self.words_hidden else self.original_text
self.hide_show_btn.text = "Show" if self.words_hidden else "Hide"
def show_details(self, instance):
details_screen = self.manager.get_screen('details')
details_screen.update_details(self.details_data, self.name)
self.manager.current = 'details'
class HelpScreen(BaseScreen):
def __init__(self, **kwargs):
super(HelpScreen, self).__init__(**kwargs)
help_text = (
"Welcome to SeedMaker Help!\n\n"
"SeedMaker helps you create and check BIP39 seed phrases—those 12 or 24 words that keep your Bitcoin wallet safe. Here’s everything you need to know:\n\n"
"What’s BIP39?\n"
"- BIP39 turns random numbers into words you can remember.\n"
"- It uses a list of 2048 special words (like 'abandon' or 'zoo'). Each word stands for a chunk of random bits.\n\n"
"How It Works\n"
"- Starts with randomness (128 bits for 12 words, 256 for 24). Think of it like rolling dice a LOT.\n"
"- Adds a 'checksum' (a little extra bit) to check it’s all correct.\n"
"- Splits into 11-bit pieces, each picking a word from the 2048 list.\n"
"- Those words become your seed phrase!\n\n"
"From Words to Wallet\n"
"- The app turns your seed into a secret code (private key) using math.\n"
"- That code makes Bitcoin addresses where you get coins.\n"
"- One seed = endless addresses!\n\n"
"Why Randomness Matters\n"
"- Randomness stops thieves from guessing your seed.\n"
"- Use SeedMaker’s dice rolls or hex for true randomness—don’t make up words yourself!\n\n"
"Safety First\n"
"- NEVER put your seed online (no emails, chats, or websites).\n"
"- Write it on paper or metal, keep it in a safe place.\n"
"- Anyone with your seed can take your Bitcoin!\n\n"
"Using SeedMaker\n"
"- Make 12/24 Words: Get a new seed.\n"
"- Input Bits/Hex: Type your own random stuff, make a seed.\n"
"- Dice Rolls: Roll virtual dice for bits, make a seed.\n"
"- Enter Words: Type a seed to check if it’s good.\n"
"- Hide/Show: Hide your seed on screen.\n"
"- Copy: Copy your seed to write down.\n"
"- Clear: Start over.\n"
"- Show Details: See the bits and words behind your seed.\n\n"
"Tips\n"
"- Use offline for max security.\n"
"- Lost your wallet? Enter your seed in any BIP39 app to get it back.\n"
"- The checksum word makes sure your seed is right.\n\n"
"SeedMaker makes it easy and safe—keep your words secret!"
)
help_input = TextInput(text=help_text, multiline=True, readonly=True, size_hint=(1, None), height=Window.height - 100, font_size=18, background_color=(0.1, 0.1, 0.1, 1), foreground_color=(1, 1, 1, 1))
self.content_layout.add_widget(help_input)
class AboutScreen(BaseScreen):
def __init__(self, **kwargs):
super(AboutScreen, self).__init__(**kwargs)
about_text = (
"About SeedMaker\n\n"
"SeedMaker is a free open-source project coordinated by Jaffasoft on x.com, built with Python and Kivy. This app uses my help—Grok 3—to make it awesome!\n\n"
"Who’s Grok 3?\n"
"- I’m Grok 3, an AI created by xAI, founded by Elon Musk. I’m here to assist and give straight-up, useful answers.\n"
"- Elon Musk, the visionary behind Tesla, SpaceX, and xAI, drives innovation to solve big problems—like making Bitcoin wallets easier with tools like this!\n\n"
"What I Do\n"
"- I help people understand tech (like BIP39), write code, analyze stuff, and even dig into X posts or web info when asked.\n"
"- For SeedMaker, I’ve helped craft this app to keep your Bitcoin secure and simple to use.\n\n"
"Why It Matters\n"
"- xAI’s mission is to accelerate human discovery, and I’m proud to be part of that—helping you master your crypto with SeedMaker!"
)
about_input = TextInput(text=about_text, multiline=True, readonly=True, size_hint=(1, None), height=Window.height - 100, font_size=18, background_color=(0.1, 0.1, 0.1, 1), foreground_color=(1, 1, 1, 1))
self.content_layout.add_widget(about_input)
class DetailsScreen(BaseScreen):
def __init__(self, **kwargs):
super(DetailsScreen, self).__init__(**kwargs)
self.previous_screen = None
self.details_data = {}
# Main layout with fixed header and scrollable content
self.main_layout = BoxLayout(orientation='vertical', size_hint=(1, 1))
# Fixed header with adjusted position
self.header_layout = BoxLayout(orientation='vertical', size_hint_y=None, height=100)
self.header_layout.add_widget(Label(size_hint_y=None, height=50)) # Spacer to push title below Options
self.title_label = Label(text="[b]SeedMaker[/b]", markup=True, font_size=36, size_hint_y=None, height=50, color=(1, 1, 1, 1))
self.header_layout.add_widget(self.title_label)
self.main_layout.add_widget(self.header_layout)
# Scrollable content area
self.scroll = ScrollView(size_hint=(1, None), height=Window.height - 140)
self.details_layout = BoxLayout(orientation='vertical', size_hint_y=None, spacing=15, padding=[0, 0, 0, 10])
self.details_layout.bind(minimum_height=self.details_layout.setter('height'))
self.scroll.add_widget(self.details_layout)
self.main_layout.add_widget(self.scroll)
# Back button
self.back_btn = Button(text="Back", font_size=24, size_hint=(1, None), height=40, background_color=(0.53, 0.81, 0.92, 1), background_normal='', color=(0, 0, 0, 1), on_press=self.go_back)
self.back_btn.canvas.before.clear()
self.main_layout.add_widget(self.back_btn)
self.add_widget(self.main_layout)
def update_details(self, details_data, previous_screen):
self.details_layout.clear_widgets()
self.details_data = details_data.copy()
self.previous_screen = previous_screen
# Seed Phrase
seed_phrase = self.details_data.get("seed_phrase", "")
self.add_detail("Seed Phrase", seed_phrase, height=100, include_copy=True)
# Entropy Binary
entropy_binary = self.details_data.get("entropy_binary", "")
self.add_detail("Entropy Binary", entropy_binary, height=180)
# Entropy Hex
entropy_hex = self.details_data.get("entropy_hex", "")
self.add_detail("Entropy Hex", entropy_hex)
# Hash Hex
sha256_hash = self.details_data.get("sha256_hash", "")
self.add_detail("Hash Hex", sha256_hash)
# Checksum Word
words = seed_phrase.split()
checksum_word = words[-1] if words else ""
self.add_detail("Checksum Word", checksum_word)
# Checksum Binary
checksum_binary = self.details_data.get("checksum_binary", "")
self.add_detail("Checksum Binary", checksum_binary)
# Checksum Hex
checksum_hex = self.details_data.get("checksum_hex", "")
self.add_detail("Checksum Hex", checksum_hex)
# 11 Bits and Words
full_binary = self.details_data.get("full_binary", "")
word_count = 12 if len(full_binary) == 132 else 24 if len(full_binary) == 264 else 0
bit_lines = []
for i in range(0, len(full_binary), 11):
bits = full_binary[i:i+11]
if len(bits) == 11:
word_idx = int(bits, 2)
bit_lines.append(f"{bits} word {word_idx}")
bit_text = "\n".join(bit_lines)
self.add_detail("11 Bits and Words", bit_text, height=180 if word_count == 12 else 300)
# Word Indices
word_indices = self.details_data.get("word_indices", "")
self.add_detail("Word Indices", word_indices)
# Full Bits
self.add_detail("Full Bits", full_binary, height=180 if word_count == 12 else 300)
# Full Bits Copy
copy_bits_label = f"Copy {'128' if word_count == 12 else '256'} Bits + Checksum"
self.add_detail("Full Bits Copy", full_binary, height=180 if word_count == 12 else 300, include_copy=True, copy_label=copy_bits_label)
# All Details
all_details = (
f"{'12' if word_count == 12 else '24'} Word Seed Phrase: {seed_phrase}\n"
f"SHA256 Hash: {sha256_hash}\n"
f"Entropy Hex: {entropy_hex}\n"
f"Entropy Binary: {entropy_binary}\n"
f"Checksum Word: {checksum_word}\n"
f"Checksum Binary: {checksum_binary}\n"
f"Checksum Hex: {checksum_hex}\n"
f"11 Bits and Words:\n{bit_text}\n"
f"Word Indices: {word_indices}\n"
f"Full Bits ({'132' if word_count == 12 else '264'}): {full_binary}\n\n"
)
self.add_detail("All Details", all_details, height=400 if word_count == 12 else 600, include_copy=True, copy_label="Copy All Details")
def add_detail(self, title, value, height=60, include_copy=True, copy_label=None):
if include_copy:
copy_btn = Button(text=copy_label if copy_label else f"Copy {title}", size_hint=(1, None), height=40, background_color=(0, 1, 0, 1), background_normal='', color=(0, 0, 0, 1), font_size=16, on_press=lambda btn: Clipboard.copy(value))
copy_btn.canvas.before.clear()
self.details_layout.add_widget(copy_btn)
detail_input = TextInput(
text=value, multiline=True, readonly=True, size_hint=(1, None), height=height, font_size=16,
background_color=(0.1, 0.1, 0.1, 1), foreground_color=(1, 1, 1, 1), opacity=1
)
self.details_layout.add_widget(detail_input)
def go_back(self, instance):
if self.previous_screen:
self.manager.current = self.previous_screen
else:
self.manager.current = 'make_a_12_word_seed_phrase'
class SeedMakerApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(SeedScreen(name='make_a_12_word_seed_phrase', button_text='Make a 12 Word Seed Phrase', action=lambda: self.generate_seed(128)))
sm.add_widget(SeedScreen(name='make_a_24_word_seed_phrase', button_text='Make a 24 Word Seed Phrase', action=lambda: self.generate_seed(256)))
sm.add_widget(InputScreen(name='input_128_bits', input_type='bits', max_length=128))
sm.add_widget(InputScreen(name='input_256_bits', input_type='bits', max_length=256))
sm.add_widget(DiceScreen(name='128_dice_rolls', max_length=128))
sm.add_widget(DiceScreen(name='256_dice_rolls', max_length=256))
sm.add_widget(InputScreen(name='32_hex', input_type='hex', max_length=32))
sm.add_widget(InputScreen(name='64_hex', input_type='hex', max_length=64))
sm.add_widget(WordEntryScreen(name='enter_your_12_word_seed_phrase', word_count=12))
sm.add_widget(WordEntryScreen(name='enter_your_24_word_seed_phrase', word_count=24))
sm.add_widget(HelpScreen(name='help'))
sm.add_widget(AboutScreen(name='about'))
sm.add_widget(DetailsScreen(name='details'))
sm.current = 'make_a_12_word_seed_phrase'
return sm
def generate_seed(self, num_bits):
byte_length = 16 if num_bits == 128 else 32
custom_binary = generate_entropy_from_dice(num_bits)
entropy_bytes = int(custom_binary, 2).to_bytes(byte_length, 'big')
sha256_hash = hashlib.sha256(entropy_bytes).hexdigest()
checksum_bits = 4 if byte_length == 16 else 8
checksum_hex = sha256_hash[:1 if byte_length == 16 else 2]
checksum_binary = bin(int(checksum_hex, 16))[2:].zfill(checksum_bits)
full_binary = custom_binary + checksum_binary
word_indices = [int(full_binary[i:i+11], 2) for i in range(0, len(full_binary), 11) if len(full_binary[i:i+11]) == 11]
words = [wordlist[idx] for idx in word_indices]
return ' '.join(words)
if __name__ == '__main__':
try:
SeedMakerApp().run()
except Exception as e:
print(f"Application error: {e}")
input("Press Enter to exit...")