mirror of
https://github.com/tcsenpai/hmywallet.git
synced 2025-06-03 01:20:04 +00:00
replaced words generation mechanism: now it works
This commit is contained in:
parent
44fa2c7c59
commit
6528dbf419
@ -1,22 +0,0 @@
|
||||
import binascii
|
||||
|
||||
# Can generate a mnemonic seed from data of 16, 20, 24, 28 or 32 bytes
|
||||
def gen_from_data(data):
|
||||
# Checking if the data length is correct
|
||||
if len(data) not in [16, 20, 24, 28, 32]:
|
||||
raise ValueError(
|
||||
"Data length should be one of the following: [16, 20, 24, 28, 32], but it is not (%d).” % len(data)"
|
||||
)
|
||||
|
||||
# Converting the data to binary
|
||||
bindata = bin(int(binascii.hexlify(data), 16))[2:].zfill(8 * len(data))
|
||||
|
||||
# Opening wordlist
|
||||
with open("data/wordlist.txt", "r") as f:
|
||||
wordlist = [w.strip() for w in f.readlines()]
|
||||
# Generating a seed from the binary data
|
||||
seed = []
|
||||
for i in range((len(bindata)//11)+1):
|
||||
index = int(bindata[11*i:11*(i+1)],2)
|
||||
seed.append(wordlist[index])
|
||||
return seed
|
5
main.py
5
main.py
@ -2,8 +2,8 @@
|
||||
from fido2.hid import CtapHidDevice
|
||||
from fido2.client import Fido2Client, UserInteraction
|
||||
from getpass import getpass
|
||||
import libs.word_gen as word_gen
|
||||
import libs.cred_manager as cred_manager
|
||||
import libs.mem_gen as mem_gen
|
||||
import hashlib
|
||||
import sys
|
||||
import os
|
||||
@ -92,8 +92,7 @@ if __name__ == "__main__":
|
||||
secret = result.extension_results["hmacGetSecret"]["output1"]
|
||||
print("[OK] Authenticated and secret retrieved")
|
||||
|
||||
mnemonic_words = word_gen.gen_from_data(secret)
|
||||
mnemonic_string = " ".join(mnemonic_words)
|
||||
mnemonic_string = mem_gen.gen_mnemonic(secret)
|
||||
print("\nALERT: This is your mnemonic seed. Keep it in a safe place. You will need it to recover your wallet.")
|
||||
print("If you lose it, you will lose access to your wallet. There is no way to recover it later.")
|
||||
print("Anyone with access to your mnemonic seed can recover your wallet. Keep it in a secure location.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user